From afed9e751c9eb70ea696436e07a535fc7c15783d Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Thu, 22 Jan 2015 12:17:44 +0000 Subject: 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 --- os_net_config/impl_eni.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'os_net_config/impl_eni.py') diff --git a/os_net_config/impl_eni.py b/os_net_config/impl_eni.py index 93aa7db..880c4e4 100644 --- a/os_net_config/impl_eni.py +++ b/os_net_config/impl_eni.py @@ -21,8 +21,6 @@ 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__) @@ -212,27 +210,26 @@ class ENINetConfig(os_net_config.NetConfig): new_config += iface_data if (utils.diff(_network_config_path(), new_config)): - if self.noop: - return {"/etc/network/interfaces": new_config} for interface in self.interfaces.keys(): - 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 self.bridges.keys(): - 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) - logger.info('writing config file') - utils.write_config(_network_config_path(), new_config) + self.write_config(_network_config_path(), new_config) for bridge in self.bridges.keys(): - 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 self.interfaces.keys(): - 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) else: logger.info('No interface changes are required.') + + return {"/etc/network/interfaces": new_config} -- cgit 1.2.3-korg