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
182 changes: 182 additions & 0 deletions data/data/install.openshift.io_installconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,47 @@ spec:
description: Nutanix is the configuration used when installing
on Nutanix.
properties:
bootType:
description: BootType indicates the boot type (Legacy, UEFI
or SecureBoot) the Machine's VM uses to boot. If this
field is empty or omitted, the VM will use the default
boot type "Legacy" to boot. "SecureBoot" depends on "UEFI"
boot, i.e., enabling "SecureBoot" means that "UEFI" boot
is also enabled.
enum:
- ""
- Legacy
- UEFI
- SecureBoot
type: string
categories:
description: Categories optionally adds one or more prism
categories (each with key and value) for the Machine's
VM to associate with. All the category key and value pairs
specified must already exist in the prism central.
items:
description: NutanixCategory identifies a pair of prism
category key and value
properties:
key:
description: key is the prism category key name
maxLength: 64
minLength: 1
type: string
value:
description: value is the prism category value associated
with the key
maxLength: 64
minLength: 1
type: string
required:
- key
- value
type: object
type: array
x-kubernetes-list-map-keys:
- key
x-kubernetes-list-type: map
coresPerSocket:
description: 'NumCoresPerSocket is the number of cores per
socket in a vm. The number of vCPUs on the vm will be
Expand Down Expand Up @@ -520,6 +561,27 @@ spec:
format: int64
type: integer
type: object
project:
description: Project optionally identifies a Prism project
for the Machine's VM to associate with.
properties:
name:
description: name is the resource name in the PC
type: string
type:
description: Type is the identifier type to use for
this resource.
enum:
- uuid
- name
type: string
uuid:
description: uuid is the UUID of the resource in the
PC.
type: string
required:
- type
type: object
type: object
openstack:
description: OpenStack is the configuration used when installing
Expand Down Expand Up @@ -1171,6 +1233,46 @@ spec:
description: Nutanix is the configuration used when installing
on Nutanix.
properties:
bootType:
description: BootType indicates the boot type (Legacy, UEFI
or SecureBoot) the Machine's VM uses to boot. If this field
is empty or omitted, the VM will use the default boot type
"Legacy" to boot. "SecureBoot" depends on "UEFI" boot, i.e.,
enabling "SecureBoot" means that "UEFI" boot is also enabled.
enum:
- ""
- Legacy
- UEFI
- SecureBoot
type: string
categories:
description: Categories optionally adds one or more prism
categories (each with key and value) for the Machine's VM
to associate with. All the category key and value pairs
specified must already exist in the prism central.
items:
description: NutanixCategory identifies a pair of prism
category key and value
properties:
key:
description: key is the prism category key name
maxLength: 64
minLength: 1
type: string
value:
description: value is the prism category value associated
with the key
maxLength: 64
minLength: 1
type: string
required:
- key
- value
type: object
type: array
x-kubernetes-list-map-keys:
- key
x-kubernetes-list-type: map
coresPerSocket:
description: 'NumCoresPerSocket is the number of cores per
socket in a vm. The number of vCPUs on the vm will be NumCPUs
Expand All @@ -1197,6 +1299,26 @@ spec:
format: int64
type: integer
type: object
project:
description: Project optionally identifies a Prism project
for the Machine's VM to associate with.
properties:
name:
description: name is the resource name in the PC
type: string
type:
description: Type is the identifier type to use for this
resource.
enum:
- uuid
- name
type: string
uuid:
description: uuid is the UUID of the resource in the PC.
type: string
required:
- type
type: object
type: object
openstack:
description: OpenStack is the configuration used when installing
Expand Down Expand Up @@ -2586,6 +2708,46 @@ spec:
used when installing on Nutanix for machine pools which do not
define their own platform configuration.
properties:
bootType:
description: BootType indicates the boot type (Legacy, UEFI
or SecureBoot) the Machine's VM uses to boot. If this field
is empty or omitted, the VM will use the default boot type
"Legacy" to boot. "SecureBoot" depends on "UEFI" boot, i.e.,
enabling "SecureBoot" means that "UEFI" boot is also enabled.
enum:
- ""
- Legacy
- UEFI
- SecureBoot
type: string
categories:
description: Categories optionally adds one or more prism
categories (each with key and value) for the Machine's VM
to associate with. All the category key and value pairs
specified must already exist in the prism central.
items:
description: NutanixCategory identifies a pair of prism
category key and value
properties:
key:
description: key is the prism category key name
maxLength: 64
minLength: 1
type: string
value:
description: value is the prism category value associated
with the key
maxLength: 64
minLength: 1
type: string
required:
- key
- value
type: object
type: array
x-kubernetes-list-map-keys:
- key
x-kubernetes-list-type: map
coresPerSocket:
description: 'NumCoresPerSocket is the number of cores per
socket in a vm. The number of vCPUs on the vm will be NumCPUs
Expand All @@ -2612,6 +2774,26 @@ spec:
format: int64
type: integer
type: object
project:
description: Project optionally identifies a Prism project
for the Machine's VM to associate with.
properties:
name:
description: name is the resource name in the PC
type: string
type:
description: Type is the identifier type to use for this
resource.
enum:
- uuid
- name
type: string
uuid:
description: uuid is the UUID of the resource in the PC.
type: string
required:
- type
type: object
type: object
ingressVIP:
description: 'DeprecatedIngressVIP is the virtual IP address for
Expand Down
10 changes: 10 additions & 0 deletions data/data/nutanix/cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ resource "nutanix_virtual_machine" "vm_master" {
value = nutanix_category_value.ocp_category_value_owned.value
}

