-
Notifications
You must be signed in to change notification settings - Fork 30
/
igmp_if_pol.go
118 lines (105 loc) · 4.21 KB
/
igmp_if_pol.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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/v2/container"
)
const (
RnIgmpIfPol = "igmpIfPol-%s"
DnIgmpIfPol = "uni/tn-%s/igmpIfPol-%s"
ParentDnIgmpIfPol = "uni/tn-%s"
IgmpIfPolClassName = "igmpIfPol"
)
type IGMPInterfacePolicy struct {
BaseAttributes
IGMPInterfacePolicyAttributes
}
type IGMPInterfacePolicyAttributes struct {
Annotation string `json:",omitempty"`
GrpTimeout string `json:",omitempty"`
IfCtrl string `json:",omitempty"`
LastMbrCnt string `json:",omitempty"`
LastMbrRespTime string `json:",omitempty"`
Name string `json:",omitempty"`
NameAlias string `json:",omitempty"`
QuerierTimeout string `json:",omitempty"`
QueryIntvl string `json:",omitempty"`
RobustFac string `json:",omitempty"`
RspIntvl string `json:",omitempty"`
StartQueryCnt string `json:",omitempty"`
StartQueryIntvl string `json:",omitempty"`
Ver string `json:",omitempty"`
}
func NewIGMPInterfacePolicy(igmpIfPolRn, parentDn, description string, igmpIfPolAttr IGMPInterfacePolicyAttributes) *IGMPInterfacePolicy {
dn := fmt.Sprintf("%s/%s", parentDn, igmpIfPolRn)
return &IGMPInterfacePolicy{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: IgmpIfPolClassName,
Rn: igmpIfPolRn,
},
IGMPInterfacePolicyAttributes: igmpIfPolAttr,
}
}
func (igmpIfPol *IGMPInterfacePolicy) ToMap() (map[string]string, error) {
igmpIfPolMap, err := igmpIfPol.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(igmpIfPolMap, "annotation", igmpIfPol.Annotation)
A(igmpIfPolMap, "grpTimeout", igmpIfPol.GrpTimeout)
A(igmpIfPolMap, "ifCtrl", igmpIfPol.IfCtrl)
A(igmpIfPolMap, "lastMbrCnt", igmpIfPol.LastMbrCnt)
A(igmpIfPolMap, "lastMbrRespTime", igmpIfPol.LastMbrRespTime)
A(igmpIfPolMap, "name", igmpIfPol.Name)
A(igmpIfPolMap, "nameAlias", igmpIfPol.NameAlias)
A(igmpIfPolMap, "querierTimeout", igmpIfPol.QuerierTimeout)
A(igmpIfPolMap, "queryIntvl", igmpIfPol.QueryIntvl)
A(igmpIfPolMap, "robustFac", igmpIfPol.RobustFac)
A(igmpIfPolMap, "rspIntvl", igmpIfPol.RspIntvl)
A(igmpIfPolMap, "startQueryCnt", igmpIfPol.StartQueryCnt)
A(igmpIfPolMap, "startQueryIntvl", igmpIfPol.StartQueryIntvl)
A(igmpIfPolMap, "ver", igmpIfPol.Ver)
return igmpIfPolMap, err
}
func IGMPInterfacePolicyFromContainerList(cont *container.Container, index int) *IGMPInterfacePolicy {
IGMPInterfacePolicyCont := cont.S("imdata").Index(index).S(IgmpIfPolClassName, "attributes")
return &IGMPInterfacePolicy{
BaseAttributes{
DistinguishedName: G(IGMPInterfacePolicyCont, "dn"),
Description: G(IGMPInterfacePolicyCont, "descr"),
Status: G(IGMPInterfacePolicyCont, "status"),
ClassName: IgmpIfPolClassName,
Rn: G(IGMPInterfacePolicyCont, "rn"),
},
IGMPInterfacePolicyAttributes{
Annotation: G(IGMPInterfacePolicyCont, "annotation"),
GrpTimeout: G(IGMPInterfacePolicyCont, "grpTimeout"),
IfCtrl: G(IGMPInterfacePolicyCont, "ifCtrl"),
LastMbrCnt: G(IGMPInterfacePolicyCont, "lastMbrCnt"),
LastMbrRespTime: G(IGMPInterfacePolicyCont, "lastMbrRespTime"),
Name: G(IGMPInterfacePolicyCont, "name"),
NameAlias: G(IGMPInterfacePolicyCont, "nameAlias"),
QuerierTimeout: G(IGMPInterfacePolicyCont, "querierTimeout"),
QueryIntvl: G(IGMPInterfacePolicyCont, "queryIntvl"),
RobustFac: G(IGMPInterfacePolicyCont, "robustFac"),
RspIntvl: G(IGMPInterfacePolicyCont, "rspIntvl"),
StartQueryCnt: G(IGMPInterfacePolicyCont, "startQueryCnt"),
StartQueryIntvl: G(IGMPInterfacePolicyCont, "startQueryIntvl"),
Ver: G(IGMPInterfacePolicyCont, "ver"),
},
}
}
func IGMPInterfacePolicyFromContainer(cont *container.Container) *IGMPInterfacePolicy {
return IGMPInterfacePolicyFromContainerList(cont, 0)
}
func IGMPInterfacePolicyListFromContainer(cont *container.Container) []*IGMPInterfacePolicy {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*IGMPInterfacePolicy, length)
for i := 0; i < length; i++ {
arr[i] = IGMPInterfacePolicyFromContainerList(cont, i)
}
return arr
}