1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
|
package nodes
import (
"time"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
type nodeResult struct {
gophercloud.Result
}
// Extract interprets any nodeResult as a Node, if possible.
func (r nodeResult) Extract() (*Node, error) {
var s Node
err := r.ExtractInto(&s)
return &s, err
}
// Extract interprets a BootDeviceResult as BootDeviceOpts, if possible.
func (r BootDeviceResult) Extract() (*BootDeviceOpts, error) {
var s BootDeviceOpts
err := r.ExtractInto(&s)
return &s, err
}
// Extract interprets a SupportedBootDeviceResult as an array of supported boot devices, if possible.
func (r SupportedBootDeviceResult) Extract() ([]string, error) {
var s struct {
Devices []string `json:"supported_boot_devices"`
}
err := r.ExtractInto(&s)
return s.Devices, err
}
// Extract interprets a ValidateResult as NodeValidation, if possible.
func (r ValidateResult) Extract() (*NodeValidation, error) {
var s NodeValidation
err := r.ExtractInto(&s)
return &s, err
}
func (r nodeResult) ExtractInto(v interface{}) error {
return r.Result.ExtractIntoStructPtr(v, "")
}
func ExtractNodesInto(r pagination.Page, v interface{}) error {
return r.(NodePage).Result.ExtractIntoSlicePtr(v, "nodes")
}
// Extract interprets a BIOSSettingsResult as an array of BIOSSetting structs, if possible.
func (r ListBIOSSettingsResult) Extract() ([]BIOSSetting, error) {
var s struct {
Settings []BIOSSetting `json:"bios"`
}
err := r.ExtractInto(&s)
return s.Settings, err
}
// Extract interprets a SingleBIOSSettingResult as a BIOSSetting struct, if possible.
func (r GetBIOSSettingResult) Extract() (*BIOSSetting, error) {
var s SingleBIOSSetting
err := r.ExtractInto(&s)
return &s.Setting, err
}
// Extract interprets a VendorPassthruMethod as
func (r VendorPassthruMethodsResult) Extract() (*VendorPassthruMethods, error) {
var s VendorPassthruMethods
err := r.ExtractInto(&s)
return &s, err
}
func (r GetAllSubscriptionsVendorPassthruResult) Extract() (*GetAllSubscriptionsVendorPassthru, error) {
var s GetAllSubscriptionsVendorPassthru
err := r.ExtractInto(&s)
return &s, err
}
func (r SubscriptionVendorPassthruResult) Extract() (*SubscriptionVendorPassthru, error) {
var s SubscriptionVendorPassthru
err := r.ExtractInto(&s)
return &s, err
}
// Node represents a node in the OpenStack Bare Metal API.
type Node struct {
// Whether automated cleaning is enabled or disabled on this node.
// Requires microversion 1.47 or later.
AutomatedClean *bool `json:"automated_clean"`
// UUID for the resource.
UUID string `json:"uuid"`
// Identifier for the Node resource. May be undefined. Certain words are reserved.
Name string `json:"name"`
// Current power state of this Node. Usually, “power on” or “power off”, but may be “None”
// if Ironic is unable to determine the power state (eg, due to hardware failure).
PowerState string `json:"power_state"`
// A power state transition has been requested, this field represents the requested (ie, “target”)
// state either “power on”, “power off”, “rebooting”, “soft power off” or “soft rebooting”.
TargetPowerState string `json:"target_power_state"`
// Current provisioning state of this Node.
ProvisionState string `json:"provision_state"`
// A provisioning action has been requested, this field represents the requested (ie, “target”) state. Note
// that a Node may go through several states during its transition to this target state. For instance, when
// requesting an instance be deployed to an AVAILABLE Node, the Node may go through the following state
// change progression: AVAILABLE -> DEPLOYING -> DEPLOYWAIT -> DEPLOYING -> ACTIVE
TargetProvisionState string `json:"target_provision_state"`
// Whether or not this Node is currently in “maintenance mode”. Setting a Node into maintenance mode removes it
// from the available resource pool and halts some internal automation. This can happen manually (eg, via an API
// request) or automatically when Ironic detects a hardware fault that prevents communication with the machine.
Maintenance bool `json:"maintenance"`
// Description of the reason why this Node was placed into maintenance mode
MaintenanceReason string `json:"maintenance_reason"`
// Fault indicates the active fault detected by ironic, typically the Node is in “maintenance mode”. None means no
// fault has been detected by ironic. “power failure” indicates ironic failed to retrieve power state from this
// node. There are other possible types, e.g., “clean failure” and “rescue abort failure”.
Fault string `json:"fault"`
// Error from the most recent (last) transaction that started but failed to finish.
LastError string `json:"last_error"`
// Name of an Ironic Conductor host which is holding a lock on this node, if a lock is held. Usually “null”,
// but this field can be useful for debugging.
Reservation string `json:"reservation"`
// Name of the driver.
Driver string `json:"driver"`
// The metadata required by the driver to manage this Node. List of fields varies between drivers, and can be
// retrieved from the /v1/drivers/<DRIVER_NAME>/properties resource.
DriverInfo map[string]interface{} `json:"driver_info"`
// Metadata set and stored by the Node’s driver. This field is read-only.
DriverInternalInfo map[string]interface{} `json:"driver_internal_info"`
// Characteristics of this Node. Populated by ironic-inspector during inspection. May be edited via the REST
// API at any time.
Properties map[string]interface{} `json:"properties"`
// Used to customize the deployed image. May include root partition size, a base 64 encoded config drive, and other
// metadata. Note that this field is erased automatically when the instance is deleted (this is done by requesting
// the Node provision state be changed to DELETED).
InstanceInfo map[string]interface{} `json:"instance_info"`
// ID of the Nova instance associated with this Node.
InstanceUUID string `json:"instance_uuid"`
// ID of the chassis associated with this Node. May be empty or None.
ChassisUUID string `json:"chassis_uuid"`
// Set of one or more arbitrary metadata key and value pairs.
Extra map[string]interface{} `json:"extra"`
// Whether console access is enabled or disabled on this node.
ConsoleEnabled bool `json:"console_enabled"`
// The current RAID configuration of the node. Introduced with the cleaning feature.
RAIDConfig map[string]interface{} `json:"raid_config"`
// The requested RAID configuration of the node, which will be applied when the Node next transitions
// through the CLEANING state. Introduced with the cleaning feature.
TargetRAIDConfig map[string]interface{} `json:"target_raid_config"`
// Current clean step. Introduced with the cleaning feature.
CleanStep map[string]interface{} `json:"clean_step"`
// Current deploy step.
DeployStep map[string]interface{} `json:"deploy_step"`
// String which can be used by external schedulers to identify this Node as a unit of a specific type of resource.
// For more details, see: https://docs.openstack.org/ironic/latest/install/configure-nova-flavors.html
ResourceClass string `json:"resource_class"`
// BIOS interface for a Node, e.g. “redfish”.
BIOSInterface string `json:"bios_interface"`
// Boot interface for a Node, e.g. “pxe”.
BootInterface string `json:"boot_interface"`
// Console interface for a node, e.g. “no-console”.
ConsoleInterface string `json:"console_interface"`
// Deploy interface for a node, e.g. “iscsi”.
DeployInterface string `json:"deploy_interface"`
// Interface used for node inspection, e.g. “no-inspect”.
InspectInterface string `json:"inspect_interface"`
// For out-of-band node management, e.g. “ipmitool”.
ManagementInterface string `json:"management_interface"`
// Network Interface provider to use when plumbing the network connections for this Node.
NetworkInterface string `json:"network_interface"`
// used for performing power actions on the node, e.g. “ipmitool”.
PowerInterface string `json:"power_interface"`
// Used for configuring RAID on this node, e.g. “no-raid”.
RAIDInterface string `json:"raid_interface"`
// Interface used for node rescue, e.g. “no-rescue”.
RescueInterface string `json:"rescue_interface"`
// Used for attaching and detaching volumes on this node, e.g. “cinder”.
StorageInterface string `json:"storage_interface"`
// Array of traits for this node.
Traits []string `json:"traits"`
// For vendor-specific functionality on this node, e.g. “no-vendor”.
VendorInterface string `json:"vendor_interface"`
// Conductor group for a node. Case-insensitive string up to 255 characters, containing a-z, 0-9, _, -, and ..
ConductorGroup string `json:"conductor_group"`
// The node is protected from undeploying, rebuilding and deletion.
Protected bool `json:"protected"`
// Reason the node is marked as protected.
ProtectedReason string `json:"protected_reason"`
// A string or UUID of the tenant who owns the baremetal node.
Owner string `json:"owner"`
// Static network configuration to use during deployment and cleaning.
NetworkData map[string]interface{} `json:"network_data"`
// The UTC date and time when the resource was created, ISO 8601 format.
CreatedAt time.Time `json:"created_at"`
// The UTC date and time when the resource was updated, ISO 8601 format. May be “null”.
UpdatedAt time.Time `json:"updated_at"`
// The UTC date and time when the provision state was updated, ISO 8601 format. May be “null”.
ProvisionUpdatedAt time.Time `json:"provision_updated_at"`
// The UTC date and time when the last inspection was started, ISO 8601 format. May be “null” if inspection hasn't been started yet.
InspectionStartedAt *time.Time `json:"inspection_started_at"`
// The UTC date and time when the last inspection was finished, ISO 8601 format. May be “null” if inspection hasn't been finished yet.
InspectionFinishedAt *time.Time `json:"inspection_finished_at"`
}
// NodePage abstracts the raw results of making a List() request against
// the API. As OpenStack extensions may freely alter the response bodies of
// structures returned to the client, you may only safely access the data
// provided through the ExtractNodes call.
type NodePage struct {
pagination.LinkedPageBase
}
// IsEmpty returns true if a page contains no Node results.
func (r NodePage) IsEmpty() (bool, error) {
if r.StatusCode == 204 {
return true, nil
}
s, err := ExtractNodes(r)
return len(s) == 0, err
}
// NextPageURL uses the response's embedded link reference to navigate to the
// next page of results.
func (r NodePage) NextPageURL() (string, error) {
var s struct {
Links []gophercloud.Link `json:"nodes_links"`
}
err := r.ExtractInto(&s)
if err != nil {
return "", err
}
return gophercloud.ExtractNextURL(s.Links)
}
// ExtractNodes interprets the results of a single page from a List() call,
// producing a slice of Node entities.
func ExtractNodes(r pagination.Page) ([]Node, error) {
var s []Node
err := ExtractNodesInto(r, &s)
return s, err
}
// GetResult is the response from a Get operation. Call its Extract
// method to interpret it as a Node.
type GetResult struct {
nodeResult
}
// CreateResult is the response from a Create operation.
type CreateResult struct {
nodeResult
}
// UpdateResult is the response from an Update operation. Call its Extract
// method to interpret it as a Node.
type UpdateResult struct {
nodeResult
}
// DeleteResult is the response from a Delete operation. Call its ExtractErr
// method to determine if the call succeeded or failed.
type DeleteResult struct {
gophercloud.ErrResult
}
// ValidateResult is the response from a Validate operation. Call its Extract
// method to interpret it as a NodeValidation struct.
type ValidateResult struct {
gophercloud.Result
}
// InjectNMIResult is the response from an InjectNMI operation. Call its ExtractErr
// method to determine if the call succeeded or failed.
type InjectNMIResult struct {
gophercloud.ErrResult
}
// BootDeviceResult is the response from a GetBootDevice operation. Call its Extract
// method to interpret it as a BootDeviceOpts struct.
type BootDeviceResult struct {
gophercloud.Result
}
// SetBootDeviceResult is the response from a SetBootDevice operation. Call its Extract
// method to interpret it as a BootDeviceOpts struct.
type SetBootDeviceResult struct {
gophercloud.ErrResult
}
// SupportedBootDeviceResult is the response from a GetSupportedBootDevices operation. Call its Extract
// method to interpret it as an array of supported boot device values.
type SupportedBootDeviceResult struct {
gophercloud.Result
}
// ChangePowerStateResult is the response from a ChangePowerState operation. Call its ExtractErr
// method to determine if the call succeeded or failed.
type ChangePowerStateResult struct {
gophercloud.ErrResult
}
// ListBIOSSettingsResult is the response from a ListBIOSSettings operation. Call its Extract
// method to interpret it as an array of BIOSSetting structs.
type ListBIOSSettingsResult struct {
gophercloud.Result
}
// GetBIOSSettingResult is the response from a GetBIOSSetting operation. Call its Extract
// method to interpret it as a BIOSSetting struct.
type GetBIOSSettingResult struct {
gophercloud.Result
}
// VendorPassthruMethodsResult is the response from a GetVendorPassthruMethods operation. Call its Extract
// method to interpret it as an array of allowed vendor methods.
type VendorPassthruMethodsResult struct {
gophercloud.Result
}
// GetAllSubscriptionsVendorPassthruResult is the response from GetAllSubscriptions operation. Call its
// Extract method to interpret it as a GetAllSubscriptionsVendorPassthru struct.
type GetAllSubscriptionsVendorPassthruResult struct {
gophercloud.Result
}
// SubscriptionVendorPassthruResult is the response from GetSubscription and CreateSubscription operation. Call its Extract
// method to interpret it as a SubscriptionVendorPassthru struct.
type SubscriptionVendorPassthruResult struct {
gophercloud.Result
}
// DeleteSubscriptionVendorPassthruResult is the response from DeleteSubscription operation. Call its
// ExtractErr method to determine if the call succeeded of failed.
type DeleteSubscriptionVendorPassthruResult struct {
gophercloud.ErrResult
}
// Each element in the response will contain a “result” variable, which will have a value of “true” or “false”, and
// also potentially a reason. A value of nil indicates that the Node’s driver does not support that interface.
type DriverValidation struct {
Result bool `json:"result"`
Reason string `json:"reason"`
}
// Ironic validates whether the Node’s driver has enough information to manage the Node. This polls each interface on
// the driver, and returns the status of that interface as an DriverValidation struct.
type NodeValidation struct {
BIOS DriverValidation `json:"bios"`
Boot DriverValidation `json:"boot"`
Console DriverValidation `json:"console"`
Deploy DriverValidation `json:"deploy"`
Inspect DriverValidation `json:"inspect"`
Management DriverValidation `json:"management"`
Network DriverValidation `json:"network"`
Power DriverValidation `json:"power"`
RAID DriverValidation `json:"raid"`
Rescue DriverValidation `json:"rescue"`
Storage DriverValidation `json:"storage"`
}
// A particular BIOS setting for a node in the OpenStack Bare Metal API.
type BIOSSetting struct {
// Identifier for the BIOS setting.
Name string `json:"name"`
// Value of the BIOS setting.
Value string `json:"value"`
// The following fields are returned in microversion 1.74 or later
// when using the `details` option
// The type of setting - Enumeration, String, Integer, or Boolean.
AttributeType string `json:"attribute_type"`
// The allowable value for an Enumeration type setting.
AllowableValues []string `json:"allowable_values"`
// The lowest value for an Integer type setting.
LowerBound *int `json:"lower_bound"`
// The highest value for an Integer type setting.
UpperBound *int `json:"upper_bound"`
// Minimum length for a String type setting.
MinLength *int `json:"min_length"`
// Maximum length for a String type setting.
MaxLength *int `json:"max_length"`
// Whether or not this setting is read only.
ReadOnly *bool `json:"read_only"`
// Whether or not a reset is required after changing this setting.
ResetRequired *bool `json:"reset_required"`
// Whether or not this setting's value is unique to this node, e.g.
// a serial number.
Unique *bool `json:"unique"`
}
type SingleBIOSSetting struct {
Setting BIOSSetting
}
// ChangeStateResult is the response from any state change operation. Call its ExtractErr
// method to determine if the call succeeded or failed.
type ChangeStateResult struct {
gophercloud.ErrResult
}
type VendorPassthruMethods struct {
CreateSubscription CreateSubscriptionMethod `json:"create_subscription,omitempty"`
DeleteSubscription DeleteSubscriptionMethod `json:"delete_subscription,omitempty"`
GetSubscription GetSubscriptionMethod `json:"get_subscription,omitempty"`
GetAllSubscriptions GetAllSubscriptionsMethod `json:"get_all_subscriptions,omitempty"`
}
// Below you can find all vendor passthru methods structs
type CreateSubscriptionMethod struct {
HTTPMethods []string `json:"http_methods"`
Async bool `json:"async"`
Description string `json:"description"`
Attach bool `json:"attach"`
RequireExclusiveLock bool `json:"require_exclusive_lock"`
}
type DeleteSubscriptionMethod struct {
HTTPMethods []string `json:"http_methods"`
Async bool `json:"async"`
Description string `json:"description"`
Attach bool `json:"attach"`
RequireExclusiveLock bool `json:"require_exclusive_lock"`
}
type GetSubscriptionMethod struct {
HTTPMethods []string `json:"http_methods"`
Async bool `json:"async"`
Description string `json:"description"`
Attach bool `json:"attach"`
RequireExclusiveLock bool `json:"require_exclusive_lock"`
}
type GetAllSubscriptionsMethod struct {
HTTPMethods []string `json:"http_methods"`
Async bool `json:"async"`
Description string `json:"description"`
Attach bool `json:"attach"`
RequireExclusiveLock bool `json:"require_exclusive_lock"`
}
// A List of subscriptions from a node in the OpenStack Bare Metal API.
type GetAllSubscriptionsVendorPassthru struct {
Context string `json:"@odata.context"`
Etag string `json:"@odata.etag"`
Id string `json:"@odata.id"`
Type string `json:"@odata.type"`
Description string `json:"Description"`
Name string `json:"Name"`
Members []map[string]string `json:"Members"`
MembersCount int `json:"Members@odata.count"`
}
// A Subscription from a node in the OpenStack Bare Metal API.
type SubscriptionVendorPassthru struct {
Id string `json:"Id"`
Context string `json:"Context"`
Destination string `json:"Destination"`
EventTypes []string `json:"EventTypes"`
Protocol string `json:"Protocol"`
}
// SetMaintenanceResult is the response from a SetMaintenance operation. Call its ExtractErr
// method to determine if the call succeeded or failed.
type SetMaintenanceResult struct {
gophercloud.ErrResult
}
|