-
Notifications
You must be signed in to change notification settings - Fork 30
/
fc_if_pol.go
130 lines (85 loc) · 3.08 KB
/
fc_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
119
120
121
122
123
124
125
126
127
128
129
130
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const FcifpolClassName = "fcIfPol"
type InterfaceFCPolicy struct {
BaseAttributes
InterfaceFCPolicyAttributes
}
type InterfaceFCPolicyAttributes struct {
Name string `json:",omitempty"`
Annotation string `json:",omitempty"`
Automaxspeed string `json:",omitempty"`
FillPattern string `json:",omitempty"`
NameAlias string `json:",omitempty"`
PortMode string `json:",omitempty"`
RxBBCredit string `json:",omitempty"`
Speed string `json:",omitempty"`
TrunkMode string `json:",omitempty"`
}
func NewInterfaceFCPolicy(fcIfPolRn, parentDn, description string, fcIfPolattr InterfaceFCPolicyAttributes) *InterfaceFCPolicy {
dn := fmt.Sprintf("%s/%s", parentDn, fcIfPolRn)
return &InterfaceFCPolicy{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: FcifpolClassName,
Rn: fcIfPolRn,
},
InterfaceFCPolicyAttributes: fcIfPolattr,
}
}
func (fcIfPol *InterfaceFCPolicy) ToMap() (map[string]string, error) {
fcIfPolMap, err := fcIfPol.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(fcIfPolMap, "name", fcIfPol.Name)
A(fcIfPolMap, "annotation", fcIfPol.Annotation)
A(fcIfPolMap, "automaxspeed", fcIfPol.Automaxspeed)
A(fcIfPolMap, "fillPattern", fcIfPol.FillPattern)
A(fcIfPolMap, "nameAlias", fcIfPol.NameAlias)
A(fcIfPolMap, "portMode", fcIfPol.PortMode)
A(fcIfPolMap, "rxBBCredit", fcIfPol.RxBBCredit)
A(fcIfPolMap, "speed", fcIfPol.Speed)
A(fcIfPolMap, "trunkMode", fcIfPol.TrunkMode)
return fcIfPolMap, err
}
func InterfaceFCPolicyFromContainerList(cont *container.Container, index int) *InterfaceFCPolicy {
InterfaceFCPolicyCont := cont.S("imdata").Index(index).S(FcifpolClassName, "attributes")
return &InterfaceFCPolicy{
BaseAttributes{
DistinguishedName: G(InterfaceFCPolicyCont, "dn"),
Description: G(InterfaceFCPolicyCont, "descr"),
Status: G(InterfaceFCPolicyCont, "status"),
ClassName: FcifpolClassName,
Rn: G(InterfaceFCPolicyCont, "rn"),
},
InterfaceFCPolicyAttributes{
Name: G(InterfaceFCPolicyCont, "name"),
Annotation: G(InterfaceFCPolicyCont, "annotation"),
Automaxspeed: G(InterfaceFCPolicyCont, "automaxspeed"),
FillPattern: G(InterfaceFCPolicyCont, "fillPattern"),
NameAlias: G(InterfaceFCPolicyCont, "nameAlias"),
PortMode: G(InterfaceFCPolicyCont, "portMode"),
RxBBCredit: G(InterfaceFCPolicyCont, "rxBBCredit"),
Speed: G(InterfaceFCPolicyCont, "speed"),
TrunkMode: G(InterfaceFCPolicyCont, "trunkMode"),
},
}
}
func InterfaceFCPolicyFromContainer(cont *container.Container) *InterfaceFCPolicy {
return InterfaceFCPolicyFromContainerList(cont, 0)
}
func InterfaceFCPolicyListFromContainer(cont *container.Container) []*InterfaceFCPolicy {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*InterfaceFCPolicy, length)
for i := 0; i < length; i++ {
arr[i] = InterfaceFCPolicyFromContainerList(cont, i)
}
return arr
}