File: doc.go

package info (click to toggle)
golang-github-gophercloud-gophercloud 0.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, bullseye-backports
  • size: 10,224 kB
  • sloc: sh: 125; makefile: 21
file content (118 lines) | stat: -rw-r--r-- 2,778 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
/*
Package nodegroups provides methods for interacting with the Magnum node group API.

All node group actions must be performed on a specific cluster,
so the cluster UUID/name is required as a parameter in each method.


Create a client to use:

    opts, err := openstack.AuthOptionsFromEnv()
    if err != nil {
        panic(err)
    }

    provider, err := openstack.AuthenticatedClient(opts)
    if err != nil {
        panic(err)
    }

    client, err := openstack.NewContainerInfraV1(provider, gophercloud.EndpointOpts{Region: os.Getenv("OS_REGION_NAME")})
    if err != nil {
        panic(err)
    }

    client.Microversion = "1.9"


Example of Getting a node group:

    ng, err := nodegroups.Get(client, clusterUUID, nodeGroupUUID).Extract()
    if err != nil {
        panic(err)
    }
    fmt.Printf("%#v\n", ng)


Example of Listing node groups:

    listOpts := nodegroup.ListOpts{
        Role: "worker",
    }

    allPages, err := nodegroups.List(client, clusterUUID, listOpts).AllPages()
    if err != nil {
        panic(err)
    }

    ngs, err := nodegroups.ExtractNodeGroups(allPages)
    if err != nil {
        panic(err)
    }

    for _, ng := range ngs {
        fmt.Printf("%#v\n", ng)
    }


Example of Creating a node group:

    // Labels, node image and node flavor will be inherited from the cluster value if not set.
    // Role will default to "worker" if not set.

    // To add a label to the new node group, need to know the cluster labels
    cluster, err := clusters.Get(client, clusterUUID).Extract()
    if err != nil {
        panic(err)
    }

    // Add the new label
    labels := cluster.Labels
    labels["availability_zone"] = "A"

    maxNodes := 5
    createOpts := nodegroups.CreateOpts{
        Name:         "new-nodegroup",
        MinNodeCount: 2,
        MaxNodeCount: &maxNodes,
        Labels: labels,
    }

    ng, err := nodegroups.Create(client, clusterUUID, createOpts).Extract()
    if err != nil {
        panic(err)
    }

    fmt.Printf("%#v\n", ng)


Example of Updating a node group:

    // Valid paths are "/min_node_count" and "/max_node_count".
    // Max node count can be unset with the "remove" op to have
    // no enforced maximum node count.

    updateOpts := []nodegroups.UpdateOptsBuilder{
        nodegroups.UpdateOpts{
            Op:    nodegroups.ReplaceOp,
            Path:  "/max_node_count",
            Value: 10,
        },
    }

    ng, err = nodegroups.Update(client, clusterUUID, nodeGroupUUID, updateOpts).Extract()
    if err != nil {
        panic(err)
    }

    fmt.Printf("%#v\n", ng)


Example of Deleting a node group:

     err = nodegroups.Delete(client, clusterUUID, nodeGroupUUID).ExtractErr()
     if err != nil {
         panic(err)
     }
*/
package nodegroups