From b90ae65e5c535286d2fd7695fff303f90f8c0611 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Thu, 5 Jul 2018 18:01:28 +0200 Subject: [PATCH] aci_static_binding_to_epg: Add description parameter (#42244) * aci_static_binding_to_epg: Add description parameter This PR adds the description parameter to this module. Tis fixes #42154 * Fix added_version --- .../network/aci/aci_static_binding_to_epg.py | 8 +++ .../aci_static_binding_to_epg/tasks/main.yml | 72 +++++++++++++------ 2 files changed, 58 insertions(+), 22 deletions(-) diff --git a/lib/ansible/modules/network/aci/aci_static_binding_to_epg.py b/lib/ansible/modules/network/aci/aci_static_binding_to_epg.py index 435803df0f7..ddcb4072d63 100644 --- a/lib/ansible/modules/network/aci/aci_static_binding_to_epg.py +++ b/lib/ansible/modules/network/aci/aci_static_binding_to_epg.py @@ -38,6 +38,11 @@ options: description: - The name of the end point group. aliases: [ epg_name ] + description: + description: + - Description for the static path to EPG binding. + aliases: [ descr ] + version_added: '2.7' encap_id: description: - The encapsulation ID associating the C(epg) with the interface path. @@ -263,6 +268,7 @@ def main(): tenant=dict(type='str', aliases=['tenant_name']), # Not required for querying all objects 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 + description=dict(type='str', aliases=['descr']), encap_id=dict(type='int', aliases=['vlan', 'vlan_id']), primary_encap_id=dict(type='int', aliases=['primary_vlan', 'primary_vlan_id']), deploy_immediacy=dict(type='str', choices=['immediate', 'lazy']), @@ -289,6 +295,7 @@ def main(): tenant = module.params['tenant'] ap = module.params['ap'] epg = module.params['epg'] + description = module.params['description'] encap_id = module.params['encap_id'] primary_encap_id = module.params['primary_encap_id'] deploy_immediacy = module.params['deploy_immediacy'] @@ -383,6 +390,7 @@ def main(): aci.payload( aci_class='fvRsPathAtt', class_config=dict( + descr=description, encap=encap_id, primaryEncap=primary_encap_id, instrImedcy=deploy_immediacy, diff --git a/test/integration/targets/aci_static_binding_to_epg/tasks/main.yml b/test/integration/targets/aci_static_binding_to_epg/tasks/main.yml index 02ce4a32044..1f19f380dfc 100644 --- a/test/integration/targets/aci_static_binding_to_epg/tasks/main.yml +++ b/test/integration/targets/aci_static_binding_to_epg/tasks/main.yml @@ -8,7 +8,7 @@ msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined -- name: ensure static path to epg is deleted for test kick off +- name: Ensure static path to epg is deleted for test kick off aci_static_binding_to_epg: &aci_static_binding_to_epg_absent host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -26,7 +26,7 @@ interface: '1/7' state: absent -- name: ensure tenant exists for tests to kick off +- name: Ensure tenant exists for tests to kick off aci_tenant: &aci_tenant_present host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -35,23 +35,23 @@ use_ssl: '{{ aci_use_ssl | default(true) }}' use_proxy: '{{ aci_use_proxy | default(true) }}' output_level: debug - state: present tenant: anstest + state: present register: tenant_present -- name: ensure ap exists +- name: Ensure ap exists aci_ap: &aci_ap_present <<: *aci_tenant_present ap: anstest register: ap_present -- name: ensure epg exists +- name: Ensure epg exists aci_epg: &aci_epg_present <<: *aci_ap_present epg: anstest register: epg_present -- name: bind static-binding to epg - check mode works +- name: Bind static-binding to epg - check mode works aci_static_binding_to_epg: &aci_static_binding_to_epg_present <<: *aci_epg_present encap_id: 222 @@ -64,30 +64,54 @@ check_mode: yes register: provide_present_check_mode -- name: bind static-binding to epg - provide works (creation w/o check-mode) +- name: Bind static-binding to epg - provide works (creation w/o check-mode) aci_static_binding_to_epg: <<: *aci_static_binding_to_epg_present ignore_errors: yes register: provide_present -- name: bind static-binding to epg - primary_encap_id works +- name: Bind static-binding to epg - primary_encap_id works aci_static_binding_to_epg: &primary_encap_id_present <<: *aci_static_binding_to_epg_present primary_encap_id: 50 register: primary_ecap_id_present -- name: bind contract to epg - idempotency works again +- name: Bind contract to epg - idempotency works again aci_static_binding_to_epg: <<: *primary_encap_id_present register: idempotent_present -- name: missing required param - failure message works +- name: Bind contract to epg - update description (check mode) + aci_static_binding_to_epg: + <<: *primary_encap_id_present + description: Binding description + register: description_cm + +- name: Bind contract to epg - update description (run mode) + aci_static_binding_to_epg: + <<: *primary_encap_id_present + description: Binding description + register: description + +- name: Bind contract to epg - update description (check mode) + aci_static_binding_to_epg: + <<: *primary_encap_id_present + description: Binding description + register: idempotent_description_cm + +- name: Bind contract to epg - update description (run mode) + aci_static_binding_to_epg: + <<: *primary_encap_id_present + description: Binding description + register: idempotent_description + +- name: Missing required param - failure message works aci_static_binding_to_epg: <<: *aci_tenant_present ignore_errors: yes register: missing_required_present -- name: present assertions +- name: Present assertions assert: that: - provide_present_check_mode.changed == true @@ -97,25 +121,29 @@ - provide_present.previous == [] - primary_ecap_id_present.changed == true - 'primary_ecap_id_present.sent == {"fvRsPathAtt": {"attributes": {"primaryEncap": "vlan-50"}}}' + - description_cm.changed == true + - description.changed == true + - idempotent_description_cm.changed == false + - idempotent_description.changed == false - missing_required_present.failed == true - 'missing_required_present.msg == "missing required arguments: interface_type"' - missing_required_present.failed == true -- name: get binding +- name: Get binding aci_static_binding_to_epg: <<: *primary_encap_id_present state: query register: query_static_binding -- name: missing required param - failure message works +- name: Missing required param - failure message works aci_static_binding_to_epg: <<: *aci_tenant_present state: query ignore_errors: yes register: missing_required_query -- name: query assertions +- name: Query assertions assert: that: - query_static_binding.changed == false @@ -128,26 +156,26 @@ - 'missing_required_query.msg == "missing required arguments: interface_type"' -- name: delete provide binding - deletion works +- name: Delete provide binding - deletion works aci_static_binding_to_epg: <<: *primary_encap_id_present state: absent register: provide_absent -- name: delete provide binding - idempotency works +- name: Delete provide binding - idempotency works aci_static_binding_to_epg: <<: *primary_encap_id_present state: absent register: provide_absent_idempotent -- name: missing param - failure message works +- name: Missing param - failure message works aci_static_binding_to_epg: <<: *aci_tenant_present state: absent ignore_errors: yes register: missing_param_absent -- name: absent assertions +- name: Absent assertions assert: that: - provide_absent.changed == true @@ -158,21 +186,21 @@ - missing_param_absent.failed == true - 'missing_param_absent.msg == "missing required arguments: interface_type"' -- name: cleanup binding +- name: Cleanup binding aci_static_binding_to_epg: <<: *aci_static_binding_to_epg_absent -- name: cleanup epg +- name: Cleanup epg aci_epg: <<: *aci_epg_present state: absent -- name: cleanup ap +- name: Cleanup ap aci_ap: <<: *aci_ap_present state: absent -- name: cleanup tenant +- name: Cleanup tenant aci_tenant: <<: *aci_tenant_present state: absent