github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/floatingips/doc.go (about) 1 /* 2 Package floatingips provides the ability to manage floating ips through the 3 Nova API. 4 5 This API has been deprecated and will be removed from a future release of the 6 Nova API service. 7 8 For environements that support this extension, this package can be used 9 regardless of if either Neutron or nova-network is used as the cloud's network 10 service. 11 12 Example to List Floating IPs 13 14 allPages, err := floatingips.List(computeClient).AllPages() 15 if err != nil { 16 panic(err) 17 } 18 19 allFloatingIPs, err := floatingips.ExtractFloatingIPs(allPages) 20 if err != nil { 21 panic(err) 22 } 23 24 for _, fip := range allFloatingIPs { 25 fmt.Printf("%+v\n", fip) 26 } 27 28 Example to Create a Floating IP 29 30 createOpts := floatingips.CreateOpts{ 31 Pool: "nova", 32 } 33 34 fip, err := floatingips.Create(computeClient, createOpts).Extract() 35 if err != nil { 36 panic(err) 37 } 38 39 Example to Delete a Floating IP 40 41 err := floatingips.Delete(computeClient, "floatingip-id").ExtractErr() 42 if err != nil { 43 panic(err) 44 } 45 46 Example to Associate a Floating IP With a Server 47 48 associateOpts := floatingips.AssociateOpts{ 49 FloatingIP: "10.10.10.2", 50 } 51 52 err := floatingips.AssociateInstance(computeClient, "server-id", associateOpts).ExtractErr() 53 if err != nil { 54 panic(err) 55 } 56 57 Example to Disassociate a Floating IP From a Server 58 59 disassociateOpts := floatingips.DisassociateOpts{ 60 FloatingIP: "10.10.10.2", 61 } 62 63 err := floatingips.DisassociateInstance(computeClient, "server-id", disassociateOpts).ExtractErr() 64 if err != nil { 65 panic(err) 66 } 67 */ 68 package floatingips