Browse Source

Add linkdelay option

Change-Id: Ica0a160ce7c8f781d37cd4da67e04cd03db7de94
Closes-Bug: 1842999
(cherry picked from commit 04f285ad02a2edf445bba7f740c9e5eb0b498a3b)
changes/82/694082/1
junbo Bob Fournier 6 months ago
parent
commit
2504f788bf
4 changed files with 25 additions and 2 deletions
  1. +3
    -0
      os_net_config/impl_ifcfg.py
  2. +5
    -2
      os_net_config/objects.py
  3. +2
    -0
      os_net_config/schema.yaml
  4. +15
    -0
      os_net_config/tests/test_impl_ifcfg.py

+ 3
- 0
os_net_config/impl_ifcfg.py 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"


+ 5
- 2
os_net_config/objects.py View File

@@ -457,7 +457,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 []
@@ -469,6 +470,7 @@ class Interface(_BaseOpts):
nm_controlled, onboot, domain)
self.ethtool_opts = ethtool_opts
self.hotplug = hotplug
self.linkdelay = linkdelay

@staticmethod
def from_json(json):
@@ -476,8 +478,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):


+ 2
- 0
os_net_config/schema.yaml 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


+ 15
- 0
os_net_config/tests/test_impl_ifcfg.py 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
@@ -659,6 +669,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)


Loading…
Cancel
Save