From 6ab45b2c76eacafe3799433f181f3dcfac64dd42 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Mota Date: Fri, 30 Sep 2016 13:40:01 +0200 Subject: [PATCH] Allow management of vlans when specifying mac In the case of ipv4_interface_mac being used, it was not following the vlan_id parameter. Add that possibility of configuration as well. Change-Id: I1479e464ce3c53544bc29c609a368f84cbaae2ef --- playbooks/library/network_metadata.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/playbooks/library/network_metadata.py b/playbooks/library/network_metadata.py index bbe1cb6bb..f68aed16b 100644 --- a/playbooks/library/network_metadata.py +++ b/playbooks/library/network_metadata.py @@ -45,6 +45,19 @@ def main(): networks = [] if module.params['ipv4_interface_mac']: + nic_id = module.params['ipv4_interface_mac'] + + if module.params['vlan_id']: + nic_id = 'vlan-%s' % module.params['ipv4_interface_mac'] + + links.append({ + 'id': nic_id, + 'type': 'vlan', + 'vlan_id': module.params['vlan_id'], + 'vlan_link': module.params['ipv4_interface_mac'], + 'vlan_mac_address': module.params['ipv4_interface_mac'], + }) + links.append({ 'id': module.params['ipv4_interface_mac'], 'type': 'phy', @@ -55,8 +68,8 @@ def main(): for nic in module.params['nics']: if nic['mac'] == module.params['ipv4_interface_mac']: networks.append({ - 'id': 'ipv4-%s' % nic['mac'], - 'link': nic['mac'], + 'id': 'ipv4-%s' % nic_id, + 'link': nic_id, 'type': 'ipv4', 'ip_address': module.params['ipv4_address'], 'netmask': module.params['ipv4_subnet_mask'],