-
Notifications
You must be signed in to change notification settings - Fork 29
/
fabricPathEp_service.go
53 lines (40 loc) · 2.38 KB
/
fabricPathEp_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
package client
import (
"fmt"
"github.com/ciscoecosystem/aci-go-client/models"
)
func (sm *ServiceManager) CreateFabricPathEndpoint(name string, fabric_path_end_point_container_nodeId string, fabric_pod_id string, description string, fabricPathEpattr models.FabricPathEndpointAttributes) (*models.FabricPathEndpoint, error) {
rn := fmt.Sprintf("pathep-[%s]", name)
parentDn := fmt.Sprintf("uni/topology/pod-%s/paths-%s", fabric_pod_id, fabric_path_end_point_container_nodeId)
fabricPathEp := models.NewFabricPathEndpoint(rn, parentDn, description, fabricPathEpattr)
err := sm.Save(fabricPathEp)
return fabricPathEp, err
}
func (sm *ServiceManager) ReadFabricPathEndpoint(name string, fabric_path_end_point_container_nodeId string, fabric_pod_id string) (*models.FabricPathEndpoint, error) {
dn := fmt.Sprintf("uni/topology/pod-%s/paths-%s/pathep-[%s]", fabric_pod_id, fabric_path_end_point_container_nodeId, name)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
fabricPathEp := models.FabricPathEndpointFromContainer(cont)
return fabricPathEp, nil
}
func (sm *ServiceManager) DeleteFabricPathEndpoint(name string, fabric_path_end_point_container_nodeId string, fabric_pod_id string) error {
dn := fmt.Sprintf("uni/topology/pod-%s/paths-%s/pathep-[%s]", fabric_pod_id, fabric_path_end_point_container_nodeId, name)
return sm.DeleteByDn(dn, models.FabricpathepClassName)
}
func (sm *ServiceManager) UpdateFabricPathEndpoint(name string, fabric_path_end_point_container_nodeId string, fabric_pod_id string, description string, fabricPathEpattr models.FabricPathEndpointAttributes) (*models.FabricPathEndpoint, error) {
rn := fmt.Sprintf("pathep-[%s]", name)
parentDn := fmt.Sprintf("uni/topology/pod-%s/paths-%s", fabric_pod_id, fabric_path_end_point_container_nodeId)
fabricPathEp := models.NewFabricPathEndpoint(rn, parentDn, description, fabricPathEpattr)
fabricPathEp.Status = "modified"
err := sm.Save(fabricPathEp)
return fabricPathEp, err
}
func (sm *ServiceManager) ListFabricPathEndpoint(fabric_path_end_point_container_nodeId string, fabric_pod_id string) ([]*models.FabricPathEndpoint, error) {
baseurlStr := "/api/node/class"
dnUrl := fmt.Sprintf("%s/uni/topology/pod-%s/paths-%s/fabricPathEp.json", baseurlStr, fabric_pod_id, fabric_path_end_point_container_nodeId)
cont, err := sm.GetViaURL(dnUrl)
list := models.FabricPathEndpointListFromContainer(cont)
return list, err
}