summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Wendlandt <dan@nicira.com>2011-08-18 09:50:24 -0700
committerDan Wendlandt <dan@nicira.com>2011-08-18 09:50:24 -0700
commit1ef677a2eac6129aa3847aa10996f4357ec72a48 (patch)
tree533c51d62f11776c53583e1ee9e3429a4eed3b84
parentb7019a57c416f7a14f8e8229776a18c28c109d38 (diff)
dhcpbridge: add better error if NETWORK_ID is not set, convert locals() to static dict
-rwxr-xr-xbin/nova-dhcpbridge12
1 files changed, 10 insertions, 2 deletions
diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge
index afafca548..1c9ae951e 100755
--- a/bin/nova-dhcpbridge
+++ b/bin/nova-dhcpbridge
@@ -113,11 +113,19 @@ def main():
if action in ['add', 'del', 'old']:
mac = argv[2]
ip = argv[3]
- msg = _("Called %(action)s for mac %(mac)s with ip %(ip)s") % locals()
+ msg = _("Called '%(action)s' for mac '%(mac)s' with ip '%(ip)s'") % \
+ {"action": action,
+ "mac": mac,
+ "ip": ip}
LOG.debug(msg)
globals()[action + '_lease'](mac, ip)
else:
- network_id = int(os.environ.get('NETWORK_ID'))
+ try:
+ network_id = int(os.environ.get('NETWORK_ID'))
+ except TypeError:
+ LOG.error(_("Environment variable 'NETWORK_ID' must be set."))
+ sys.exit(1)
+
print init_leases(network_id)
if __name__ == "__main__":