Skip to content

Commit 2476cc7

Browse files
authored
Merge pull request gophercloud#3228 from Sharpz7/node-api-parity
Added required fields for Node API Parity
2 parents 8f11cce + 3d2bb51 commit 2476cc7

File tree

2 files changed

+177
-38
lines changed

2 files changed

+177
-38
lines changed

openstack/baremetal/v1/nodes/results.go

+64-18
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,19 @@ func (r SubscriptionVendorPassthruResult) Extract() (*SubscriptionVendorPassthru
9090
return &s, err
9191
}
9292

93+
// Link represents a hyperlink and its relationship to the current resource.
94+
type Link struct {
95+
// Href is the URL of the related resource.
96+
Href string `json:"href"`
97+
98+
// Rel describes the relationship of the resource to the current
99+
// context (e.g., "self", "bookmark").
100+
Rel string `json:"rel"`
101+
}
102+
93103
// Node represents a node in the OpenStack Bare Metal API.
104+
// https://docs.openstack.org/api-ref/baremetal/#list-nodes-detailed
94105
type Node struct {
95-
// Whether automated cleaning is enabled or disabled on this node.
96-
// Requires microversion 1.47 or later.
97-
AutomatedClean *bool `json:"automated_clean"`
98-
99106
// UUID for the resource.
100107
UUID string `json:"uuid"`
101108

@@ -183,8 +190,17 @@ type Node struct {
183190
// Current deploy step.
184191
DeployStep map[string]any `json:"deploy_step"`
185192

186-
// Current service step.
187-
ServiceStep map[string]any `json:"service_step"`
193+
// A list of relative links. Includes the self and bookmark links.
194+
Links []Link `json:"links"`
195+
196+
// Links to the collection of ports on this node
197+
Ports []Link `json:"ports"`
198+
199+
// Links to the collection of portgroups on this node.
200+
PortGroups []Link `json:"portgroups"`
201+
202+
// Links to the collection of states. Note that this resource is also used to request state transitions.
203+
States []Link `json:"states"`
188204

189205
// String which can be used by external schedulers to identify this Node as a unit of a specific type of resource.
190206
// For more details, see: https://docs.openstack.org/ironic/latest/install/configure-nova-flavors.html
@@ -202,9 +218,6 @@ type Node struct {
202218
// Deploy interface for a node, e.g. “iscsi”.
203219
DeployInterface string `json:"deploy_interface"`
204220

205-
// Firmware interface for a node, e.g. “redfish”.
206-
FirmwareInterface string `json:"firmware_interface"`
207-
208221
// Interface used for node inspection, e.g. “no-inspect”.
209222
InspectInterface string `json:"inspect_interface"`
210223

@@ -232,9 +245,15 @@ type Node struct {
232245
// For vendor-specific functionality on this node, e.g. “no-vendor”.
233246
VendorInterface string `json:"vendor_interface"`
234247

248+
// Links to the volume resources.
249+
Volume []Link `json:"volume"`
250+
235251
// Conductor group for a node. Case-insensitive string up to 255 characters, containing a-z, 0-9, _, -, and ..
236252
ConductorGroup string `json:"conductor_group"`
237253

254+
// An optional UUID which can be used to denote the “parent” baremetal node.
255+
ParentNode string `json:"parent_node"`
256+
238257
// The node is protected from undeploying, rebuilding and deletion.
239258
Protected bool `json:"protected"`
240259

@@ -244,14 +263,42 @@ type Node struct {
244263
// A string or UUID of the tenant who owns the baremetal node.
245264
Owner string `json:"owner"`
246265

266+
// A string or UUID of the tenant who is leasing the object.
267+
Lessee string `json:"lessee"`
268+
269+
// A string indicating the shard this node belongs to.
270+
Shard string `json:"shard"`
271+
272+
// Informational text about this node.
273+
Description string `json:"description"`
274+
275+
// The conductor currently servicing a node. This field is read-only.
276+
Conductor string `json:"conductor"`
277+
278+
// The UUID of the allocation associated with the node. If not null, will be the same as instance_uuid
279+
// (the opposite is not always true). Unlike instance_uuid, this field is read-only. Please use the
280+
// Allocation API to remove allocations.
281+
AllocationUUID string `json:"allocation_uuid"`
282+
283+
// Whether the node is retired. A Node tagged as retired will prevent any further
284+
// scheduling of instances, but will still allow for other operations, such as cleaning, to happen
285+
Retired bool `json:"retired"`
286+
287+
// Reason the node is marked as retired.
288+
RetiredReason string `json:"retired_reason"`
289+
247290
// Static network configuration to use during deployment and cleaning.
248291
NetworkData map[string]any `json:"network_data"`
249292

250-
// The UTC date and time when the resource was created, ISO 8601 format.
251-
CreatedAt time.Time `json:"created_at"`
293+
// Whether automated cleaning is enabled or disabled on this node.
294+
// Requires microversion 1.47 or later.
295+
AutomatedClean *bool `json:"automated_clean"`
252296

253-
// The UTC date and time when the resource was updated, ISO 8601 format. May be “null”.
254-
UpdatedAt time.Time `json:"updated_at"`
297+
// Current service step.
298+
ServiceStep map[string]any `json:"service_step"`
299+
300+
// Firmware interface for a node, e.g. “redfish”.
301+
FirmwareInterface string `json:"firmware_interface"`
255302

256303
// The UTC date and time when the provision state was updated, ISO 8601 format. May be “null”.
257304
ProvisionUpdatedAt time.Time `json:"provision_updated_at"`
@@ -262,12 +309,11 @@ type Node struct {
262309
// The UTC date and time when the last inspection was finished, ISO 8601 format. May be “null” if inspection hasn't been finished yet.
263310
InspectionFinishedAt *time.Time `json:"inspection_finished_at"`
264311

265-
// Whether the node is retired. A Node tagged as retired will prevent any further
266-
// scheduling of instances, but will still allow for other operations, such as cleaning, to happen
267-
Retired bool `json:"retired"`
312+
// The UTC date and time when the resource was created, ISO 8601 format.
313+
CreatedAt time.Time `json:"created_at"`
268314

269-
// Reason the node is marked as retired.
270-
RetiredReason string `json:"retired_reason"`
315+
// The UTC date and time when the resource was updated, ISO 8601 format. May be “null”.
316+
UpdatedAt time.Time `json:"updated_at"`
271317
}
272318

273319
// NodePage abstracts the raw results of making a List() request against

openstack/baremetal/v1/nodes/testing/fixtures_test.go

+113-20
Original file line numberDiff line numberDiff line change
@@ -925,23 +925,57 @@ var (
925925
"deploy_ramdisk": "http://172.22.0.1/images/tinyipa-stable-rocky.gz",
926926
"ipmi_password": "admin",
927927
},
928-
DriverInternalInfo: map[string]any{},
929-
Properties: map[string]any{},
930-
InstanceInfo: map[string]any{},
931-
InstanceUUID: "",
932-
ChassisUUID: "",
933-
Extra: map[string]any{},
934-
ConsoleEnabled: false,
935-
RAIDConfig: map[string]any{},
936-
TargetRAIDConfig: map[string]any{},
937-
CleanStep: map[string]any{},
938-
DeployStep: map[string]any{},
928+
DriverInternalInfo: map[string]any{},
929+
Properties: map[string]any{},
930+
InstanceInfo: map[string]any{},
931+
InstanceUUID: "",
932+
ChassisUUID: "",
933+
Extra: map[string]any{},
934+
ConsoleEnabled: false,
935+
RAIDConfig: map[string]any{},
936+
TargetRAIDConfig: map[string]any{},
937+
CleanStep: map[string]any{},
938+
DeployStep: map[string]any{},
939+
Links: []nodes.Link{
940+
{
941+
Href: "http://ironic.example.com:6385/v1/nodes/d2630783-6ec8-4836-b556-ab427c4b581e",
942+
Rel: "self",
943+
},
944+
{
945+
Href: "http://ironic.example.com:6385/nodes/d2630783-6ec8-4836-b556-ab427c4b581e",
946+
Rel: "bookmark",
947+
},
948+
},
949+
Ports: []nodes.Link{
950+
{
951+
Href: "http://ironic.example.com:6385/v1/nodes/d2630783-6ec8-4836-b556-ab427c4b581e/ports",
952+
Rel: "self",
953+
},
954+
{
955+
Href: "http://ironic.example.com:6385/nodes/d2630783-6ec8-4836-b556-ab427c4b581e/ports",
956+
Rel: "bookmark",
957+
},
958+
},
959+
PortGroups: []nodes.Link{
960+
{
961+
Href: "http://ironic.example.com:6385/v1/nodes/d2630783-6ec8-4836-b556-ab427c4b581e/portgroups",
962+
Rel: "self",
963+
},
964+
{
965+
Href: "http://ironic.example.com:6385/nodes/d2630783-6ec8-4836-b556-ab427c4b581e/portgroups",
966+
Rel: "bookmark"},
967+
},
968+
States: []nodes.Link{
969+
{
970+
Href: "http://ironic.example.com:6385/v1/nodes/d2630783-6ec8-4836-b556-ab427c4b581e/states",
971+
Rel: "self",
972+
},
973+
},
939974
ResourceClass: "",
940975
BIOSInterface: "no-bios",
941976
BootInterface: "pxe",
942977
ConsoleInterface: "no-console",
943978
DeployInterface: "iscsi",
944-
FirmwareInterface: "no-firmware",
945979
InspectInterface: "no-inspect",
946980
ManagementInterface: "ipmitool",
947981
NetworkInterface: "flat",
@@ -951,14 +985,33 @@ var (
951985
StorageInterface: "noop",
952986
Traits: []string{},
953987
VendorInterface: "ipmitool",
954-
ConductorGroup: "",
955-
Protected: false,
956-
ProtectedReason: "",
957-
CreatedAt: createdAtFoo,
958-
UpdatedAt: updatedAt,
959-
ProvisionUpdatedAt: provisonUpdatedAt,
960-
Retired: false,
961-
RetiredReason: "No longer needed",
988+
Volume: []nodes.Link{
989+
{
990+
Href: "http://ironic.example.com:6385/v1/nodes/d2630783-6ec8-4836-b556-ab427c4b581e/volume",
991+
Rel: "self",
992+
},
993+
},
994+
ConductorGroup: "",
995+
ParentNode: "",
996+
Protected: false,
997+
ProtectedReason: "",
998+
Owner: "",
999+
Lessee: "",
1000+
Shard: "",
1001+
Description: "",
1002+
Conductor: "",
1003+
AllocationUUID: "",
1004+
Retired: false,
1005+
RetiredReason: "No longer needed",
1006+
NetworkData: map[string]interface{}(nil),
1007+
AutomatedClean: nil,
1008+
ServiceStep: map[string]interface{}(nil),
1009+
FirmwareInterface: "no-firmware",
1010+
ProvisionUpdatedAt: provisonUpdatedAt,
1011+
InspectionStartedAt: nil,
1012+
InspectionFinishedAt: nil,
1013+
CreatedAt: createdAtFoo,
1014+
UpdatedAt: updatedAt,
9621015
}
9631016

9641017
NodeFooValidation = nodes.NodeValidation{
@@ -1070,6 +1123,26 @@ var (
10701123
InspectionFinishedAt: &InspectionFinishedAt,
10711124
Retired: false,
10721125
RetiredReason: "No longer needed",
1126+
Links: []nodes.Link{
1127+
{Href: "http://ironic.example.com:6385/v1/nodes/08c84581-58f5-4ea2-a0c6-dd2e5d2b3662", Rel: "self"},
1128+
{Href: "http://ironic.example.com:6385/nodes/08c84581-58f5-4ea2-a0c6-dd2e5d2b3662", Rel: "bookmark"},
1129+
},
1130+
Ports: []nodes.Link{
1131+
{Href: "http://ironic.example.com:6385/v1/nodes/08c84581-58f5-4ea2-a0c6-dd2e5d2b3662/ports", Rel: "self"},
1132+
{Href: "http://ironic.example.com:6385/nodes/08c84581-58f5-4ea2-a0c6-dd2e5d2b3662/ports", Rel: "bookmark"},
1133+
},
1134+
PortGroups: []nodes.Link{
1135+
{Href: "http://ironic.example.com:6385/v1/nodes/08c84581-58f5-4ea2-a0c6-dd2e5d2b3662/portgroups", Rel: "self"},
1136+
{Href: "http://ironic.example.com:6385/nodes/08c84581-58f5-4ea2-a0c6-dd2e5d2b3662/portgroups", Rel: "bookmark"},
1137+
},
1138+
States: []nodes.Link{
1139+
{Href: "http://ironic.example.com:6385/v1/nodes/08c84581-58f5-4ea2-a0c6-dd2e5d2b3662/states", Rel: "self"},
1140+
{Href: "http://ironic.example.com:6385/nodes/08c84581-58f5-4ea2-a0c6-dd2e5d2b3662/states", Rel: "bookmark"},
1141+
},
1142+
Volume: []nodes.Link{
1143+
{Href: "http://ironic.example.com:6385/v1/nodes/08c84581-58f5-4ea2-a0c6-dd2e5d2b3662/volume", Rel: "self"},
1144+
{Href: "http://ironic.example.com:6385/nodes/08c84581-58f5-4ea2-a0c6-dd2e5d2b3662/volume", Rel: "bookmark"},
1145+
},
10731146
}
10741147

10751148
NodeBaz = nodes.Node{
@@ -1119,6 +1192,26 @@ var (
11191192
UpdatedAt: updatedAt,
11201193
Retired: false,
11211194
RetiredReason: "No longer needed",
1195+
Links: []nodes.Link{
1196+
{Href: "http://ironic.example.com:6385/v1/nodes/c9afd385-5d89-4ecb-9e1c-68194da6b474", Rel: "self"},
1197+
{Href: "http://ironic.example.com:6385/nodes/c9afd385-5d89-4ecb-9e1c-68194da6b474", Rel: "bookmark"},
1198+
},
1199+
Ports: []nodes.Link{
1200+
{Href: "http://ironic.example.com:6385/v1/nodes/c9afd385-5d89-4ecb-9e1c-68194da6b474/ports", Rel: "self"},
1201+
{Href: "http://ironic.example.com:6385/nodes/c9afd385-5d89-4ecb-9e1c-68194da6b474/ports", Rel: "bookmark"},
1202+
},
1203+
PortGroups: []nodes.Link{
1204+
{Href: "http://ironic.example.com:6385/v1/nodes/c9afd385-5d89-4ecb-9e1c-68194da6b474/portgroups", Rel: "self"},
1205+
{Href: "http://ironic.example.com:6385/nodes/c9afd385-5d89-4ecb-9e1c-68194da6b474/portgroups", Rel: "bookmark"},
1206+
},
1207+
States: []nodes.Link{
1208+
{Href: "http://ironic.example.com:6385/v1/nodes/c9afd385-5d89-4ecb-9e1c-68194da6b474/states", Rel: "self"},
1209+
{Href: "http://ironic.example.com:6385/nodes/c9afd385-5d89-4ecb-9e1c-68194da6b474/states", Rel: "bookmark"},
1210+
},
1211+
Volume: []nodes.Link{
1212+
{Href: "http://ironic.example.com:6385/v1/nodes/c9afd385-5d89-4ecb-9e1c-68194da6b474/volume", Rel: "self"},
1213+
{Href: "http://ironic.example.com:6385/nodes/c9afd385-5d89-4ecb-9e1c-68194da6b474/volume", Rel: "bookmark"},
1214+
},
11221215
}
11231216

11241217
ConfigDriveMap = nodes.ConfigDrive{

0 commit comments

Comments
 (0)