diff options
author | Steven Hardy <shardy@redhat.com> | 2015-01-22 12:17:44 +0000 |
---|---|---|
committer | Steven Hardy <shardy@redhat.com> | 2015-02-24 09:21:11 +0000 |
commit | afed9e751c9eb70ea696436e07a535fc7c15783d (patch) | |
tree | 059f74155bf867153016d1edb431bb5fe11c20b4 /os_net_config/impl_eni.py | |
parent | c86a76e13ea07005e31890695c220081b0ed816d (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_eni.py')
-rw-r--r-- | os_net_config/impl_eni.py | 29 |
1 files changed, 13 insertions, 16 deletions
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} |