-
Notifications
You must be signed in to change notification settings - Fork 29
/
bgp_peer_p.go
148 lines (94 loc) · 3.81 KB
/
bgp_peer_p.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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const BgppeerpClassName = "bgpPeerP"
type BgpPeerConnectivityProfile struct {
BaseAttributes
BgpPeerConnectivityProfileAttributes
}
type BgpPeerConnectivityProfileAttributes struct {
Addr string `json:",omitempty"`
AddrTCtrl string `json:",omitempty"`
AllowedSelfAsCnt string `json:",omitempty"`
Annotation string `json:",omitempty"`
Ctrl string `json:",omitempty"`
NameAlias string `json:",omitempty"`
Password string `json:",omitempty"`
PeerCtrl string `json:",omitempty"`
PrivateASctrl string `json:",omitempty"`
Ttl string `json:",omitempty"`
Weight string `json:",omitempty"`
AdminSt string `json:",omitempty"`
}
func NewBgpPeerConnectivityProfile(bgpPeerPRn, parentDn, description string, bgpPeerPattr BgpPeerConnectivityProfileAttributes) *BgpPeerConnectivityProfile {
dn := fmt.Sprintf("%s/%s", parentDn, bgpPeerPRn)
return &BgpPeerConnectivityProfile{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: BgppeerpClassName,
Rn: bgpPeerPRn,
},
BgpPeerConnectivityProfileAttributes: bgpPeerPattr,
}
}
func (bgpPeerP *BgpPeerConnectivityProfile) ToMap() (map[string]string, error) {
bgpPeerPMap, err := bgpPeerP.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(bgpPeerPMap, "addr", bgpPeerP.Addr)
A(bgpPeerPMap, "addrTCtrl", bgpPeerP.AddrTCtrl)
A(bgpPeerPMap, "allowedSelfAsCnt", bgpPeerP.AllowedSelfAsCnt)
A(bgpPeerPMap, "annotation", bgpPeerP.Annotation)
A(bgpPeerPMap, "ctrl", bgpPeerP.Ctrl)
A(bgpPeerPMap, "nameAlias", bgpPeerP.NameAlias)
A(bgpPeerPMap, "password", bgpPeerP.Password)
A(bgpPeerPMap, "peerCtrl", bgpPeerP.PeerCtrl)
A(bgpPeerPMap, "privateASctrl", bgpPeerP.PrivateASctrl)
A(bgpPeerPMap, "ttl", bgpPeerP.Ttl)
A(bgpPeerPMap, "weight", bgpPeerP.Weight)
A(bgpPeerPMap, "adminSt", bgpPeerP.AdminSt)
return bgpPeerPMap, err
}
func BgpPeerConnectivityProfileFromContainerList(cont *container.Container, index int) *BgpPeerConnectivityProfile {
BgpPeerConnectivityProfileCont := cont.S("imdata").Index(index).S(BgppeerpClassName, "attributes")
return &BgpPeerConnectivityProfile{
BaseAttributes{
DistinguishedName: G(BgpPeerConnectivityProfileCont, "dn"),
Description: G(BgpPeerConnectivityProfileCont, "descr"),
Status: G(BgpPeerConnectivityProfileCont, "status"),
ClassName: BgppeerpClassName,
Rn: G(BgpPeerConnectivityProfileCont, "rn"),
},
BgpPeerConnectivityProfileAttributes{
Addr: G(BgpPeerConnectivityProfileCont, "addr"),
AddrTCtrl: G(BgpPeerConnectivityProfileCont, "addrTCtrl"),
AllowedSelfAsCnt: G(BgpPeerConnectivityProfileCont, "allowedSelfAsCnt"),
Annotation: G(BgpPeerConnectivityProfileCont, "annotation"),
Ctrl: G(BgpPeerConnectivityProfileCont, "ctrl"),
NameAlias: G(BgpPeerConnectivityProfileCont, "nameAlias"),
Password: G(BgpPeerConnectivityProfileCont, "password"),
PeerCtrl: G(BgpPeerConnectivityProfileCont, "peerCtrl"),
PrivateASctrl: G(BgpPeerConnectivityProfileCont, "privateASctrl"),
Ttl: G(BgpPeerConnectivityProfileCont, "ttl"),
Weight: G(BgpPeerConnectivityProfileCont, "weight"),
AdminSt: G(BgpPeerConnectivityProfileCont, "adminSt"),
},
}
}
func BgpPeerConnectivityProfileFromContainer(cont *container.Container) *BgpPeerConnectivityProfile {
return BgpPeerConnectivityProfileFromContainerList(cont, 0)
}
func BgpPeerConnectivityProfileListFromContainer(cont *container.Container) []*BgpPeerConnectivityProfile {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*BgpPeerConnectivityProfile, length)
for i := 0; i < length; i++ {
arr[i] = BgpPeerConnectivityProfileFromContainerList(cont, i)
}
return arr
}