blob: 37f60b5f3ef65a4b3b264cd7ad85612cdba22571 [file] [log] [blame]
Michal Kobusf6113582019-09-09 15:58:21 +02001/*
2Package nodes provides information and interaction with the nodes API
3resource in the OpenStack Bare Metal service.
4
5Example to List Nodes with Detail
6
7 nodes.ListDetail(client, nodes.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
8 nodeList, err := nodes.ExtractNodes(page)
9 if err != nil {
10 return false, err
11 }
12
13 for _, n := range nodeList {
14 // Do something
15 }
16
17 return true, nil
18 })
19
20Example to List Nodes
21
22 listOpts := nodes.ListOpts{
23 ProvisionState: nodes.Deploying,
24 Fields: []string{"name"},
25 }
26
27 nodes.List(client, listOpts).EachPage(func(page pagination.Page) (bool, error) {
28 nodeList, err := nodes.ExtractNodes(page)
29 if err != nil {
30 return false, err
31 }
32
33 for _, n := range nodeList {
34 // Do something
35 }
36
37 return true, nil
38 })
39
40Example to Create Node
41
42 createOpts := nodes.CreateOpts
43 Driver: "ipmi",
44 BootInterface: "pxe",
45 Name: "coconuts",
46 DriverInfo: map[string]interface{}{
47 "ipmi_port": "6230",
48 "ipmi_username": "admin",
49 "deploy_kernel": "http://172.22.0.1/images/tinyipa-stable-rocky.vmlinuz",
50 "ipmi_address": "192.168.122.1",
51 "deploy_ramdisk": "http://172.22.0.1/images/tinyipa-stable-rocky.gz",
52 "ipmi_password": "admin",
53 },
54 }
55
56 createNode, err := nodes.Create(client, createOpts).Extract()
57 if err != nil {
58 panic(err)
59 }
60
61Example to Get Node
62
63 showNode, err := nodes.Get(client, "c9afd385-5d89-4ecb-9e1c-68194da6b474").Extract()
64 if err != nil {
65 panic(err)
66 }
67
68Example to Update Node
69
70 updateOpts := nodes.UpdateOpts{
71 nodes.UpdateOperation{
72 Op: ReplaceOp,
73 Path: "/maintenance",
74 Value: "true",
75 },
76 }
77
78 updateNode, err := nodes.Update(client, "c9afd385-5d89-4ecb-9e1c-68194da6b474", updateOpts).Extract()
79 if err != nil {
80 panic(err)
81 }
82
83Example to Delete Node
84
85 err = nodes.Delete(client, "c9afd385-5d89-4ecb-9e1c-68194da6b474").ExtractErr()
86 if err != nil {
87 panic(err)
88 }
89
90Example to Validate Node
91
92 validation, err := nodes.Validate(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8").Extract()
93 if err != nil {
94 panic(err)
95 }
96
97Example to inject non-masking interrupts
98
99 err := nodes.InjectNMI(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8").ExtractErr()
100 if err != nil {
101 panic(err)
102 }
103
104Example to get array of supported boot devices for a node
105
106 bootDevices, err := nodes.GetSupportedBootDevices(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8").Extract()
107 if err != nil {
108 panic(err)
109 }
110
111Example to set boot device for a node
112
113 bootOpts := nodes.BootDeviceOpts{
114 BootDevice: "pxe",
115 Persistent: false,
116 }
117
118 err := nodes.SetBootDevice(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8", bootOpts).ExtractErr()
119 if err != nil {
120 panic(err)
121 }
122
123Example to get boot device for a node
124
125 bootDevice, err := nodes.GetBootDevice(client, "a62b8495-52e2-407b-b3cb-62775d04c2b8").Extract()
126 if err != nil {
127 panic(err)
128 }
129*/
130package nodes