Skip to content

Commit 2383635

Browse files
committed
WIP added all the types as a placeholder to share across team members
1 parent 6143b4e commit 2383635

File tree

3 files changed

+333
-1
lines changed

3 files changed

+333
-1
lines changed

api/v1alpha1/nutanix_clusterconfig_types.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import (
88
)
99

1010
type NutanixSpec struct {
11+
PrismCentralEndpoint *NutanixPrismCentralEndpointSpec `json:"prismCentralEndpoint,omitempty"`
1112
ControlPlaneEndpoint *NutanixControlPlaneEndpointSpec `json:"controlPlaneEndpoint,omitempty"`
13+
FailureDomains []NutanixFailureDomain `json:"faultDomains,omitempty"`
1214
}
1315

1416
func (NutanixSpec) VariableSchema() clusterv1.VariableSchema {
@@ -17,7 +19,43 @@ func (NutanixSpec) VariableSchema() clusterv1.VariableSchema {
1719
Description: "Nutanix cluster configuration",
1820
Type: "object",
1921
Properties: map[string]clusterv1.JSONSchemaProps{
22+
"prismCentralEndpoint": NutanixPrismCentralEndpointSpec{}.VariableSchema().OpenAPIV3Schema,
2023
"controlPlaneEndpoint": NutanixControlPlaneEndpointSpec{}.VariableSchema().OpenAPIV3Schema,
24+
// TODO "failureDomains": []NutanixFailureDomain{}.VariableSchema().OpenAPIV3Schema,
25+
},
26+
},
27+
}
28+
}
29+
30+
type NutanixPrismCentralEndpointSpec struct {
31+
Host string `json:"host,omitempty"`
32+
Port int32 `json:"port,omitempty"`
33+
Insecure bool `json:"insecure,omitempty"`
34+
AdditionalTrustBundle string `json:"additionalTrustBundle,omitempty"`
35+
}
36+
37+
func (NutanixPrismCentralEndpointSpec) VariableSchema() clusterv1.VariableSchema {
38+
return clusterv1.VariableSchema{
39+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
40+
Description: "Nutanix Prism Central endpoint configuration",
41+
Type: "object",
42+
Properties: map[string]clusterv1.JSONSchemaProps{
43+
"host": {
44+
Description: "host ip/fqdn for Prism Central Server",
45+
Type: "string",
46+
},
47+
"port": {
48+
Description: "port for Prism Central Server",
49+
Type: "integer",
50+
},
51+
"insecure": {
52+
Description: "Prism Central Certificate checking",
53+
Type: "boolean",
54+
},
55+
"additionalTrustBundle": {
56+
Description: "Certificate trust bundle used for Prism Central connection",
57+
Type: "string",
58+
},
2159
},
2260
},
2361
}
@@ -46,3 +84,44 @@ func (NutanixControlPlaneEndpointSpec) VariableSchema() clusterv1.VariableSchema
4684
},
4785
}
4886
}
87+
88+
type NutanixFailureDomain struct {
89+
// name defines the unique name of a failure domain.
90+
// Name is required and must be at most 64 characters in length.
91+
// It must consist of only lower case alphanumeric characters and hyphens (-).
92+
// It must start and end with an alphanumeric character.
93+
// This value is arbitrary and is used to identify the failure domain within the platform.
94+
Name string `json:"name"`
95+
96+
// cluster is to identify the cluster (the Prism Element under management of the Prism Central),
97+
// in which the Machine's VM will be created. The cluster identifier (uuid or name) can be obtained
98+
// from the Prism Central console or using the prism_central API.
99+
Cluster NutanixResourceIdentifier `json:"cluster"`
100+
101+
// subnets holds a list of identifiers (one or more) of the cluster's network subnets
102+
// for the Machine's VM to connect to. The subnet identifiers (uuid or name) can be
103+
// obtained from the Prism Central console or using the prism_central API.
104+
Subnets []NutanixResourceIdentifier `json:"subnets"`
105+
106+
// indicates if a failure domain is suited for control plane nodes
107+
ControlPlane bool `json:"controlPlane,omitempty"`
108+
}
109+
110+
func (NutanixFailureDomain) VariableSchema() clusterv1.VariableSchema {
111+
return clusterv1.VariableSchema{
112+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
113+
Description: "Nutanix Failure Domain",
114+
Type: "object",
115+
Properties: map[string]clusterv1.JSONSchemaProps{
116+
"name": {
117+
Description: "name of failure domain",
118+
Type: "string",
119+
},
120+
"cluster": {
121+
Description: "",
122+
Type: "integer",
123+
},
124+
},
125+
},
126+
}
127+
}

api/v1alpha1/nutanix_node_types.go

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,60 @@
44
package v1alpha1
55

66
import (
7+
"k8s.io/apimachinery/pkg/api/resource"
78
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
89
)
910

