mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-19 15:39:10 -07:00
aci_access_port_to_interface_policy_leaf_profile module (#34398)
* added aci_switch_leaf_policy_profile module WIP * fixed pep8 errors for PR * fixed unwanted modifications and fixed pep8 errors * fixed suggested errors for PR * adding WIP aci_switch_leaf_selector module * fixed for pull request * fixing pep8 errors, bad indents * improved initial description * fixed pep8 doc errors * updated module to include infra:NodeBlk and infra:RsAccNodePGrp instead of having seperate modules for the latter * fixing pep8 * adding 'name' alias to leaf_selector * updating example * updating aliases, forgot 'name' again * adding aci_interface_policy_leaf_profile module * removing unwanted module.. man I always make this mistake * add aci_access_port_to_interface_policy_leaf_profile module * added example and integration tests * Fix pylint errors
This commit is contained in:
parent
d23d290be8
commit
61d50a12e5
3 changed files with 318 additions and 0 deletions
|
@ -0,0 +1,2 @@
|
|||
# No ACI simulator yet, so not enabled
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
# Test code for the ACI modules
|
||||
# Copyright 2017, Bruno Calogero <bcalogero@cisco.com>
|
||||
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Test that we have an ACI APIC host, ACI username and ACI password
|
||||
fail:
|
||||
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: Ensuring Interface Policy Leaf profile exists for kick off
|
||||
aci_interface_policy_leaf_profile: &aci_interface_policy_leaf_profile_present
|
||||
host: "{{ aci_hostname }}"
|
||||
username: "{{ aci_username }}"
|
||||
password: "{{ aci_password }}"
|
||||
leaf_interface_profile: leafintprftest
|
||||
validate_certs: no
|
||||
use_ssl: no
|
||||
use_proxy: no
|
||||
state: present
|
||||
register: leaf_profile_present
|
||||
|
||||
# TODO: Ensure that leaf Policy Group Exists (module missing) (infra:AccPortGrp)
|
||||
|
||||
- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - check mode works
|
||||
aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_present
|
||||
<<: *aci_interface_policy_leaf_profile_present
|
||||
access_port_selector: anstest_accessportselector
|
||||
leaf_port_blk: anstest_leafportblkname
|
||||
fromPort: 13
|
||||
toPort: 16
|
||||
check_mode: yes
|
||||
register: accessport_to_intf_check_mode_present
|
||||
|
||||
- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - creation works
|
||||
aci_access_port_to_interface_policy_leaf_profile:
|
||||
<<: *aci_access_port_to_interface_policy_leaf_profile_present
|
||||
register: accessport_to_intf_present
|
||||
|
||||
- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - idempotency works
|
||||
aci_access_port_to_interface_policy_leaf_profile:
|
||||
<<: *aci_access_port_to_interface_policy_leaf_profile_present
|
||||
register: accessport_to_intf_idempotent
|
||||
|
||||
- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - update works
|
||||
aci_access_port_to_interface_policy_leaf_profile:
|
||||
<<: *aci_access_port_to_interface_policy_leaf_profile_present
|
||||
policy_group: anstest_policygroupname
|
||||
register: accessport_to_intf_update
|
||||
|
||||
# TODO: also test for errors
|
||||
- name: present assertions
|
||||
assert:
|
||||
that:
|
||||
- accessport_to_intf_check_mode_present.changed == true
|
||||
- accessport_to_intf_present.changed == true
|
||||
- accessport_to_intf_present.existing == []
|
||||
- 'accessport_to_intf_present.config == {"infraHPortS": {"attributes": {"name": "anstest_accessportselector"}, "children": [{"infraPortBlk": {"attributes": {"fromPort": "13", "name": "anstest_leafportblkname", "toPort": "16"}}}, {"infraRsAccBaseGrp": {"attributes": {"tDn": "uni/infra/funcprof/accportgrp-None"}}}]}}'
|
||||
- accessport_to_intf_idempotent.changed == false
|
||||
- accessport_to_intf_idempotent.config == {}
|
||||
- accessport_to_intf_update.changed == true
|
||||
- 'accessport_to_intf_update.config == {"infraHPortS": {"attributes": {},"children": [{"infraRsAccBaseGrp": {"attributes": {"tDn": "uni/infra/funcprof/accportgrp-anstest_policygroupname"}}}]}}'
|
||||
|
||||
- name: Query Specific access_port_selector and leaf_interface_profile binding
|
||||
aci_access_port_to_interface_policy_leaf_profile:
|
||||
<<: *aci_interface_policy_leaf_profile_present
|
||||
access_port_selector: anstest_accessportselector # "{{ fake_var | default(omit) }}" ?
|
||||
state: query
|
||||
register: binding_query
|
||||
|
||||
- name: present assertions
|
||||
assert:
|
||||
that:
|
||||
- binding_query.changed == false
|
||||
- binding_query.existing | length >= 1
|
||||
- '"api/mo/uni/infra/accportprof-leafintprftest/hports-anstest_accessportselector-typ-range.json" in binding_query.url'
|
||||
|
||||
- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode
|
||||
aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_absent
|
||||
<<: *aci_interface_policy_leaf_profile_present
|
||||
access_port_selector: anstest_accessportselector
|
||||
state: absent
|
||||
check_mode: yes
|
||||
register: accessport_to_intf_check_mode_absent
|
||||
|
||||
- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - delete works
|
||||
aci_access_port_to_interface_policy_leaf_profile:
|
||||
<<: *aci_access_port_to_interface_policy_leaf_profile_absent
|
||||
register: accessport_to_intf_absent
|
||||
|
||||
- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - idempotency works
|
||||
aci_access_port_to_interface_policy_leaf_profile:
|
||||
<<: *aci_access_port_to_interface_policy_leaf_profile_absent
|
||||
register: accessport_to_intf_absent_idempotent
|
||||
|
||||
- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode
|
||||
aci_access_port_to_interface_policy_leaf_profile:
|
||||
<<: *aci_interface_policy_leaf_profile_present
|
||||
#access_port_selector: anstest_accessportselector
|
||||
state: absent
|
||||
ignore_errors: yes
|
||||
register: accessport_to_intf_absent_missing_param
|
||||
|
||||
- name: absent assertions
|
||||
assert:
|
||||
that:
|
||||
- accessport_to_intf_check_mode_absent.changed == true
|
||||
- accessport_to_intf_check_mode_absent.existing != []
|
||||
- accessport_to_intf_absent.changed == true
|
||||
- accessport_to_intf_absent.existing == accessport_to_intf_check_mode_absent.existing
|
||||
- accessport_to_intf_absent_idempotent.changed == false
|
||||
- accessport_to_intf_absent_idempotent.existing == []
|
||||
- accessport_to_intf_absent_missing_param.failed == true
|
||||
- 'accessport_to_intf_absent_missing_param.msg == "state is absent but all of the following are missing: access_port_selector"'
|
||||
|
||||
|
||||
- name: Remove an interface access port selector associated with an Interface Policy Leaf Profile - Clean up
|
||||
aci_access_port_to_interface_policy_leaf_profile:
|
||||
<<: *aci_access_port_to_interface_policy_leaf_profile_absent
|
||||
state: absent
|
||||
|
||||
- name: Remove Interface policy leaf profile - Cleanup
|
||||
aci_interface_policy_leaf_profile:
|
||||
<<: *aci_interface_policy_leaf_profile_present
|
||||
state: absent
|
Loading…
Add table
Add a link
Reference in a new issue