dhcpbridge: add better error if NETWORK_ID is not set, convert locals() to static dict

This commit is contained in:
Dan Wendlandt
2011-08-18 09:50:24 -07:00
parent 8ce5f15484
commit 14c1209593

View File

@@ -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__":