Merge "Add linkdelay option"

This commit is contained in:
Zuul 2019-09-20 13:06:14 +00:00 committed by Gerrit Code Review
commit 2ec6d366ee
4 changed files with 25 additions and 2 deletions

View File

@ -376,6 +376,9 @@ class IfcfgNetConfig(os_net_config.NetConfig):
data += "TYPE=Infiniband\n"
elif re.match('\w+\.\d+$', base_opt.name):
data += "VLAN=yes\n"
elif isinstance(base_opt, objects.Interface):
if base_opt.linkdelay:
data += "LINKDELAY=%s\n" % base_opt.linkdelay
if base_opt.linux_bond_name:
data += "MASTER=%s\n" % base_opt.linux_bond_name
data += "SLAVE=yes\n"

View File

@ -463,7 +463,8 @@ class Interface(_BaseOpts):
routes=None, rules=None, mtu=None, primary=False,
nic_mapping=None, persist_mapping=False, defroute=True,
dhclient_args=None, dns_servers=None, nm_controlled=False,
onboot=True, domain=None, ethtool_opts=None, hotplug=False):
onboot=True, domain=None, ethtool_opts=None, hotplug=False,
linkdelay=None):
addresses = addresses or []
routes = routes or []
rules = rules or []
@ -475,6 +476,7 @@ class Interface(_BaseOpts):
nm_controlled, onboot, domain)
self.ethtool_opts = ethtool_opts
self.hotplug = hotplug
self.linkdelay = linkdelay
@staticmethod
def from_json(json):
@ -482,8 +484,9 @@ class Interface(_BaseOpts):
hotplug = strutils.bool_from_string(str(json.get('hotplug', False)))
opts = _BaseOpts.base_opts_from_json(json)
ethtool_opts = json.get('ethtool_opts', None)
linkdelay = json.get('linkdelay', None)
return Interface(name, *opts, ethtool_opts=ethtool_opts,
hotplug=hotplug)
hotplug=hotplug, linkdelay=linkdelay)
class Vlan(_BaseOpts):

View File

@ -291,6 +291,8 @@ definitions:
$ref: "#/definitions/bool_or_param"
domain:
$ref: "#/definitions/list_of_domain_name_string_or_domain_name_string"
linkdelay:
$ref: "#/definitions/int_or_param"
required:
- type
- name

View File

@ -63,6 +63,16 @@ PEERDNS=no
BOOTPROTO=none
"""
_LINKDELAY = """# This file is autogenerated by os-net-config
DEVICE=em1
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
PEERDNS=no
LINKDELAY=10
BOOTPROTO=none
"""
_NO_IP = _BASE_IFCFG + "BOOTPROTO=none\n"
_V4_IFCFG = _BASE_IFCFG + """BOOTPROTO=static
@ -678,6 +688,11 @@ class TestIfcfgNetConfig(base.TestCase):
self.provider.add_interface(interface)
self.assertEqual(_ONBOOT, self.get_interface_config())
def test_add_interface_with_linkdelay(self):
interface = objects.Interface('em1', linkdelay=10)
self.provider.add_interface(interface)
self.assertEqual(_LINKDELAY, self.get_interface_config())
def test_add_base_interface_vlan(self):
interface = objects.Interface('em1.120')
self.provider.add_interface(interface)