diff --git a/data/data/install.openshift.io_installconfigs.yaml b/data/data/install.openshift.io_installconfigs.yaml index 7dac713ffe0..503405df094 100644 --- a/data/data/install.openshift.io_installconfigs.yaml +++ b/data/data/install.openshift.io_installconfigs.yaml @@ -2457,6 +2457,9 @@ spec: - address - port type: object + name: + description: Name is prism endpoint Name + type: string uuid: description: UUID is the UUID of the Prism Element (cluster) type: string diff --git a/pkg/asset/installconfig/nutanix/validation.go b/pkg/asset/installconfig/nutanix/validation.go index fd1fcd87070..ec319b7cadc 100644 --- a/pkg/asset/installconfig/nutanix/validation.go +++ b/pkg/asset/installconfig/nutanix/validation.go @@ -17,21 +17,6 @@ func Validate(ic *types.InstallConfig) error { return field.Required(field.NewPath("platform", "nutanix"), "nutanix validation requires a nutanix platform configuration") } - p := ic.Platform.Nutanix - nc, err := nutanixtypes.CreateNutanixClient(context.TODO(), - p.PrismCentral.Endpoint.Address, - strconv.Itoa(int(p.PrismCentral.Endpoint.Port)), - p.PrismCentral.Username, - p.PrismCentral.Password) - - // validate whether a prism element with the UUID actually exists - for _, pe := range p.PrismElements { - _, err = nc.V3.GetCluster(pe.UUID) - if err != nil { - return field.InternalError(field.NewPath("platform", "nutanix", "prismElements"), errors.Wrapf(err, "prism element UUID %s does not correspond to a valid prism element in Prism", pe.UUID)) - } - } - return nil } @@ -53,6 +38,14 @@ func ValidateForProvisioning(ic *types.InstallConfig) error { return field.InternalError(field.NewPath("platform", "nutanix"), errors.Wrapf(err, "unable to connect to Prism Central %q", p.PrismCentral.Endpoint.Address)) } + // validate whether a prism element with the UUID actually exists + for _, pe := range p.PrismElements { + _, err = nc.V3.GetCluster(pe.UUID) + if err != nil { + return field.InternalError(field.NewPath("platform", "nutanix", "prismElements"), errors.Wrapf(err, "prism element UUID %s does not correspond to a valid prism element in Prism", pe.UUID)) + } + } + // validate whether a subnet with the UUID actually exists for _, subnetUUID := range p.SubnetUUIDs { _, err = nc.V3.GetSubnet(subnetUUID) diff --git a/pkg/asset/manifests/infrastructure.go b/pkg/asset/manifests/infrastructure.go index bb6ffb05b49..72e8e7c203b 100644 --- a/pkg/asset/manifests/infrastructure.go +++ b/pkg/asset/manifests/infrastructure.go @@ -214,19 +214,24 @@ func (i *Infrastructure) Generate(dependencies asset.Parents) error { nutanixPlatform := installConfig.Config.Nutanix // Retrieve the prism element name - nc, err := nutanix.CreateNutanixClient(context.Background(), - nutanixPlatform.PrismCentral.Endpoint.Address, - strconv.Itoa(int(nutanixPlatform.PrismCentral.Endpoint.Port)), - nutanixPlatform.PrismCentral.Username, - nutanixPlatform.PrismCentral.Password) - if err != nil { - return errors.Wrapf(err, "unable to connect to Prism Central %s", nutanixPlatform.PrismCentral.Endpoint.Address) - } - pe, err := nc.V3.GetCluster(nutanixPlatform.PrismElements[0].UUID) - if err != nil { - return errors.Wrapf(err, "fail to find the Prism Element (cluster) with uuid %s", nutanixPlatform.PrismElements[0].UUID) + var peName string + if len(nutanixPlatform.PrismElements[0].Name) == 0 { + nc, err := nutanix.CreateNutanixClient(context.Background(), + nutanixPlatform.PrismCentral.Endpoint.Address, + strconv.Itoa(int(nutanixPlatform.PrismCentral.Endpoint.Port)), + nutanixPlatform.PrismCentral.Username, + nutanixPlatform.PrismCentral.Password) + if err != nil { + return errors.Wrapf(err, "unable to connect to Prism Central %s", nutanixPlatform.PrismCentral.Endpoint.Address) + } + pe, err := nc.V3.GetCluster(nutanixPlatform.PrismElements[0].UUID) + if err != nil { + return errors.Wrapf(err, "fail to find the Prism Element (cluster) with uuid %s", nutanixPlatform.PrismElements[0].UUID) + } + peName = *pe.Spec.Name + } else { + peName = nutanixPlatform.PrismElements[0].Name } - peName := *pe.Spec.Name config.Spec.PlatformSpec.Type = configv1.NutanixPlatformType config.Spec.PlatformSpec.Nutanix = &configv1.NutanixPlatformSpec{ diff --git a/pkg/types/nutanix/platform.go b/pkg/types/nutanix/platform.go index efee9677d61..98e33ff4bee 100644 --- a/pkg/types/nutanix/platform.go +++ b/pkg/types/nutanix/platform.go @@ -57,6 +57,9 @@ type PrismElement struct { // Endpoint holds the address and port of the Prism Element Endpoint PrismEndpoint `json:"endpoint"` + + // Name is prism endpoint Name + Name string `json:"name,omitempty"` } // PrismEndpoint holds the endpoint address and port to access the Nutanix Prism Central or Element (cluster)