summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/db/sqlalchemy/api.py1
-rw-r--r--nova/network/linux_net.py11
2 files changed, 7 insertions, 5 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index cc496e558..4cc086006 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -437,6 +437,7 @@ def network_get(_context, network_id):
def network_get_associated_fixed_ips(_context, network_id):
session = get_session()
return session.query(models.FixedIp
+ ).options(joinedload_all('instance')
).filter_by(network_id=network_id
).filter(models.FixedIp.instance_id != None
).filter_by(deleted=False
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index 41aeb5da7..621ae54ea 100644
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -132,8 +132,9 @@ def ensure_bridge(bridge, interface, net_attrs=None):
def get_dhcp_hosts(context, network_id):
"""Get a string containing a network's hosts config in dnsmasq format"""
hosts = []
- for fixed_ip in db.network_get_associated_fixed_ips(context, network_id):
- hosts.append(_host_dhcp(fixed_ip['str_id']))
+ for fixed_ip_ref in db.network_get_associated_fixed_ips(context,
+ network_id):
+ hosts.append(_host_dhcp(fixed_ip_ref))
return '\n'.join(hosts)
@@ -171,12 +172,12 @@ def update_dhcp(context, network_id):
_execute(command, addl_env=env)
-def _host_dhcp(address):
+def _host_dhcp(fixed_ip_ref):
"""Return a host string for an address"""
- instance_ref = db.fixed_ip_get_instance(None, address)
+ instance_ref = fixed_ip_ref['instance']
return "%s,%s.novalocal,%s" % (instance_ref['mac_address'],
instance_ref['hostname'],
- address)
+ fixed_ip_ref['str_id'])
def _execute(cmd, *args, **kwargs):