Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/data/install.openshift.io_installconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 8 additions & 15 deletions pkg/asset/installconfig/nutanix/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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))
}
}

Copy link
Contributor

@sadasu sadasu Aug 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you getting the "Name" of the PrismElement as an optional parameter, do you need to validate if that exists also? And I am assuming that the Name of the PrismElement should correspond to the same UUID in the Nutanix cluster.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the name should match the UUID, it is being validated in create cluster phase - or filled in if its unset.

// validate whether a subnet with the UUID actually exists
for _, subnetUUID := range p.SubnetUUIDs {
_, err = nc.V3.GetSubnet(subnetUUID)
Expand Down
29 changes: 17 additions & 12 deletions pkg/asset/manifests/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
3 changes: 3 additions & 0 deletions pkg/types/nutanix/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down