From 433a0f3cbe59fd5da183245bf7e6dcd4af4b8c88 Mon Sep 17 00:00:00 2001 From: Brent Eagles Date: Mon, 7 Nov 2016 17:57:02 -0330 Subject: Add support for enabling hotplug on interfaces This patch adds support for enabling hotplugging on interfaces (disabled by default). This is useful for configuring SR-IOV root devices so that they "return" to the system when no longer used by a VM. Note: also updates an invalid value in the interface and ib_interface sample files. Partial-Bug: #1639901 Change-Id: Idfc17d6f20bb306271838895bc53f4b109dd664d --- os_net_config/objects.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'os_net_config/objects.py') diff --git a/os_net_config/objects.py b/os_net_config/objects.py index 8d52e73..741f304 100644 --- a/os_net_config/objects.py +++ b/os_net_config/objects.py @@ -287,7 +287,7 @@ class Interface(_BaseOpts): def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None, routes=None, mtu=None, primary=False, nic_mapping=None, persist_mapping=False, defroute=True, dhclient_args=None, - dns_servers=None, ethtool_opts=None): + dns_servers=None, ethtool_opts=None, hotplug=False): addresses = addresses or [] routes = routes or [] dns_servers = dns_servers or [] @@ -296,13 +296,16 @@ class Interface(_BaseOpts): persist_mapping, defroute, dhclient_args, dns_servers) self.ethtool_opts = ethtool_opts + self.hotplug = hotplug @staticmethod def from_json(json): name = _get_required_field(json, 'name', 'Interface') + hotplug = strutils.bool_from_string(str(json.get('hotplug', False))) opts = _BaseOpts.base_opts_from_json(json) ethtool_opts = json.get('ethtool_opts', None) - return Interface(name, *opts, ethtool_opts=ethtool_opts) + return Interface(name, *opts, ethtool_opts=ethtool_opts, + hotplug=hotplug) class Vlan(_BaseOpts): -- cgit 1.2.3-korg