Skip to content

Commit

Permalink
S5 dev (#106)
Browse files Browse the repository at this point in the history
sprint resource models and service files added
  • Loading branch information
AshuSoni-crest authored May 3, 2021
1 parent c366ebd commit 61e7f74
Show file tree
Hide file tree
Showing 17 changed files with 1,346 additions and 13 deletions.
100 changes: 100 additions & 0 deletions client/bfdIfP_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package client

import (
"fmt"

"github.com/ciscoecosystem/aci-go-client/container"
"github.com/ciscoecosystem/aci-go-client/models"
)

func (sm *ServiceManager) CreateBFDInterfaceProfile(logical_interface_profile string, logical_node_profile string, l3_outside string, tenant string, description string, bfdIfPattr models.BFDInterfaceProfileAttributes) (*models.BFDInterfaceProfile, error) {
rn := fmt.Sprintf("bfdIfP")
parentDn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/lifp-%s", tenant, l3_outside, logical_node_profile, logical_interface_profile)
bfdIfP := models.NewBFDInterfaceProfile(rn, parentDn, description, bfdIfPattr)
err := sm.Save(bfdIfP)
return bfdIfP, err
}

func (sm *ServiceManager) ReadBFDInterfaceProfile(logical_interface_profile string, logical_node_profile string, l3_outside string, tenant string) (*models.BFDInterfaceProfile, error) {
dn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/lifp-%s/bfdIfP", tenant, l3_outside, logical_node_profile, logical_interface_profile)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}

bfdIfP := models.BFDInterfaceProfileFromContainer(cont)
return bfdIfP, nil
}

func (sm *ServiceManager) DeleteBFDInterfaceProfile(logical_interface_profile string, logical_node_profile string, l3_outside string, tenant string) error {
dn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/lifp-%s/bfdIfP", tenant, l3_outside, logical_node_profile, logical_interface_profile)
return sm.DeleteByDn(dn, models.BfdifpClassName)
}

func (sm *ServiceManager) UpdateBFDInterfaceProfile(logical_interface_profile string, logical_node_profile string, l3_outside string, tenant string, description string, bfdIfPattr models.BFDInterfaceProfileAttributes) (*models.BFDInterfaceProfile, error) {
rn := fmt.Sprintf("bfdIfP")
parentDn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/lifp-%s", tenant, l3_outside, logical_node_profile, logical_interface_profile)
bfdIfP := models.NewBFDInterfaceProfile(rn, parentDn, description, bfdIfPattr)

bfdIfP.Status = "modified"
err := sm.Save(bfdIfP)
return bfdIfP, err

}

func (sm *ServiceManager) ListBFDInterfaceProfile(logical_interface_profile string, logical_node_profile string, l3_outside string, tenant string) ([]*models.BFDInterfaceProfile, error) {

baseurlStr := "/api/node/class"
dnUrl := fmt.Sprintf("%s/uni/tn-%s/out-%s/lnodep-%s/lifp-%s/bfdIfP.json", baseurlStr, tenant, l3_outside, logical_node_profile, logical_interface_profile)

cont, err := sm.GetViaURL(dnUrl)
list := models.BFDInterfaceProfileListFromContainer(cont)

return list, err
}

func (sm *ServiceManager) CreateRelationbfdRsIfPolFromInterfaceProfile(parentDn, tnBfdIfPolName string) error {
dn := fmt.Sprintf("%s/bfdIfP/rsIfPol", parentDn)
containerJSON := []byte(fmt.Sprintf(`{
"%s": {
"attributes": {
"dn": "%s","tnBfdIfPolName": "%s","annotation":"orchestrator:terraform"
}
}
}`, "bfdRsIfPol", dn, tnBfdIfPolName))

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) ReadRelationbfdRsIfPolFromInterfaceProfile(parentDn string) (interface{}, error) {
baseurlStr := "/api/node/class"
dnUrl := fmt.Sprintf("%s/%s/%s.json", baseurlStr, parentDn, "bfdRsIfPol")
cont, err := sm.GetViaURL(dnUrl)

contList := models.ListFromContainer(cont, "bfdRsIfPol")

if len(contList) > 0 {
dat := models.G(contList[0], "tnBfdIfPolName")
return dat, err
} else {
return nil, err
}

}
100 changes: 100 additions & 0 deletions client/bgpProtP_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package client

import (
"fmt"

"github.com/ciscoecosystem/aci-go-client/container"
"github.com/ciscoecosystem/aci-go-client/models"
)

func (sm *ServiceManager) CreateL3outBGPProtocolProfile(logical_node_profile string, l3_outside string, tenant string, bgpProtPattr models.L3outBGPProtocolProfileAttributes) (*models.L3outBGPProtocolProfile, error) {
rn := fmt.Sprintf("protp")
parentDn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s", tenant, l3_outside, logical_node_profile)
bgpProtP := models.NewL3outBGPProtocolProfile(rn, parentDn, bgpProtPattr)
err := sm.Save(bgpProtP)
return bgpProtP, err
}

func (sm *ServiceManager) ReadL3outBGPProtocolProfile(logical_node_profile string, l3_outside string, tenant string) (*models.L3outBGPProtocolProfile, error) {
dn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/protp", tenant, l3_outside, logical_node_profile)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}

bgpProtP := models.L3outBGPProtocolProfileFromContainer(cont)
return bgpProtP, nil
}

func (sm *ServiceManager) DeleteL3outBGPProtocolProfile(logical_node_profile string, l3_outside string, tenant string) error {
dn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/protp", tenant, l3_outside, logical_node_profile)
return sm.DeleteByDn(dn, models.BgpprotpClassName)
}

func (sm *ServiceManager) UpdateL3outBGPProtocolProfile(logical_node_profile string, l3_outside string, tenant string, bgpProtPattr models.L3outBGPProtocolProfileAttributes) (*models.L3outBGPProtocolProfile, error) {
rn := fmt.Sprintf("protp")
parentDn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s", tenant, l3_outside, logical_node_profile)
bgpProtP := models.NewL3outBGPProtocolProfile(rn, parentDn, bgpProtPattr)

bgpProtP.Status = "modified"
err := sm.Save(bgpProtP)
return bgpProtP, err

}

func (sm *ServiceManager) ListL3outBGPProtocolProfile(logical_node_profile string, l3_outside string, tenant string) ([]*models.L3outBGPProtocolProfile, error) {

baseurlStr := "/api/node/class"
dnUrl := fmt.Sprintf("%s/uni/tn-%s/out-%s/lnodep-%s/bgpProtP.json", baseurlStr, tenant, l3_outside, logical_node_profile)

cont, err := sm.GetViaURL(dnUrl)
list := models.L3outBGPProtocolProfileListFromContainer(cont)

return list, err
}

func (sm *ServiceManager) CreateRelationbgpRsBgpNodeCtxPolFromL3outBGPProtocolProfile(parentDn, tnBgpCtxPolName string) error {
dn := fmt.Sprintf("%s/protp/rsbgpNodeCtxPol", parentDn)
containerJSON := []byte(fmt.Sprintf(`{
"%s": {
"attributes": {
"dn": "%s",
"tnBgpCtxPolName": "%s",
"annotation":"orchestrator:terraform"}
}
}`, "bgpRsBgpNodeCtxPol", dn, tnBgpCtxPolName))

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) ReadRelationbgpRsBgpNodeCtxPolFromL3outBGPProtocolProfile(parentDn string) (interface{}, error) {
baseurlStr := "/api/node/class"
dnUrl := fmt.Sprintf("%s/%s/%s.json", baseurlStr, parentDn, "bgpRsBgpNodeCtxPol")
cont, err := sm.GetViaURL(dnUrl)

contList := models.ListFromContainer(cont, "bgpRsBgpNodeCtxPol")

if len(contList) > 0 {
dat := models.G(contList[0], "tnBgpCtxPolName")
return dat, err
} else {
return nil, err
}

}
8 changes: 4 additions & 4 deletions client/fabricExplicitGEp_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"github.com/ciscoecosystem/aci-go-client/models"
)

