-
Notifications
You must be signed in to change notification settings - Fork 29
/
ospf_if_pol.go
148 lines (94 loc) · 3.56 KB
/
ospf_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
137
138
139
140
141
142
143
144
145
146
147
148
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/v2/container"
)
const OspfifpolClassName = "ospfIfPol"
type OSPFInterfacePolicy struct {
BaseAttributes
OSPFInterfacePolicyAttributes
}
type OSPFInterfacePolicyAttributes struct {
Name string `json:",omitempty"`
Annotation string `json:",omitempty"`
Cost string `json:",omitempty"`
Ctrl string `json:",omitempty"`
DeadIntvl string `json:",omitempty"`
HelloIntvl string `json:",omitempty"`
NameAlias string `json:",omitempty"`
NwT string `json:",omitempty"`
PfxSuppress string `json:",omitempty"`
Prio string `json:",omitempty"`
RexmitIntvl string `json:",omitempty"`
XmitDelay string `json:",omitempty"`
}
func NewOSPFInterfacePolicy(ospfIfPolRn, parentDn, description string, ospfIfPolattr OSPFInterfacePolicyAttributes) *OSPFInterfacePolicy {
dn := fmt.Sprintf("%s/%s", parentDn, ospfIfPolRn)
return &OSPFInterfacePolicy{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: OspfifpolClassName,
Rn: ospfIfPolRn,
},
OSPFInterfacePolicyAttributes: ospfIfPolattr,
}
}
func (ospfIfPol *OSPFInterfacePolicy) ToMap() (map[string]string, error) {
ospfIfPolMap, err := ospfIfPol.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(ospfIfPolMap, "name", ospfIfPol.Name)
A(ospfIfPolMap, "annotation", ospfIfPol.Annotation)
A(ospfIfPolMap, "cost", ospfIfPol.Cost)
A(ospfIfPolMap, "ctrl", ospfIfPol.Ctrl)
A(ospfIfPolMap, "deadIntvl", ospfIfPol.DeadIntvl)
A(ospfIfPolMap, "helloIntvl", ospfIfPol.HelloIntvl)
A(ospfIfPolMap, "nameAlias", ospfIfPol.NameAlias)
A(ospfIfPolMap, "nwT", ospfIfPol.NwT)
A(ospfIfPolMap, "pfxSuppress", ospfIfPol.PfxSuppress)
A(ospfIfPolMap, "prio", ospfIfPol.Prio)
A(ospfIfPolMap, "rexmitIntvl", ospfIfPol.RexmitIntvl)
A(ospfIfPolMap, "xmitDelay", ospfIfPol.XmitDelay)
return ospfIfPolMap, err
}
func OSPFInterfacePolicyFromContainerList(cont *container.Container, index int) *OSPFInterfacePolicy {
OSPFInterfacePolicyCont := cont.S("imdata").Index(index).S(OspfifpolClassName, "attributes")
return &OSPFInterfacePolicy{
BaseAttributes{
DistinguishedName: G(OSPFInterfacePolicyCont, "dn"),
Description: G(OSPFInterfacePolicyCont, "descr"),
Status: G(OSPFInterfacePolicyCont, "status"),
ClassName: OspfifpolClassName,
Rn: G(OSPFInterfacePolicyCont, "rn"),
},
OSPFInterfacePolicyAttributes{
Name: G(OSPFInterfacePolicyCont, "name"),
Annotation: G(OSPFInterfacePolicyCont, "annotation"),
Cost: G(OSPFInterfacePolicyCont, "cost"),
Ctrl: G(OSPFInterfacePolicyCont, "ctrl"),
DeadIntvl: G(OSPFInterfacePolicyCont, "deadIntvl"),
HelloIntvl: G(OSPFInterfacePolicyCont, "helloIntvl"),
NameAlias: G(OSPFInterfacePolicyCont, "nameAlias"),
NwT: G(OSPFInterfacePolicyCont, "nwT"),
PfxSuppress: G(OSPFInterfacePolicyCont, "pfxSuppress"),
Prio: G(OSPFInterfacePolicyCont, "prio"),
RexmitIntvl: G(OSPFInterfacePolicyCont, "rexmitIntvl"),
XmitDelay: G(OSPFInterfacePolicyCont, "xmitDelay"),
},
}
}
func OSPFInterfacePolicyFromContainer(cont *container.Container) *OSPFInterfacePolicy {
return OSPFInterfacePolicyFromContainerList(cont, 0)
}
func OSPFInterfacePolicyListFromContainer(cont *container.Container) []*OSPFInterfacePolicy {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*OSPFInterfacePolicy, length)
for i := 0; i < length; i++ {
arr[i] = OSPFInterfacePolicyFromContainerList(cont, i)
}
return arr
}