diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index 4b8983fd..141aa6d9 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -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" diff --git a/os_net_config/objects.py b/os_net_config/objects.py index 6ac64573..d3217b05 100644 --- a/os_net_config/objects.py +++ b/os_net_config/objects.py @@ -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): diff --git a/os_net_config/schema.yaml b/os_net_config/schema.yaml index e6431cdc..6bb7ac63 100644 --- a/os_net_config/schema.yaml +++ b/os_net_config/schema.yaml @@ -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 diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index 347b672d..ca07a99d 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -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)