Skip to content

Commit

Permalink
[minor_change] Add model and client files for PIM external (pimExtP),…
Browse files Browse the repository at this point in the history
… PIM (pimIfP and pimIfPol), PIM IPv6 (pimIPV6IfP) and IGMP interface (igmpIfPol and igmpIfP) profiles, add relation to l3extLIfP and fix issue with re-creation of cloudtemplateRegionDetail
  • Loading branch information
shrsr authored Jul 6, 2023
1 parent dcdfa9b commit 64e486d
Show file tree
Hide file tree
Showing 14 changed files with 1,201 additions and 1 deletion.
99 changes: 99 additions & 0 deletions client/igmpIfP_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package client

import (
"fmt"

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

func (sm *ServiceManager) CreateIGMPInterfaceProfile(parentDn string, description string, igmpIfPAttr models.IGMPInterfaceProfileAttributes) (*models.IGMPInterfaceProfile, error) {

igmpIfP := models.NewIGMPInterfaceProfile(parentDn, description, igmpIfPAttr)

err := sm.Save(igmpIfP)
return igmpIfP, err
}

func (sm *ServiceManager) ReadIGMPInterfaceProfile(parentDn string) (*models.InterfaceProfile, error) {

dn := fmt.Sprintf("%s/%s", parentDn, models.RnIgmpIfP)

cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
igmpIfP := models.InterfaceProfileFromContainer(cont)
return igmpIfP, nil
}

func (sm *ServiceManager) DeleteIGMPInterfaceProfile(parentDn string) error {

dn := fmt.Sprintf("%s/%s", parentDn, models.RnIgmpIfP)

return sm.DeleteByDn(dn, models.IgmpIfPClassName)
}

func (sm *ServiceManager) UpdateIGMPInterfaceProfile(parentDn string, description string, igmpIfPAttr models.IGMPInterfaceProfileAttributes) (*models.IGMPInterfaceProfile, error) {

igmpIfP := models.NewIGMPInterfaceProfile(parentDn, description, igmpIfPAttr)

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

func (sm *ServiceManager) ListIGMPInterfaceProfile(parentDn string) ([]*models.InterfaceProfile, error) {

dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, models.IgmpIfPClassName)

cont, err := sm.GetViaURL(dnUrl)
list := models.InterfaceProfileListFromContainer(cont)
return list, err
}

func (sm *ServiceManager) CreateRelationIGMPRsIfPol(parentDn, annotation, tDn string) error {
dn := fmt.Sprintf("%s/rsIfPol", parentDn)
containerJSON := []byte(fmt.Sprintf(`{
"%s": {
"attributes": {
"dn": "%s",
"annotation": "%s",
"tDn": "%s"
}
}
}`, "igmpRsIfPol", 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) DeleteRelationIGMPRsIfPol(parentDn string) error {
dn := fmt.Sprintf("%s/rsIfPol", parentDn)
return sm.DeleteByDn(dn, "igmpRsIfPol")
}

func (sm *ServiceManager) ReadRelationIGMPRsIfPol(parentDn string) (interface{}, error) {
dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, "igmpRsIfPol")
cont, err := sm.GetViaURL(dnUrl)
contList := models.ListFromContainer(cont, "igmpRsIfPol")

if len(contList) > 0 {
dat := models.G(contList[0], "tDn")
return dat, err
} else {
return nil, err
}
}
65 changes: 65 additions & 0 deletions client/igmpIfPol_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package client

import (
"fmt"

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

func (sm *ServiceManager) CreateIGMPInterfacePolicy(name string, tenant string, description string, igmpIfPolAttr models.IGMPInterfacePolicyAttributes) (*models.IGMPInterfacePolicy, error) {

rn := fmt.Sprintf(models.RnIgmpIfPol, name)

parentDn := fmt.Sprintf(models.ParentDnIgmpIfPol, tenant)
igmpIfPol := models.NewIGMPInterfacePolicy(rn, parentDn, description, igmpIfPolAttr)

err := sm.Save(igmpIfPol)
return igmpIfPol, err
}

func (sm *ServiceManager) ReadIGMPInterfacePolicy(name string, tenant string) (*models.IGMPInterfacePolicy, error) {

rn := fmt.Sprintf(models.RnIgmpIfPol, name)

parentDn := fmt.Sprintf(models.ParentDnIgmpIfPol, tenant)
dn := fmt.Sprintf("%s/%s", parentDn, rn)

cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
igmpIfPol := models.IGMPInterfacePolicyFromContainer(cont)
return igmpIfPol, nil
}

func (sm *ServiceManager) DeleteIGMPInterfacePolicy(name string, tenant string) error {

rn := fmt.Sprintf(models.RnIgmpIfPol, name)

parentDn := fmt.Sprintf(models.ParentDnIgmpIfPol, tenant)
dn := fmt.Sprintf("%s/%s", parentDn, rn)

return sm.DeleteByDn(dn, models.IgmpIfPolClassName)
}

func (sm *ServiceManager) UpdateIGMPInterfacePolicy(name string, tenant string, description string, igmpIfPolAttr models.IGMPInterfacePolicyAttributes) (*models.IGMPInterfacePolicy, error) {

rn := fmt.Sprintf(models.RnIgmpIfPol, name)

parentDn := fmt.Sprintf(models.ParentDnIgmpIfPol, tenant)
igmpIfPol := models.NewIGMPInterfacePolicy(rn, parentDn, description, igmpIfPolAttr)

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

func (sm *ServiceManager) ListIGMPInterfacePolicy(tenant string) ([]*models.IGMPInterfacePolicy, error) {

parentDn := fmt.Sprintf(models.ParentDnIgmpIfPol, tenant)
dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, models.IgmpIfPolClassName)

cont, err := sm.GetViaURL(dnUrl)
list := models.IGMPInterfacePolicyListFromContainer(cont)
return list, err
}
138 changes: 138 additions & 0 deletions client/l3extLIfP_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,141 @@ func (sm *ServiceManager) ReadRelationl3extRsNdIfPolFromLogicalInterfaceProfile(
}

}

func (sm *ServiceManager) CreateRelationPIMRsIfPolFromLogicalInterfaceProfile(parentDn, tDn string) error {
dn := fmt.Sprintf("%s/rsIfPol", parentDn)
containerJSON := []byte(fmt.Sprintf(`{
"%s": {
"attributes": {
"dn": "%s",
"annotation": "orchestrator:terraform",
"tDn": "%s"
}
}
}`, "pimRsIfPol", dn, 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) ReadRelationPIMRsIfPolFromLogicalInterfaceProfile(parentDn string) (interface{}, error) {
dnUrl := fmt.Sprintf("%s/%s/%s/%s.json", models.BaseurlStr, parentDn, models.RnPimIfP, "pimRsIfPol")
cont, err := sm.GetViaURL(dnUrl)
contList := models.ListFromContainer(cont, "pimRsIfPol")

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

func (sm *ServiceManager) DeleteRelationPIMRsIfPolFromLogicalInterfaceProfile(parentDn string) error {
dn := fmt.Sprintf("%s/rsIfPol", parentDn)
return sm.DeleteByDn(dn, "pimRsIfPol")
}

func (sm *ServiceManager) CreateRelationPIMIPv6RsIfPolFromLogicalInterfaceProfile(parentDn, tDn string) error {
dn := fmt.Sprintf("%s/rsV6IfPol", parentDn)
containerJSON := []byte(fmt.Sprintf(`{
"%s": {
"attributes": {
"dn": "%s",
"annotation": "orchestrator:terraform",
"tDn": "%s"
}
}
}`, "pimRsV6IfPol", dn, 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) ReadRelationPIMIPv6RsIfPolFromLogicalInterfaceProfile(parentDn string) (interface{}, error) {
dnUrl := fmt.Sprintf("%s/%s/%s/%s.json", models.BaseurlStr, parentDn, models.RnPimIPV6IfP, "pimRsV6IfPol")
cont, err := sm.GetViaURL(dnUrl)
contList := models.ListFromContainer(cont, "pimRsV6IfPol")

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

func (sm *ServiceManager) DeleteRelationPIMIPv6RsIfPolFromLogicalInterfaceProfile(parentDn string) error {
dn := fmt.Sprintf("%s/rsV6IfPol", parentDn)
return sm.DeleteByDn(dn, "pimRsV6IfPol")
}

func (sm *ServiceManager) CreateRelationIGMPRsIfPolFromLogicalInterfaceProfile(parentDn, tDn string) error {
dn := fmt.Sprintf("%s/rsIfPol", parentDn)
containerJSON := []byte(fmt.Sprintf(`{
"%s": {
"attributes": {
"dn": "%s",
"annotation": "orchestrator:terraform",
"tDn": "%s"
}
}
}`, "igmpRsIfPol", dn, 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) ReadRelationIGMPRsIfPolFromLogicalInterfaceProfile(parentDn string) (interface{}, error) {
dnUrl := fmt.Sprintf("%s/%s/%s/%s.json", models.BaseurlStr, parentDn, models.RnIgmpIfP, "igmpRsIfPol")
cont, err := sm.GetViaURL(dnUrl)
contList := models.ListFromContainer(cont, "igmpRsIfPol")

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

func (sm *ServiceManager) DeleteRelationIGMPRsIfPolFromLogicalInterfaceProfile(parentDn string) error {
dn := fmt.Sprintf("%s/rsIfPol", parentDn)
return sm.DeleteByDn(dn, "igmpRsIfPol")
}
57 changes: 57 additions & 0 deletions client/pimExtP_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package client

import (
"fmt"

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

func (sm *ServiceManager) CreatePIMExternalProfile(l3_outside string, tenant string, description string, pimExtPAttr models.PIMExternalProfileAttributes) (*models.PIMExternalProfile, error) {

parentDn := fmt.Sprintf(models.ParentDnPimExtP, tenant, l3_outside)
pimExtP := models.NewPIMExternalProfile(parentDn, description, pimExtPAttr)

err := sm.Save(pimExtP)
return pimExtP, err
}

func (sm *ServiceManager) ReadPIMExternalProfile(l3_outside string, tenant string) (*models.PIMExternalProfile, error) {

parentDn := fmt.Sprintf(models.ParentDnPimExtP, tenant, l3_outside)
dn := fmt.Sprintf("%s/%s", parentDn, models.RnPimExtP)

cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
pimExtP := models.PIMExternalProfileFromContainer(cont)
return pimExtP, nil
}

func (sm *ServiceManager) DeletePIMExternalProfile(l3_outside string, tenant string) error {

parentDn := fmt.Sprintf(models.ParentDnPimExtP, tenant, l3_outside)
dn := fmt.Sprintf("%s/%s", parentDn, models.RnPimExtP)

return sm.DeleteByDn(dn, models.PimExtPClassName)
}

func (sm *ServiceManager) UpdatePIMExternalProfile(l3_outside string, tenant string, description string, pimExtPAttr models.PIMExternalProfileAttributes) (*models.PIMExternalProfile, error) {

parentDn := fmt.Sprintf(models.ParentDnPimExtP, tenant, l3_outside)
pimExtP := models.NewPIMExternalProfile(parentDn, description, pimExtPAttr)

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

func (sm *ServiceManager) ListPIMExternalProfile(l3_outside string, tenant string) ([]*models.PIMExternalProfile, error) {

parentDn := fmt.Sprintf(models.ParentDnPimExtP, tenant, l3_outside)
dnUrl := fmt.Sprintf("%s/%s/%s.json", models.BaseurlStr, parentDn, models.PimExtPClassName)

cont, err := sm.GetViaURL(dnUrl)
list := models.PIMExternalProfileListFromContainer(cont)
return list, err
}
Loading

0 comments on commit 64e486d

Please sign in to comment.