func (sm *ServiceManager) CreateVPCExplicitProtectionGroup(name string, description string, switch1 string, switch2 string, vpcDomainPolicy string, fabricExplicitGEpattr models.VPCExplicitProtectionGroupAttributes) (*models.VPCExplicitProtectionGroup, error) {
func (sm *ServiceManager) CreateVPCExplicitProtectionGroup(name string, switch1 string, switch2 string, vpcDomainPolicy string, fabricExplicitGEpattr models.VPCExplicitProtectionGroupAttributes) (*models.VPCExplicitProtectionGroup, error) {
rn := fmt.Sprintf("fabric/protpol/expgep-%s", name)
parentDn := fmt.Sprintf("uni")
fabricExplicitGEp := models.NewVPCExplicitProtectionGroup(rn, parentDn, description, fabricExplicitGEpattr)
fabricExplicitGEp := models.NewVPCExplicitProtectionGroup(rn, parentDn, fabricExplicitGEpattr)
jsonPayload, _, err := sm.PrepareModel(fabricExplicitGEp)
fabricNodePEp1 := []byte(fmt.Sprintf(`
{
Expand Down Expand Up @@ -81,10 +81,10 @@ func (sm *ServiceManager) DeleteVPCExplicitProtectionGroup(name string) error {
return sm.DeleteByDn(dn, models.FabricexplicitgepClassName)
}

func (sm *ServiceManager) UpdateVPCExplicitProtectionGroup(name string, description string, switch1 string, switch2 string, vpcDomainPolicy string, fabricExplicitGEpattr models.VPCExplicitProtectionGroupAttributes) (*models.VPCExplicitProtectionGroup, error) {
func (sm *ServiceManager) UpdateVPCExplicitProtectionGroup(name string, switch1 string, switch2 string, vpcDomainPolicy string, fabricExplicitGEpattr models.VPCExplicitProtectionGroupAttributes) (*models.VPCExplicitProtectionGroup, error) {
rn := fmt.Sprintf("fabric/protpol/expgep-%s", name)
parentDn := fmt.Sprintf("uni")
fabricExplicitGEp := models.NewVPCExplicitProtectionGroup(rn, parentDn, description, fabricExplicitGEpattr)
fabricExplicitGEp := models.NewVPCExplicitProtectionGroup(rn, parentDn, fabricExplicitGEpattr)

fabricExplicitGEp.Status = "modified"
jsonPayload, _, err := sm.PrepareModel(fabricExplicitGEp)
Expand Down
53 changes: 53 additions & 0 deletions client/hsrpSecVip_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package client

import (
"fmt"

"github.com/ciscoecosystem/aci-go-client/models"
)

func (sm *ServiceManager) CreateL3outHSRPSecondaryVIP(ip string, hsrp_group_profile string, logical_interface_profile string, logical_node_profile string, l3_outside string, tenant string, description string, hsrpSecVipattr models.L3outHSRPSecondaryVIPAttributes) (*models.L3outHSRPSecondaryVIP, error) {
rn := fmt.Sprintf("hsrpSecVip-[%s]", ip)
parentDn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/lifp-%s/hsrpIfP/hsrpGroupP-%s", tenant, l3_outside, logical_node_profile, logical_interface_profile, hsrp_group_profile)
hsrpSecVip := models.NewL3outHSRPSecondaryVIP(rn, parentDn, description, hsrpSecVipattr)
err := sm.Save(hsrpSecVip)
return hsrpSecVip, err
}

func (sm *ServiceManager) ReadL3outHSRPSecondaryVIP(ip string, hsrp_group_profile string, logical_interface_profile string, logical_node_profile string, l3_outside string, tenant string) (*models.L3outHSRPSecondaryVIP, error) {
dn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/lifp-%s/hsrpIfP/hsrpGroupP-%s/hsrpSecVip-[%s]", tenant, l3_outside, logical_node_profile, logical_interface_profile, hsrp_group_profile, ip)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}

hsrpSecVip := models.L3outHSRPSecondaryVIPFromContainer(cont)
return hsrpSecVip, nil
}

func (sm *ServiceManager) DeleteL3outHSRPSecondaryVIP(ip string, hsrp_group_profile string, logical_interface_profile string, logical_node_profile string, l3_outside string, tenant string) error {
dn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/lifp-%s/hsrpIfP/hsrpGroupP-%s/hsrpSecVip-[%s]", tenant, l3_outside, logical_node_profile, logical_interface_profile, hsrp_group_profile, ip)
return sm.DeleteByDn(dn, models.HsrpsecvipClassName)
}

func (sm *ServiceManager) UpdateL3outHSRPSecondaryVIP(ip string, hsrp_group_profile string, logical_interface_profile string, logical_node_profile string, l3_outside string, tenant string, description string, hsrpSecVipattr models.L3outHSRPSecondaryVIPAttributes) (*models.L3outHSRPSecondaryVIP, error) {
rn := fmt.Sprintf("hsrpSecVip-[%s]", ip)
parentDn := fmt.Sprintf("uni/tn-%s/out-%s/lnodep-%s/lifp-%s/hsrpIfP/hsrpGroupP-%s", tenant, l3_outside, logical_node_profile, logical_interface_profile, hsrp_group_profile)
hsrpSecVip := models.NewL3outHSRPSecondaryVIP(rn, parentDn, description, hsrpSecVipattr)

hsrpSecVip.Status = "modified"
err := sm.Save(hsrpSecVip)
return hsrpSecVip, err

}

func (sm *ServiceManager) ListL3outHSRPSecondaryVIP(hsrp_group_profile string, logical_interface_profile string, logical_node_profile string, l3_outside string, tenant string) ([]*models.L3outHSRPSecondaryVIP, error) {

baseurlStr := "/api/node/class"
dnUrl := fmt.Sprintf("%s/uni/tn-%s/out-%s/lnodep-%s/lifp-%s/hsrpIfP/hsrpGroupP-%s/hsrpSecVip.json", baseurlStr, tenant, l3_outside, logical_node_profile, logical_interface_profile, hsrp_group_profile)

cont, err := sm.GetViaURL(dnUrl)
list := models.L3outHSRPSecondaryVIPListFromContainer(cont)

return list, err
}
Loading

0 comments on commit 61e7f74

Please sign in to comment.