diff options
Diffstat (limited to 'os_net_config')
-rw-r--r-- | os_net_config/impl_ifcfg.py | 6 | ||||
-rw-r--r-- | os_net_config/objects.py | 2 | ||||
-rw-r--r-- | os_net_config/tests/test_impl_ifcfg.py | 14 |
3 files changed, 21 insertions, 1 deletions
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index c4d6d93..7f8ad96 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -89,6 +89,9 @@ class IfcfgNetConfig(os_net_config.NetConfig): data += "VLAN=yes\n" if base_opt.device: data += "PHYSDEV=%s\n" % base_opt.device + else: + if base_opt.linux_bond_name: + data += "PHYSDEV=%s\n" % base_opt.linux_bond_name elif isinstance(base_opt, objects.IvsInterface): data += "TYPE=IVSIntPort\n" elif re.match('\w+\.\d+$', base_opt.name): @@ -163,7 +166,8 @@ class IfcfgNetConfig(os_net_config.NetConfig): members = [member.name for member in base_opt.members] self.member_names[base_opt.name] = members for member in members: - self.bond_slaves[member] = base_opt.name + if isinstance(member, objects.Interface): + self.bond_slaves[member] = base_opt.name if base_opt.bonding_options: data += "BONDING_OPTS=\"%s\"\n" % base_opt.bonding_options else: diff --git a/os_net_config/objects.py b/os_net_config/objects.py index 2b6d4bf..4f3e0d5 100644 --- a/os_net_config/objects.py +++ b/os_net_config/objects.py @@ -171,6 +171,7 @@ class _BaseOpts(object): self.bridge_name = None # internal self.linux_bridge_name = None # internal self.ivs_bridge_name = None # internal + self.linux_bond_name = None # internal self.ovs_port = False # internal self.primary_interface_name = None # internal @@ -515,6 +516,7 @@ class LinuxBond(_BaseOpts): self.members = members self.bonding_options = bonding_options for member in self.members: + member.linux_bond_name = name if member.primary: if self.primary_interface_name: msg = 'Only one primary interface allowed per bond.' diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index bf3ce7c..0390768 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -165,6 +165,11 @@ OVS_OPTIONS="tag=5" BOOTPROTO=none """ +_VLAN_LINUX_BRIDGE = _BASE_VLAN_OVS + """VLAN=yes +BRIDGE=br-ctlplane +BOOTPROTO=none +""" + _OVS_BOND_DHCP = """# This file is autogenerated by os-net-config DEVICE=bond0 @@ -417,6 +422,15 @@ class TestIfcfgNetConfig(base.TestCase): self.provider.add_bridge(bridge) self.assertEqual(_VLAN_OVS_BRIDGE, self.get_interface_config('vlan5')) + def test_add_linux_bridge_with_vlan(self): + vlan = objects.Vlan(None, 5) + bridge = objects.LinuxBridge('br-ctlplane', use_dhcp=True, + members=[vlan]) + self.provider.add_vlan(vlan) + self.provider.add_bridge(bridge) + self.assertEqual(_VLAN_LINUX_BRIDGE, + self.get_interface_config('vlan5')) + def test_ovs_bond(self): interface1 = objects.Interface('em1') interface2 = objects.Interface('em2') |