summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2014-07-08 10:07:37 -0400
committerDan Prince <dprince@redhat.com>2014-07-08 10:07:37 -0400
commit958fc000c96772afa5755bc0516eb6e5aef2b526 (patch)
treed787c5aba5df4b2af0b78ef193a11549f96bd349
parent40bf150bac7d375a096f28125b9accb4390a1d05 (diff)
Add logging to the eni provider.
-rw-r--r--os_net_config/impl_eni.py24
-rw-r--r--os_net_config/impl_ifcfg.py9
2 files changed, 28 insertions, 5 deletions
diff --git a/os_net_config/impl_eni.py b/os_net_config/impl_eni.py
index 95658f8..f652c91 100644
--- a/os_net_config/impl_eni.py
+++ b/os_net_config/impl_eni.py
@@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import logging
+
import netaddr
import os_net_config
from os_net_config import objects
@@ -22,6 +24,9 @@ from os_net_config import utils
from os_net_config.openstack.common import processutils
+logger = logging.getLogger(__name__)
+
+
# TODO(?): should move to interfaces.d
def _network_config_path():
return "/etc/network/interfaces"
@@ -38,6 +43,7 @@ class ENINetConfig(os_net_config.NetConfig):
self.interfaces = {}
self.routes = {}
self.bridges = {}
+ logger.info('Ifcfg net config provider created.')
def _addCommon(self, interface, static_addr=None):
@@ -118,27 +124,31 @@ class ENINetConfig(os_net_config.NetConfig):
return data
def addInterface(self, interface):
+ logger.info('adding interface: %s' % interface.name)
data = self._addCommon(interface)
-
+ logger.debug('interface data: %s' % data)
self.interfaces[interface.name] = data
if interface.routes:
self._addRoutes(interface.name, interface.routes)
def addBridge(self, bridge):
+ logger.info('adding bridge: %s' % bridge.name)
data = self._addCommon(bridge)
-
+ logger.debug('bridge data: %s' % data)
self.bridges[bridge.name] = data
if bridge.routes:
self._addRoutes(bridge.name, bridge.routes)
def addVlan(self, vlan):
+ logger.info('adding vlan: %s' % vlan.name)
data = self._addCommon(vlan)
-
+ logger.debug('vlan data: %s' % data)
self.interfaces[vlan.name] = data
if vlan.routes:
self._addRoutes(vlan.name, vlan.routes)
def _addRoutes(self, interface_name, routes=[]):
+ logger.info('adding custom route for interface: %s' % interface_name)
data = ""
for route in routes:
rt = netaddr.IPNetwork(route.ip_netmask)
@@ -147,6 +157,7 @@ class ENINetConfig(os_net_config.NetConfig):
data += "down route del -net %s netmask %s gw %s\n" % (
str(rt.ip), str(rt.netmask), route.next_hop)
self.routes[interface_name] = data
+ logger.debug('route data: %s' % self.routes[interface_name])
def apply(self):
new_config = ""
@@ -165,17 +176,24 @@ class ENINetConfig(os_net_config.NetConfig):
if (utils.diff(_network_config_path(), 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)
for bridge in self.bridges.keys():
+ logger.info('running ifdown on bridge: %s' % bridge)
processutils.execute('/sbin/ifdown', bridge,
check_exit_code=False)
+ logger.info('writing config file')
utils.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)
for interface in self.interfaces.keys():
+ logger.info('running ifup on interface: %s' % interface)
processutils.execute('/sbin/ifup', interface)
+ else:
+ logger.info('No interface changes are required.')
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py
index ff6f6e5..271c9f5 100644
--- a/os_net_config/impl_ifcfg.py
+++ b/os_net_config/impl_ifcfg.py
@@ -175,6 +175,9 @@ 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
+ else:
+ logger.info('No changes required for interface: %s' %
+ interface_name)
for bridge_name, bridge_data in self.bridges.iteritems():
route_data = self.routes.get(bridge_name)
@@ -183,6 +186,8 @@ 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
+ else:
+ logger.info('No changes required for bridge: %s' % bridge_name)
for interface in restart_interfaces:
logger.info('running ifdown on interface: %s' % interface)
@@ -190,7 +195,7 @@ class IfcfgNetConfig(os_net_config.NetConfig):
check_exit_code=False)
for bridge in restart_bridges:
- logger.info('running ifdown on bridge: %s' % interface)
+ logger.info('running ifdown on bridge: %s' % bridge)
processutils.execute('/sbin/ifdown', bridge,
check_exit_code=False)
@@ -199,7 +204,7 @@ class IfcfgNetConfig(os_net_config.NetConfig):
utils.write_config(location, data)
for bridge in restart_bridges:
- logger.info('running ifup on bridge: %s' % interface)
+ logger.info('running ifup on bridge: %s' % bridge)
processutils.execute('/sbin/ifup', bridge)
for interface in restart_interfaces: