github.com/openshift/installer@v1.4.17/pkg/asset/installconfig/ovirt/ovirt.go (about)

     1  package ovirt
     2  
     3  import (
     4  	ovirtsdk4 "github.com/ovirt/go-ovirt"
     5  	"github.com/pkg/errors"
     6  	"github.com/sirupsen/logrus"
     7  
     8  	"github.com/openshift/installer/pkg/types/ovirt"
     9  )
    10  
    11  const platformValidationMaxTries = 3
    12  
    13  // Platform collects ovirt-specific configuration.
    14  func Platform() (*ovirt.Platform, error) {
    15  	p := ovirt.Platform{}
    16  
    17  	var c *ovirtsdk4.Connection
    18  
    19  	ovirtConfig, err := NewConfig()
    20  	for tries := 0; tries < platformValidationMaxTries; tries++ {
    21  		if err != nil {
    22  			ovirtConfig, err = engineSetup()
    23  			if err != nil {
    24  				logrus.Error(errors.Wrap(err, "oVirt configuration failed"))
    25  			}
    26  		}
    27  
    28  		if err == nil {
    29  			c, err = ovirtConfig.getValidatedConnection()
    30  			if err != nil {
    31  				logrus.Error(errors.Wrap(err, "failed to validate oVirt configuration"))
    32  			} else {
    33  				break
    34  			}
    35  		}
    36  	}
    37  	if err != nil {
    38  		// Last error is not nil, we don't have a valid config.
    39  		return nil, errors.Wrap(err, "maximum retries for configuration exhausted")
    40  	}
    41  	defer c.Close()
    42  	if err = ovirtConfig.Save(); err != nil {
    43  		return nil, err
    44  	}
    45  
    46  	clusterName, err := askCluster(c, &p)
    47  	if err != nil {
    48  		return &p, err
    49  	}
    50  
    51  	err = askStorage(c, &p, clusterName)
    52  	if err != nil {
    53  		return &p, err
    54  	}
    55  
    56  	err = askNetwork(c, &p)
    57  	if err != nil {
    58  		return &p, err
    59  	}
    60  
    61  	err = askVNICProfileID(c, &p)
    62  	if err != nil {
    63  		return &p, err
    64  	}
    65  
    66  	err = askVIPs(&p)
    67  	if err != nil {
    68  		return &p, err
    69  	}
    70  
    71  	return &p, nil
    72  }