-
Notifications
You must be signed in to change notification settings - Fork 30
/
lacpIfPol_service.go
48 lines (39 loc) · 1.61 KB
/
lacpIfPol_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
package client
import (
"fmt"
"github.com/ciscoecosystem/aci-go-client/models"
)
func (sm *ServiceManager) CreateLACPMemberPolicy(name string, description string, lacpIfPolAttr models.LACPMemberPolicyAttributes) (*models.LACPMemberPolicy, error) {
rn := fmt.Sprintf(models.RnlacpIfPol, name)
parentDn := fmt.Sprintf(models.ParentDnlacpIfPol)
lacpIfPol := models.NewLACPMemberPolicy(rn, parentDn, description, lacpIfPolAttr)
err := sm.Save(lacpIfPol)
return lacpIfPol, err
}
func (sm *ServiceManager) ReadLACPMemberPolicy(name string) (*models.LACPMemberPolicy, error) {
dn := fmt.Sprintf(models.DnlacpIfPol, name)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
lacpIfPol := models.LACPMemberPolicyFromContainer(cont)
return lacpIfPol, nil
}
func (sm *ServiceManager) DeleteLACPMemberPolicy(name string) error {
dn := fmt.Sprintf(models.DnlacpIfPol, name)
return sm.DeleteByDn(dn, models.LacpifpolClassName)
}
func (sm *ServiceManager) UpdateLACPMemberPolicy(name string, description string, lacpIfPolAttr models.LACPMemberPolicyAttributes) (*models.LACPMemberPolicy, error) {
rn := fmt.Sprintf(models.RnlacpIfPol, name)
parentDn := fmt.Sprintf(models.ParentDnlacpIfPol)
lacpIfPol := models.NewLACPMemberPolicy(rn, parentDn, description, lacpIfPolAttr)
lacpIfPol.Status = "modified"
err := sm.Save(lacpIfPol)
return lacpIfPol, err
}
func (sm *ServiceManager) ListLACPMemberPolicy() ([]*models.LACPMemberPolicy, error) {
dnUrl := fmt.Sprintf("%s/uni/infra/lacpIfPol.json", models.BaseurlStr)
cont, err := sm.GetViaURL(dnUrl)
list := models.LACPMemberPolicyListFromContainer(cont)
return list, err
}