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,9 +124,10 @@ 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]
|
||||
out = out.split()
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if name in out else False
|
||||
|
||||
|
|
|
@ -103,7 +103,8 @@ def check_cli(module, cli):
|
|||
cli += ' dhcp-filter-show format name no-show-headers'
|
||||
out = run_commands(module, cli)[1]
|
||||
|
||||
out = out.split()
|
||||
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]
|
||||
|
||||
out = out.split()
|
||||
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]
|
||||
|
||||
out = out.split()
|
||||
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,7 +133,8 @@ def check_cli(module, cli):
|
|||
cli += ' role-show format name no-show-headers'
|
||||
out = run_commands(module, cli)[1]
|
||||
|
||||
out = out.split()
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if role_name in out else False
|
||||
|
||||
|
|
|
@ -102,7 +102,8 @@ def check_cli(module, cli):
|
|||
cli += ' snmp-community-show format community-string no-show-headers'
|
||||
out = run_commands(module, cli)[1]
|
||||
|
||||
out = out.split()
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if comm_str in out else False
|
||||
|
||||
|
|
|
@ -110,14 +110,16 @@ def check_cli(module, cli):
|
|||
cli += ' snmp-community-show format community-string no-show-headers'
|
||||
rc, out, err = run_commands(module, cli)
|
||||
|
||||
out = out.split()
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
if community in out:
|
||||
cli = show
|
||||
cli += ' snmp-trap-sink-show community %s format type,dest-host no-show-headers' % community
|
||||
rc, out, err = run_commands(module, cli)
|
||||
|
||||
out = out.split()
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if dest_host in out else False
|
||||
else:
|
||||
|
|
|
@ -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,7 +125,8 @@ def check_cli(module, cli):
|
|||
cli += ' snmp-vacm-show format user-name no-show-headers'
|
||||
out = run_commands(module, cli)[1]
|
||||
|
||||
out = out.split()
|
||||
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]
|
||||
out = out.split()
|
||||
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
|
||||
|
@ -151,9 +152,11 @@ def check_cli(module, cli):
|
|||
if nic_str:
|
||||
# Check for nic
|
||||
show = cli + ' vrouter-interface-show vrouter-name %s ' % vrouter_name
|
||||
show += ' format nic no-show-headers'
|
||||
show += 'format nic no-show-headers'
|
||||
out = run_commands(module, show)[1]
|
||||
out = out.split()
|
||||
|
||||
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,7 +111,8 @@ 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]
|
||||
out = out.split()
|
||||
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]
|
||||
out = out.split()
|
||||
if out[-1] == name:
|
||||
if out:
|
||||
out = out.split()
|
||||
if name in out:
|
||||
pass
|
||||
else:
|
||||
return False
|
||||
|
@ -108,7 +109,8 @@ 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]
|
||||
out = out.split()
|
||||
if out:
|
||||
out = out.split()
|
||||
|
||||
return True if 'none' not in out else False
|
||||
|
||||
|
|
Loading…
Reference in a new issue