ifcfg: add VLAN=yes when needed
Add the VLAN=yes parameter if the interface name is in the foo.123 format. This is the behavior and Debian allow the same os-net-config configuration file to be consistent with Red Hat systems. See also: https://bugzilla.redhat.com/show_bug.cgi?id=1283812 Change-Id: Iab2a4861e2231b34899c379963abbef59cf73328 Closes-Bug: #1518449
This commit is contained in:
parent
f0c42a7cda
commit
f00d545041
@ -16,6 +16,7 @@
|
||||
|
||||
import glob
|
||||
import logging
|
||||
import re
|
||||
|
||||
import os_net_config
|
||||
from os_net_config import objects
|
||||
@ -83,6 +84,8 @@ class IfcfgNetConfig(os_net_config.NetConfig):
|
||||
data += "VLAN=yes\n"
|
||||
if base_opt.device:
|
||||
data += "PHYSDEV=%s\n" % base_opt.device
|
||||
elif re.match('\w+\.\d+$', base_opt.name):
|
||||
data += "VLAN=yes\n"
|
||||
if base_opt.ovs_port:
|
||||
data += "DEVICETYPE=ovs\n"
|
||||
if base_opt.bridge_name:
|
||||
|
@ -39,6 +39,15 @@ IPADDR=192.168.1.2
|
||||
NETMASK=255.255.255.0
|
||||
"""
|
||||
|
||||
_IFCFG_VLAN = """# This file is autogenerated by os-net-config
|
||||
DEVICE=em1.120
|
||||
ONBOOT=yes
|
||||
HOTPLUG=no
|
||||
NM_CONTROLLED=no
|
||||
VLAN=yes
|
||||
BOOTPROTO=none
|
||||
"""
|
||||
|
||||
_V4_IFCFG_MAPPED = _V4_IFCFG.replace('em1', 'nic1') + "HWADDR=a1:b2:c3:d4:e5\n"
|
||||
|
||||
_V4_IFCFG_MULTIPLE = _V4_IFCFG + """IPADDR1=192.168.1.3
|
||||
@ -199,6 +208,11 @@ class TestIfcfgNetConfig(base.TestCase):
|
||||
self.provider.add_interface(interface)
|
||||
self.assertEqual(_NO_IP, self.get_interface_config())
|
||||
|
||||
def test_add_base_interface_vlan(self):
|
||||
interface = objects.Interface('em1.120')
|
||||
self.provider.add_interface(interface)
|
||||
self.assertEqual(_IFCFG_VLAN, self.get_interface_config('em1.120'))
|
||||
|
||||
def test_add_ovs_interface(self):
|
||||
interface = objects.Interface('em1')
|
||||
interface.ovs_port = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user