Skip to content

Commit

Permalink
Logging indicates when service starts and terminates
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Gary Kotton committed Oct 9, 2012
1 parent 94e4861 commit 15604ab
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions quantum/common/config.py
Expand Up @@ -118,6 +118,7 @@ def setup_logging(conf):

handler.setFormatter(formatter)
root_logger.addHandler(handler)
LOG.info("Logging enabled!")


def load_paste_app(app_name):
Expand Down
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions quantum/plugins/linuxbridge/lb_quantum_plugin.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 9 additions & 4 deletions quantum/plugins/openvswitch/agent/ovs_quantum_agent.py
Expand Up @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -803,7 +805,8 @@ def main():
enable_tunneling = cfg.CONF.OVS.enable_tunneling

if enable_tunneling and not local_ip:
LOG.error("Invalid local_ip. (%s)" % repr(local_ip))
LOG.error("Invalid local_ip. (%s). "
"Agent terminated!" % repr(local_ip))
sys.exit(1)

bridge_mappings = {}
Expand All @@ -816,14 +819,16 @@ 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,
root_helper, polling_interval,
reconnect_interval, rpc, enable_tunneling)

# Start everything.
LOG.info("Agent initialized successfully, now running... ")
plugin.daemon_loop(db_connection_url)

sys.exit(0)
Expand Down
12 changes: 8 additions & 4 deletions quantum/plugins/openvswitch/ovs_quantum_plugin.py
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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:
Expand All @@ -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)

Expand Down

0 comments on commit 15604ab

Please sign in to comment.