-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sprint resource models and service files added
- Loading branch information
1 parent
c366ebd
commit 61e7f74
Showing
17 changed files
with
1,346 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.