Skip to content

Commit

Permalink
[ignore] Added rtctrlProfile details in the classes and properites ya…
Browse files Browse the repository at this point in the history
…ml file and added logic to exclude resource creation in the generator.go
  • Loading branch information
sajagana committed May 22, 2024
1 parent eb2a16b commit a3cb817
Show file tree
Hide file tree
Showing 11 changed files with 1,034 additions and 46 deletions.
1 change: 1 addition & 0 deletions gen/definitions/classes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ vzCPIf:
rtctrlProfile:
resource_name: "route_control_profile"
rn_format: "/prof-{name}"
exclude: true

vzOOBBrCP:
resource_name: "out_of_band_contract"
Expand Down
29 changes: 18 additions & 11 deletions gen/definitions/properties.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ l3extRsOutToFBRGroup:
class_in_parent: false
targets:
- class_name: "fvFBRGroup"
parent_dependency: "fvCtx"
parent_dependency_dn: "aci_vrf.test.id"
parent_dn: "aci_vrf_fallback_route_group.test.id"
target_dn: "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"
parent_dependency: "fvCtx"
parent_dependency_dn: "aci_vrf.test.id"

l3extProvLbl:
test_values:
Expand Down Expand Up @@ -310,10 +310,17 @@ l3extRsLblToInstP:
class_in_parent: false
targets:
- class_name: "l3extInstP"
parent_dependency: "l3extOut"
parent_dependency_dn: "aci_external_network_instance_profile.test.id"
parent_dn: "aci_l3_outside.test.id"
parent_dn: "aci_external_network_instance_profile.test.id"
target_dn: "uni/tn-test_tenant/out-test_l3_outside/instP-testInstP" # Used for the current resource test
parent_dependency: "l3extOut"
parent_dependency_dn: "aci_l3_outside.test.id"

rtctrlProfile:
test_values:
default:
name: "external_epg"
all:
name: "external_epg"

l3extRsLblToProfile:
documentation:
Expand All @@ -333,16 +340,16 @@ l3extRsLblToProfile:
target_dn: aci_route_control_profile.test.id
direction: "import"
test_values_for_parent:
- target_dn: "uni/tn-test_tenant/prof-test_rctp1"
- target_dn: "uni/tn-test_tenant/prof-test_rctp2"
- target_dn: "uni/tn-test_tenant/prof-test_name1"
- target_dn: "uni/tn-test_tenant/prof-test_name2"
parents:
- class_name: "l3extOut"
parent_dependency: "fvTenant"
parent_dn: "aci_l3_outside.test.id"
class_in_parent: false
targets:
- class_name: "rtctrlProfile"
parent_dependency: "l3extOut"
parent_dependency_dn: "aci_route_control_profile.test.id"
parent_dn: "aci_l3_outside.test.id"
target_dn: "uni/tn-test_tenant/prof-test_rctp"
parent_dn: "aci_route_control_profile.test.id"
target_dn: "uni/tn-test_tenant/prof-test_name"
parent_dependency: "fvTenant"
parent_dependency_dn: "aci_tenant.test.id"
17 changes: 16 additions & 1 deletion gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func main() {
for _, model := range classModels {

// Only render resources and datasources when the class has a unique identifier or is marked as include in the classes definitions YAML file
if len(model.IdentifiedBy) > 0 || model.Include {
if (len(model.IdentifiedBy) > 0 || model.Include) && !model.Exclude {

// All classmodels have been read, thus now the model, child and relational resources names can be set
// When done before additional files would need to be opened and read which would slow down the generation process
Expand Down Expand Up @@ -713,6 +713,7 @@ type Model struct {
HasNamedProperties bool
HasChildNamedProperties bool
Include bool
Exclude bool
}

// A Property represents a ACI class property
Expand Down Expand Up @@ -769,6 +770,7 @@ func (m *Model) setClassModel(metaPath string, child bool, definitions Definitio
m.SetClassDnFormats(classDetails)
m.SetClassIdentifiers(classDetails)
m.SetClassInclude()
m.SetClassExclude()
m.SetClassAllowDelete(classDetails)
m.SetClassContainedByAndParent(classDetails, parents)
m.SetClassContains(classDetails)
Expand Down Expand Up @@ -939,6 +941,19 @@ func (m *Model) SetClassInclude() {
}
}

func (m *Model) SetClassExclude() {
if classDetails, ok := m.Definitions.Classes[m.PkgName]; ok {
for key, value := range classDetails.(map[interface{}]interface{}) {
if key.(string) == "exclude" {
m.Exclude = value.(bool)
return
} else {
m.Exclude = false
}
}
}
}

func (m *Model) SetClassAllowDelete(classDetails interface{}) {
if classDetails.(map[string]interface{})["isCreatableDeletable"].(string) == "never" || !AllowClassDelete(m.PkgName, m.Definitions) {
m.AllowDelete = false
Expand Down
Loading

0 comments on commit a3cb817

Please sign in to comment.