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
|
/*
Package nodes provides information and interaction with the nodes API
resource in the OpenStack Bare Metal service.
Example to List Nodes with Detail
nodes.ListDetail(client, nodes.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
nodeList, err := nodes.ExtractNodes(page)
if err != nil {
return false, err
}
for _, n := range nodeList {
// Do something
}
return true, nil
})
Example to List Nodes
listOpts := nodes.ListOpts{
ProvisionState: nodes.Deploying,
Fields: []string{"name"},
}
nodes.List(client, listOpts).EachPage(func(page pagination.Page) (bool, error) {
nodeList, err := nodes.ExtractNodes(page)
if err != nil {
return false, err
}
for _, n := range nodeList {
// Do something
}
return true, nil
})
Example to Create Node
createOpts := nodes.CreateOpts
Driver: "ipmi",
BootInterface: "pxe",
Name: "coconuts",
DriverInfo: map[string]interface{}{
"ipmi_port": "6230",
"ipmi_username": "admin",
"deploy_kernel": "http://172.22.0.1/images/tinyipa-stable-rocky.vmlinuz",
"ipmi_address": "192.168.122.1",
"deploy_ramdisk": "http://172.22.0.1/images/tinyipa-stable-rocky.gz",
"ipmi_password": "admin",
},
}
createNode, err := nodes.Create(client, createOpts).Extract()
if err != nil {
panic(err)
}
Example to Get Node
showNode, err := nodes.Get(client, "c9afd385-5d89-4ecb-9e1c-68194da6b474").Extract()
if err != nil {
panic(err)
}
Example to Update Node
updateOpts := nodes.UpdateOpts{
nodes.UpdateOperation{
Op: ReplaceOp,
Path: "/maintenance",
Value: "true",
},
}
updateNode, err := nodes.Update(client, "c9afd385-5d89-4ecb-9e1c-68194da6b474", updateOpts).Extract()
if err != nil {
panic(err)
}
Example to Delete Node
err = nodes.Delete(client, "c9afd385-5d89-4ecb-9e1c-68194da6b474").ExtractErr()
if err != nil {
panic(err)
}
Example to Validate Node
validation, err := nodes.Validate(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8").Extract()
if err != nil {
panic(err)
}
Example to inject non-masking interrupts
err := nodes.InjectNMI(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8").ExtractErr()
if err != nil {
panic(err)
}
Example to get array of supported boot devices for a node
bootDevices, err := nodes.GetSupportedBootDevices(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8").Extract()
if err != nil {
panic(err)
}
Example to set boot device for a node
bootOpts := nodes.BootDeviceOpts{
BootDevice: "pxe",
Persistent: false,
}
err := nodes.SetBootDevice(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8", bootOpts).ExtractErr()
if err != nil {
panic(err)
}
Example to get boot device for a node
bootDevice, err := nodes.GetBootDevice(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8").Extract()
if err != nil {
panic(err)
}
Example to list all vendor passthru methods
methods, err := nodes.GetVendorPassthruMethods(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8").Extract()
if err != nil {
panic(err)
}
Example to list all subscriptions
method := nodes.CallVendorPassthruOpts{
Method: "get_all_subscriptions",
}
allSubscriptions, err := nodes.GetAllSubscriptions(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8", method).Extract()
if err != nil {
panic(err)
}
Example to get a subscription
method := nodes.CallVendorPassthruOpts{
Method: "get_subscription",
}
subscriptionOpt := nodes.GetSubscriptionOpts{
Id: "subscription id",
}
subscription, err := nodes.GetSubscription(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8", method, subscriptionOpt).Extract()
if err != nil {
panic(err)
}
Example to delete a subscription
method := nodes.CallVendorPassthruOpts{
Method: "delete_subscription",
}
subscriptionDeleteOpt := nodes.DeleteSubscriptionOpts{
Id: "subscription id",
}
err := nodes.DeleteSubscription(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8", method, subscriptionDeleteOpt).ExtractErr()
if err != nil {
panic(err)
}
Example to create a subscription
method := nodes.CallVendorPassthruOpts{
Method: "create_subscription",
}
subscriptionCreateOpt := nodes.CreateSubscriptionOpts{
Destination: "https://subscription_destination_url"
Context: "MyContext",
Protocol: "Redfish",
EventTypes: ["Alert"],
HttpHeaders: [{"Key1":"Value1"}, {"Key2":"Value2"}],
}
newSubscription, err := nodes.CreateSubscription(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8", method, subscriptionCreateOpt).Extract()
if err != nil {
panic(err)
}
*/
package nodes
|