-
Notifications
You must be signed in to change notification settings - Fork 30
/
fabric_node_ident_p.go
136 lines (88 loc) · 3.39 KB
/
fabric_node_ident_p.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 FabricnodeidentpClassName = "fabricNodeIdentP"
type FabricNodeMember struct {
BaseAttributes
FabricNodeMemberAttributes
}
type FabricNodeMemberAttributes struct {
Serial string `json:",omitempty"`
Annotation string `json:",omitempty"`
ExtPoolId string `json:",omitempty"`
FabricId string `json:",omitempty"`
Name string `json:",omitempty"`
NameAlias string `json:",omitempty"`
NodeId string `json:",omitempty"`
NodeType string `json:",omitempty"`
PodId string `json:",omitempty"`
Role string `json:",omitempty"`
}
func NewFabricNodeMember(fabricNodeIdentPRn, parentDn, description string, fabricNodeIdentPattr FabricNodeMemberAttributes) *FabricNodeMember {
dn := fmt.Sprintf("%s/%s", parentDn, fabricNodeIdentPRn)
return &FabricNodeMember{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: FabricnodeidentpClassName,
Rn: fabricNodeIdentPRn,
},
FabricNodeMemberAttributes: fabricNodeIdentPattr,
}
}
func (fabricNodeIdentP *FabricNodeMember) ToMap() (map[string]string, error) {
fabricNodeIdentPMap, err := fabricNodeIdentP.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(fabricNodeIdentPMap, "serial", fabricNodeIdentP.Serial)
A(fabricNodeIdentPMap, "annotation", fabricNodeIdentP.Annotation)
A(fabricNodeIdentPMap, "extPoolId", fabricNodeIdentP.ExtPoolId)
A(fabricNodeIdentPMap, "fabricId", fabricNodeIdentP.FabricId)
A(fabricNodeIdentPMap, "name", fabricNodeIdentP.Name)
A(fabricNodeIdentPMap, "nameAlias", fabricNodeIdentP.NameAlias)
A(fabricNodeIdentPMap, "nodeId", fabricNodeIdentP.NodeId)
A(fabricNodeIdentPMap, "nodeType", fabricNodeIdentP.NodeType)
A(fabricNodeIdentPMap, "podId", fabricNodeIdentP.PodId)
A(fabricNodeIdentPMap, "role", fabricNodeIdentP.Role)
return fabricNodeIdentPMap, err
}
func FabricNodeMemberFromContainerList(cont *container.Container, index int) *FabricNodeMember {
FabricNodeMemberCont := cont.S("imdata").Index(index).S(FabricnodeidentpClassName, "attributes")
return &FabricNodeMember{
BaseAttributes{
DistinguishedName: G(FabricNodeMemberCont, "dn"),
Description: G(FabricNodeMemberCont, "descr"),
Status: G(FabricNodeMemberCont, "status"),
ClassName: FabricnodeidentpClassName,
Rn: G(FabricNodeMemberCont, "rn"),
},
FabricNodeMemberAttributes{
Serial: G(FabricNodeMemberCont, "serial"),
Annotation: G(FabricNodeMemberCont, "annotation"),
ExtPoolId: G(FabricNodeMemberCont, "extPoolId"),
FabricId: G(FabricNodeMemberCont, "fabricId"),
NameAlias: G(FabricNodeMemberCont, "nameAlias"),
Name: G(FabricNodeMemberCont, "name"),
NodeId: G(FabricNodeMemberCont, "nodeId"),
NodeType: G(FabricNodeMemberCont, "nodeType"),
PodId: G(FabricNodeMemberCont, "podId"),
Role: G(FabricNodeMemberCont, "role"),
},
}
}
func FabricNodeMemberFromContainer(cont *container.Container) *FabricNodeMember {
return FabricNodeMemberFromContainerList(cont, 0)
}
func FabricNodeMemberListFromContainer(cont *container.Container) []*FabricNodeMember {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*FabricNodeMember, length)
for i := 0; i < length; i++ {
arr[i] = FabricNodeMemberFromContainerList(cont, i)
}
return arr
}