File: doc.go

package info (click to toggle)
golang-github-gophercloud-gophercloud 0.0~git20180917.45f1c769-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,768 kB
  • sloc: sh: 98; makefile: 14
file content (73 lines) | stat: -rw-r--r-- 1,844 bytes parent folder | download | duplicates (6)
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
69
70
71
72
73
/*
Package ports contains functionality for working with Neutron port resources.

A port represents a virtual switch port on a logical network switch. Virtual
instances attach their interfaces into ports. The logical port also defines
the MAC address and the IP address(es) to be assigned to the interfaces
plugged into them. When IP addresses are associated to a port, this also
implies the port is associated with a subnet, as the IP address was taken
from the allocation pool for a specific subnet.

Example to List Ports

	listOpts := ports.ListOpts{
		DeviceID: "b0b89efe-82f8-461d-958b-adbf80f50c7d",
	}

	allPages, err := ports.List(networkClient, listOpts).AllPages()
	if err != nil {
		panic(err)
	}

	allPorts, err := ports.ExtractPorts(allPages)
	if err != nil {
		panic(err)
	}

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

Example to Create a Port

	createOtps := ports.CreateOpts{
		Name:         "private-port",
		AdminStateUp: &asu,
		NetworkID:    "a87cc70a-3e15-4acf-8205-9b711a3531b7",
		FixedIPs: []ports.IP{
			{SubnetID: "a0304c3a-4f08-4c43-88af-d796509c97d2", IPAddress: "10.0.0.2"},
		},
		SecurityGroups: &[]string{"foo"},
		AllowedAddressPairs: []ports.AddressPair{
			{IPAddress: "10.0.0.4", MACAddress: "fa:16:3e:c9:cb:f0"},
		},
	}

	port, err := ports.Create(networkClient, createOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Update a Port

	portID := "c34bae2b-7641-49b6-bf6d-d8e473620ed8"

	updateOpts := ports.UpdateOpts{
		Name:           "new_name",
		SecurityGroups: &[]string{},
	}

	port, err := ports.Update(networkClient, portID, updateOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Delete a Port

	portID := "c34bae2b-7641-49b6-bf6d-d8e473620ed8"
	err := ports.Delete(networkClient, portID).ExtractErr()
	if err != nil {
		panic(err)
	}
*/
package ports