mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-03 23:20:19 -07:00
Update Cisco NSO module required versions. (#36736)
NSO modules will now work with older versions of NSO, update version requirements.
This commit is contained in:
parent
26d9de6f3e
commit
f8d20f970f
5 changed files with 31 additions and 12 deletions
|
@ -625,10 +625,7 @@ def connect(params):
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
|
||||||
def verify_version(client, required_versions=None):
|
def verify_version(client, required_versions):
|
||||||
if required_versions is None:
|
|
||||||
required_versions = [(4, 5), (4, 4, 3)]
|
|
||||||
|
|
||||||
version_str = client.get_system_setting('version')
|
version_str = client.get_system_setting('version')
|
||||||
if not verify_version_str(version_str, required_versions):
|
if not verify_version_str(version_str, required_versions):
|
||||||
supported_versions = ', '.join(
|
supported_versions = ', '.join(
|
||||||
|
|
|
@ -37,7 +37,7 @@ description:
|
||||||
- This module provices support for executing Cisco NSO actions and then
|
- This module provices support for executing Cisco NSO actions and then
|
||||||
verifying that the output is as expected.
|
verifying that the output is as expected.
|
||||||
requirements:
|
requirements:
|
||||||
- Cisco NSO version 4.4.3 or higher.
|
- Cisco NSO version 3.4 or higher.
|
||||||
author: "Claes Nästén (@cnasten)"
|
author: "Claes Nästén (@cnasten)"
|
||||||
options:
|
options:
|
||||||
path:
|
path:
|
||||||
|
@ -87,6 +87,10 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
class NsoAction(object):
|
class NsoAction(object):
|
||||||
|
REQUIRED_VERSIONS = [
|
||||||
|
(3, 4)
|
||||||
|
]
|
||||||
|
|
||||||
def __init__(self, check_mode, client,
|
def __init__(self, check_mode, client,
|
||||||
path, input,
|
path, input,
|
||||||
output_required, output_invalid, validate_strict):
|
output_required, output_invalid, validate_strict):
|
||||||
|
@ -167,7 +171,7 @@ def main():
|
||||||
p['output_invalid'],
|
p['output_invalid'],
|
||||||
p['validate_strict'])
|
p['validate_strict'])
|
||||||
try:
|
try:
|
||||||
verify_version(client)
|
verify_version(client, NsoAction.REQUIRED_VERSIONS)
|
||||||
|
|
||||||
output = nso_action.main()
|
output = nso_action.main()
|
||||||
client.logout()
|
client.logout()
|
||||||
|
|
|
@ -37,7 +37,8 @@ description:
|
||||||
- This module provides support for managing configuration in Cisco NSO and
|
- This module provides support for managing configuration in Cisco NSO and
|
||||||
can also ensure services are in sync.
|
can also ensure services are in sync.
|
||||||
requirements:
|
requirements:
|
||||||
- Cisco NSO version 4.4.3 or higher.
|
- Cisco NSO version 3.4.12 or higher, 4.2.7 or higher,
|
||||||
|
4.3.8 or higher, 4.4.3 or higher, 4.5 or higher.
|
||||||
author: "Claes Nästén (@cnasten)"
|
author: "Claes Nästén (@cnasten)"
|
||||||
options:
|
options:
|
||||||
data:
|
data:
|
||||||
|
@ -144,6 +145,14 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
class NsoConfig(object):
|
class NsoConfig(object):
|
||||||
|
REQUIRED_VERSIONS = [
|
||||||
|
(4, 5),
|
||||||
|
(4, 4, 3),
|
||||||
|
(4, 3, 8),
|
||||||
|
(4, 2, 7),
|
||||||
|
(3, 4, 12)
|
||||||
|
]
|
||||||
|
|
||||||
def __init__(self, check_mode, client, data):
|
def __init__(self, check_mode, client, data):
|
||||||
self._check_mode = check_mode
|
self._check_mode = check_mode
|
||||||
self._client = client
|
self._client = client
|
||||||
|
@ -257,7 +266,7 @@ def main():
|
||||||
client = connect(p)
|
client = connect(p)
|
||||||
nso_config = NsoConfig(module.check_mode, client, p['data'])
|
nso_config = NsoConfig(module.check_mode, client, p['data'])
|
||||||
try:
|
try:
|
||||||
verify_version(client)
|
verify_version(client, NsoConfig.REQUIRED_VERSIONS)
|
||||||
|
|
||||||
changes, diffs = nso_config.main()
|
changes, diffs = nso_config.main()
|
||||||
client.logout()
|
client.logout()
|
||||||
|
|
|
@ -37,7 +37,8 @@ description:
|
||||||
- This module provides support for verifying Cisco NSO configuration is in
|
- This module provides support for verifying Cisco NSO configuration is in
|
||||||
compliance with specified values.
|
compliance with specified values.
|
||||||
requirements:
|
requirements:
|
||||||
- Cisco NSO version 4.4.3 or higher.
|
- Cisco NSO version 3.4.12 or higher, 4.2.7 or higher,
|
||||||
|
4.3.8 or higher, 4.4.3 or higher, 4.5 or higher.
|
||||||
author: "Claes Nästén (@cnasten)"
|
author: "Claes Nästén (@cnasten)"
|
||||||
options:
|
options:
|
||||||
data:
|
data:
|
||||||
|
@ -99,6 +100,14 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
class NsoVerify(object):
|
class NsoVerify(object):
|
||||||
|
REQUIRED_VERSIONS = [
|
||||||
|
(4, 5),
|
||||||
|
(4, 4, 3),
|
||||||
|
(4, 3, 8),
|
||||||
|
(4, 2, 7),
|
||||||
|
(3, 4, 12)
|
||||||
|
]
|
||||||
|
|
||||||
def __init__(self, client, data):
|
def __init__(self, client, data):
|
||||||
self._client = client
|
self._client = client
|
||||||
self._data = data
|
self._data = data
|
||||||
|
@ -165,7 +174,7 @@ def main():
|
||||||
client = connect(p)
|
client = connect(p)
|
||||||
nso_verify = NsoVerify(client, p['data'])
|
nso_verify = NsoVerify(client, p['data'])
|
||||||
try:
|
try:
|
||||||
verify_version(client)
|
verify_version(client, NsoVerify.REQUIRED_VERSIONS)
|
||||||
|
|
||||||
violations = nso_verify.main()
|
violations = nso_verify.main()
|
||||||
client.logout()
|
client.logout()
|
||||||
|
|
|
@ -32,11 +32,11 @@ class TestNsoConfig(nso_module.TestNsoModule):
|
||||||
|
|
||||||
@patch('ansible.module_utils.network.nso.nso.open_url')
|
@patch('ansible.module_utils.network.nso.nso.open_url')
|
||||||
def test_nso_config_invalid_version_short(self, open_url_mock):
|
def test_nso_config_invalid_version_short(self, open_url_mock):
|
||||||
self._test_invalid_version(open_url_mock, '4.4')
|
self._test_invalid_version(open_url_mock, '3.3')
|
||||||
|
|
||||||
@patch('ansible.module_utils.network.nso.nso.open_url')
|
@patch('ansible.module_utils.network.nso.nso.open_url')
|
||||||
def test_nso_config_invalid_version_long(self, open_url_mock):
|
def test_nso_config_invalid_version_long(self, open_url_mock):
|
||||||
self._test_invalid_version(open_url_mock, '4.4.2')
|
self._test_invalid_version(open_url_mock, '3.3.2')
|
||||||
|
|
||||||
def _test_invalid_version(self, open_url_mock, version):
|
def _test_invalid_version(self, open_url_mock, version):
|
||||||
calls = [
|
calls = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue