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
|
package drivers
import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
type driverResult struct {
gophercloud.Result
}
// Extract interprets any driverResult as a Driver, if possible.
func (r driverResult) Extract() (*Driver, error) {
var s Driver
err := r.ExtractInto(&s)
return &s, err
}
func (r driverResult) ExtractInto(v interface{}) error {
return r.Result.ExtractIntoStructPtr(v, "")
}
func ExtractDriversInto(r pagination.Page, v interface{}) error {
return r.(DriverPage).Result.ExtractIntoSlicePtr(v, "drivers")
}
// Driver represents a driver in the OpenStack Bare Metal API.
type Driver struct {
// Name and Identifier of the driver
Name string `json:"name"`
// A list of active hosts that support this driver
Hosts []string `json:"hosts"`
// Type of this driver (“classic” or “dynamic”)
Type string `json:"type"`
// The default bios interface used for a node with a dynamic driver,
// if no bios interface is specified for the node.
DefaultBiosInterface string `json:"default_bios_interface"`
// The default boot interface used for a node with a dynamic driver,
// if no boot interface is specified for the node.
DefaultBootInterface string `json:"default_boot_interface"`
// The default console interface used for a node with a dynamic driver,
// if no console interface is specified for the node.
DefaultConsoleInterface string `json:"default_console_interface"`
// The default deploy interface used for a node with a dynamic driver,
// if no deploy interface is specified for the node.
DefaultDeployInterface string `json:"default_deploy_interface"`
// The default inspection interface used for a node with a dynamic driver,
// if no inspection interface is specified for the node.
DefaultInspectInterface string `json:"default_inspect_interface"`
// The default management interface used for a node with a dynamic driver,
// if no management interface is specified for the node.
DefaultManagementInterface string `json:"default_management_interface"`
// The default network interface used for a node with a dynamic driver,
// if no network interface is specified for the node.
DefaultNetworkInterface string `json:"default_network_interface"`
// The default power interface used for a node with a dynamic driver,
// if no power interface is specified for the node.
DefaultPowerInterface string `json:"default_power_interface"`
// The default RAID interface used for a node with a dynamic driver,
// if no RAID interface is specified for the node.
DefaultRaidInterface string `json:"default_raid_interface"`
// The default rescue interface used for a node with a dynamic driver,
// if no rescue interface is specified for the node.
DefaultRescueInterface string `json:"default_rescue_interface"`
// The default storage interface used for a node with a dynamic driver,
// if no storage interface is specified for the node.
DefaultStorageInterface string `json:"default_storage_interface"`
// The default vendor interface used for a node with a dynamic driver,
// if no vendor interface is specified for the node.
DefaultVendorInterface string `json:"default_vendor_interface"`
// The enabled bios interfaces for this driver.
EnabledBiosInterfaces []string `json:"enabled_bios_interfaces"`
// The enabled boot interfaces for this driver.
EnabledBootInterfaces []string `json:"enabled_boot_interfaces"`
// The enabled console interfaces for this driver.
EnabledConsoleInterface []string `json:"enabled_console_interfaces"`
// The enabled deploy interfaces for this driver.
EnabledDeployInterfaces []string `json:"enabled_deploy_interfaces"`
// The enabled inspection interfaces for this driver.
EnabledInspectInterfaces []string `json:"enabled_inspect_interfaces"`
// The enabled management interfaces for this driver.
EnabledManagementInterfaces []string `json:"enabled_management_interfaces"`
// The enabled network interfaces for this driver.
EnabledNetworkInterfaces []string `json:"enabled_network_interfaces"`
// The enabled power interfaces for this driver.
EnabledPowerInterfaces []string `json:"enabled_power_interfaces"`
// The enabled rescue interfaces for this driver.
EnabledRescueInterfaces []string `json:"enabled_rescue_interfaces"`
// The enabled RAID interfaces for this driver.
EnabledRaidInterfaces []string `json:"enabled_raid_interfaces"`
// The enabled storage interfaces for this driver.
EnabledStorageInterfaces []string `json:"enabled_storage_interfaces"`
// The enabled vendor interfaces for this driver.
EnabledVendorInterfaces []string `json:"enabled_vendor_interfaces"`
//A list of relative links. Includes the self and bookmark links.
Links []interface{} `json:"links"`
// A list of links to driver properties.
Properties []interface{} `json:"properties"`
}
// DriverPage abstracts the raw results of making a ListDrivers() request
// against the API.
type DriverPage struct {
pagination.LinkedPageBase
}
// IsEmpty returns true if a page contains no Driver results.
func (r DriverPage) IsEmpty() (bool, error) {
if r.StatusCode == 204 {
return true, nil
}
s, err := ExtractDrivers(r)
return len(s) == 0, err
}
// NextPageURL uses the response's embedded link reference to navigate to the
// next page of results.
func (r DriverPage) NextPageURL() (string, error) {
var s struct {
Links []gophercloud.Link `json:"drivers_links"`
}
err := r.ExtractInto(&s)
if err != nil {
return "", err
}
return gophercloud.ExtractNextURL(s.Links)
}
// ExtractDrivers interprets the results of a single page from ListDrivers()
// call, producing a slice of Driver entities.
func ExtractDrivers(r pagination.Page) ([]Driver, error) {
var s []Driver
err := ExtractDriversInto(r, &s)
return s, err
}
// GetDriverResult is the response from a Get operation.
// Call its Extract method to interpret it as a Driver.
type GetDriverResult struct {
driverResult
}
// DriverProperties represents driver properties in the OpenStack Bare Metal API.
type DriverProperties map[string]interface{}
// Extract interprets any GetPropertiesResult as DriverProperties, if possible.
func (r GetPropertiesResult) Extract() (*DriverProperties, error) {
var s DriverProperties
err := r.ExtractInto(&s)
return &s, err
}
// GetPropertiesResult is the response from a GetDriverProperties operation.
// Call its Extract method to interpret it as DriverProperties.
type GetPropertiesResult struct {
gophercloud.Result
}
// DiskProperties represents driver disk properties in the OpenStack Bare Metal API.
type DiskProperties map[string]interface{}
// Extract interprets any GetDiskPropertiesResult as DiskProperties, if possible.
func (r GetDiskPropertiesResult) Extract() (*DiskProperties, error) {
var s DiskProperties
err := r.ExtractInto(&s)
return &s, err
}
// GetDiskPropertiesResult is the response from a GetDriverDiskProperties operation.
// Call its Extract method to interpret it as DiskProperties.
type GetDiskPropertiesResult struct {
gophercloud.Result
}
|