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 (108 lines) | stat: -rw-r--r-- 2,246 bytes parent folder | download | duplicates (5)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
Package routers enables management and retrieval of Routers from the OpenStack
Networking service.

Example to List Routers

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

	allRouters, err := routers.ExtractRouters(allPages)
	if err != nil {
		panic(err)
	}

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

Example to Create a Router

	iTrue := true
	gwi := routers.GatewayInfo{
		NetworkID: "8ca37218-28ff-41cb-9b10-039601ea7e6b",
	}

	createOpts := routers.CreateOpts{
		Name:         "router_1",
		AdminStateUp: &iTrue,
		GatewayInfo:  &gwi,
	}

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

Example to Update a Router

	routerID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"

	routes := []routers.Route{{
		DestinationCIDR: "40.0.1.0/24",
		NextHop:         "10.1.0.10",
	}}

	updateOpts := routers.UpdateOpts{
		Name:   "new_name",
		Routes: routes,
	}

	router, err := routers.Update(networkClient, routerID, updateOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Remove all Routes from a Router

	routerID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"

	routes := []routers.Route{}

	updateOpts := routers.UpdateOpts{
		Routes: routes,
	}

	router, err := routers.Update(networkClient, routerID, updateOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Delete a Router

	routerID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
	err := routers.Delete(networkClient, routerID).ExtractErr()
	if err != nil {
		panic(err)
	}

Example to Add an Interface to a Router

	routerID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"

	intOpts := routers.AddInterfaceOpts{
		SubnetID: "a2f1f29d-571b-4533-907f-5803ab96ead1",
	}

	interface, err := routers.AddInterface(networkClient, routerID, intOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Remove an Interface from a Router

	routerID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"

	intOpts := routers.RemoveInterfaceOpts{
		SubnetID: "a2f1f29d-571b-4533-907f-5803ab96ead1",
	}

	interface, err := routers.RemoveInterface(networkClient, routerID, intOpts).Extract()
	if err != nil {
		panic(err)
	}
*/
package routers