4
4
package v1alpha1
5
5
6
6
import (
7
- capxv1 "github.com/d2iq-labs/capi-runtime-extensions/api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1"
8
- "github.com/d2iq-labs/capi-runtime-extensions/api/variables"
9
7
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
10
8
)
11
9
10
+ const (
11
+ // NutanixIdentifierUUID is a resource identifier identifying the object by UUID.
12
+ NutanixIdentifierUUID NutanixIdentifierType = "uuid"
13
+
14
+ // NutanixIdentifierName is a resource identifier identifying the object by Name.
15
+ NutanixIdentifierName NutanixIdentifierType = "name"
16
+
17
+ // NutanixBootTypeLegacy is a resource identifier identifying the legacy boot type for virtual machines.
18
+ NutanixBootTypeLegacy NutanixBootType = "legacy"
19
+
20
+ // NutanixBootTypeUEFI is a resource identifier identifying the UEFI boot type for virtual machines.
21
+ NutanixBootTypeUEFI NutanixBootType = "uefi"
22
+ )
23
+
12
24
// NutanixIdentifierType is an enumeration of different resource identifier types.
13
25
type NutanixIdentifierType string
14
26
27
+ func (NutanixIdentifierType ) VariableSchema () clusterv1.VariableSchema {
28
+ return clusterv1.VariableSchema {
29
+ OpenAPIV3Schema : clusterv1.JSONSchemaProps {
30
+ Type : "string" ,
31
+ Description : "NutanixIdentifierType is an enumeration of different resource identifier types" ,
32
+ },
33
+ }
34
+ }
35
+
15
36
// NutanixBootType is an enumeration of different boot types.
16
37
type NutanixBootType string
17
38
39
+ func (NutanixBootType ) VariableSchema () clusterv1.VariableSchema {
40
+ return clusterv1.VariableSchema {
41
+ OpenAPIV3Schema : clusterv1.JSONSchemaProps {
42
+ Type : "string" ,
43
+ Description : "NutanixBootType is an enumeration of different boot types." ,
44
+ },
45
+ }
46
+ }
47
+
18
48
// NutanixGPUIdentifierType is an enumeration of different resource identifier types for GPU entities.
19
49
type NutanixGPUIdentifierType string
20
50
21
- type NutanixNodeSpec struct {
51
+ func (NutanixGPUIdentifierType ) VariableSchema () clusterv1.VariableSchema {
52
+ return clusterv1.VariableSchema {
53
+ OpenAPIV3Schema : clusterv1.JSONSchemaProps {
54
+ Type : "string" ,
55
+ Description : "NutanixGPUIdentifierType is an enumeration of different resource identifier types for GPU entities." ,
56
+ },
57
+ }
58
+ }
59
+
60
+ type NutanixMachineDetails struct {
22
61
// vcpusPerSocket is the number of vCPUs per socket of the VM
23
62
VCPUsPerSocket int32 `json:"vcpusPerSocket"`
24
63
@@ -48,10 +87,10 @@ type NutanixNodeSpec struct {
48
87
AdditionalCategories []NutanixCategoryIdentifier `json:"additionalCategories,omitempty"`
49
88
50
89
// Add the machine resources to a Prism Central project
51
- Project * NutanixResourceIdentifier `json:"project,omitempty"`
90
+ Project NutanixResourceIdentifier `json:"project,omitempty"`
52
91
53
92
// Defines the boot type of the virtual machine. Only supports UEFI and Legacy
54
- BootType string `json:"bootType,omitempty"` //TODO use NutanixBootType enum somehow
93
+ BootType NutanixBootType `json:"bootType,omitempty"`
55
94
56
95
// systemDiskSize is size (in Quantity format) of the system disk of the VM
57
96
// The minimum systemDiskSize is 20Gi bytes
@@ -61,10 +100,10 @@ type NutanixNodeSpec struct {
61
100
GPUs []NutanixGPU `json:"gpus,omitempty"`
62
101
}
63
102
64
- func (NutanixNodeSpec ) VariableSchema () clusterv1.VariableSchema {
103
+ func (NutanixMachineDetails ) VariableSchema () clusterv1.VariableSchema {
65
104
return clusterv1.VariableSchema {
66
105
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
67
- Description : "Nutanix Node configuration" ,
106
+ Description : "Nutanix Machine configuration" ,
68
107
Type : "object" ,
69
108
Properties : map [string ]clusterv1.JSONSchemaProps {
70
109
"vcpusPerSocket" : {
@@ -79,41 +118,33 @@ func (NutanixNodeSpec) VariableSchema() clusterv1.VariableSchema {
79
118
Description : "memorySize is the memory size (in Quantity format) of the VM eg. 4Gi" ,
80
119
Type : "string" ,
81
120
},
82
- "image" : NutanixResourceIdentifier {}.VariableSchema ().OpenAPIV3Schema ,
83
- "cluster" : NutanixResourceIdentifier {}.VariableSchema ().OpenAPIV3Schema ,
84
- "subnet" : NutanixResourceIdentifiers {}.VariableSchema ().OpenAPIV3Schema ,
85
- "bootType" : {
86
- Description : "Defines the boot type of the virtual machine. Only supports UEFI and Legacy" ,
87
- Type : "string" ,
88
- },
121
+ "image" : NutanixResourceIdentifier {}.VariableSchema ().OpenAPIV3Schema ,
122
+ "cluster" : NutanixResourceIdentifier {}.VariableSchema ().OpenAPIV3Schema ,
123
+ "subnet" : NutanixResourceIdentifiers {}.VariableSchema ().OpenAPIV3Schema ,
124
+ "bootType" : NutanixBootType ("legacy" ).VariableSchema ().OpenAPIV3Schema ,
89
125
"systemDiskSize" : {
90
126
Description : "systemDiskSize is size (in Quantity format) of the system disk of the VM eg. 20Gi" ,
91
127
Type : "string" ,
92
128
},
93
- // "project": {} ,
129
+ "project" : NutanixResourceIdentifier {}. VariableSchema (). OpenAPIV3Schema ,
94
130
// "additionalCategories": {},
95
131
// "gpus": {},
96
132
},
97
133
},
98
134
}
99
135
}
100
136
101
- func (NutanixBootType ) VariableSchema () clusterv1.VariableSchema {
102
- supportedBootType := []capxv1.NutanixBootType {
103
- capxv1 .NutanixBootTypeLegacy ,
104
- capxv1 .NutanixBootTypeUEFI ,
105
- }
137
+ type NutanixNodeSpec struct {
138
+ MachineDetails * NutanixMachineDetails `json:"machineDetails"`
139
+ }
106
140
141
+ func (NutanixNodeSpec ) VariableSchema () clusterv1.VariableSchema {
107
142
return clusterv1.VariableSchema {
108
143
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
109
- Description : "Nutanix Boot type enum " ,
110
- Type : "string " ,
144
+ Description : "Nutanix Node configuration " ,
145
+ Type : "object " ,
111
146
Properties : map [string ]clusterv1.JSONSchemaProps {
112
- "bootType" : {
113
- Description : "Defines the boot type of the virtual machine. Only supports UEFI and Legacy" ,
114
- Type : "string" ,
115
- Enum : variables .MustMarshalValuesToEnumJSON (supportedBootType ... ),
116
- },
147
+ "machineDetails" : NutanixMachineDetails {}.VariableSchema ().OpenAPIV3Schema ,
117
148
},
118
149
},
119
150
}
@@ -127,7 +158,7 @@ type NutanixResourceIdentifier struct {
127
158
// +optional
128
159
UUID * string `json:"uuid,omitempty"`
129
160
130
- // name is the resource name in the PC
161
+ // name is the resource name in the PC.
131
162
// +optional
132
163
Name * string `json:"name,omitempty"`
133
164
}
@@ -137,7 +168,17 @@ func (NutanixResourceIdentifier) VariableSchema() clusterv1.VariableSchema {
137
168
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
138
169
Description : "Nutanix Resource Identifier" ,
139
170
Type : "object" ,
140
- Properties : map [string ]clusterv1.JSONSchemaProps {},
171
+ Properties : map [string ]clusterv1.JSONSchemaProps {
172
+ "type" : NutanixIdentifierType ("name" ).VariableSchema ().OpenAPIV3Schema ,
173
+ "uuid" : {
174
+ Type : "string" ,
175
+ Description : "uuid is the UUID of the resource in the PC." ,
176
+ },
177
+ "name" : {
178
+ Type : "string" ,
179
+ Description : "name is the resource name in the PC." ,
180
+ },
181
+ },
141
182
},
142
183
}
143
184
}
@@ -147,7 +188,7 @@ type NutanixCategoryIdentifier struct {
147
188
// +optional
148
189
Key string `json:"key,omitempty"`
149
190
150
- // value is the category value linked to the category key in PC
191
+ // value is the category value linked to the category key in PC.
151
192
// +optional
152
193
Value string `json:"value,omitempty"`
153
194
}
@@ -157,7 +198,16 @@ func (NutanixCategoryIdentifier) VariableSchema() clusterv1.VariableSchema {
157
198
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
158
199
Description : "Nutanix Category Identifier" ,
159
200
Type : "object" ,
160
- Properties : map [string ]clusterv1.JSONSchemaProps {},
201
+ Properties : map [string ]clusterv1.JSONSchemaProps {
202
+ "key" : {
203
+ Type : "string" ,
204
+ Description : "key is the Key of category in PC." ,
205
+ },
206
+ "value" : {
207
+ Type : "string" ,
208
+ Description : "value is the category value linked to the category key in PC" ,
209
+ },
210
+ },
161
211
},
162
212
}
163
213
}
@@ -170,7 +220,7 @@ type NutanixGPU struct {
170
220
// +optional
171
221
DeviceID * int64 `json:"deviceID,omitempty"`
172
222
173
- // name is the GPU name
223
+ // name is the GPU name.
174
224
// +optional
175
225
Name * string `json:"name,omitempty"`
176
226
}
@@ -180,7 +230,17 @@ func (NutanixGPU) VariableSchema() clusterv1.VariableSchema {
180
230
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
181
231
Description : "Nutanix GPU type" ,
182
232
Type : "object" ,
183
- Properties : map [string ]clusterv1.JSONSchemaProps {},
233
+ Properties : map [string ]clusterv1.JSONSchemaProps {
234
+ "type" : NutanixGPUIdentifierType ("name" ).VariableSchema ().OpenAPIV3Schema ,
235
+ "deviceID" : {
236
+ Type : "int64" ,
237
+ Description : "deviceID is the id of the GPU entity." ,
238
+ },
239
+ "name" : {
240
+ Type : "string" ,
241
+ Description : "name is the GPU name." ,
242
+ },
243
+ },
184
244
},
185
245
}
186
246
}
0 commit comments