From eb0232fa866260b4f3c24afbc87a6ccb19e9afb6 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Thu, 15 Feb 2018 02:59:54 +0100 Subject: [PATCH] aci_encap_pool: Standardize on 'pool_allocation_mode' (#36215) (cherry picked from commit e431d578da1cca2d0ecab2d74184158527fc925b) --- .../modules/network/aci/aci_encap_pool.py | 32 +++++++++---------- .../targets/aci_encap_pool/tasks/main.yml | 6 ++-- .../targets/aci_encap_pool/tasks/vlan.yml | 10 +++--- .../targets/aci_encap_pool/tasks/vsan.yml | 2 +- .../targets/aci_encap_pool/tasks/vxlan.yml | 6 ++-- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/ansible/modules/network/aci/aci_encap_pool.py b/lib/ansible/modules/network/aci/aci_encap_pool.py index 8e297c85626..f80f6aca44f 100644 --- a/lib/ansible/modules/network/aci/aci_encap_pool.py +++ b/lib/ansible/modules/network/aci/aci_encap_pool.py @@ -23,12 +23,6 @@ author: - Jacob McGill (@jmcgill298) version_added: '2.5' options: - allocation_mode: - description: - - The method used for allocating encaps to resources. - - Only vlan and vsan support allocation modes. - aliases: [ mode ] - choices: [ dynamic, static] description: description: - Description for the C(pool). @@ -37,6 +31,12 @@ options: description: - The name of the pool. aliases: [ name, pool_name ] + pool_allocation_mode: + description: + - The method used for allocating encaps to resources. + - Only vlan and vsan support allocation modes. + choices: [ dynamic, static ] + aliases: [ allocation_mode, mode ] pool_type: description: - The encap type of C(pool). @@ -217,9 +217,9 @@ ACI_MAPPING = dict( def main(): argument_spec = aci_argument_spec() argument_spec.update( - allocation_mode=dict(type='str', aliases=['mode'], choices=['dynamic', 'static']), description=dict(type='str', aliases=['descr']), pool=dict(type='str', aliases=['name', 'pool_name']), + pool_allocation_mode=dict(type='str', aliases=['allocation_mode', 'mode'], choices=['dynamic', 'static']), pool_type=dict(type='str', aliases=['type'], choices=['vlan', 'vxlan', 'vsan'], required=True), state=dict(type='str', default='present', choices=['absent', 'present', 'query']), ) @@ -233,26 +233,26 @@ def main(): ], ) - allocation_mode = module.params['allocation_mode'] description = module.params['description'] pool = module.params['pool'] pool_type = module.params['pool_type'] + pool_allocation_mode = module.params['pool_allocation_mode'] state = module.params['state'] aci_class = ACI_MAPPING[pool_type]["aci_class"] aci_mo = ACI_MAPPING[pool_type]["aci_mo"] pool_name = pool - # ACI Pool URL requires the allocation mode for vlan and vsan pools (ex: uni/infra/vlanns-[poolname]-static) + # ACI Pool URL requires the pool_allocation mode for vlan and vsan pools (ex: uni/infra/vlanns-[poolname]-static) if pool_type != 'vxlan' and pool is not None: - if allocation_mode is not None: - pool_name = '[{0}]-{1}'.format(pool, allocation_mode) + if pool_allocation_mode is not None: + pool_name = '[{0}]-{1}'.format(pool, pool_allocation_mode) else: - module.fail_json(msg='ACI requires the "allocation_mode" for "pool_type" of "vlan" and "vsan" when the "pool" is provided') + module.fail_json(msg="ACI requires parameter 'pool_allocation_mode' for 'pool_type' of 'vlan' and 'vsan' when parameter 'pool' is provided") - # Vxlan pools do not support allocation modes - if pool_type == 'vxlan' and allocation_mode is not None: - module.fail_json(msg='vxlan pools do not support setting the allocation_mode; please remove this parameter from the task') + # Vxlan pools do not support pool allocation modes + if pool_type == 'vxlan' and pool_allocation_mode is not None: + module.fail_json(msg="vxlan pools do not support setting the 'pool_allocation_mode'; please remove this parameter from the task") aci = ACIModule(module) aci.construct_url( @@ -271,7 +271,7 @@ def main(): aci.payload( aci_class=aci_class, class_config=dict( - allocMode=allocation_mode, + allocMode=pool_allocation_mode, descr=description, name=pool, ) diff --git a/test/integration/targets/aci_encap_pool/tasks/main.yml b/test/integration/targets/aci_encap_pool/tasks/main.yml index a086126abd4..e158bc0c4de 100644 --- a/test/integration/targets/aci_encap_pool/tasks/main.yml +++ b/test/integration/targets/aci_encap_pool/tasks/main.yml @@ -9,10 +9,10 @@ when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - include_tasks: vlan.yml - when: "vlan is not defined or (vlan is defined and vlan == 'True')" + when: vlan is not defined or vlan - include_tasks: vxlan.yml - when: "vxlan is not defined or (vxlan is defined and vxlan == 'True')" + when: vxlan is not defined or vxlan - include_tasks: vsan.yml - when: "vsan is not defined or (vsan is defined and vsan == 'True')" + when: vsan is not defined or vsan diff --git a/test/integration/targets/aci_encap_pool/tasks/vlan.yml b/test/integration/targets/aci_encap_pool/tasks/vlan.yml index 534ab76514a..10837a2d2ff 100644 --- a/test/integration/targets/aci_encap_pool/tasks/vlan.yml +++ b/test/integration/targets/aci_encap_pool/tasks/vlan.yml @@ -11,12 +11,12 @@ state: absent pool: anstest pool_type: vlan - allocation_mode: static + pool_allocation_mode: static - name: ensure vlan pool does not exist for tests to kick off aci_encap_pool: &aci_pool_absent_dynamic <<: *aci_pool_absent_static - allocation_mode: dynamic + pool_allocation_mode: dynamic - name: create static vlan pool - check mode works aci_encap_pool: &aci_pool_present_static @@ -109,7 +109,7 @@ - name: missing param - failure message works aci_encap_pool: <<: *aci_pool_present_dynamic - allocation_mode: "{{ fake_var | default(omit) }}" + pool_allocation_mode: "{{ fake_var | default(omit) }}" ignore_errors: yes register: vlan_alloc_fail @@ -117,7 +117,7 @@ assert: that: - vlan_alloc_fail.failed == true - - 'vlan_alloc_fail.msg == "ACI requires the \"allocation_mode\" for \"pool_type\" of \"vlan\" and \"vsan\" when the \"pool\" is provided"' + - "vlan_alloc_fail.msg == 'ACI requires parameter \\'pool_allocation_mode\\' for \\'pool_type\\' of \\'vlan\\' and \\'vsan\\' when parameter \\'pool\\' is provided'" - name: missing param - failure message works aci_encap_pool: @@ -150,7 +150,7 @@ <<: *aci_pool_absent_static state: query pool: "{{ fake_var | default(omit) }}" - allocation_mode: "{{ fake_var | default(omit) }}" + pool_allocation_mode: "{{ fake_var | default(omit) }}" register: get_all_pools - name: assertion test - query diff --git a/test/integration/targets/aci_encap_pool/tasks/vsan.yml b/test/integration/targets/aci_encap_pool/tasks/vsan.yml index 040481963fc..a7fb749b9b5 100644 --- a/test/integration/targets/aci_encap_pool/tasks/vsan.yml +++ b/test/integration/targets/aci_encap_pool/tasks/vsan.yml @@ -10,4 +10,4 @@ state: absent pool: anstest pool_type: vsan - allocation_mode: static + pool_allocation_mode: static diff --git a/test/integration/targets/aci_encap_pool/tasks/vxlan.yml b/test/integration/targets/aci_encap_pool/tasks/vxlan.yml index 94f3d5d0814..502c47ae4fa 100644 --- a/test/integration/targets/aci_encap_pool/tasks/vxlan.yml +++ b/test/integration/targets/aci_encap_pool/tasks/vxlan.yml @@ -73,11 +73,11 @@ that: - create_vxlan_2.changed == true -- name: create vxlan pool with allocation mode - failure message works +- name: create vxlan pool with pool allocation mode - failure message works aci_encap_pool: <<: *aci_vxlan_present name: anstest_3 - allocation_mode: dynamic + pool_allocation_mode: dynamic ignore_errors: yes register: create_vxlan_alloc_mode @@ -85,7 +85,7 @@ assert: that: - create_vxlan_alloc_mode.failed == true - - 'create_vxlan_alloc_mode.msg == "vxlan pools do not support setting the allocation_mode; please remove this parameter from the task"' + - 'create_vxlan_alloc_mode.msg == "vxlan pools do not support setting the pool_allocation_mode; please remove this parameter from the task"' - name: get vxlan pool - get object works aci_encap_pool: &aci_vxlan_query