|
|
@ -199,24 +199,22 @@ 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, ['show vlan'])
|
|
|
|
vlans = run_commands(module, ['show vlan conf | json'])
|
|
|
|
lines = output[0].strip().splitlines()[2:]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for l in lines:
|
|
|
|
for vlan in vlans[0]['vlans']:
|
|
|
|
splitted_line = re.split(r'\s{2,}', l.strip())
|
|
|
|
|
|
|
|
obj = {}
|
|
|
|
obj = {}
|
|
|
|
obj['vlan_id'] = splitted_line[0]
|
|
|
|
obj['vlan_id'] = vlan
|
|
|
|
obj['name'] = splitted_line[1]
|
|
|
|
obj['name'] = vlans[0]['vlans'][vlan]['name']
|
|
|
|
obj['state'] = splitted_line[2]
|
|
|
|
obj['state'] = vlans[0]['vlans'][vlan]['status']
|
|
|
|
|
|
|
|
obj['interfaces'] = []
|
|
|
|
|
|
|
|
|
|
|
|
if obj['state'] == 'suspended':
|
|
|
|
interfaces = vlans[0]['vlans'][vlan]
|
|
|
|
obj['state'] = 'suspend'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj['interfaces'] = []
|
|
|
|
for interface in interfaces['interfaces']:
|
|
|
|
if len(splitted_line) > 3:
|
|
|
|
obj['interfaces'].append(interface)
|
|
|
|
|
|
|
|
|
|
|
|
for i in splitted_line[3].split(','):
|
|
|
|
if obj['state'] == 'suspended':
|
|
|
|
obj['interfaces'].append(i.strip().replace('Et', 'ethernet'))
|
|
|
|
obj['state'] = 'suspend'
|
|
|
|
|
|
|
|
|
|
|
|
objs.append(obj)
|
|
|
|
objs.append(obj)
|
|
|
|
|
|
|
|
|
|
|
|