dynamic "categories" {
for_each = (var.nutanix_control_plane_categories == null) ? {} : var.nutanix_control_plane_categories
content {
name = categories.key
value = categories.value
}
}

project_reference = (length(var.nutanix_control_plane_project_uuid) != 0) ? { kind = "project", uuid = var.nutanix_control_plane_project_uuid } : null

guest_customization_cloud_init_user_data = base64encode(var.ignition_master)
nic_list {
subnet_uuid = var.nutanix_subnet_uuid
Expand Down
18 changes: 18 additions & 0 deletions data/data/nutanix/variables-nutanix.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,21 @@ variable "nutanix_control_plane_num_cpus" {
variable "nutanix_control_plane_cores_per_socket" {
type = number
}

variable "nutanix_control_plane_project_uuid" {
type = string
default = null
description = "(optional) An existing prism-central project to be applied to control-plane vms."
}

variable "nutanix_control_plane_categories" {
type = map(string)

description = <<EOF
(optional) The existing prism-central categories to be applied to control-plane vms.

Example: `{ "key" = "value", "foo" = "bar" }`
EOF

default = {}
}
3 changes: 3 additions & 0 deletions pkg/asset/machines/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ func (m *Master) Generate(dependencies asset.Parents) error {
mpool.NumCPUs = 8
mpool.Set(ic.Platform.Nutanix.DefaultMachinePlatform)
mpool.Set(pool.Platform.Nutanix)
if err = mpool.ValidateConfig(ic.Platform.Nutanix); err != nil {
return errors.Wrap(err, "failed to create master machine objects")
}
pool.Platform.Nutanix = &mpool
templateName := nutanixtypes.RHCOSImageName(clusterID.InfraID)

Expand Down
21 changes: 19 additions & 2 deletions pkg/asset/machines/nutanix/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func provider(clusterID string, platform *nutanix.Platform, mpool *nutanix.Machi
subnets = append(subnets, subnet)
}

return &machinev1.NutanixMachineProviderConfig{
providerCfg := &machinev1.NutanixMachineProviderConfig{
TypeMeta: metav1.TypeMeta{
APIVersion: machinev1.GroupVersion.String(),
Kind: "NutanixMachineProviderConfig",
Expand All @@ -95,7 +95,24 @@ func provider(clusterID string, platform *nutanix.Platform, mpool *nutanix.Machi
UUID: &platform.PrismElements[0].UUID,
},
SystemDiskSize: resource.MustParse(fmt.Sprintf("%dGi", mpool.OSDisk.DiskSizeGiB)),
}, nil
}

if len(mpool.BootType) != 0 {
providerCfg.BootType = mpool.BootType
}

if mpool.Project != nil && mpool.Project.Type == machinev1.NutanixIdentifierUUID {
providerCfg.Project = machinev1.NutanixResourceIdentifier{
Type: machinev1.NutanixIdentifierUUID,
UUID: mpool.Project.UUID,
}
}

if len(mpool.Categories) > 0 {
providerCfg.Categories = mpool.Categories
}

return providerCfg, nil
}

// ConfigMasters sets the PublicIP flag and assigns a set of load balancers to the given machines
Expand Down
3 changes: 3 additions & 0 deletions pkg/asset/machines/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ func (w *Worker) Generate(dependencies asset.Parents) error {
mpool := defaultNutanixMachinePoolPlatform()
mpool.Set(ic.Platform.Nutanix.DefaultMachinePlatform)
mpool.Set(pool.Platform.Nutanix)
if err = mpool.ValidateConfig(ic.Platform.Nutanix); err != nil {
return errors.Wrap(err, "failed to create master machine objects")
}
pool.Platform.Nutanix = &mpool
imageName := nutanixtypes.RHCOSImageName(clusterID.InfraID)

Expand Down
39 changes: 25 additions & 14 deletions pkg/tfvars/nutanix/nutanix.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@ import (
)

type config struct {
PrismCentralAddress string `json:"nutanix_prism_central_address"`
Port string `json:"nutanix_prism_central_port"`
Username string `json:"nutanix_username"`
Password string `json:"nutanix_password"`
MemoryMiB int64 `json:"nutanix_control_plane_memory_mib"`
DiskSizeMiB int64 `json:"nutanix_control_plane_disk_mib"`
NumCPUs int64 `json:"nutanix_control_plane_num_cpus"`
NumCoresPerSocket int64 `json:"nutanix_control_plane_cores_per_socket"`
PrismElementUUID string `json:"nutanix_prism_element_uuid"`
SubnetUUID string `json:"nutanix_subnet_uuid"`
Image string `json:"nutanix_image"`
ImageURI string `json:"nutanix_image_uri"`
BootstrapIgnitionImage string `json:"nutanix_bootstrap_ignition_image"`
BootstrapIgnitionImageFilePath string `json:"nutanix_bootstrap_ignition_image_filepath"`
PrismCentralAddress string `json:"nutanix_prism_central_address"`
Port string `json:"nutanix_prism_central_port"`
Username string `json:"nutanix_username"`
Password string `json:"nutanix_password"`
MemoryMiB int64 `json:"nutanix_control_plane_memory_mib"`
DiskSizeMiB int64 `json:"nutanix_control_plane_disk_mib"`
NumCPUs int64 `json:"nutanix_control_plane_num_cpus"`
NumCoresPerSocket int64 `json:"nutanix_control_plane_cores_per_socket"`
ProjectUUID string `json:"nutanix_control_plane_project_uuid"`
Categories map[string]string `json:"nutanix_control_plane_categories"`
PrismElementUUID string `json:"nutanix_prism_element_uuid"`
SubnetUUID string `json:"nutanix_subnet_uuid"`
Image string `json:"nutanix_image"`
ImageURI string `json:"nutanix_image_uri"`
BootstrapIgnitionImage string `json:"nutanix_bootstrap_ignition_image"`
BootstrapIgnitionImageFilePath string `json:"nutanix_bootstrap_ignition_image_filepath"`
}

// TFVarsSources contains the parameters to be converted into Terraform variables
Expand Down Expand Up @@ -63,5 +65,14 @@ func TFVars(sources TFVarsSources) ([]byte, error) {
BootstrapIgnitionImage: bootstrapIgnitionImageName,
BootstrapIgnitionImageFilePath: bootstrapIgnitionImagePath,
}

if controlPlaneConfig.Project.Type == machinev1.NutanixIdentifierUUID {
cfg.ProjectUUID = *controlPlaneConfig.Project.UUID
}
cfg.Categories = make(map[string]string, len(controlPlaneConfig.Categories))
for _, category := range controlPlaneConfig.Categories {
cfg.Categories[category.Key] = category.Value
}

return json.MarshalIndent(cfg, "", " ")
}
12 changes: 11 additions & 1 deletion pkg/types/nutanix/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package nutanix
import (
"context"
"fmt"
"strconv"
"time"

nutanixclient "github.com/nutanix-cloud-native/prism-go-client"
nutanixclientv3 "github.com/nutanix-cloud-native/prism-go-client/v3"
)

// CreateNutanixClient creates a Nutanix V3 Client
// CreateNutanixClient creates a Nutanix V3 Client.
func CreateNutanixClient(ctx context.Context, prismCentral, port, username, password string) (*nutanixclientv3.Client, error) {
ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
Expand All @@ -24,3 +25,12 @@ func CreateNutanixClient(ctx context.Context, prismCentral, port, username, pass

return nutanixclientv3.NewV3Client(cred)
}

// CreateNutanixClientFromPlatform creates a Nutanix V3 clinet based on the platform configuration.
func CreateNutanixClientFromPlatform(platform *Platform) (*nutanixclientv3.Client, error) {
return CreateNutanixClient(context.TODO(),
platform.PrismCentral.Endpoint.Address,
strconv.Itoa(int(platform.PrismCentral.Endpoint.Port)),
platform.PrismCentral.Username,
platform.PrismCentral.Password)
}
Loading