From 3b5e8789871e1722f8a5122236893730cf3d1751 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 21 Aug 2014 13:25:38 -0400 Subject: A vlan on an OVS bridge doesn't require a device Updates the object model so that a VLAN on top of a bridge (an OVS int port) doesn't require a physical device to be set in the object model. --- os_net_config/impl_eni.py | 5 +++-- os_net_config/impl_ifcfg.py | 3 ++- os_net_config/objects.py | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'os_net_config') diff --git a/os_net_config/impl_eni.py b/os_net_config/impl_eni.py index c40a4b0..944893e 100644 --- a/os_net_config/impl_eni.py +++ b/os_net_config/impl_eni.py @@ -89,8 +89,9 @@ class ENINetConfig(os_net_config.NetConfig): for i in interface.members: data += " %s" % i.name data += "\n" - for i in interface.members: - data += " pre-up ip addr flush dev %s\n" % i.name + for mem in interface.members: + if isinstance(mem, objects.Interface): + data += " pre-up ip addr flush dev %s\n" % mem.name if interface.primary_interface_name: mac = utils.interface_mac(interface.primary_interface_name) data += (" ovs_extra set bridge %s " diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index f603054..ab6bf4d 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -61,7 +61,8 @@ class IfcfgNetConfig(os_net_config.NetConfig): data += "HOTPLUG=no\n" if isinstance(base_opt, objects.Vlan): data += "VLAN=yes\n" - data += "PHYSDEV=%s\n" % base_opt.device + if base_opt.device: + data += "PHYSDEV=%s\n" % base_opt.device if base_opt.ovs_port: data += "DEVICETYPE=ovs\n" if base_opt.bridge_name: diff --git a/os_net_config/objects.py b/os_net_config/objects.py index b73122c..12b1c99 100644 --- a/os_net_config/objects.py +++ b/os_net_config/objects.py @@ -205,7 +205,8 @@ class Vlan(_BaseOpts): @staticmethod def from_json(json): - device = _get_required_field(json, 'device', 'Vlan') + # A vlan on an OVS bridge won't require a device (OVS Int Port) + device = json.get('device') vlan_id = _get_required_field(json, 'vlan_id', 'Vlan') opts = _BaseOpts.base_opts_from_json(json) return Vlan(device, vlan_id, *opts) -- cgit 1.2.3-korg