-
Notifications
You must be signed in to change notification settings - Fork 30
/
top_system.go
224 lines (204 loc) · 9.4 KB
/
top_system.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const TopSystemClassName = "topSystem"
type System struct {
BaseAttributes
SystemAttributes
}
type SystemAttributes struct {
Address string `json:",omitempty"`
BootstrapState string `json:",omitempty"`
ChildAction string `json:",omitempty"`
ConfigIssues string `json:",omitempty"`
ControlPlaneMTU string `json:",omitempty"`
CurrentTime string `json:",omitempty"`
EnforceSubnetCheck string `json:",omitempty"`
EtepAddr string `json:",omitempty"`
FabricDomain string `json:",omitempty"`
FabricId string `json:",omitempty"`
FabricMAC string `json:",omitempty"`
Id string `json:",omitempty"`
InbMgmtAddr string `json:",omitempty"`
InbMgmtAddr6 string `json:",omitempty"`
InbMgmtAddr6Mask string `json:",omitempty"`
InbMgmtAddrMask string `json:",omitempty"`
InbMgmtGateway string `json:",omitempty"`
InbMgmtGateway6 string `json:",omitempty"`
LastRebootTime string `json:",omitempty"`
LastResetReason string `json:",omitempty"`
LcOwn string `json:",omitempty"`
ModTs string `json:",omitempty"`
Mode string `json:",omitempty"`
MonPolDn string `json:",omitempty"`
Name string `json:",omitempty"`
NameAlias string `json:",omitempty"`
NodeType string `json:",omitempty"`
OobMgmtAddr string `json:",omitempty"`
OobMgmtAddr6 string `json:",omitempty"`
OobMgmtAddr6Mask string `json:",omitempty"`
OobMgmtAddrMask string `json:",omitempty"`
OobMgmtGateway string `json:",omitempty"`
OobMgmtGateway6 string `json:",omitempty"`
PodId string `json:",omitempty"`
RemoteNetworkId string `json:",omitempty"`
RemoteNode string `json:",omitempty"`
RlOperPodId string `json:",omitempty"`
RlRoutableMode string `json:",omitempty"`
RldirectMode string `json:",omitempty"`
Role string `json:",omitempty"`
Serial string `json:",omitempty"`
ServerType string `json:",omitempty"`
SiteId string `json:",omitempty"`
State string `json:",omitempty"`
SystemUpTime string `json:",omitempty"`
TepPool string `json:",omitempty"`
UnicastXrEpLearnDisable string `json:",omitempty"`
Version string `json:",omitempty"`
VirtualMode string `json:",omitempty"`
}
func NewSystem(topSystemRn, parentDn, description string, topSystemattr SystemAttributes) *System {
dn := fmt.Sprintf("%s/%s", parentDn, topSystemRn)
return &System{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "",
ClassName: TopSystemClassName,
Rn: topSystemRn,
},
SystemAttributes: topSystemattr,
}
}
func (topSystem *System) ToMap() (map[string]string, error) {
topSystemMap, err := topSystem.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(topSystemMap, "address", topSystem.Address)
A(topSystemMap, "bootstrapState", topSystem.BootstrapState)
A(topSystemMap, "childAction", topSystem.ChildAction)
A(topSystemMap, "configIssues", topSystem.ConfigIssues)
A(topSystemMap, "controlPlaneMTU", topSystem.ControlPlaneMTU)
A(topSystemMap, "currentTime", topSystem.CurrentTime)
A(topSystemMap, "enforceSubnetCheck", topSystem.EnforceSubnetCheck)
A(topSystemMap, "etepAddr", topSystem.EtepAddr)
A(topSystemMap, "fabricDomain", topSystem.FabricDomain)
A(topSystemMap, "fabricId", topSystem.FabricId)
A(topSystemMap, "fabricMAC", topSystem.FabricMAC)
A(topSystemMap, "id", topSystem.Id)
A(topSystemMap, "inbMgmtAddr", topSystem.InbMgmtAddr)
A(topSystemMap, "inbMgmtAddr6", topSystem.InbMgmtAddr6)
A(topSystemMap, "inbMgmtAddr6Mask", topSystem.InbMgmtAddr6Mask)
A(topSystemMap, "inbMgmtAddrMask", topSystem.InbMgmtAddrMask)
A(topSystemMap, "inbMgmtGateway", topSystem.InbMgmtGateway)
A(topSystemMap, "inbMgmtGateway6", topSystem.InbMgmtGateway6)
A(topSystemMap, "lastRebootTime", topSystem.LastRebootTime)
A(topSystemMap, "lastResetReason", topSystem.LastResetReason)
A(topSystemMap, "lcOwn", topSystem.LcOwn)
A(topSystemMap, "modTs", topSystem.ModTs)
A(topSystemMap, "mode", topSystem.Mode)
A(topSystemMap, "monPolDn", topSystem.MonPolDn)
A(topSystemMap, "name", topSystem.Name)
A(topSystemMap, "nameAlias", topSystem.NameAlias)
A(topSystemMap, "nodeType", topSystem.NodeType)
A(topSystemMap, "oobMgmtAddr", topSystem.OobMgmtAddr)
A(topSystemMap, "oobMgmtAddr6", topSystem.OobMgmtAddr6)
A(topSystemMap, "oobMgmtAddr6Mask", topSystem.OobMgmtAddr6Mask)
A(topSystemMap, "oobMgmtAddrMask", topSystem.OobMgmtAddrMask)
A(topSystemMap, "oobMgmtGateway", topSystem.OobMgmtGateway)
A(topSystemMap, "oobMgmtGateway6", topSystem.OobMgmtGateway6)
A(topSystemMap, "podId", topSystem.PodId)
A(topSystemMap, "remoteNetworkId", topSystem.RemoteNetworkId)
A(topSystemMap, "remoteNode", topSystem.RemoteNode)
A(topSystemMap, "rlOperPodId", topSystem.RlOperPodId)
A(topSystemMap, "rlRoutableMode", topSystem.RlRoutableMode)
A(topSystemMap, "rldirectMode", topSystem.RldirectMode)
A(topSystemMap, "role", topSystem.Role)
A(topSystemMap, "serial", topSystem.Serial)
A(topSystemMap, "serverType", topSystem.ServerType)
A(topSystemMap, "siteId", topSystem.SiteId)
A(topSystemMap, "state", topSystem.State)
A(topSystemMap, "systemUpTime", topSystem.SystemUpTime)
A(topSystemMap, "tepPool", topSystem.TepPool)
A(topSystemMap, "unicastXrEpLearnDisable", topSystem.UnicastXrEpLearnDisable)
A(topSystemMap, "version", topSystem.Version)
A(topSystemMap, "virtualMode", topSystem.VirtualMode)
return topSystemMap, err
}
func SystemFromContainerList(cont *container.Container, index int) *System {
SystemCont := cont.S("imdata").Index(index).S(TopSystemClassName, "attributes")
return &System{
BaseAttributes{
DistinguishedName: G(SystemCont, "dn"),
Status: G(SystemCont, "status"),
ClassName: TopSystemClassName,
Rn: G(SystemCont, "rn"),
},
SystemAttributes{
Address: G(SystemCont, "address"),
BootstrapState: G(SystemCont, "bootstrapState"),
ChildAction: G(SystemCont, "childAction"),
ConfigIssues: G(SystemCont, "configIssues"),
ControlPlaneMTU: G(SystemCont, "controlPlaneMTU"),
CurrentTime: G(SystemCont, "currentTime"),
EnforceSubnetCheck: G(SystemCont, "enforceSubnetCheck"),
EtepAddr: G(SystemCont, "etepAddr"),
FabricDomain: G(SystemCont, "fabricDomain"),
FabricId: G(SystemCont, "fabricId"),
FabricMAC: G(SystemCont, "fabricMAC"),
Id: G(SystemCont, "id"),
InbMgmtAddr: G(SystemCont, "inbMgmtAddr"),
InbMgmtAddr6: G(SystemCont, "inbMgmtAddr6"),
InbMgmtAddr6Mask: G(SystemCont, "inbMgmtAddr6Mask"),
InbMgmtAddrMask: G(SystemCont, "inbMgmtAddrMask"),
InbMgmtGateway: G(SystemCont, "inbMgmtGateway"),
InbMgmtGateway6: G(SystemCont, "inbMgmtGateway6"),
LastRebootTime: G(SystemCont, "lastRebootTime"),
LastResetReason: G(SystemCont, "lastResetReason"),
LcOwn: G(SystemCont, "lcOwn"),
ModTs: G(SystemCont, "modTs"),
Mode: G(SystemCont, "mode"),
MonPolDn: G(SystemCont, "monPolDn"),
Name: G(SystemCont, "name"),
NameAlias: G(SystemCont, "nameAlias"),
NodeType: G(SystemCont, "nodeType"),
OobMgmtAddr: G(SystemCont, "oobMgmtAddr"),
OobMgmtAddr6: G(SystemCont, "oobMgmtAddr6"),
OobMgmtAddr6Mask: G(SystemCont, "oobMgmtAddr6Mask"),
OobMgmtAddrMask: G(SystemCont, "oobMgmtAddrMask"),
OobMgmtGateway: G(SystemCont, "oobMgmtGateway"),
OobMgmtGateway6: G(SystemCont, "oobMgmtGateway6"),
PodId: G(SystemCont, "podId"),
RemoteNetworkId: G(SystemCont, "remoteNetworkId"),
RemoteNode: G(SystemCont, "remoteNode"),
RlOperPodId: G(SystemCont, "rlOperPodId"),
RlRoutableMode: G(SystemCont, "rlRoutableMode"),
RldirectMode: G(SystemCont, "rldirectMode"),
Role: G(SystemCont, "role"),
Serial: G(SystemCont, "serial"),
ServerType: G(SystemCont, "serverType"),
SiteId: G(SystemCont, "siteId"),
State: G(SystemCont, "state"),
SystemUpTime: G(SystemCont, "systemUpTime"),
TepPool: G(SystemCont, "tepPool"),
UnicastXrEpLearnDisable: G(SystemCont, "unicastXrEpLearnDisable"),
Version: G(SystemCont, "version"),
VirtualMode: G(SystemCont, "virtualMode"),
},
}
}
func SystemFromContainer(cont *container.Container) *System {
return SystemFromContainerList(cont, 0)
}
func SystemListFromContainer(cont *container.Container) []*System {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*System, length)
for i := 0; i < length; i++ {
arr[i] = SystemFromContainerList(cont, i)
}
return arr
}