File: doc.go

package info (click to toggle)
golang-github-gophercloud-gophercloud 0.0~git20180917.45f1c769-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,768 kB
  • sloc: sh: 98; makefile: 14
file content (227 lines) | stat: -rw-r--r-- 5,301 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
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
/*
Package clusters provides information and interaction with the clusters through
the OpenStack Clustering service.

Example to Create a Cluster

	createOpts := clusters.CreateOpts{
		Name:            "test-cluster",
		DesiredCapacity: 1,
		ProfileID:       "b7b870ee-d3c5-4a93-b9d7-846c53b2c2da",
	}

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

Example to Get a Cluster

	clusterName := "cluster123"
	cluster, err := clusters.Get(serviceClient, clusterName).Extract()
	if err != nil {
		panic(err)
	}
	fmt.Printf("%+v\n", cluster)

Example to List Clusters

	listOpts := clusters.ListOpts{
		Name: "testcluster",
	}

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

	allClusters, err := clusters.ExtractClusters(allPages)
	if err != nil {
		panic(err)
	}

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

Example to Update a Cluster

	updateOpts := clusters.UpdateOpts{
		Name:       "testcluster",
		ProfileID:  "b7b870ee-d3c5-4a93-b9d7-846c53b2c2da",
	}

	clusterID := "7d85f602-a948-4a30-afd4-e84f47471c15"
	cluster, err := clusters.Update(serviceClient, clusterName, opts).Extract()
	if err != nil {
		panic(err)
	}
	fmt.Printf("%+v\n", cluster)

Example to Delete a Cluster

	clusterID := "dc6d336e3fc4c0a951b5698cd1236ee"
	err := clusters.Delete(serviceClient, clusterID).ExtractErr()
	if err != nil {
		panic(err)
	}

Example to Resize a Cluster

	number := 1
	maxSize := 5
	minSize := 1
	minStep := 1
	strict := true

	resizeOpts := clusters.ResizeOpts{
		AdjustmentType: clusters.ChangeInCapacityAdjustment,
		Number:         number,
		MaxSize:        &maxSize,
		MinSize:        &minSize,
		MinStep:        &minStep,
		Strict:         &strict,
	}

	actionID, err := clusters.Resize(client, clusterName, resizeOpts).Extract()
	if err != nil {
		t.Fatalf("Unable to resize cluster: %v", err)
	}
	fmt.Println("Resize actionID", actionID)

Example to ScaleIn a Cluster

	count := 2
	scaleInOpts := clusters.ScaleInOpts{
		Count: &count,
	}
	clusterID:  "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"

	action, err := clusters.ScaleIn(computeClient, clusterID, scaleInOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to ScaleOut a cluster

	scaleOutOpts := clusters.ScaleOutOpts{
		Count: 2,
	}
	clusterID := "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"

	actionID, err := clusters.ScaleOut(computeClient, clusterID, scaleOutOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to List Policies for a Cluster

	clusterID := "7d85f602-a948-4a30-afd4-e84f47471c15"
	allPages, err := clusters.ListPolicies(serviceClient, clusterID, nil).AllPages()
	if err != nil {
		panic(err)
	}

	allClusterPolicies, err := clusters.ExtractClusterPolicies(allPages)
	if err != nil {
		panic(err)
	}

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

Example to Get a Cluster Policy

	clusterID := "7d85f602-a948-4a30-afd4-e84f47471c15"
	profileID := "714fe676-a08f-4196-b7af-61d52eeded15"
	clusterPolicy, err := clusterpolicies.Get(serviceCLient, clusterID, profileID).Extract()
	if err != nil {
		panic(err)
	}

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

Example to Attach a Policy to a Cluster

	enabled := true
	attachPolicyOpts := clusters.AttachPolicyOpts{
		PolicyID: "policy-123",
		Enabled:  &enabled,
	}

	clusterID := "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
	actionID, err := clusters.AttachPolicy(serviceClient, clusterID, attachPolicyOpts).Extract()
	if err != nil {
		panic(err)
	}

	fmt.Println("Attach Policy actionID", actionID)

Example to Detach a Policy to Cluster

	detachpolicyOpts := clusters.DetachPolicyOpts{
		PolicyID: "policy-123",
	}

	clusterID :=  "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
	actionID, err := clusters.DetachPolicy(serviceClient, clusterID, detachpolicyOpts).Extract()
	if err != nil {
		panic(err)
	}

	fmt.Println("Update Policy actionID", actionID)

Example to Update a Policy to a Cluster

	enabled := true
	updatePolicyOpts := clusters.UpdatePolicyOpts{
		PolicyID: "policy-123",
		Enabled:  &enabled,
	}

	clusterID := "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
	actionID, err := clusters.UpdatePolicy(serviceClient, clusterID, updatePolicyOpts).Extract()
	if err != nil {
		panic(err)
	}

	fmt.Println("Attach Policy actionID", actionID)

Example to Recover a Cluster

	check := true
	checkCapacity := true
	recoverOpts := clusters.RecoverOpts{
		Operation:     clusters.RebuildRecovery,
		Check:         &check,
		CheckCapacity: &checkCapacity,
	}

	clusterID := "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
	actionID, err := clusters.Recover(computeClient, clusterID, recoverOpts).Extract()
	if err != nil {
		panic(err)
	}
	fmt.Println("action=", actionID)

Example to Check a Cluster

	clusterID :=  "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
	action, err := clusters.Check(computeClient, clusterID).Extract()
	if err != nil {
		panic(err)
	}

Example to Complete Life Cycle

	clusterID :=  "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
	lifecycleOpts := clusters.CompleteLifecycleOpts{LifecycleActionTokenID: "2b827124-69e1-496e-9484-33ca769fe4df"}

	action, err := clusters.CompleteLifecycle(computeClient, clusterID, lifecycleOpts).Extract()
	if err != nil {
		panic(err)
	}

*/
package clusters