forked from ciscoecosystem/aci-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fvns_vxlan_inst_p.go
94 lines (67 loc) · 2.17 KB
/
fvns_vxlan_inst_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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const FvnsvxlaninstpClassName = "fvnsVxlanInstP"
type VXLANPool struct {
BaseAttributes
VXLANPoolAttributes
}
type VXLANPoolAttributes struct {
Name string `json:",omitempty"`
Annotation string `json:",omitempty"`
NameAlias string `json:",omitempty"`
}
func NewVXLANPool(fvnsVxlanInstPRn, parentDn, description string, fvnsVxlanInstPattr VXLANPoolAttributes) *VXLANPool {
dn := fmt.Sprintf("%s/%s", parentDn, fvnsVxlanInstPRn)
return &VXLANPool{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: FvnsvxlaninstpClassName,
Rn: fvnsVxlanInstPRn,
},
VXLANPoolAttributes: fvnsVxlanInstPattr,
}
}
func (fvnsVxlanInstP *VXLANPool) ToMap() (map[string]string, error) {
fvnsVxlanInstPMap, err := fvnsVxlanInstP.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(fvnsVxlanInstPMap, "name", fvnsVxlanInstP.Name)
A(fvnsVxlanInstPMap, "annotation", fvnsVxlanInstP.Annotation)
A(fvnsVxlanInstPMap, "nameAlias", fvnsVxlanInstP.NameAlias)
return fvnsVxlanInstPMap, err
}
func VXLANPoolFromContainerList(cont *container.Container, index int) *VXLANPool {
VXLANPoolCont := cont.S("imdata").Index(index).S(FvnsvxlaninstpClassName, "attributes")
return &VXLANPool{
BaseAttributes{
DistinguishedName: G(VXLANPoolCont, "dn"),
Description: G(VXLANPoolCont, "descr"),
Status: G(VXLANPoolCont, "status"),
ClassName: FvnsvxlaninstpClassName,
Rn: G(VXLANPoolCont, "rn"),
},
VXLANPoolAttributes{
Name: G(VXLANPoolCont, "name"),
Annotation: G(VXLANPoolCont, "annotation"),
NameAlias: G(VXLANPoolCont, "nameAlias"),
},
}
}
func VXLANPoolFromContainer(cont *container.Container) *VXLANPool {
return VXLANPoolFromContainerList(cont, 0)
}
func VXLANPoolListFromContainer(cont *container.Container) []*VXLANPool {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*VXLANPool, length)
for i := 0; i < length; i++ {
arr[i] = VXLANPoolFromContainerList(cont, i)
}
return arr
}