github.com/gophercloud/gophercloud@v1.11.0/openstack/compute/v2/extensions/servergroups/doc.go (about) 1 /* 2 Package servergroups provides the ability to manage server groups. 3 4 Example to List Server Groups 5 6 allpages, err := servergroups.List(computeClient).AllPages() 7 if err != nil { 8 panic(err) 9 } 10 11 allServerGroups, err := servergroups.ExtractServerGroups(allPages) 12 if err != nil { 13 panic(err) 14 } 15 16 for _, sg := range allServerGroups { 17 fmt.Printf("%#v\n", sg) 18 } 19 20 Example to Create a Server Group 21 22 createOpts := servergroups.CreateOpts{ 23 Name: "my_sg", 24 Policies: []string{"anti-affinity"}, 25 } 26 27 sg, err := servergroups.Create(computeClient, createOpts).Extract() 28 if err != nil { 29 panic(err) 30 } 31 32 Example to Create a Server Group with additional microversion 2.64 fields 33 34 createOpts := servergroups.CreateOpts{ 35 Name: "my_sg", 36 Policy: "anti-affinity", 37 Rules: &servergroups.Rules{ 38 MaxServerPerHost: 3, 39 }, 40 } 41 42 computeClient.Microversion = "2.64" 43 result := servergroups.Create(computeClient, createOpts) 44 45 serverGroup, err := result.Extract() 46 if err != nil { 47 panic(err) 48 } 49 50 Example to Delete a Server Group 51 52 sgID := "7a6f29ad-e34d-4368-951a-58a08f11cfb7" 53 err := servergroups.Delete(computeClient, sgID).ExtractErr() 54 if err != nil { 55 panic(err) 56 } 57 */ 58 package servergroups