Browse Source

Handle empty trunk binding

In the case where a trunk had no subports assigned, the
trunked_vlans array was empty, evaluating to false which
meant nothing would be passed through to the playbook.

It would then read a default value of null, which isn't
iterable so templating would fail.

Change-Id: If084a20e29de6c82042eb8718005edb01dcf7c31
tags/0.3.2^0
michaeltchapman 2 months ago
parent
commit
9b23dc9f1c
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      networking_ansible/ansible_networking.py

+ 4
- 2
networking_ansible/ansible_networking.py View File

@@ -19,6 +19,7 @@ from oslo_log import log as logging
from networking_ansible import exceptions

LOG = logging.getLogger(__name__)
TRUNK_TASK = 'conf_trunk_port'


class AnsibleNetworking(object):
@@ -77,7 +78,8 @@ class AnsibleNetworking(object):
}
}]
}]
if trunked_vlans:

if task == TRUNK_TASK:
playbook[0]['tasks'][0]['vars']['trunked_vlans'] = trunked_vlans
if switch_port:
playbook[0]['tasks'][0]['vars']['port_name'] = switch_port
@@ -171,7 +173,7 @@ class AnsibleNetworking(object):
:param trunked_vlans: A list of VLAN IDs to add to the port in
addition to the default VLAN.
"""
return self._run_task('conf_trunk_port',
return self._run_task(TRUNK_TASK,
hostname, vlan_id,
switch_port=port,
trunked_vlans=trunked_vlans)

Loading…
Cancel
Save