mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add input validation for the new asn parameter
Fix asn type from str to int
This commit is contained in:
parent
165000adcd
commit
01db7239ed
1 changed files with 11 additions and 6 deletions
|
@ -61,7 +61,7 @@ options:
|
||||||
description:
|
description:
|
||||||
- Routing protocol for the L3Out
|
- Routing protocol for the L3Out
|
||||||
type: list
|
type: list
|
||||||
choices: [ static, bgp, ospf, eigrp, pim ]
|
choices: [ static, bgp, eigrp, ospf, pim ]
|
||||||
asn:
|
asn:
|
||||||
description:
|
description:
|
||||||
- The AS number for the L3Out. Only applicable when using 'eigrp' as the l3protocol
|
- The AS number for the L3Out. Only applicable when using 'eigrp' as the l3protocol
|
||||||
|
@ -239,8 +239,8 @@ def main():
|
||||||
choices=['AF11', 'AF12', 'AF13', 'AF21', 'AF22', 'AF23', 'AF31', 'AF32', 'AF33', 'AF41', 'AF42',
|
choices=['AF11', 'AF12', 'AF13', 'AF21', 'AF22', 'AF23', 'AF31', 'AF32', 'AF33', 'AF41', 'AF42',
|
||||||
'AF43', 'CS0', 'CS1', 'CS2', 'CS3', 'CS4', 'CS5', 'CS6', 'CS7', 'EF', 'VA', 'unspecified'],
|
'AF43', 'CS0', 'CS1', 'CS2', 'CS3', 'CS4', 'CS5', 'CS6', 'CS7', 'EF', 'VA', 'unspecified'],
|
||||||
aliases=['target']),
|
aliases=['target']),
|
||||||
l3protocol=dict(type='list', choices=['static', 'bgp', 'ospf', 'eigrp', 'pim']),
|
l3protocol=dict(type='list', choices=['static', 'bgp', 'eigrp', 'ospf', 'pim']),
|
||||||
asn=dict(type='str', aliases=['as_number']),
|
asn=dict(type='int', aliases=['as_number']),
|
||||||
state=dict(type='str', default='present', choices=['absent', 'present', 'query'])
|
state=dict(type='str', default='present', choices=['absent', 'present', 'query'])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -265,6 +265,11 @@ def main():
|
||||||
asn = module.params['asn']
|
asn = module.params['asn']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
tenant = module.params['tenant']
|
tenant = module.params['tenant']
|
||||||
|
|
||||||
|
if asn and 'eigrp' not in l3protocol:
|
||||||
|
module._warnings = ["Parameter 'asn' is only applicable when l3protocol is 'eigrp'. The ASN will be ignored"]
|
||||||
|
if not asn and 'eigrp' in l3protocol:
|
||||||
|
module.fail_json(msg="Parameter 'asn' is required when l3protocol is 'eigrp'")
|
||||||
|
|
||||||
enforce_ctrl = ''
|
enforce_ctrl = ''
|
||||||
if enforceRtctrl is not None:
|
if enforceRtctrl is not None:
|
||||||
|
@ -305,12 +310,12 @@ def main():
|
||||||
if protocol == 'bgp':
|
if protocol == 'bgp':
|
||||||
child_configs.append(
|
child_configs.append(
|
||||||
dict(bgpExtP=dict(attributes=dict(descr='', nameAlias=''))))
|
dict(bgpExtP=dict(attributes=dict(descr='', nameAlias=''))))
|
||||||
elif protocol == 'ospf':
|
|
||||||
child_configs.append(
|
|
||||||
dict(ospfExtP=dict(attributes=dict(descr='', nameAlias=''))))
|
|
||||||
elif protocol == 'eigrp':
|
elif protocol == 'eigrp':
|
||||||
child_configs.append(
|
child_configs.append(
|
||||||
dict(eigrpExtP=dict(attributes=dict(descr='', nameAlias='', asn=asn))))
|
dict(eigrpExtP=dict(attributes=dict(descr='', nameAlias='', asn=asn))))
|
||||||
|
elif protocol == 'ospf':
|
||||||
|
child_configs.append(
|
||||||
|
dict(ospfExtP=dict(attributes=dict(descr='', nameAlias=''))))
|
||||||
elif protocol == 'pim':
|
elif protocol == 'pim':
|
||||||
child_configs.append(
|
child_configs.append(
|
||||||
dict(pimExtP=dict(attributes=dict(descr='', nameAlias=''))))
|
dict(pimExtP=dict(attributes=dict(descr='', nameAlias=''))))
|
||||||
|
|
Loading…
Reference in a new issue