aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/__init__.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-27 02:25:14 +0000
committerGerrit Code Review <review@openstack.org>2017-06-27 02:25:14 +0000
commit03d3a5dea1b70c62d585dd6de5e3f9c04345e58b (patch)
tree7e22874692c56825d4d8a85534e4740b34495562 /os_net_config/__init__.py
parent187c1e66d4341e6c1fad308ca4d17d4d5026f61a (diff)
parent5c840c4941d8401ee3c2d15c9a6cfb4f6a074deb (diff)
Merge "Continue bringing up interfaces even if one fails"
Diffstat (limited to 'os_net_config/__init__.py')
-rw-r--r--os_net_config/__init__.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/os_net_config/__init__.py b/os_net_config/__init__.py
index cb56059..609d5dc 100644
--- a/os_net_config/__init__.py
+++ b/os_net_config/__init__.py
@@ -30,6 +30,10 @@ class NotImplemented(Exception):
pass
+class ConfigurationError(Exception):
+ pass
+
+
class NetConfig(object):
"""Common network config methods class."""
@@ -37,6 +41,7 @@ class NetConfig(object):
self.noop = noop
self.log_prefix = "NOOP: " if noop else ""
self.root_dir = root_dir
+ self.errors = []
def add_object(self, obj):
"""Convenience method to add any type of object to the network config.
@@ -249,8 +254,20 @@ class NetConfig(object):
self.execute(msg, '/sbin/ifdown', interface, check_exit_code=False)
def ifup(self, interface, iftype='interface'):
+ """Run 'ifup' on the specified interface
+
+ If a failure occurs when bringing up the interface it will be saved
+ to self.errors for later handling. This allows callers to continue
+ trying to bring up interfaces even if one fails.
+
+ :param interface: The name of the interface to be started.
+ :param iftype: The type of the interface.
+ """
msg = 'running ifup on %s: %s' % (iftype, interface)
- self.execute(msg, '/sbin/ifup', interface)
+ try:
+ self.execute(msg, '/sbin/ifup', interface)
+ except processutils.ProcessExecutionError as e:
+ self.errors.append(e)
def ifrename(self, oldname, newname):
msg = 'renaming %s to %s: ' % (oldname, newname)