summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-09-09 10:43:19 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-09-09 10:43:19 -0700
commit9165579a501cf9e248ac5d2d43a80f4abbb58365 (patch)
treea6c7551b638be0e95c8c7882970d2a2424b04aca /nova
parent1f5524f64a09502a1d225001f4c5d3039551fa07 (diff)
remove extraneous get_host calls that were requiring an extra db trip
Diffstat (limited to 'nova')
-rw-r--r--nova/db/api.py15
-rw-r--r--nova/db/sqlalchemy/api.py15
-rw-r--r--nova/endpoint/cloud.py12
3 files changed, 6 insertions, 36 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index 59313b0af..0cab7db8e 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -220,11 +220,6 @@ def instance_get_by_str(context, str_id):
return IMPL.instance_get_by_str(context, str_id)
-def instance_get_host(context, instance_id):
- """Get the host that the instance is running on."""
- return IMPL.instance_get_host(context, instance_id)
-
-
def instance_is_vpn(context, instance_id):
"""True if instance is a vpn."""
return IMPL.instance_is_vpn(context, instance_id)
@@ -298,11 +293,6 @@ def network_get_by_bridge(context, bridge):
return IMPL.network_get_by_bridge(context, bridge)
-def network_get_host(context, network_id):
- """Get host assigned to network or raise"""
- return IMPL.network_get_host(context, network_id)
-
-
def network_get_index(context, network_id):
"""Get non-conflicting index for network"""
return IMPL.network_get_index(context, network_id)
@@ -424,11 +414,6 @@ def volume_get_by_str(context, str_id):
return IMPL.volume_get_by_str(context, str_id)
-def volume_get_host(context, volume_id):
- """Get the host that the volume is running on."""
- return IMPL.volume_get_host(context, volume_id)
-
-
def volume_get_shelf_and_blade(context, volume_id):
"""Get the shelf and blade allocated to the volume."""
return IMPL.volume_get_shelf_and_blade(context, volume_id)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 8b94f6036..326a01593 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -285,11 +285,6 @@ def instance_get_floating_address(_context, instance_id):
return instance_ref.fixed_ip.floating_ips[0]['address']
-def instance_get_host(context, instance_id):
- instance_ref = instance_get(context, instance_id)
- return instance_ref['host']
-
-
def instance_is_vpn(context, instance_id):
# TODO(vish): Move this into image code somewhere
instance_ref = instance_get(context, instance_id)
@@ -404,11 +399,6 @@ def network_get_by_bridge(_context, bridge):
return rv
-def network_get_host(context, network_id):
- network_ref = network_get(context, network_id)
- return network_ref['host']
-
-
def network_get_index(_context, network_id):
session = get_session()
with session.begin():
@@ -582,11 +572,6 @@ def volume_get_by_str(_context, str_id):
return models.Volume.find_by_str(str_id)
-def volume_get_host(context, volume_id):
- volume_ref = volume_get(context, volume_id)
- return volume_ref['host']
-
-
def volume_get_instance(_context, volume_id):
session = get_session()
with session.begin():
diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py
index cb625bfa8..6cda79406 100644
--- a/nova/endpoint/cloud.py
+++ b/nova/endpoint/cloud.py
@@ -299,7 +299,7 @@ class CloudController(object):
if volume_ref['attach_status'] == "attached":
raise exception.ApiError("Volume is already attached")
instance_ref = db.instance_get_by_str(context, instance_id)
- host = db.instance_get_host(context, instance_ref['id'])
+ host = instance_ref['host']
rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host),
{"method": "attach_volume",
"args": {"context": None,
@@ -323,7 +323,7 @@ class CloudController(object):
if volume_ref['status'] == "available":
raise exception.Error("Volume is already detached")
try:
- host = db.instance_get_host(context, instance_ref['id'])
+ host = instance_ref['host']
rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host),
{"method": "detach_volume",
"args": {"context": None,
@@ -483,7 +483,7 @@ class CloudController(object):
def _get_network_topic(self, context):
"""Retrieves the network host for a project"""
network_ref = db.project_get_network(context, context.project.id)
- host = db.network_get_host(context, network_ref['id'])
+ host = network_ref['host']
if not host:
host = yield rpc.call(FLAGS.network_topic,
{"method": "set_network_host",
@@ -608,7 +608,7 @@ class CloudController(object):
# we will need to cast here.
db.fixed_ip_deallocate(context, address)
- host = db.instance_get_host(context, instance_ref['id'])
+ host = instance_ref['host']
if host:
rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host),
{"method": "terminate_instance",
@@ -623,7 +623,7 @@ class CloudController(object):
"""instance_id is a list of instance ids"""
for id_str in instance_id:
instance_ref = db.instance_get_by_str(context, id_str)
- host = db.instance_get_host(context, instance_ref['id'])
+ host = instance_ref['host']
rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host),
{"method": "reboot_instance",
"args": {"context": None,
@@ -634,7 +634,7 @@ class CloudController(object):
def delete_volume(self, context, volume_id, **kwargs):
# TODO: return error if not authorized
volume_ref = db.volume_get_by_str(context, volume_id)
- host = db.volume_get_host(context, volume_ref['id'])
+ host = volume_ref['host']
rpc.cast(db.queue_get_for(context, FLAGS.volume_topic, host),
{"method": "delete_volume",
"args": {"context": None,