From 607f486ef5483303bcb9c458b54bbaae6402150d Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Mon, 8 Oct 2012 02:44:50 +0000 Subject: [PATCH] Logging indicates when service starts and terminates Fixes bug 1064070 The patch adds a log entry indication that the service has started. In addition to this if there is an "exit" statement in the code, then the log message will indicate that the service has been terminated. Change-Id: Idb6cff4b85d26331df2c6e14aa0680e82b4e2cd7 --- quantum/common/config.py | 1 + .../linuxbridge/agent/linuxbridge_quantum_agent.py | 6 ++++-- quantum/plugins/linuxbridge/lb_quantum_plugin.py | 6 ++++-- .../plugins/openvswitch/agent/ovs_quantum_agent.py | 10 +++++++--- quantum/plugins/openvswitch/ovs_quantum_plugin.py | 12 ++++++++---- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/quantum/common/config.py b/quantum/common/config.py index 1ca191aa99d..5db4ddb1bd5 100644 --- a/quantum/common/config.py +++ b/quantum/common/config.py @@ -114,6 +114,7 @@ def setup_logging(conf): handler.setFormatter(formatter) root_logger.addHandler(handler) + LOG.info("Logging enabled!") def load_paste_app(app_name): diff --git a/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py b/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py index 2cb25c32dda..9cf021916e0 100755 --- a/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py +++ b/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py @@ -636,7 +636,8 @@ def setup_rpc(self, physical_interfaces): if devices: mac = utils.get_interface_mac(devices[0].name) else: - LOG.error("Unable to obtain MAC of any device for agent_id") + LOG.error("Unable to obtain MAC address for unique ID. " + "Agent terminated!") exit(1) self.agent_id = '%s%s' % ('lb', (mac.replace(":", ""))) LOG.info("RPC agent_id: %s" % self.agent_id) @@ -800,7 +801,8 @@ def main(): LOG.debug("physical network %s mapped to physical interface %s" % (physical_network, physical_interface)) except ValueError as ex: - LOG.error("Invalid physical interface mapping: \'%s\' - %s" % + LOG.error("Invalid physical interface mapping: %s - %s. " + "Agent terminated!" % (mapping, ex)) sys.exit(1) diff --git a/quantum/plugins/linuxbridge/lb_quantum_plugin.py b/quantum/plugins/linuxbridge/lb_quantum_plugin.py index 5aeb687d6cb..edcb668419f 100644 --- a/quantum/plugins/linuxbridge/lb_quantum_plugin.py +++ b/quantum/plugins/linuxbridge/lb_quantum_plugin.py @@ -163,7 +163,8 @@ def __init__(self): if self.tenant_network_type not in [constants.TYPE_LOCAL, constants.TYPE_VLAN, constants.TYPE_NONE]: - LOG.error("Invalid tenant_network_type: %s" % + LOG.error("Invalid tenant_network_type: %s. " + "Service terminated!" % self.tenant_network_type) sys.exit(1) self.agent_rpc = cfg.CONF.AGENT.rpc @@ -194,7 +195,8 @@ def _parse_network_vlan_ranges(self): int(vlan_min), int(vlan_max)) except ValueError as ex: - LOG.error("Invalid network VLAN range: \'%s\' - %s" % + LOG.error("Invalid network VLAN range: '%s' - %s. " + "Service terminated!" % (entry, ex)) sys.exit(1) else: diff --git a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py index e82ec9eede9..830321d9ca5 100755 --- a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py +++ b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py @@ -452,7 +452,8 @@ def setup_tunnel_br(self, tun_br): if int(self.patch_tun_ofport) < 0 or int(self.patch_int_ofport) < 0: LOG.error("Failed to create OVS patch port. Cannot have tunneling " "enabled on this agent, since this version of OVS does " - "not support tunnels or patch ports.") + "not support tunnels or patch ports. " + "Agent terminated!") exit(1) self.tun_br.remove_all_flows() self.tun_br.add_flow(priority=1, actions="drop") @@ -471,7 +472,8 @@ def setup_physical_bridges(self, bridge_mappings): for physical_network, bridge in bridge_mappings.iteritems(): # setup physical bridge if not ip_lib.device_exists(bridge, self.root_helper): - LOG.error("Bridge %s for physical network %s does not exist", + LOG.error("Bridge %s for physical network %s does not exist. " + "Agent terminated!", bridge, physical_network) sys.exit(1) br = ovs_lib.OVSBridge(bridge, self.root_helper) @@ -816,7 +818,8 @@ def main(): LOG.info("Physical network %s mapped to bridge %s", physical_network, bridge) except ValueError as ex: - LOG.error("Invalid bridge mapping: \'%s\' - %s", mapping, ex) + LOG.error("Invalid bridge mapping: %s - %s. " + "Agent terminated!", mapping, ex) sys.exit(1) plugin = OVSQuantumAgent(integ_br, tun_br, local_ip, bridge_mappings, @@ -824,6 +827,7 @@ def main(): reconnect_interval, rpc, enable_tunneling) # Start everything. + LOG.info("Agent initialized successfully, now running... ") plugin.daemon_loop(db_connection_url) sys.exit(0) diff --git a/quantum/plugins/openvswitch/ovs_quantum_plugin.py b/quantum/plugins/openvswitch/ovs_quantum_plugin.py index 01601717b21..5c3ca5a9999 100644 --- a/quantum/plugins/openvswitch/ovs_quantum_plugin.py +++ b/quantum/plugins/openvswitch/ovs_quantum_plugin.py @@ -200,7 +200,8 @@ def __init__(self, configfile=None): constants.TYPE_VLAN, constants.TYPE_GRE, constants.TYPE_NONE]: - LOG.error("Invalid tenant_network_type: %s", + LOG.error("Invalid tenant_network_type: %s. " + "Agent terminated!", self.tenant_network_type) sys.exit(1) self.enable_tunneling = cfg.CONF.OVS.enable_tunneling @@ -209,7 +210,8 @@ def __init__(self, configfile=None): self._parse_tunnel_id_ranges() ovs_db_v2.sync_tunnel_allocations(self.tunnel_id_ranges) elif self.tenant_network_type == constants.TYPE_GRE: - LOG.error("Tunneling disabled but tenant_network_type is 'gre'") + LOG.error("Tunneling disabled but tenant_network_type is 'gre'. " + "Agent terminated!") sys.exit(1) self.agent_rpc = cfg.CONF.AGENT.rpc self.setup_rpc() @@ -239,7 +241,8 @@ def _parse_network_vlan_ranges(self): int(vlan_min), int(vlan_max)) except ValueError as ex: - LOG.error("Invalid network VLAN range: \'%s\' - %s", + LOG.error("Invalid network VLAN range: '%s' - %s. " + "Agent terminated!", entry, ex) sys.exit(1) else: @@ -261,7 +264,8 @@ def _parse_tunnel_id_ranges(self): tun_min, tun_max = entry.split(':') self.tunnel_id_ranges.append((int(tun_min), int(tun_max))) except ValueError as ex: - LOG.error("Invalid tunnel ID range: \'%s\' - %s", entry, ex) + LOG.error("Invalid tunnel ID range: '%s' - %s. " + "Agent terminated!", entry, ex) sys.exit(1) LOG.info("Tunnel ID ranges: %s", self.tunnel_id_ranges)