forked from vmware/go-vcloud-director
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnsxt_edgegateway_bgp_neighbor_test.go
83 lines (66 loc) · 2.86 KB
/
nsxt_edgegateway_bgp_neighbor_test.go
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
//go:build network || nsxt || functional || openapi || ALL
// +build network nsxt functional openapi ALL
package govcd
import (
"github.com/vmware/go-vcloud-director/v2/types/v56"
. "gopkg.in/check.v1"
)
func (vcd *TestVCD) Test_NsxEdgeBgpNeighbor(check *C) {
skipNoNsxtConfiguration(vcd, check)
skipOpenApiEndpointTest(vcd, check, types.OpenApiPathVersion1_0_0+types.OpenApiEndpointEdgeBgpNeighbor)
org, err := vcd.client.GetOrgByName(vcd.config.VCD.Org)
check.Assert(err, IsNil)
nsxtVdc, err := org.GetVDCByName(vcd.config.VCD.Nsxt.Vdc, false)
check.Assert(err, IsNil)
edge, err := nsxtVdc.GetNsxtEdgeGatewayByName(vcd.config.VCD.Nsxt.EdgeGateway)
check.Assert(err, IsNil)
// Switch Edge Gateway to use dedicated uplink for the time of this test and then turn it off
err = switchEdgeGatewayDedication(edge, true) // Turn on Dedicated Tier 0 gateway
check.Assert(err, IsNil)
defer switchEdgeGatewayDedication(edge, false) // Turn off Dedicated Tier 0 gateway
// Create a new BGP IP Neighbor
bgpNeighbor := &types.EdgeBgpNeighbor{
NeighborAddress: "11.11.11.11",
RemoteASNumber: "64123",
KeepAliveTimer: 80,
HoldDownTimer: 241,
NeighborPassword: "iQuee-ph2phe",
AllowASIn: true,
GracefulRestartMode: "HELPER_ONLY",
IpAddressTypeFiltering: "DISABLED",
}
createdBgpNeighbor, err := edge.CreateBgpNeighbor(bgpNeighbor)
check.Assert(err, IsNil)
check.Assert(createdBgpNeighbor, NotNil)
// Get all BGP Neighbors
BgpNeighbors, err := edge.GetAllBgpNeighbors(nil)
check.Assert(err, IsNil)
check.Assert(BgpNeighbors, NotNil)
check.Assert(len(BgpNeighbors), Equals, 1)
check.Assert(BgpNeighbors[0].EdgeBgpNeighbor.NeighborAddress, Equals, bgpNeighbor.NeighborAddress)
// Get BGP Neighbor By Neighbor IP Address
bgpNeighborByIp, err := edge.GetBgpNeighborByIp(bgpNeighbor.NeighborAddress)
check.Assert(err, IsNil)
check.Assert(bgpNeighborByIp, NotNil)
// Get BGP Neighbor By Id
bgpNeighborById, err := edge.GetBgpNeighborById(createdBgpNeighbor.EdgeBgpNeighbor.ID)
check.Assert(err, IsNil)
check.Assert(bgpNeighborById, NotNil)
// Update BGP Neighbor
bgpNeighbor.NeighborAddress = "12.12.12.12"
bgpNeighbor.ID = BgpNeighbors[0].EdgeBgpNeighbor.ID
updatedBgpNeighbor, err := BgpNeighbors[0].Update(bgpNeighbor)
check.Assert(err, IsNil)
check.Assert(updatedBgpNeighbor, NotNil)
check.Assert(updatedBgpNeighbor.EdgeBgpNeighbor.ID, Equals, BgpNeighbors[0].EdgeBgpNeighbor.ID)
// Delete BGP Neighbor
err = BgpNeighbors[0].Delete()
check.Assert(err, IsNil)
// Try to get deleted BGP Neighbor once again and ensure it is not there
notFoundByIp, err := edge.GetBgpNeighborByIp(bgpNeighbor.NeighborAddress)
check.Assert(err, NotNil)
check.Assert(notFoundByIp, IsNil)
notFoundById, err := edge.GetBgpNeighborById(createdBgpNeighbor.EdgeBgpNeighbor.ID)
check.Assert(err, NotNil)
check.Assert(notFoundById, IsNil)
}