aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/impl_ifcfg.py
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2014-08-11 15:59:51 -0400
committerDan Prince <dprince@redhat.com>2014-08-11 15:59:51 -0400
commit2da33853506c694684ced99675d6914053246b2a (patch)
tree6091799daa57cfca066285e40addfd4310296bab /os_net_config/impl_ifcfg.py
parent97f5eee7d135f462e82aa2c1ac9716971ad16ddc (diff)
Use --noop instead of --mock.
Updates the apply() function for each NetConfig object so that it now accepts noop instead. Also, the updated files are not returned (always instead of conditionally if mock was used).
Diffstat (limited to 'os_net_config/impl_ifcfg.py')
-rw-r--r--os_net_config/impl_ifcfg.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py
index 6b920ae..87cf3d5 100644
--- a/os_net_config/impl_ifcfg.py
+++ b/os_net_config/impl_ifcfg.py
@@ -162,9 +162,15 @@ class IfcfgNetConfig(os_net_config.NetConfig):
if bond.routes:
self._addRoutes(bond.name, bond.routes)
- def apply(self, mock=False):
- if not mock:
- logger.info('applying network configs...')
+ def apply(self, noop=False):
+ """Apply the network configuration.
+
+ :param noop: A boolean which indicates whether this is a no-op.
+ :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).
+ """
+ logger.info('applying network configs...')
restart_interfaces = []
restart_bridges = []
update_files = {}
@@ -176,7 +182,6 @@ class IfcfgNetConfig(os_net_config.NetConfig):
restart_interfaces.append(interface_name)
update_files[ifcfg_config_path(interface_name)] = iface_data
update_files[route_config_path(interface_name)] = route_data
- elif not mock:
logger.info('No changes required for interface: %s' %
interface_name)
@@ -187,14 +192,10 @@ class IfcfgNetConfig(os_net_config.NetConfig):
restart_bridges.append(bridge_name)
update_files[bridge_config_path(bridge_name)] = bridge_data
update_files[route_config_path(bridge_name)] = route_data
- elif not mock:
logger.info('No changes required for bridge: %s' % bridge_name)
- if mock:
- mock_str = ""
- for location, data in update_files.iteritems():
- mock_str += "%s:\n%s" % (location, data)
- return mock_str
+ if noop:
+ return update_files
for interface in restart_interfaces:
logger.info('running ifdown on interface: %s' % interface)
@@ -217,3 +218,5 @@ class IfcfgNetConfig(os_net_config.NetConfig):
for interface in restart_interfaces:
logger.info('running ifup on interface: %s' % interface)
processutils.execute('/sbin/ifup', interface)
+
+ return update_files