-
Notifications
You must be signed in to change notification settings - Fork 30
/
bfd_if_pol.go
136 lines (88 loc) · 3.28 KB
/
bfd_if_pol.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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const BfdifpolClassName = "bfdIfPol"
type BFDInterfacePolicy struct {
BaseAttributes
BFDInterfacePolicyAttributes
}
type BFDInterfacePolicyAttributes struct {
Name string `json:",omitempty"`
AdminSt string `json:",omitempty"`
Annotation string `json:",omitempty"`
Ctrl string `json:",omitempty"`
DetectMult string `json:",omitempty"`
EchoAdminSt string `json:",omitempty"`
EchoRxIntvl string `json:",omitempty"`
MinRxIntvl string `json:",omitempty"`
MinTxIntvl string `json:",omitempty"`
NameAlias string `json:",omitempty"`
}
func NewBFDInterfacePolicy(bfdIfPolRn, parentDn, description string, bfdIfPolattr BFDInterfacePolicyAttributes) *BFDInterfacePolicy {
dn := fmt.Sprintf("%s/%s", parentDn, bfdIfPolRn)
return &BFDInterfacePolicy{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: BfdifpolClassName,
Rn: bfdIfPolRn,
},
BFDInterfacePolicyAttributes: bfdIfPolattr,
}
}
func (bfdIfPol *BFDInterfacePolicy) ToMap() (map[string]string, error) {
bfdIfPolMap, err := bfdIfPol.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(bfdIfPolMap, "name", bfdIfPol.Name)
A(bfdIfPolMap, "adminSt", bfdIfPol.AdminSt)
A(bfdIfPolMap, "annotation", bfdIfPol.Annotation)
A(bfdIfPolMap, "ctrl", bfdIfPol.Ctrl)
A(bfdIfPolMap, "detectMult", bfdIfPol.DetectMult)
A(bfdIfPolMap, "echoAdminSt", bfdIfPol.EchoAdminSt)
A(bfdIfPolMap, "echoRxIntvl", bfdIfPol.EchoRxIntvl)
A(bfdIfPolMap, "minRxIntvl", bfdIfPol.MinRxIntvl)
A(bfdIfPolMap, "minTxIntvl", bfdIfPol.MinTxIntvl)
A(bfdIfPolMap, "nameAlias", bfdIfPol.NameAlias)
return bfdIfPolMap, err
}
func BFDInterfacePolicyFromContainerList(cont *container.Container, index int) *BFDInterfacePolicy {
BFDInterfacePolicyCont := cont.S("imdata").Index(index).S(BfdifpolClassName, "attributes")
return &BFDInterfacePolicy{
BaseAttributes{
DistinguishedName: G(BFDInterfacePolicyCont, "dn"),
Description: G(BFDInterfacePolicyCont, "descr"),
Status: G(BFDInterfacePolicyCont, "status"),
ClassName: BfdifpolClassName,
Rn: G(BFDInterfacePolicyCont, "rn"),
},
BFDInterfacePolicyAttributes{
Name: G(BFDInterfacePolicyCont, "name"),
AdminSt: G(BFDInterfacePolicyCont, "adminSt"),
Annotation: G(BFDInterfacePolicyCont, "annotation"),
Ctrl: G(BFDInterfacePolicyCont, "ctrl"),
DetectMult: G(BFDInterfacePolicyCont, "detectMult"),
EchoAdminSt: G(BFDInterfacePolicyCont, "echoAdminSt"),
EchoRxIntvl: G(BFDInterfacePolicyCont, "echoRxIntvl"),
MinRxIntvl: G(BFDInterfacePolicyCont, "minRxIntvl"),
MinTxIntvl: G(BFDInterfacePolicyCont, "minTxIntvl"),
NameAlias: G(BFDInterfacePolicyCont, "nameAlias"),
},
}
}
func BFDInterfacePolicyFromContainer(cont *container.Container) *BFDInterfacePolicy {
return BFDInterfacePolicyFromContainerList(cont, 0)
}
func BFDInterfacePolicyListFromContainer(cont *container.Container) []*BFDInterfacePolicy {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*BFDInterfacePolicy, length)
for i := 0; i < length; i++ {
arr[i] = BFDInterfacePolicyFromContainerList(cont, i)
}
return arr
}