Skip to content

Commit

Permalink
[minor_change] Add support for name attribute in mso_schema_template_…
Browse files Browse the repository at this point in the history
…external_epg_subnet module
  • Loading branch information
akinross authored and lhercot committed Nov 11, 2024
1 parent e19f206 commit e1febee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions plugins/modules/mso_schema_template_external_epg_subnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

# Copyright: (c) 2021, Anvitha Jain (@anvitha-jain) <[email protected]>
# Copyright: (c) 2024, Akini Ross (@akinross) <[email protected]>
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
Expand All @@ -19,6 +20,7 @@
author:
- Devarshi Shah (@devarshishah3)
- Anvitha Jain (@anvitha-jain)
- Akini Ross (@akinross)
version_added: '0.0.8'
options:
schema:
Expand All @@ -40,6 +42,10 @@
description:
- The IP range in CIDR notation.
type: str
name:
description:
- The name of the External EPG Subnet.
type: str
scope:
description:
- The scope parameter contains two sections 1. Route Control and 2. External EPG Classification.
Expand Down Expand Up @@ -132,6 +138,7 @@ def main():
external_epg=dict(type="str", required=True),
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
subnet=dict(type="str"),
name=dict(type="str"),
scope=dict(type="list", elements="str", default=[]),
aggregate=dict(type="list", elements="str", default=[]),
)
Expand All @@ -149,6 +156,7 @@ def main():
template = module.params.get("template").replace(" ", "")
external_epg = module.params.get("external_epg")
subnet = module.params.get("subnet")
name = module.params.get("name")
scope = module.params.get("scope")
aggregate = module.params.get("aggregate")
state = module.params.get("state")
Expand Down Expand Up @@ -201,6 +209,7 @@ def main():
ip=subnet,
scope=scope,
aggregate=aggregate,
name=name,
)

mso.sanitize(payload, collate=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Test code for the MSO modules
# Copyright: (c) 2021, Anvitha Jain (@anvitha-jain) <[email protected]>
# Copyright: (c) 2024, Akini Ross (@akinross) <[email protected]>
#

# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
Expand Down Expand Up @@ -188,6 +189,7 @@
template: Template 1
external_epg: ansible_test_1
subnet: 10.0.0.2/24
name: subnet2
state: present
register: add_epg_subnet_2

Expand All @@ -196,6 +198,7 @@
that:
- add_epg_subnet_2 is changed
- add_epg_subnet_2.current.ip == "10.0.0.2/24"
- add_epg_subnet_2.current.name == "subnet2"

# QUERY ALL EPG Subnets
- name: Query all EPG (check_mode)
Expand Down Expand Up @@ -343,6 +346,14 @@
- add_epg_subnet_no_ag.msg == "MSO Error 400{{':'}} ExternalEPG{{':'}} ansible_test_1 in Schema{{':'}} ansible_test , Template{{':'}} Template1 External EPG validation error{{':'}} aggregate should be enabled only if shared-rtctrl is enabled in Scope for subnet 10.0.0.2/24"
when:
- version.current.version is version('4.0', '>=')
- version.current.version is version('4.3', '<')

- name: Verify add_epg_subnet_no_ag (version >= 4.3)
ansible.builtin.assert:
that:
- add_epg_subnet_no_ag.msg == "MSO Error 400{{':'}} ExternalEPG{{':'}} ansible_test_1 in Schema{{':'}} ansible_test, Template{{':'}} Template1, External EPG validation error{{':'}} aggregate should be enabled only if shared-rtctrl is enabled in Scope for subnet 10.0.0.2/24"
when:
- version.current.version is version('4.3', '>=')

- name: Execute tasks only for MSO version < 4.0
# mso_schema_validate not supported after 4.0, validation executed upon request
Expand Down

0 comments on commit e1febee

Please sign in to comment.