github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/lbaas_v2/loadbalancers/doc.go (about) 1 /* 2 Package loadbalancers provides information and interaction with Load Balancers 3 of the LBaaS v2 extension for the OpenStack Networking service. 4 5 Example to List Load Balancers 6 7 listOpts := loadbalancers.ListOpts{ 8 Provider: "haproxy", 9 } 10 11 allPages, err := loadbalancers.List(networkClient, listOpts).AllPages() 12 if err != nil { 13 panic(err) 14 } 15 16 allLoadbalancers, err := loadbalancers.ExtractLoadBalancers(allPages) 17 if err != nil { 18 panic(err) 19 } 20 21 for _, lb := range allLoadbalancers { 22 fmt.Printf("%+v\n", lb) 23 } 24 25 Example to Create a Load Balancer 26 27 createOpts := loadbalancers.CreateOpts{ 28 Name: "db_lb", 29 AdminStateUp: golangsdk.Enabled, 30 VipSubnetID: "9cedb85d-0759-4898-8a4b-fa5a5ea10086", 31 VipAddress: "10.30.176.48", 32 Flavor: "medium", 33 Provider: "haproxy", 34 } 35 36 lb, err := loadbalancers.Create(networkClient, createOpts).Extract() 37 if err != nil { 38 panic(err) 39 } 40 41 Example to Update a Load Balancer 42 43 lbID := "d67d56a6-4a86-4688-a282-f46444705c64" 44 45 i1001 := 1001 46 updateOpts := loadbalancers.UpdateOpts{ 47 Name: "new-name", 48 } 49 50 lb, err := loadbalancers.Update(networkClient, lbID, updateOpts).Extract() 51 if err != nil { 52 panic(err) 53 } 54 55 Example to Delete a Load Balancers 56 57 lbID := "d67d56a6-4a86-4688-a282-f46444705c64" 58 err := loadbalancers.Delete(networkClient, lbID).ExtractErr() 59 if err != nil { 60 panic(err) 61 } 62 63 Example to Get the Status of a Load Balancer 64 65 lbID := "d67d56a6-4a86-4688-a282-f46444705c64" 66 status, err := loadbalancers.GetStatuses(networkClient, LBID).Extract() 67 if err != nil { 68 panic(err) 69 } 70 */ 71 package loadbalancers