Coverity Bug Fix for cnos_vrf.py (#55954)
* Coverity Bug Fix for cnos_vrf.py * Update cnos_vrf.pypull/4420/head
parent
6610d678f8
commit
d9a1c8954f
|
@ -228,27 +228,27 @@ def map_obj_to_commands(updates, module):
|
||||||
def map_config_to_obj(module):
|
def map_config_to_obj(module):
|
||||||
objs = []
|
objs = []
|
||||||
output = run_commands(module, {'command': 'show vrf'})
|
output = run_commands(module, {'command': 'show vrf'})
|
||||||
if output is None:
|
if output is not None:
|
||||||
|
vrfText = output[0].strip()
|
||||||
|
vrfList = vrfText.split('VRF')
|
||||||
|
for vrfItem in vrfList:
|
||||||
|
if 'FIB ID' in vrfItem:
|
||||||
|
obj = dict()
|
||||||
|
list_of_words = vrfItem.split()
|
||||||
|
vrfName = list_of_words[0]
|
||||||
|
obj['name'] = vrfName[:-1]
|
||||||
|
obj['rd'] = list_of_words[list_of_words.index('RD') + 1]
|
||||||
|
start = False
|
||||||
|
obj['interfaces'] = []
|
||||||
|
for intName in list_of_words:
|
||||||
|
if 'Interfaces' in intName:
|
||||||
|
start = True
|
||||||
|
if start is True:
|
||||||
|
if '!' not in intName and 'Interfaces' not in intName:
|
||||||
|
obj['interfaces'].append(intName.strip().lower())
|
||||||
|
objs.append(obj)
|
||||||
|
else:
|
||||||
module.fail_json(msg='Could not fetch VRF details from device')
|
module.fail_json(msg='Could not fetch VRF details from device')
|
||||||
vrfText = output[0].strip()
|
|
||||||
vrfList = vrfText.split('VRF')
|
|
||||||
for vrfItem in vrfList:
|
|
||||||
if 'FIB ID' in vrfItem:
|
|
||||||
obj = dict()
|
|
||||||
list_of_words = vrfItem.split()
|
|
||||||
vrfName = list_of_words[0]
|
|
||||||
obj['name'] = vrfName[:-1]
|
|
||||||
obj['rd'] = list_of_words[list_of_words.index('RD') + 1]
|
|
||||||
start = False
|
|
||||||
obj['interfaces'] = []
|
|
||||||
for intName in list_of_words:
|
|
||||||
if 'Interfaces' in intName:
|
|
||||||
start = True
|
|
||||||
if start is True:
|
|
||||||
if '!' not in intName and 'Interfaces' not in intName:
|
|
||||||
obj['interfaces'].append(intName.strip().lower())
|
|
||||||
objs.append(obj)
|
|
||||||
|
|
||||||
return objs
|
return objs
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue