aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/impl_ifcfg.py
diff options
context:
space:
mode:
authorSteven Hardy <shardy@redhat.com>2015-01-26 18:44:21 +0000
committerSteven Hardy <shardy@redhat.com>2015-03-05 13:11:09 +0000
commit3304fa066d1dae93df0f597c1709c955e3857a5d (patch)
treeb5347080f433cdc99b0b8e1f386b7bb5437ae09f /os_net_config/impl_ifcfg.py
parent4cf8c1a0fd3c029ea81092a8901d786bfce77735 (diff)
Add a --no-activate option to disable device up/down actions
Allows you to only install the config, but not take interfaces down/up. Useful if you wish to defer activation of a new config until a later time (e.g reboot). Change-Id: I42f3195e1d3d5d3b9d1c9dbb1f7cf1364503cbd3
Diffstat (limited to 'os_net_config/impl_ifcfg.py')
-rw-r--r--os_net_config/impl_ifcfg.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py
index 100edeb..78433d8 100644
--- a/os_net_config/impl_ifcfg.py
+++ b/os_net_config/impl_ifcfg.py
@@ -208,12 +208,16 @@ class IfcfgNetConfig(os_net_config.NetConfig):
if bond.routes:
self._add_routes(bond.name, bond.routes)
- def apply(self, cleanup=False):
+ def apply(self, cleanup=False, activate=True):
"""Apply the network configuration.
:param cleanup: A boolean which indicates whether any undefined
(existing but not present in the object model) interface
should be disabled and deleted.
+ :param activate: A boolean which indicates if the config should
+ be activated by stopping/starting interfaces
+ NOTE: if cleanup is specified we will deactivate interfaces even
+ if activate is false
:returns: a dict of the format: filename/data which contains info
for each file that was changed (or would be changed if in --noop
mode).
@@ -264,19 +268,21 @@ class IfcfgNetConfig(os_net_config.NetConfig):
self.ifdown(interface_name)
self.remove_config(ifcfg_file)
- for interface in restart_interfaces:
- self.ifdown(interface)
+ if activate:
+ for interface in restart_interfaces:
+ self.ifdown(interface)
- for bridge in restart_bridges:
- self.ifdown(bridge, iftype='bridge')
+ for bridge in restart_bridges:
+ self.ifdown(bridge, iftype='bridge')
for location, data in update_files.iteritems():
self.write_config(location, data)
- for bridge in restart_bridges:
- self.ifup(bridge, iftype='bridge')
+ if activate:
+ for bridge in restart_bridges:
+ self.ifup(bridge, iftype='bridge')
- for interface in restart_interfaces:
- self.ifup(interface)
+ for interface in restart_interfaces:
+ self.ifup(interface)
return update_files