11+
// NutanixIdentifierType is an enumeration of different resource identifier types.
12+
type NutanixIdentifierType string
13+
14+
// NutanixBootType is an enumeration of different boot types.
15+
type NutanixBootType string
16+
17+
// NutanixGPUIdentifierType is an enumeration of different resource identifier types for GPU entities.
18+
type NutanixGPUIdentifierType string
19+
1020
type NutanixNodeSpec struct {
21+
// vcpusPerSocket is the number of vCPUs per socket of the VM
22+
VCPUsPerSocket int32 `json:"vcpusPerSocket"`
23+
24+
// vcpuSockets is the number of vCPU sockets of the VM
25+
VCPUSockets int32 `json:"vcpuSockets"`
26+
27+
// memorySize is the memory size (in Quantity format) of the VM
28+
MemorySize resource.Quantity `json:"memorySize"`
29+
30+
// image is to identify the rhcos image uploaded to the Prism Central (PC)
31+
// The image identifier (uuid or name) can be obtained from the Prism Central console
32+
// or using the prism_central API.
33+
Image NutanixResourceIdentifier `json:"image"`
34+
35+
// cluster is to identify the cluster (the Prism Element under management
36+
// of the Prism Central), in which the Machine's VM will be created.
37+
// The cluster identifier (uuid or name) can be obtained from the Prism Central console
38+
// or using the prism_central API.
39+
Cluster NutanixResourceIdentifier `json:"cluster"`
40+
41+
// subnet is to identify the cluster's network subnet to use for the Machine's VM
42+
// The cluster identifier (uuid or name) can be obtained from the Prism Central console
43+
// or using the prism_central API.
44+
Subnets []NutanixResourceIdentifier `json:"subnet"`
45+
46+
// List of categories that need to be added to the machines. Categories must already exist in Prism Central
47+
AdditionalCategories []NutanixCategoryIdentifier `json:"additionalCategories,omitempty"`
48+
49+
// Add the machine resources to a Prism Central project
50+
Project *NutanixResourceIdentifier `json:"project,omitempty"`
51+
52+
// Defines the boot type of the virtual machine. Only supports UEFI and Legacy
53+
BootType string `json:"bootType,omitempty"` //TODO use enum NutanixBootType
54+
55+
// systemDiskSize is size (in Quantity format) of the system disk of the VM
56+
// The minimum systemDiskSize is 20Gi bytes
57+
SystemDiskSize resource.Quantity `json:"systemDiskSize"`
58+
59+
// List of GPU devices that need to be added to the machines.
60+
GPUs []NutanixGPU `json:"gpus,omitempty"`
1161
}
1262

1363
func (NutanixNodeSpec) VariableSchema() clusterv1.VariableSchema {
@@ -19,3 +69,69 @@ func (NutanixNodeSpec) VariableSchema() clusterv1.VariableSchema {
1969
},
2070
}
2171
}
72+
73+
type NutanixResourceIdentifier struct {
74+
// Type is the identifier type to use for this resource.
75+
Type NutanixIdentifierType `json:"type"`
76+
77+
// uuid is the UUID of the resource in the PC.
78+
// +optional
79+
UUID *string `json:"uuid,omitempty"`
80+
81+
// name is the resource name in the PC
82+
// +optional
83+
Name *string `json:"name,omitempty"`
84+
}
85+
86+
func (NutanixResourceIdentifier) VariableSchema() clusterv1.VariableSchema {
87+
return clusterv1.VariableSchema{
88+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
89+
Description: "Nutanix Resource Identifier",
90+
Type: "object",
91+
Properties: map[string]clusterv1.JSONSchemaProps{},
92+
},
93+
}
94+
}
95+
96+
type NutanixCategoryIdentifier struct {
97+
// key is the Key of category in PC.
98+
// +optional
99+
Key string `json:"key,omitempty"`
100+
101+
// value is the category value linked to the category key in PC
102+
// +optional
103+
Value string `json:"value,omitempty"`
104+
}
105+
106+
func (NutanixCategoryIdentifier) VariableSchema() clusterv1.VariableSchema {
107+
return clusterv1.VariableSchema{
108+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
109+
Description: "Nutanix Category Identifier",
110+
Type: "object",
111+
Properties: map[string]clusterv1.JSONSchemaProps{},
112+
},
113+
}
114+
}
115+
116+
type NutanixGPU struct {
117+
// Type is the identifier type to use for this resource.
118+
Type NutanixGPUIdentifierType `json:"type"`
119+
120+
// deviceID is the id of the GPU entity.
121+
// +optional
122+
DeviceID *int64 `json:"deviceID,omitempty"`
123+
124+
// name is the GPU name
125+
// +optional
126+
Name *string `json:"name,omitempty"`
127+
}
128+
129+
func (NutanixGPU) VariableSchema() clusterv1.VariableSchema {
130+
return clusterv1.VariableSchema{
131+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
132+
Description: "Nutanix GPU type",
133+
Type: "object",
134+
Properties: map[string]clusterv1.JSONSchemaProps{},
135+
},
136+
}
137+
}

0 commit comments

Comments
 (0)