-
Notifications
You must be signed in to change notification settings - Fork 30
/
isis_lvl_comp.go
117 lines (107 loc) · 3.75 KB
/
isis_lvl_comp.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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const (
DnisisLvlComp = "uni/fabric/isisDomP-%s/lvl-%s"
RnisisLvlComp = "lvl-%s"
ParentDnisisLvlComp = "uni/fabric/isisDomP-%s"
IsislvlcompClassName = "isisLvlComp"
)
type ISISLevel struct {
BaseAttributes
NameAliasAttribute
ISISLevelAttributes
}
type ISISLevelAttributes struct {
Annotation string `json:",omitempty"`
LspFastFlood string `json:",omitempty"`
LspGenInitIntvl string `json:",omitempty"`
LspGenMaxIntvl string `json:",omitempty"`
LspGenSecIntvl string `json:",omitempty"`
Name string `json:",omitempty"`
SpfCompInitIntvl string `json:",omitempty"`
SpfCompMaxIntvl string `json:",omitempty"`
SpfCompSecIntvl string `json:",omitempty"`
ISISLevel_type string `json:",omitempty"`
}
func NewISISLevel(isisLvlCompRn, parentDn, description, nameAlias string, isisLvlCompAttr ISISLevelAttributes) *ISISLevel {
dn := fmt.Sprintf("%s/%s", parentDn, isisLvlCompRn)
return &ISISLevel{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: IsislvlcompClassName,
Rn: isisLvlCompRn,
},
NameAliasAttribute: NameAliasAttribute{
NameAlias: nameAlias,
},
ISISLevelAttributes: isisLvlCompAttr,
}
}
func (isisLvlComp *ISISLevel) ToMap() (map[string]string, error) {
isisLvlCompMap, err := isisLvlComp.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
alias, err := isisLvlComp.NameAliasAttribute.ToMap()
if err != nil {
return nil, err
}
for key, value := range alias {
A(isisLvlCompMap, key, value)
}
A(isisLvlCompMap, "annotation", isisLvlComp.Annotation)
A(isisLvlCompMap, "lspFastFlood", isisLvlComp.LspFastFlood)
A(isisLvlCompMap, "lspGenInitIntvl", isisLvlComp.LspGenInitIntvl)
A(isisLvlCompMap, "lspGenMaxIntvl", isisLvlComp.LspGenMaxIntvl)
A(isisLvlCompMap, "lspGenSecIntvl", isisLvlComp.LspGenSecIntvl)
A(isisLvlCompMap, "name", isisLvlComp.Name)
A(isisLvlCompMap, "spfCompInitIntvl", isisLvlComp.SpfCompInitIntvl)
A(isisLvlCompMap, "spfCompMaxIntvl", isisLvlComp.SpfCompMaxIntvl)
A(isisLvlCompMap, "spfCompSecIntvl", isisLvlComp.SpfCompSecIntvl)
A(isisLvlCompMap, "type", isisLvlComp.ISISLevel_type)
return isisLvlCompMap, err
}
func ISISLevelFromContainerList(cont *container.Container, index int) *ISISLevel {
ISISLevelCont := cont.S("imdata").Index(index).S(IsislvlcompClassName, "attributes")
return &ISISLevel{
BaseAttributes{
DistinguishedName: G(ISISLevelCont, "dn"),
Description: G(ISISLevelCont, "descr"),
Status: G(ISISLevelCont, "status"),
ClassName: IsislvlcompClassName,
Rn: G(ISISLevelCont, "rn"),
},
NameAliasAttribute{
NameAlias: G(ISISLevelCont, "nameAlias"),
},
ISISLevelAttributes{
Annotation: G(ISISLevelCont, "annotation"),
LspFastFlood: G(ISISLevelCont, "lspFastFlood"),
LspGenInitIntvl: G(ISISLevelCont, "lspGenInitIntvl"),
LspGenMaxIntvl: G(ISISLevelCont, "lspGenMaxIntvl"),
LspGenSecIntvl: G(ISISLevelCont, "lspGenSecIntvl"),
Name: G(ISISLevelCont, "name"),
SpfCompInitIntvl: G(ISISLevelCont, "spfCompInitIntvl"),
SpfCompMaxIntvl: G(ISISLevelCont, "spfCompMaxIntvl"),
SpfCompSecIntvl: G(ISISLevelCont, "spfCompSecIntvl"),
ISISLevel_type: G(ISISLevelCont, "type"),
},
}
}
func ISISLevelFromContainer(cont *container.Container) *ISISLevel {
return ISISLevelFromContainerList(cont, 0)
}
func ISISLevelListFromContainer(cont *container.Container) []*ISISLevel {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*ISISLevel, length)
for i := 0; i < length; i++ {
arr[i] = ISISLevelFromContainerList(cont, i)
}
return arr
}