From 6ba3ae42963070e8ccadacb8e5d2c4133b776736 Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Mon, 24 Aug 2015 21:25:26 +0000 Subject: [PATCH] Support setting vlan in config drive Config-drive now supports specifying vlan interfaces. Support setting a vlan when vlan_id is set. Change-Id: Idb5634fa3959a8ac4b4f10ee4a087bd57122e56d --- playbooks/library/network_metadata.py | 21 +++++++++++++++---- .../tasks/main.yml | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/playbooks/library/network_metadata.py b/playbooks/library/network_metadata.py index 355dd79ad..2c912bcb1 100644 --- a/playbooks/library/network_metadata.py +++ b/playbooks/library/network_metadata.py @@ -31,6 +31,7 @@ def main(): ipv4_interface_mac=dict(required=False), ipv4_nameserver=dict(required=False), ipv4_subnet_mask=dict(required=False), + vlan_id=dict(required=False), network_mtu=dict(required=False), nics=dict(required=False), node_network_info=dict(required=False) @@ -70,6 +71,18 @@ def main(): }) else: for i, nic in enumerate(module.params['nics']): + nic_id = nic['mac'] + if module.params['vlan_id']: + nic_id = 'vlan-%s' % nic['mac'] + + links.append({ + 'id': nic_id, + 'type': 'vlan', + 'vlan_id': module.params['vlan_id'], + 'vlan_link': nic['mac'], + 'vlan_mac_address': nic['mac'] + }) + links.append({ 'id': nic['mac'], 'type': 'phy', @@ -79,8 +92,8 @@ def main(): if i == 0: 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'], @@ -95,8 +108,8 @@ def main(): }) else: networks.append({ - 'id': 'ipv4-dhcp-%s' % nic['mac'], - 'link': nic['mac'], + 'id': 'ipv4-dhcp-%s' % nic_id, + 'link': nic_id, 'type': 'ipv4_dhcp', }) diff --git a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml index b2ff3a749..6ff9e613e 100644 --- a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml @@ -33,6 +33,7 @@ ipv4_interface_mac: "{{ ipv4_interface_mac | default('') }}" ipv4_nameserver: "{{ ipv4_nameserver }}" ipv4_subnet_mask: "{{ ipv4_subnet_mask }}" + vlan_id: "{{ vlan_id | default('') }}" network_mtu: "{{ network_mtu }}" nics: "{{ nics }}" node_network_info: "{{ node_network_info | default('') }}"