eos_l2_interface: Handle Interface does not exist
(#56140)
* Fail on switchport error * Handle `Interface does not exist` when gathering switchport.
This commit is contained in:
parent
776ec08ad5
commit
1097632039
1 changed files with 6 additions and 3 deletions
|
@ -200,7 +200,7 @@ def map_obj_to_commands(updates, module):
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
|
|
||||||
def map_config_to_obj(module):
|
def map_config_to_obj(module, warnings):
|
||||||
config = get_config(module, flags=['| section interface'])
|
config = get_config(module, flags=['| section interface'])
|
||||||
configobj = NetworkConfig(indent=3, contents=config)
|
configobj = NetworkConfig(indent=3, contents=config)
|
||||||
|
|
||||||
|
@ -214,7 +214,10 @@ def map_config_to_obj(module):
|
||||||
command = {'command': 'show interfaces {0} switchport | include Switchport'.format(item),
|
command = {'command': 'show interfaces {0} switchport | include Switchport'.format(item),
|
||||||
'output': 'text'}
|
'output': 'text'}
|
||||||
command_result = run_commands(module, command)
|
command_result = run_commands(module, command)
|
||||||
if command_result[0] != "":
|
if command_result[0] == "% Interface does not exist":
|
||||||
|
warnings.append("Could not gather switchport information for {0}: {1}".format(item, command_result[0]))
|
||||||
|
continue
|
||||||
|
elif command_result[0] != "":
|
||||||
switchport_cfg = command_result[0].split(':')[1].strip()
|
switchport_cfg = command_result[0].split(':')[1].strip()
|
||||||
|
|
||||||
if switchport_cfg == 'Enabled':
|
if switchport_cfg == 'Enabled':
|
||||||
|
@ -302,7 +305,7 @@ def main():
|
||||||
result['warnings'] = warnings
|
result['warnings'] = warnings
|
||||||
|
|
||||||
want = map_params_to_obj(module)
|
want = map_params_to_obj(module)
|
||||||
have = map_config_to_obj(module)
|
have = map_config_to_obj(module, warnings)
|
||||||
commands = map_obj_to_commands((want, have), module)
|
commands = map_obj_to_commands((want, have), module)
|
||||||
result['commands'] = commands
|
result['commands'] = commands
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue