diff options
Diffstat (limited to 'os_net_config/__init__.py')
-rw-r--r-- | os_net_config/__init__.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/os_net_config/__init__.py b/os_net_config/__init__.py index faa5e92..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. @@ -95,6 +100,8 @@ class NetConfig(object): self.add_ovs_dpdk_port(obj) elif isinstance(obj, objects.OvsDpdkBond): self.add_ovs_dpdk_bond(obj) + elif isinstance(obj, objects.VppInterface): + self.add_vpp_interface(obj) def add_interface(self, interface): """Add an Interface object to the net config object. @@ -201,6 +208,13 @@ class NetConfig(object): """ raise NotImplementedError("add_ovs_dpdk_bond is not implemented.") + def add_vpp_interface(self, vpp_interface): + """Add a VppInterface object to the net config object. + + :param vpp_interface: The VppInterface object to add. + """ + raise NotImplementedError("add_vpp_interface is not implemented.") + def apply(self, cleanup=False): """Apply the network configuration. @@ -240,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) |