-
Notifications
You must be signed in to change notification settings - Fork 29
/
cloudtemplate_ext_network.go
112 lines (97 loc) · 4.29 KB
/
cloudtemplate_ext_network.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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/v2/container"
)
const (
DncloudtemplateExtNetwork = "uni/tn-%s/infranetwork-%s/extnetwork-%s"
RncloudtemplateExtNetwork = "extnetwork-%s"
ParentDncloudtemplateExtNetwork = "uni/tn-%s/infranetwork-%s"
CloudtemplateextnetworkClassName = "cloudtemplateExtNetwork"
CloudInfraNetworkDefaultTemplateDn = "uni/tn-infra/infranetwork-default"
)
type CloudTemplateforExternalNetwork struct {
BaseAttributes
NameAliasAttribute
CloudTemplateforExternalNetworkAttributes
}
type CloudTemplateforExternalNetworkAttributes struct {
Annotation string `json:",omitempty"`
HubNetworkName string `json:",omitempty"`
Name string `json:",omitempty"`
VrfName string `json:",omitempty"`
AllRegion string `json:",omitempty"`
HostRouterName string `json:",omitempty"`
VpnRouterName string `json:",omitempty"`
}
func NewCloudTemplateforExternalNetwork(cloudtemplateExtNetworkRn, parentDn, nameAlias string, cloudtemplateExtNetworkAttr CloudTemplateforExternalNetworkAttributes) *CloudTemplateforExternalNetwork {
dn := fmt.Sprintf("%s/%s", parentDn, cloudtemplateExtNetworkRn)
return &CloudTemplateforExternalNetwork{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Status: "created, modified",
ClassName: CloudtemplateextnetworkClassName,
Rn: cloudtemplateExtNetworkRn,
},
NameAliasAttribute: NameAliasAttribute{
NameAlias: nameAlias,
},
CloudTemplateforExternalNetworkAttributes: cloudtemplateExtNetworkAttr,
}
}
func (cloudtemplateExtNetwork *CloudTemplateforExternalNetwork) ToMap() (map[string]string, error) {
cloudtemplateExtNetworkMap, err := cloudtemplateExtNetwork.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
alias, err := cloudtemplateExtNetwork.NameAliasAttribute.ToMap()
if err != nil {
return nil, err
}
for key, value := range alias {
A(cloudtemplateExtNetworkMap, key, value)
}
A(cloudtemplateExtNetworkMap, "annotation", cloudtemplateExtNetwork.Annotation)
A(cloudtemplateExtNetworkMap, "hubNetworkName", cloudtemplateExtNetwork.HubNetworkName)
A(cloudtemplateExtNetworkMap, "name", cloudtemplateExtNetwork.Name)
A(cloudtemplateExtNetworkMap, "vrfName", cloudtemplateExtNetwork.VrfName)
A(cloudtemplateExtNetworkMap, "allRegion", cloudtemplateExtNetwork.AllRegion)
A(cloudtemplateExtNetworkMap, "hostRouterName", cloudtemplateExtNetwork.HostRouterName)
A(cloudtemplateExtNetworkMap, "vpnRouterName", cloudtemplateExtNetwork.VpnRouterName)
return cloudtemplateExtNetworkMap, err
}
func CloudTemplateforExternalNetworkFromContainerList(cont *container.Container, index int) *CloudTemplateforExternalNetwork {
CloudTemplateforExternalNetworkCont := cont.S("imdata").Index(index).S(CloudtemplateextnetworkClassName, "attributes")
return &CloudTemplateforExternalNetwork{
BaseAttributes{
DistinguishedName: G(CloudTemplateforExternalNetworkCont, "dn"),
Status: G(CloudTemplateforExternalNetworkCont, "status"),
ClassName: CloudtemplateextnetworkClassName,
Rn: G(CloudTemplateforExternalNetworkCont, "rn"),
},
NameAliasAttribute{
NameAlias: G(CloudTemplateforExternalNetworkCont, "nameAlias"),
},
CloudTemplateforExternalNetworkAttributes{
Annotation: G(CloudTemplateforExternalNetworkCont, "annotation"),
HubNetworkName: G(CloudTemplateforExternalNetworkCont, "hubNetworkName"),
Name: G(CloudTemplateforExternalNetworkCont, "name"),
VrfName: G(CloudTemplateforExternalNetworkCont, "vrfName"),
AllRegion: G(CloudTemplateforExternalNetworkCont, "allRegion"),
HostRouterName: G(CloudTemplateforExternalNetworkCont, "hostRouterName"),
VpnRouterName: G(CloudTemplateforExternalNetworkCont, "vpnRouterName"),
},
}
}
func CloudTemplateforExternalNetworkFromContainer(cont *container.Container) *CloudTemplateforExternalNetwork {
return CloudTemplateforExternalNetworkFromContainerList(cont, 0)
}
func CloudTemplateforExternalNetworkListFromContainer(cont *container.Container) []*CloudTemplateforExternalNetwork {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*CloudTemplateforExternalNetwork, length)
for i := 0; i < length; i++ {
arr[i] = CloudTemplateforExternalNetworkFromContainerList(cont, i)
}
return arr
}