mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Pluribus Networks modules handling empty output (#54971)
* Handling empty output string * Change log fragment for PR 54971
This commit is contained in:
parent
5f8342bc4c
commit
19c87d829f
14 changed files with 54 additions and 30 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- pluribus networks modules to handle empty output string.
|
|
@ -100,7 +100,10 @@ def check_cli(module, cli):
|
|||
list_name = module.params['pn_name']
|
||||
|
||||
cli += ' access-list-show format name no-show-headers'
|
||||
out = run_commands(module, cli)
|
||||
out = run_commands(module, cli)[1]
|
||||
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if list_name in out else False
|
||||
|
||||
|
|
|
@ -124,8 +124,9 @@ def check_cli(module, cli):
|
|||
)
|
||||
|
||||
cli = clicopy
|
||||
cli += ' cpu-class-show name %s format name no-show-headers' % name
|
||||
cli += ' cpu-class-show format name no-show-headers'
|
||||
out = run_commands(module, cli)[1]
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if name in out else False
|
||||
|
|
|
@ -103,6 +103,7 @@ def check_cli(module, cli):
|
|||
cli += ' dhcp-filter-show format name no-show-headers'
|
||||
out = run_commands(module, cli)[1]
|
||||
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if user_name in out else False
|
||||
|
|
|
@ -92,12 +92,13 @@ def check_cli(module, cli):
|
|||
"""
|
||||
name = module.params['pn_name']
|
||||
|
||||
cli += ' dscp-map-show name %s format name no-show-headers' % name
|
||||
cli += ' dscp-map-show format name no-show-headers'
|
||||
out = run_commands(module, cli)[1]
|
||||
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if name in out[-1] else False
|
||||
return True if name in out else False
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -100,12 +100,13 @@ def check_cli(module, cli):
|
|||
"""
|
||||
name = module.params['pn_name']
|
||||
|
||||
cli += ' dscp-map-show name %s format name no-show-headers' % name
|
||||
cli += ' dscp-map-show format name no-show-headers'
|
||||
out = run_commands(module, cli)[1]
|
||||
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if name in out[-1] else False
|
||||
return True if name in out else False
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -116,7 +116,7 @@ def check_cli(module, cli):
|
|||
rc, out, err = run_commands(module, cli)
|
||||
|
||||
if out:
|
||||
out = out.split()[1]
|
||||
out = out.split()[-1]
|
||||
return True if network in out.split('/')[0] else False
|
||||
|
||||
return False
|
||||
|
|
|
@ -133,6 +133,7 @@ def check_cli(module, cli):
|
|||
cli += ' role-show format name no-show-headers'
|
||||
out = run_commands(module, cli)[1]
|
||||
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if role_name in out else False
|
||||
|
|
|
@ -102,6 +102,7 @@ def check_cli(module, cli):
|
|||
cli += ' snmp-community-show format community-string no-show-headers'
|
||||
out = run_commands(module, cli)[1]
|
||||
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if comm_str in out else False
|
||||
|
|
|
@ -110,6 +110,7 @@ def check_cli(module, cli):
|
|||
cli += ' snmp-community-show format community-string no-show-headers'
|
||||
rc, out, err = run_commands(module, cli)
|
||||
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
if community in out:
|
||||
|
@ -117,6 +118,7 @@ def check_cli(module, cli):
|
|||
cli += ' snmp-trap-sink-show community %s format type,dest-host no-show-headers' % community
|
||||
rc, out, err = run_commands(module, cli)
|
||||
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if dest_host in out else False
|
||||
|
|
|
@ -113,9 +113,10 @@ def check_cli(module, cli):
|
|||
user_name = module.params['pn_user_name']
|
||||
show = cli
|
||||
|
||||
cli += ' snmp-user-show user-name %s format user-name no-show-headers' % user_name
|
||||
cli += ' snmp-user-show format user-name no-show-headers'
|
||||
rc, out, err = run_commands(module, cli)
|
||||
if out:
|
||||
|
||||
if out and user_name in out.split():
|
||||
pass
|
||||
else:
|
||||
return None
|
||||
|
@ -124,6 +125,7 @@ def check_cli(module, cli):
|
|||
cli += ' snmp-vacm-show format user-name no-show-headers'
|
||||
out = run_commands(module, cli)[1]
|
||||
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if user_name in out else False
|
||||
|
|
|
@ -131,11 +131,12 @@ def check_cli(module, cli):
|
|||
nic_str = module.params['pn_nic']
|
||||
|
||||
# Check for vRouter
|
||||
check_vrouter = cli + ' vrouter-show name %s format name no-show-headers ' % vrouter_name
|
||||
check_vrouter = cli + ' vrouter-show format name no-show-headers'
|
||||
out = run_commands(module, check_vrouter)[1]
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
VROUTER_EXISTS = True if vrouter_name in out[-1] else False
|
||||
VROUTER_EXISTS = True if vrouter_name in out else False
|
||||
|
||||
if interface_ip:
|
||||
# Check for interface and VRRP and fetch nic for VRRP
|
||||
|
@ -153,6 +154,8 @@ def check_cli(module, cli):
|
|||
show = cli + ' vrouter-interface-show vrouter-name %s ' % vrouter_name
|
||||
show += 'format nic no-show-headers'
|
||||
out = run_commands(module, show)[1]
|
||||
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
NIC_EXISTS = True if nic_str in out else False
|
||||
|
@ -221,7 +224,7 @@ def main():
|
|||
if INTERFACE_EXISTS is True:
|
||||
module.exit_json(
|
||||
skipped=True,
|
||||
msg='vRouter with interface %s exist' % ip
|
||||
msg='vRouter with interface ip %s exist' % ip
|
||||
)
|
||||
cli += ' nic %s ip %s ' % (nic, ip)
|
||||
|
||||
|
@ -236,7 +239,7 @@ def main():
|
|||
if INTERFACE_EXISTS is False:
|
||||
module.exit_json(
|
||||
skipped=True,
|
||||
msg='vRouter with interface %s does not exist' % ip
|
||||
msg='vRouter with interface ip %s does not exist' % ip
|
||||
)
|
||||
if nic:
|
||||
cli += ' nic %s ' % nic
|
||||
|
|
|
@ -111,6 +111,7 @@ def check_cli(module, cli):
|
|||
# Check for vRouter
|
||||
check_vrouter = cli + ' vrouter-show format name no-show-headers '
|
||||
out = run_commands(module, check_vrouter)[1]
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
VROUTER_EXISTS = True if vrouter_name in out else False
|
||||
|
@ -120,6 +121,9 @@ def check_cli(module, cli):
|
|||
show = cli + ' vrouter-ospf6-show vrouter-name %s format nic no-show-headers' % vrouter_name
|
||||
out = run_commands(module, show)[1]
|
||||
|
||||
if out:
|
||||
out.split()
|
||||
|
||||
NIC_EXISTS = True if nic_str in out else False
|
||||
|
||||
return VROUTER_EXISTS, NIC_EXISTS
|
||||
|
|
|
@ -97,10 +97,11 @@ def check_cli(module, cli):
|
|||
name = module.params['pn_vrouter_name']
|
||||
|
||||
show = cli
|
||||
cli += ' vrouter-show name %s format name no-show-headers ' % name
|
||||
cli += ' vrouter-show format name no-show-headers '
|
||||
out = run_commands(module, cli)[1]
|
||||
if out:
|
||||
out = out.split()
|
||||
if out[-1] == name:
|
||||
if name in out:
|
||||
pass
|
||||
else:
|
||||
return False
|
||||
|
@ -108,6 +109,7 @@ def check_cli(module, cli):
|
|||
cli = show
|
||||
cli += ' vrouter-show name %s format proto-multi no-show-headers' % name
|
||||
out = run_commands(module, cli)[1]
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if 'none' not in out else False
|
||||
|
|
Loading…
Reference in a new issue