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 (68 lines) | stat: -rw-r--r-- 1,522 bytes parent folder | download | duplicates (3)
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
/*
Package floatingips provides the ability to manage floating ips through the
Nova API.

This API has been deprecated and will be removed from a future release of the
Nova API service.

For environements that support this extension, this package can be used
regardless of if either Neutron or nova-network is used as the cloud's network
service.

Example to List Floating IPs

	allPages, err := floatingips.List(computeClient).AllPages()
	if err != nil {
		panic(err)
	}

	allFloatingIPs, err := floatingips.ExtractFloatingIPs(allPages)
	if err != nil {
		panic(err)
	}

	for _, fip := range allFloatingIPs {
		fmt.Printf("%+v\n", fip)
	}

Example to Create a Floating IP

	createOpts := floatingips.CreateOpts{
		Pool: "nova",
	}

	fip, err := floatingips.Create(computeClient, createOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Delete a Floating IP

	err := floatingips.Delete(computeClient, "floatingip-id").ExtractErr()
	if err != nil {
		panic(err)
	}

Example to Associate a Floating IP With a Server

	associateOpts := floatingips.AssociateOpts{
		FloatingIP: "10.10.10.2",
	}

	err := floatingips.AssociateInstance(computeClient, "server-id", associateOpts).ExtractErr()
	if err != nil {
		panic(err)
	}

Example to Disassociate a Floating IP From a Server

	disassociateOpts := floatingips.DisassociateOpts{
		FloatingIP: "10.10.10.2",
	}

	err := floatingips.DisassociateInstance(computeClient, "server-id", disassociateOpts).ExtractErr()
	if err != nil {
		panic(err)
	}
*/
package floatingips