github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/lbaas_v2/pools/doc.go (about) 1 /* 2 Package pools provides information and interaction with Pools and 3 Members of the LBaaS v2 extension for the OpenStack Networking service. 4 5 Example to List Pools 6 7 listOpts := pools.ListOpts{ 8 LoadbalancerID: "c79a4468-d788-410c-bf79-9a8ef6354852", 9 } 10 11 allPages, err := pools.List(networkClient, listOpts).AllPages() 12 if err != nil { 13 panic(err) 14 } 15 16 allPools, err := pools.ExtractMonitors(allPages) 17 if err != nil { 18 panic(err) 19 } 20 21 for _, pools := range allPools { 22 fmt.Printf("%+v\n", pool) 23 } 24 25 Example to Create a Pool 26 27 createOpts := pools.CreateOpts{ 28 LBMethod: pools.LBMethodRoundRobin, 29 Protocol: "HTTP", 30 Name: "Example pool", 31 LoadbalancerID: "79e05663-7f03-45d2-a092-8b94062f22ab", 32 } 33 34 pool, err := pools.Create(networkClient, createOpts).Extract() 35 if err != nil { 36 panic(err) 37 } 38 39 Example to Update a Pool 40 41 poolID := "d67d56a6-4a86-4688-a282-f46444705c64" 42 43 updateOpts := pools.UpdateOpts{ 44 Name: "new-name", 45 } 46 47 pool, err := pools.Update(networkClient, poolID, updateOpts).Extract() 48 if err != nil { 49 panic(err) 50 } 51 52 Example to Delete a Pool 53 54 poolID := "d67d56a6-4a86-4688-a282-f46444705c64" 55 err := pools.Delete(networkClient, poolID).ExtractErr() 56 if err != nil { 57 panic(err) 58 } 59 60 Example to List Pool Members 61 62 poolID := "d67d56a6-4a86-4688-a282-f46444705c64" 63 64 listOpts := pools.ListMemberOpts{ 65 ProtocolPort: 80, 66 } 67 68 allPages, err := pools.ListMembers(networkClient, poolID, listOpts).AllPages() 69 if err != nil { 70 panic(err) 71 } 72 73 allMembers, err := pools.ExtractMembers(allPages) 74 if err != nil { 75 panic(err) 76 } 77 78 for _, member := allMembers { 79 fmt.Printf("%+v\n", member) 80 } 81 82 Example to Create a Member 83 84 poolID := "d67d56a6-4a86-4688-a282-f46444705c64" 85 86 createOpts := pools.CreateMemberOpts{ 87 Name: "db", 88 SubnetID: "1981f108-3c48-48d2-b908-30f7d28532c9", 89 Address: "10.0.2.11", 90 ProtocolPort: 80, 91 Weight: 10, 92 } 93 94 member, err := pools.CreateMember(networkClient, poolID, createOpts).Extract() 95 if err != nil { 96 panic(err) 97 } 98 99 Example to Update a Member 100 101 poolID := "d67d56a6-4a86-4688-a282-f46444705c64" 102 memberID := "64dba99f-8af8-4200-8882-e32a0660f23e" 103 104 updateOpts := pools.UpdateMemberOpts{ 105 Name: "new-name", 106 Weight: 4, 107 } 108 109 member, err := pools.UpdateMember(networkClient, poolID, memberID, updateOpts).Extract() 110 if err != nil { 111 panic(err) 112 } 113 114 Example to Delete a Member 115 116 poolID := "d67d56a6-4a86-4688-a282-f46444705c64" 117 memberID := "64dba99f-8af8-4200-8882-e32a0660f23e" 118 119 err := pools.DeleteMember(networkClient, poolID, memberID).ExtractErr() 120 if err != nil { 121 panic(err) 122 } 123 */ 124 package pools