Quantum dhcp crashes if no networks exist

Fixes bug 1043583

Change-Id: Ibdfeb98c094b80ea63e79b23f14811e00525d96b
This commit is contained in:
Aaron Rosen 2012-08-31 15:34:49 -07:00
parent 76ba706f91
commit affa613883

View File

@ -435,11 +435,15 @@ class DhcpLeaseRelay(object):
def __init__(self, lease_update_callback):
self.callback = lease_update_callback
try:
os.unlink(cfg.CONF.dhcp_lease_relay_socket)
except OSError:
if os.path.exists(cfg.CONF.dhcp_lease_relay_socket):
raise
dirname = os.path.dirname(cfg.CONF.dhcp_lease_relay_socket)
if os.path.isdir(dirname):
try:
os.unlink(cfg.CONF.dhcp_lease_relay_socket)
except OSError:
if os.path.exists(cfg.CONF.dhcp_lease_relay_socket):
raise
else:
os.makedirs(dirname, 0755)
def _validate_field(self, value, regex):
"""Validate value against a regular expression and return if valid."""