diff --git a/plugins/modules/aci_node_mgmt_epg_to_contract.py b/plugins/modules/aci_inbepg_to_contract.py similarity index 86% rename from plugins/modules/aci_node_mgmt_epg_to_contract.py rename to plugins/modules/aci_inbepg_to_contract.py index bcc9b4cd2..b2d1cc985 100644 --- a/plugins/modules/aci_node_mgmt_epg_to_contract.py +++ b/plugins/modules/aci_inbepg_to_contract.py @@ -258,29 +258,25 @@ def main(): argument_spec = aci_argument_spec() argument_spec.update(aci_annotation_spec()) argument_spec.update( - type=dict(type="str", choices=["in_band", "out_of_band"], required=True) #>>>> really required, both are under the same class + # 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 contract_type=dict(type="str", required=True, choices=["consumer", "provider", "taboo", "interface"]), - # ap=dict(type="str", aliases=["app_profile", "app_profile_name"]), # Not required for querying all objects epg=dict(type="str", aliases=["epg_name"]), # Not required for querying all objects contract=dict(type="str", aliases=["contract_name", "contract_interface"]), # Not required for querying all objects priority=dict(type="str", choices=["level1", "level2", "level3", "level4", "level5", "level6", "unspecified"]), provider_match=dict(type="str", choices=["all", "at_least_one", "at_most_one", "none"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), - # tenant=dict(type="str", aliases=["tenant_name"]), # Not required for querying all objects >>>>>> HARDCODE mgmt TENANT ??? - # contract_label=dict(type="str"), - # subject_label=dict(type="str"), ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, required_if=[ - ["state", "absent", ["contract", "epg"]], - ["state", "present", ["contract", "epg"]], + ["state", "absent", ["contract_type", "epg", "contract"]], + ["state", "present", ["contract_type", "epg","contract"]], ], ) - # ap = module.params.get("ap") + # epg_type = module.params.get("type") contract = module.params.get("contract") contract_type = module.params.get("contract_type") epg = module.params.get("epg") @@ -289,10 +285,6 @@ def main(): if provider_match is not None: provider_match = PROVIDER_MATCH_MAPPING[provider_match] state = module.params.get("state") - # tenant = module.params.get("tenant") - # contract_label = module.params.get("contract_label") - # subject_label = module.params.get("subject_label") - aci_class = ACI_CLASS_MAPPING[contract_type]["class"] aci_rn = ACI_CLASS_MAPPING[contract_type]["rn"] aci_name = ACI_CLASS_MAPPING[contract_type]["name"] @@ -301,14 +293,6 @@ def main(): if contract_type != "provider" and provider_match is not None: module.fail_json(msg="the 'provider_match' is only configurable for Provided Contracts") - # if contract_type in ["taboo", "interface"] and (contract_label is not None or subject_label is not None): - # module.fail_json(msg="the 'contract_label' and 'subject_label' are not configurable for {0} contracts".format(contract_type)) - - if contract_type not in ["taboo", "interface"]: - contract_label_class = CONTRACT_LABEL_MAPPING.get(contract_type) - subject_label_class = SUBJ_LABEL_MAPPING.get(contract_type) - child_classes = [subject_label_class, contract_label_class] - aci = ACIModule(module) aci.construct_url( root_class=dict( @@ -324,8 +308,8 @@ def main(): target_filter={"name": "default"}, ), subclass_2=dict( - aci_class="fvAEPg", - aci_rn="epg-{0}".format(epg), + aci_class="mgmtInB", + aci_rn="inb-{0}".format(epg), module_object=epg, target_filter={"name": epg}, ), @@ -342,10 +326,6 @@ def main(): if state == "present": child_configs = [] - # if contract_label is not None: - # child_configs.append({contract_label_class: {"attributes": {"name": contract_label}}}) - # if subject_label is not None: - # child_configs.append({subject_label_class: {"attributes": {"name": subject_label}}}) aci.payload( aci_class=aci_class, class_config={"matchT": provider_match, "prio": priority, aci_name: contract}, diff --git a/tests/integration/targets/aci_node_mgmt_epg_to_contract/aliases b/tests/integration/targets/aci_inbepg_to_contract/aliases similarity index 100% rename from tests/integration/targets/aci_node_mgmt_epg_to_contract/aliases rename to tests/integration/targets/aci_inbepg_to_contract/aliases diff --git a/tests/integration/targets/aci_node_mgmt_epg_to_contract/tasks/main.yml b/tests/integration/targets/aci_inbepg_to_contract/tasks/main.yml similarity index 68% rename from tests/integration/targets/aci_node_mgmt_epg_to_contract/tasks/main.yml rename to tests/integration/targets/aci_inbepg_to_contract/tasks/main.yml index 4227134ac..d6907f17f 100644 --- a/tests/integration/targets/aci_node_mgmt_epg_to_contract/tasks/main.yml +++ b/tests/integration/targets/aci_inbepg_to_contract/tasks/main.yml @@ -20,53 +20,50 @@ use_proxy: '{{ aci_use_proxy | default(true) }}' output_level: debug +- name: Tenant meta + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: mgmt + state: present + +- name: ensuring Test Inband Node-mgmt EPG is not present before + cisco.aci.aci_node_mgmt_epg module: &inb_epg_absent + <<: *aci_info + epg: ansible-inband + type: in_band + state: absent + - name: Verify Cloud and Non-Cloud Sites in use. ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml +- name: Creating Test Inband Node-mgmt EPG + cisco.aci.aci_node_mgmt_epg module: &inb_epg_present + <<: *inb_epg_absent + state: present + - name: Ensure contract binding does not exist prior to testing cisco.aci.aci_node_mgmt_epg_to_contract: - host: "{{ aci_hostname }}" - username: "{{ aci_username }}" - password: "{{ aci_password }}" - validate_certs: '{{ aci_validate_certs | default(false) }}' - use_ssl: '{{ aci_use_ssl | default(true) }}' - use_proxy: '{{ aci_use_proxy | default(true) }}' - output_level: '{{ aci_output_level | default("info") }}' - epg: "{{ item }}" - contract_type: provider - contract: "anstest_http" - state: absent + <<: *inb_epg_present + contract: ansible_http_test + contract_type: "{{item}}" + loop: + - provider + - consumer + - taboo + - interface - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - - name: Remove node mgmt in_band epg - cisco.aci.aci_node_mgmt_epg: + - name: Ensuring Inband EPG exists + cisco.aci.aci_node_mgmt_epg: &aci_inbepg_present <<: *aci_info type: in_band - epg: "{{ item }}" + epg: ansible-inband encap: vlan-1 - bd: bd1 - state: absent - loop: - - ansible-inband - - ansible-inband-2 - - - name: Remove node mgmt out_of_band epg - cisco.aci.aci_node_mgmt_epg: - <<: *aci_info - type: out_of_band - epg: "{{ item }}" - state: absent - loop: - - ansible-outofband - - ansible-outofband-2 - - - name: ensure tenant exists for tests to kick off - cisco.aci.aci_tenant: &aci_tenant_present - <<: *aci_tenant_absent + bd: inb state: present - register: tenant_present + register: inb_present - name: ensure contracts exist for tests to kick off cisco.aci.aci_contract: @@ -74,70 +71,59 @@ contract: "{{ item }}" with_items: ["anstest_http", "anstest_https", "anstest_db", "anstest_no_previous", "anstest_no_lb_no_v"] - - name: ensure ap exists - cisco.aci.aci_ap: &aci_ap_present + - name: ensuring taboo contract exists + cisco.aci.aci_taboo_contract: <<: *aci_tenant_present - ap: anstest - register: ap_present - - - name: ensure epg exists - cisco.aci.aci_epg: &aci_epg_present - <<: *aci_ap_present - epg: anstest - register: epg_present - - - name: bind contract to epg - check mode works - cisco.aci.aci_epg_to_contract: &aci_epg_provide_present - <<: *aci_epg_present + contract: "anstest-taboo" + + - name: bind contract to inband epg - check mode + cisco.aci.aci_inbepg_to_contract: &aci_inbepg_provide_present + <<: *aci_inbepg_present contract_type: provider contract: anstest_http - contract_label: anstest_contract_label - subject_label: anstest_subject_label check_mode: true register: provide_present_check_mode - - name: bind contract to epg - provide works - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_provide_present + - name: bind contract to inband epg - provide works + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_provide_present register: provide_present - - name: bind contract to epg - consume works - cisco.aci.aci_epg_to_contract: &aci_epg_consume_present - <<: *aci_epg_provide_present + - name: bind contract to inband epg - consume works + cisco.aci.aci_inbepg_to_contract: &aci_inbepg_consume_present + <<: *aci_inbepg_provide_present contract_type: consumer contract: anstest_db register: consume_present - - - name: bind contract to epg - add additional contract - cisco.aci.aci_epg_to_contract: &aci_epg_provide_present2 - <<: *aci_epg_provide_present +th + - name: bind contract to inband epg - add additional contract + cisco.aci.aci_inbepg_to_contract: &aci_inbepg_provide_present2 + <<: *aci_inbepg_provide_present contract: anstest_https provider_match: at_most_one - contract_label: "{{ fakevar | default(omit) }}" - subject_label: "{{ fakevar | default(omit) }}" register: provide_present2 - - name: bind contract to epg - idempotency works - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_provide_present + - name: bind contract to inband epg - idempotency works + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_provide_present register: idempotent_present - name: missing param - failure message works - cisco.aci.aci_epg_to_contract: + cisco.aci.aci_inbepg_to_contract: <<: *aci_tenant_present contract_type: provider ignore_errors: true register: missing_param_present - name: missing required param - failure message works - cisco.aci.aci_epg_to_contract: + cisco.aci.aci_inbepg_to_contract: <<: *aci_tenant_present ignore_errors: true register: missing_required_present - name: incompatible param - failure message works - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_consume_present + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_consume_present provider_match: all ignore_errors: true register: incompatible_present @@ -157,54 +143,25 @@ - provide_present2 is changed - provide_present2.previous == [] - missing_param_present is failed - - 'missing_param_present.msg == "state is present but all of the following are missing: ap, contract, epg"' + - 'missing_param_present.msg == "state is present but all of the following are missing: epg, contract"' - missing_required_present is failed - 'missing_required_present.msg == "missing required arguments: contract_type"' - incompatible_present is failed - incompatible_present.msg == "the 'provider_match' is only configurable for Provided Contracts" - - name: bind taboo contract to epg - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_present - contract: anstest_https + - name: bind taboo contract to inband epg + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_present + contract: anstest_taboo contract_type: taboo register: taboo_present - - name: bind interface contract to epg - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_present + - name: bind interface contract to inband epg #>>>>>>>> Contract_Interface module is unavailable, need to create that first + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_present contract: anstest_https contract_type: interface register: interface_present - - - name: bind intra epg contract to epg - cisco.aci.aci_epg_to_contract: &aci_epg_intra_present - <<: *aci_epg_present - contract: anstest_https - contract_type: intra_epg - register: intra_epg_present - - - name: bind intra epg contract to epg (error contract label) - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_intra_present - contract_label: anstest_contract_label - ignore_errors: true - register: err_contract_label - - - name: bind intra epg contract to epg (error subject label) - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_intra_present - subject_label: anstest_subject_label - ignore_errors: true - register: err_subject_label - - - name: bind intra epg contract to epg (error subject and contract label) - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_intra_present - contract_label: anstest_contract_label - subject_label: anstest_subject_label - ignore_errors: true - register: err_subject_and_contract_label - name: present assertions for taboo, interface and intra_epg contract types assert: @@ -226,39 +183,39 @@ - err_subject_and_contract_label.msg == "the 'contract_label' and 'subject_label' are not configurable for intra_epg contracts" # TEST NO PREVIOUS - - name: create epg contract to epg with no previous (check mode) - cisco.aci.aci_epg_to_contract: &aci_epg_to_contract_no_previous - <<: *aci_epg_consume_present + - name: create epg contract to inband epg with no previous (check mode) + cisco.aci.aci_inbepg_to_contract: &aci_inbepg_to_contract_no_previous + <<: *aci_inbepg_consume_present contract: anstest_no_previous no_previous: true check_mode: true register: epg_to_contract_present_no_previous_cm - - name: create epg contract to epg with no previous - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_to_contract_no_previous + - name: create epg contract to inband epg with no previous + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_to_contract_no_previous register: epg_to_contract_present_no_previous - - name: create epg contract to epg with no previous again - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_to_contract_no_previous + - name: create epg contract to inband epg with no previous again + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_to_contract_no_previous register: epg_to_contract_present_no_previous_again - - name: update epg contract to epg with no previous - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_to_contract_no_previous + - name: update epg contract to inband epg with no previous + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_to_contract_no_previous priority: level1 register: update_epg_to_contract_present_no_previous - - name: delete epg contract to epg with no previous - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_to_contract_no_previous + - name: delete epg contract to inband epg with no previous + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_to_contract_no_previous state: absent register: delete_epg_to_contract_present_no_previous - - name: delete epg contract to epg with no previous again - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_to_contract_no_previous + - name: delete epg contract to inband epg with no previous again + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_to_contract_no_previous state: absent register: delete_epg_to_contract_present_no_previous_again @@ -295,40 +252,40 @@ - delete_epg_to_contract_present_no_previous_again.proposed == {} # TEST NO PREVIOUS & NO VERIFICATION - - name: create epg contract to epg with no previous & no verify (check mode) - cisco.aci.aci_epg_to_contract: &aci_epg_to_contract_no_lb_no_v - <<: *aci_epg_consume_present + - name: create epg contract to inband epg with no previous & no verify (check mode) + cisco.aci.aci_inbepg_to_contract: &aci_inbepg_to_contract_no_lb_no_v + <<: *aci_inbepg_consume_present contract: anstest_no_lb_no_v no_previous: true no_verify: true check_mode: true register: epg_to_contract_present_no_lb_no_v_cm - - name: create epg contract to epg with no look bac & no verify - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_to_contract_no_lb_no_v + - name: create epg contract to inband epg with no look bac & no verify + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_to_contract_no_lb_no_v register: epg_to_contract_present_no_lb_no_v - - name: create epg contract to epg with no previous again & no verify - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_to_contract_no_lb_no_v + - name: create epg contract to inband epg with no previous again & no verify + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_to_contract_no_lb_no_v register: epg_to_contract_present_no_lb_no_v_again - - name: update epg contract to epg with no previous & no verify - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_to_contract_no_lb_no_v + - name: update epg contract to inband epg with no previous & no verify + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_to_contract_no_lb_no_v priority: level1 register: update_epg_to_contract_present_no_lb_no_v - - name: delete epg contract to epg with no previous & no verify - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_to_contract_no_lb_no_v + - name: delete epg contract to inband epg with no previous & no verify + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_to_contract_no_lb_no_v state: absent register: delete_epg_to_contract_present_no_lb_no_v - - name: delete epg contract to epg with no previous again & no verify - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_to_contract_no_lb_no_v + - name: delete epg contract to inband epg with no previous again & no verify + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_to_contract_no_lb_no_v state: absent register: delete_epg_to_contract_present_no_lb_no_v_again @@ -360,20 +317,22 @@ - delete_epg_to_contract_present_no_lb_no_v_again.previous == [] - delete_epg_to_contract_present_no_lb_no_v_again.proposed == {} + # Query Tests + - name: get binding - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_provide_present2 + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_provide_present2 state: query register: query_provide_contract - name: get binding - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_consume_present + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_consume_present state: query register: query_consume_contract - name: get all bindings - cisco.aci.aci_epg_to_contract: + cisco.aci.aci_inbepg_to_contract: <<: *aci_tenant_present state: query tenant: "{{ fakevar | default(omit) }}" @@ -381,7 +340,7 @@ register: query_all - name: missing required param - failure message works - cisco.aci.aci_epg_to_contract: + cisco.aci.aci_inbepg_to_contract: <<: *aci_tenant_present state: query ignore_errors: true @@ -401,45 +360,47 @@ - missing_required_query is failed - 'missing_required_query.msg == "missing required arguments: contract_type"' + #Absent tasks + - name: delete consume binding - check mode works - cisco.aci.aci_epg_to_contract: &aci_epg_consume_absent - <<: *aci_epg_consume_present + cisco.aci.aci_inbepg_to_contract: &aci_inbepg_consume_absent + <<: *aci_inbepg_consume_present state: absent check_mode: true register: consume_absent_check_mode - name: delete consume binding - deletion works - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_consume_absent + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_consume_absent register: consume_absent - name: delete provide binding - deletion works - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_provide_present + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_provide_present state: absent register: provide_absent - name: delete provide binding - deletion works - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_provide_present2 + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_provide_present2 state: absent register: provide_absent2 - name: delete consume binding - idempotency works - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_consume_absent + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_consume_absent register: consume_absent_idempotent - name: missing param - failure message works - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_consume_absent + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_consume_absent contract: "{{ fakevar | default(omit) }}" ignore_errors: true register: missing_param_absent - name: missing required param - failure message works - cisco.aci.aci_epg_to_contract: - <<: *aci_epg_consume_absent + cisco.aci.aci_inbepg_to_contract: + <<: *aci_inbepg_consume_absent contract_type: "{{ fakevar | default(omit) }}" ignore_errors: true register: missing_required_absent @@ -461,6 +422,8 @@ - missing_required_absent is failed - 'missing_required_absent.msg == "missing required arguments: contract_type"' + # Object Cleanup + - name: cleanup contracts cisco.aci.aci_contract: <<: *aci_tenant_present @@ -469,19 +432,7 @@ with_items: ["anstest_http", "anstest_https", "anstest_db", "anstest_no_previous", "anstest_no_lb_no_v"] - name: cleanup epg - cisco.aci.aci_epg: - <<: *aci_epg_present - state: absent - when: epg_present is changed - - - name: cleanup ap - cisco.aci.aci_ap: - <<: *aci_ap_present - state: absent - when: ap_present is changed - - - name: cleanup tenant - cisco.aci.aci_tenant: - <<: *aci_tenant_present + cisco.aci.aci_inbepg: + <<: *aci_inbepg_present state: absent - when: tenant_present is changed \ No newline at end of file + when: inb_epg_present is changed