Cherry pick 35568 (#38347)

* eos_vlan: Modified logic to allow for more than 6 interfaces to be assigned to … (#35568)

* Modified logic to allow for more than 6 interfaces to be assigned to a vlan

* arista output to json.  removing logic for string size.

(cherry picked from commit 99627ab99d)

* Add changelog fragment
This commit is contained in:
Ricardo Carrillo Cruz 2018-04-10 18:57:56 +02:00 committed by GitHub
parent 7f55954cc1
commit bbcb7d9118
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- eos_vlan - fixed eos_vlan not working when having more than 6 interfaces (https://github.com/ansible/ansible/pull/38347)

View file

@ -213,25 +213,23 @@ def map_obj_to_commands(updates, module):
def map_config_to_obj(module):
objs = []
output = run_commands(module, ['show vlan'])
lines = output[0].strip().splitlines()[2:]
vlans = run_commands(module, ['show vlan conf | json'])
for l in lines:
splitted_line = re.split(r'\s{2,}', l.strip())
for vlan in vlans[0]['vlans']:
obj = {}
obj['vlan_id'] = splitted_line[0]
obj['name'] = splitted_line[1]
obj['state'] = splitted_line[2]
obj['vlan_id'] = vlan
obj['name'] = vlans[0]['vlans'][vlan]['name']
obj['state'] = vlans[0]['vlans'][vlan]['status']
obj['interfaces'] = []
interfaces = vlans[0]['vlans'][vlan]
for interface in interfaces['interfaces']:
obj['interfaces'].append(interface)
if obj['state'] == 'suspended':
obj['state'] = 'suspend'
obj['interfaces'] = []
if len(splitted_line) > 3:
for i in splitted_line[3].split(','):
obj['interfaces'].append(i.strip().replace('Et', 'ethernet'))
objs.append(obj)
return objs