aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/impl_ifcfg.py
diff options
context:
space:
mode:
authorSteven Hardy <shardy@redhat.com>2015-01-22 12:17:44 +0000
committerSteven Hardy <shardy@redhat.com>2015-02-24 09:21:11 +0000
commitafed9e751c9eb70ea696436e07a535fc7c15783d (patch)
tree059f74155bf867153016d1edb431bb5fe11c20b4 /os_net_config/impl_ifcfg.py
parentc86a76e13ea07005e31890695c220081b0ed816d (diff)
Refactor noop to enable logging of disabled operations
Currently we only output the config file contents in noop mode, but it's very useful to see what would be done in terms of taking interfaces up and down, and especially what will be removed when --cleanup mode is specified So this refactors the operations skipped by noop into the base-class so we can conveniently log what they would do when --noop is selected. Change-Id: Ia9cfa9a05b2df02c165a2ff992765ab63e55ae6b
Diffstat (limited to 'os_net_config/impl_ifcfg.py')
-rw-r--r--os_net_config/impl_ifcfg.py37
1 files changed, 13 insertions, 24 deletions
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py
index 0c23630..56a0e47 100644
--- a/os_net_config/impl_ifcfg.py
+++ b/os_net_config/impl_ifcfg.py
@@ -16,16 +16,12 @@
import glob
import logging
-import os
import os_net_config
from os_net_config import objects
from os_net_config import utils
-from oslo_concurrency import processutils
-
-
logger = logging.getLogger(__name__)
@@ -258,40 +254,33 @@ class IfcfgNetConfig(os_net_config.NetConfig):
update_files[bridge_route_path] = route_data
logger.info('No changes required for bridge: %s' % bridge_name)
- if self.noop:
- return update_files
-
if cleanup:
for ifcfg_file in glob.iglob(cleanup_pattern()):
if ifcfg_file not in all_file_names:
interface_name = ifcfg_file[len(cleanup_pattern()) - 1:]
if interface_name != 'lo':
- logger.info('cleaning up interface: %s' %
- interface_name)
- processutils.execute('/sbin/ifdown', interface_name,
- check_exit_code=False)
- os.remove(ifcfg_file)
+ msg = 'cleaning up interface: %s' % interface_name
+ self.execute(msg, '/sbin/ifdown', interface_name,
+ check_exit_code=False)
+ self.remove_config(ifcfg_file)
for interface in restart_interfaces:
- logger.info('running ifdown on interface: %s' % interface)
- processutils.execute('/sbin/ifdown', interface,
- check_exit_code=False)
+ msg = 'running ifdown on interface: %s' % interface
+ self.execute(msg, '/sbin/ifdown', interface, check_exit_code=False)
for bridge in restart_bridges:
- logger.info('running ifdown on bridge: %s' % bridge)
- processutils.execute('/sbin/ifdown', bridge,
- check_exit_code=False)
+ msg = 'running ifdown on bridge: %s' % bridge
+ self.execute(msg, '/sbin/ifdown', bridge, check_exit_code=False)
for location, data in update_files.iteritems():
- logger.info('writing config file: %s' % location)
- utils.write_config(location, data)
+ self.write_config(location, data)
for bridge in restart_bridges:
- logger.info('running ifup on bridge: %s' % bridge)
- processutils.execute('/sbin/ifup', bridge)
+ msg = 'running ifup on bridge: %s' % bridge
+ self.execute(msg, '/sbin/ifup', bridge)
for interface in restart_interfaces:
- logger.info('running ifup on interface: %s' % interface)
- processutils.execute('/sbin/ifup', interface)
+ msg = 'running ifup on interface: %s' % interface
+ self.execute(msg, '/sbin/ifup', interface)
return update_files