Skip to content

Commit 820f4cc

Browse files
committed
added aci_inbepg_to_contract module and its test file
1 parent d44b606 commit 820f4cc

File tree

3 files changed

+134
-203
lines changed

3 files changed

+134
-203
lines changed

plugins/modules/aci_node_mgmt_epg_to_contract.py renamed to plugins/modules/aci_inbepg_to_contract.py

+6-26
Original file line numberDiff line numberDiff line change
@@ -258,29 +258,25 @@ def main():
258258
argument_spec = aci_argument_spec()
259259
argument_spec.update(aci_annotation_spec())
260260
argument_spec.update(
261-
type=dict(type="str", choices=["in_band", "out_of_band"], required=True) #>>>> really required, both are under the same class
261+
# type=dict(type="str", choices=["in_band", "out_of_band"], required=True) #>>>> really required? both are under the same class ----> yes, inb class and oob class difference in building URL
262262
contract_type=dict(type="str", required=True, choices=["consumer", "provider", "taboo", "interface"]),
263-
# ap=dict(type="str", aliases=["app_profile", "app_profile_name"]), # Not required for querying all objects
264263
epg=dict(type="str", aliases=["epg_name"]), # Not required for querying all objects
265264
contract=dict(type="str", aliases=["contract_name", "contract_interface"]), # Not required for querying all objects
266265
priority=dict(type="str", choices=["level1", "level2", "level3", "level4", "level5", "level6", "unspecified"]),
267266
provider_match=dict(type="str", choices=["all", "at_least_one", "at_most_one", "none"]),
268267
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
269-
# tenant=dict(type="str", aliases=["tenant_name"]), # Not required for querying all objects >>>>>> HARDCODE mgmt TENANT ???
270-
# contract_label=dict(type="str"),
271-
# subject_label=dict(type="str"),
272268
)
273269

274270
module = AnsibleModule(
275271
argument_spec=argument_spec,
276272
supports_check_mode=True,
277273
required_if=[
278-
["state", "absent", ["contract", "epg"]],
279-
["state", "present", ["contract", "epg"]],
274+
["state", "absent", ["contract_type", "epg", "contract"]],
275+
["state", "present", ["contract_type", "epg","contract"]],
280276
],
281277
)
282278

283-
# ap = module.params.get("ap")
279+
# epg_type = module.params.get("type")
284280
contract = module.params.get("contract")
285281
contract_type = module.params.get("contract_type")
286282
epg = module.params.get("epg")
@@ -289,10 +285,6 @@ def main():
289285
if provider_match is not None:
290286
provider_match = PROVIDER_MATCH_MAPPING[provider_match]
291287
state = module.params.get("state")
292-
# tenant = module.params.get("tenant")
293-
# contract_label = module.params.get("contract_label")
294-
# subject_label = module.params.get("subject_label")
295-
296288
aci_class = ACI_CLASS_MAPPING[contract_type]["class"]
297289
aci_rn = ACI_CLASS_MAPPING[contract_type]["rn"]
298290
aci_name = ACI_CLASS_MAPPING[contract_type]["name"]
@@ -301,14 +293,6 @@ def main():
301293
if contract_type != "provider" and provider_match is not None:
302294
module.fail_json(msg="the 'provider_match' is only configurable for Provided Contracts")
303295

304-
# if contract_type in ["taboo", "interface"] and (contract_label is not None or subject_label is not None):
305-
# module.fail_json(msg="the 'contract_label' and 'subject_label' are not configurable for {0} contracts".format(contract_type))
306-
307-
if contract_type not in ["taboo", "interface"]:
308-
contract_label_class = CONTRACT_LABEL_MAPPING.get(contract_type)
309-
subject_label_class = SUBJ_LABEL_MAPPING.get(contract_type)
310-
child_classes = [subject_label_class, contract_label_class]
311-
312296
aci = ACIModule(module)
313297
aci.construct_url(
314298
root_class=dict(
@@ -324,8 +308,8 @@ def main():
324308
target_filter={"name": "default"},
325309
),
326310
subclass_2=dict(
327-
aci_class="fvAEPg",
328-
aci_rn="epg-{0}".format(epg),
311+
aci_class="mgmtInB",
312+
aci_rn="inb-{0}".format(epg),
329313
module_object=epg,
330314
target_filter={"name": epg},
331315
),
@@ -342,10 +326,6 @@ def main():
342326

343327
if state == "present":
344328
child_configs = []
345-
# if contract_label is not None:
346-
# child_configs.append({contract_label_class: {"attributes": {"name": contract_label}}})
347-
# if subject_label is not None:
348-
# child_configs.append({subject_label_class: {"attributes": {"name": subject_label}}})
349329
aci.payload(
350330
aci_class=aci_class,
351331
class_config={"matchT": provider_match, "prio": priority, aci_name: contract},

0 commit comments

Comments
 (0)