-
Notifications
You must be signed in to change notification settings - Fork 30
/
fvAEPgLagPolAtt_service.go
95 lines (81 loc) · 3.78 KB
/
fvAEPgLagPolAtt_service.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
package client
import (
"fmt"
"github.com/ciscoecosystem/aci-go-client/container"
"github.com/ciscoecosystem/aci-go-client/models"
)
func (sm *ServiceManager) CreateApplicationEPGLagPolicy(domain_dn string, application_epg string, application_profile string, tenant string, fvAEPgLagPolAttAttr models.ApplicationEPGLagPolicyAttributes) (*models.ApplicationEPGLagPolicy, error) {
rn := fmt.Sprintf(models.RnfvAEPgLagPolAtt)
parentDn := fmt.Sprintf(models.ParentDnfvAEPgLagPolAtt, tenant, application_profile, application_epg, domain_dn)
fvAEPgLagPolAtt := models.NewApplicationEPGLagPolicy(rn, parentDn, fvAEPgLagPolAttAttr)
err := sm.Save(fvAEPgLagPolAtt)
return fvAEPgLagPolAtt, err
}
func (sm *ServiceManager) ReadApplicationEPGLagPolicy(domain_dn string, application_epg string, application_profile string, tenant string) (*models.ApplicationEPGLagPolicy, error) {
dn := fmt.Sprintf(models.DnfvAEPgLagPolAtt, tenant, application_profile, application_epg, domain_dn)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
fvAEPgLagPolAtt := models.ApplicationEPGLagPolicyFromContainer(cont)
return fvAEPgLagPolAtt, nil
}
func (sm *ServiceManager) DeleteApplicationEPGLagPolicy(domain_dn string, application_epg string, application_profile string, tenant string) error {
dn := fmt.Sprintf(models.DnfvAEPgLagPolAtt, tenant, application_profile, application_epg, domain_dn)
return sm.DeleteByDn(dn, models.FvAEPgLagPolAttClassName)
}
func (sm *ServiceManager) UpdateApplicationEPGLagPolicy(domain_dn string, application_epg string, application_profile string, tenant string, fvAEPgLagPolAttAttr models.ApplicationEPGLagPolicyAttributes) (*models.ApplicationEPGLagPolicy, error) {
rn := fmt.Sprintf(models.RnfvAEPgLagPolAtt)
parentDn := fmt.Sprintf(models.ParentDnfvAEPgLagPolAtt, tenant, application_profile, application_epg, domain_dn)
fvAEPgLagPolAtt := models.NewApplicationEPGLagPolicy(rn, parentDn, fvAEPgLagPolAttAttr)
fvAEPgLagPolAtt.Status = "modified"
err := sm.Save(fvAEPgLagPolAtt)
return fvAEPgLagPolAtt, err
}
func (sm *ServiceManager) ListApplicationEPGLagPolicy(domain_dn string, application_epg string, application_profile string, tenant string) ([]*models.ApplicationEPGLagPolicy, error) {
dnUrl := fmt.Sprintf("%s/uni/tn-%s/ap-%s/epg-%s/rsdomAtt-[%s]/fvAEPgLagPolAtt.json", models.BaseurlStr, tenant, application_profile, application_epg, domain_dn)
cont, err := sm.GetViaURL(dnUrl)
list := models.ApplicationEPGLagPolicyListFromContainer(cont)
return list, err
}
func (sm *ServiceManager) CreateRelationfvRsVmmVSwitchEnhancedLagPol(parentDn, annotation, tDn string) error {
dn := fmt.Sprintf("%s/rsvmmVSwitchEnhancedLagPol", parentDn)
containerJSON := []byte(fmt.Sprintf(`{
"%s": {
"attributes": {
"dn": "%s",
"annotation": "%s",
"tDn": "%s"
}
}
}`, "fvRsVmmVSwitchEnhancedLagPol", dn, annotation, tDn))
jsonPayload, err := container.ParseJSON(containerJSON)
if err != nil {
return err
}
req, err := sm.client.MakeRestRequest("POST", fmt.Sprintf("%s.json", sm.MOURL), jsonPayload, true)
if err != nil {
return err
}
cont, _, err := sm.client.Do(req)
if err != nil {
return err
}
fmt.Printf("%+v", cont)
return nil
}
func (sm *ServiceManager) DeleteRelationfvRsVmmVSwitchEnhancedLagPol(parentDn string) error {
dn := fmt.Sprintf("%s/rsvmmVSwitchEnhancedLagPol", parentDn)
return sm.DeleteByDn(dn, "fvRsVmmVSwitchEnhancedLagPol")
}
func (sm *ServiceManager) ReadRelationfvRsVmmVSwitchEnhancedLagPol(parentDn string) (interface{}, error) {
dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, "fvRsVmmVSwitchEnhancedLagPol")
cont, err := sm.GetViaURL(dnUrl)
contList := models.ListFromContainer(cont, "fvRsVmmVSwitchEnhancedLagPol")
if len(contList) > 0 {
dat := models.G(contList[0], "tDn")
return dat, err
} else {
return nil, err
}
}