File: doc.go

package info (click to toggle)
golang-github-gophercloud-gophercloud 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,416 kB
  • sloc: sh: 99; makefile: 21
file content (110 lines) | stat: -rw-r--r-- 2,306 bytes parent folder | download
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
/*
Package nodes provides information and interaction with the nodes through
the OpenStack Clustering service.

Example to Create a Node

	createOpts := nodes.CreateOpts{
		ClusterID: "e395be1e-8d8e-43bb-bd6c-943eccf76a6d",
		Metadata:  map[string]interface{}{},
		Name:      "node-e395be1e-002",
		ProfileID: "d8a48377-f6a3-4af4-bbbb-6e8bcaa0cbc0",
		Role:      "",
	}

	node, err := nodes.Create(serviceClient, createOpts).Extract()
	if err != nil {
		panic(err)
	}

	fmt.Printf("node", node)

Example to List Nodes

	listOpts := nodes.ListOpts{
		Name: "testnode",
	}

	allPages, err := nodes.List(serviceClient, listOpts).AllPages()
	if err != nil {
		panic(err)
	}

	allNodes, err := nodes.ExtractNodes(allPages)
	if err != nil {
		panic(err)
	}

	for _, node := range allNodes {
		fmt.Printf("%+v\n", node)
	}

Example to Update a Node

	opts := nodes.UpdateOpts{
		Name: "new-node-name",
	}

	nodeID := "82fe28e0-9fcb-42ca-a2fa-6eb7dddd75a1"
	node, err := nodes.Update(serviceClient, nodeID, opts).Extract()
	if err != nil {
		panic(err)
	}

	fmt.Printf("%+v\n", node)

Example to Delete a Node

	nodeID := "6dc6d336e3fc4c0a951b5698cd1236ee"
	err := nodes.Delete(serviceClient, nodeID).ExtractErr()
	if err != nil {
		panic(err)
	}

Example to Get a Node

	nodeID := "node123"
	node, err := nodes.Get(serviceClient, nodeID).Extract()
	if err != nil {
		panic(err)
	}

	fmt.Printf("%+v\n", node)

Example to Perform an Operation on a Node

	serviceClient.Microversion = "1.4"
	nodeID := "node123"
	operationOpts := nodes.OperationOpts{
		Operation: nodes.RebootOperation,
		Params:    nodes.OperationParams{"type": "SOFT"},
	}
	actionID, err := nodes.Ops(serviceClient, nodeID, operationOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Recover a Node

	nodeID := "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
	check := true
	recoverOpts := nodes.RecoverOpts{
		Operation:     nodes.RebuildRecovery,
		Check:         &check,
	}
	actionID, err := nodes.Recover(computeClient, nodeID, recoverOpts).Extract()
	if err != nil {
		panic(err)
	}
	fmt.Println("action=", actionID)

Example to Check a Node

	nodeID := "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
	actionID, err := nodes.Check(serviceClient, nodeID).Extract()
	if err != nil {
		panic(err)
	}
	fmt.Println("action=", actionID)
*/
package nodes