-
Notifications
You must be signed in to change notification settings - Fork 30
/
fv_ae_pg.go
154 lines (97 loc) · 3.5 KB
/
fv_ae_pg.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
149
150
151
152
153
154
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const FvaepgClassName = "fvAEPg"
type ApplicationEPG struct {
BaseAttributes
ApplicationEPGAttributes
}
type ApplicationEPGAttributes struct {
Name string `json:",omitempty"`
Annotation string `json:",omitempty"`
ExceptionTag string `json:",omitempty"`
FloodOnEncap string `json:",omitempty"`
FwdCtrl string `json:",omitempty"`
HasMcastSource string `json:",omitempty"`
IsAttrBasedEPg string `json:",omitempty"`
MatchT string `json:",omitempty"`
NameAlias string `json:",omitempty"`
PcEnfPref string `json:",omitempty"`
PrefGrMemb string `json:",omitempty"`
Prio string `json:",omitempty"`
Shutdown string `json:",omitempty"`
}
func NewApplicationEPG(fvAEPgRn, parentDn, description string, fvAEPgattr ApplicationEPGAttributes) *ApplicationEPG {
dn := fmt.Sprintf("%s/%s", parentDn, fvAEPgRn)
return &ApplicationEPG{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: FvaepgClassName,
Rn: fvAEPgRn,
},
ApplicationEPGAttributes: fvAEPgattr,
}
}
func (fvAEPg *ApplicationEPG) ToMap() (map[string]string, error) {
fvAEPgMap, err := fvAEPg.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(fvAEPgMap, "name", fvAEPg.Name)
A(fvAEPgMap, "annotation", fvAEPg.Annotation)
A(fvAEPgMap, "exceptionTag", fvAEPg.ExceptionTag)
A(fvAEPgMap, "floodOnEncap", fvAEPg.FloodOnEncap)
A(fvAEPgMap, "fwdCtrl", fvAEPg.FwdCtrl)
A(fvAEPgMap, "hasMcastSource", fvAEPg.HasMcastSource)
A(fvAEPgMap, "isAttrBasedEPg", fvAEPg.IsAttrBasedEPg)
A(fvAEPgMap, "matchT", fvAEPg.MatchT)
A(fvAEPgMap, "nameAlias", fvAEPg.NameAlias)
A(fvAEPgMap, "pcEnfPref", fvAEPg.PcEnfPref)
A(fvAEPgMap, "prefGrMemb", fvAEPg.PrefGrMemb)
A(fvAEPgMap, "prio", fvAEPg.Prio)
A(fvAEPgMap, "shutdown", fvAEPg.Shutdown)
return fvAEPgMap, err
}
func ApplicationEPGFromContainerList(cont *container.Container, index int) *ApplicationEPG {
ApplicationEPGCont := cont.S("imdata").Index(index).S(FvaepgClassName, "attributes")
return &ApplicationEPG{
BaseAttributes{
DistinguishedName: G(ApplicationEPGCont, "dn"),
Description: G(ApplicationEPGCont, "descr"),
Status: G(ApplicationEPGCont, "status"),
ClassName: FvaepgClassName,
Rn: G(ApplicationEPGCont, "rn"),
},
ApplicationEPGAttributes{
Name: G(ApplicationEPGCont, "name"),
Annotation: G(ApplicationEPGCont, "annotation"),
ExceptionTag: G(ApplicationEPGCont, "exceptionTag"),
FloodOnEncap: G(ApplicationEPGCont, "floodOnEncap"),
FwdCtrl: G(ApplicationEPGCont, "fwdCtrl"),
HasMcastSource: G(ApplicationEPGCont, "hasMcastSource"),
IsAttrBasedEPg: G(ApplicationEPGCont, "isAttrBasedEPg"),
MatchT: G(ApplicationEPGCont, "matchT"),
NameAlias: G(ApplicationEPGCont, "nameAlias"),
PcEnfPref: G(ApplicationEPGCont, "pcEnfPref"),
PrefGrMemb: G(ApplicationEPGCont, "prefGrMemb"),
Prio: G(ApplicationEPGCont, "prio"),
Shutdown: G(ApplicationEPGCont, "shutdown"),
},
}
}
func ApplicationEPGFromContainer(cont *container.Container) *ApplicationEPG {
return ApplicationEPGFromContainerList(cont, 0)
}
func ApplicationEPGListFromContainer(cont *container.Container) []*ApplicationEPG {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*ApplicationEPG, length)
for i := 0; i < length; i++ {
arr[i] = ApplicationEPGFromContainerList(cont, i)
}
return arr
}