summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMuneyuki Noguchi <noguchimn@nttdata.co.jp>2011-03-29 10:40:48 +0900
committerMuneyuki Noguchi <noguchimn@nttdata.co.jp>2011-03-29 10:40:48 +0900
commite5b0f3921331b5c0acbe321b00e2a9fa8d27be4e (patch)
tree34c8882f957124a2d48605ebf8413503786f4ea8
parent10acd84b0173b172dfa52e3779ba7b13b62bde76 (diff)
downloadnova-e5b0f3921331b5c0acbe321b00e2a9fa8d27be4e.tar.gz
nova-e5b0f3921331b5c0acbe321b00e2a9fa8d27be4e.tar.xz
nova-e5b0f3921331b5c0acbe321b00e2a9fa8d27be4e.zip
Add remove_volume to compute API.
-rw-r--r--nova/compute/api.py7
-rw-r--r--nova/compute/manager.py26
2 files changed, 21 insertions, 12 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 266cbe677..0cdb8f4b7 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -668,6 +668,13 @@ class API(base.Base):
"volume_id": volume_id}})
return instance
+ def remove_volume(self, context, volume_id, host):
+ """Remove volume on specified compute host."""
+ rpc.call(context,
+ self.db.queue_get_for(context, FLAGS.compute_topic, host),
+ {"method": "remove_volume",
+ "args": {'volume_id': volume_id}})
+
def associate_floating_ip(self, context, instance_id, address):
instance = self.get(context, instance_id)
self.network_api.associate_floating_ip(context,
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index aa612b137..bbd1fed1a 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -46,6 +46,7 @@ import functools
from eventlet import greenthread
+from nova import compute
from nova import exception
from nova import flags
from nova import log as logging
@@ -772,6 +773,14 @@ class ComputeManager(manager.SchedulerDependentManager):
self.db.volume_detached(context, volume_id)
return True
+ def remove_volume(self, context, volume_id):
+ """Remove volume on compute host.
+
+ :param context: security context
+ :param volume_id: nova.db.sqlalchemy.models.Volume.id
+ """
+ self.volume_manager.remove_compute_volume(context, volume_id)
+
@exception.wrap_exception
def compare_cpu(self, context, cpu_info):
"""Checks the host cpu is compatible to a cpu given by xml.
@@ -1018,22 +1027,15 @@ class ComputeManager(manager.SchedulerDependentManager):
'state': power_state.RUNNING,
'host': host})
+ if dest:
+ # NOTE(noguchimn): We set image_service here
+ # not to import an image service object.
+ compute_api = compute.API(image_service=1)
for volume in instance_ref['volumes']:
volume_id = volume['id']
self.db.volume_update(ctxt, volume_id, {'status': 'in-use'})
if dest:
- topic = self.db.queue_get_for(ctxt, FLAGS.compute_topic, dest)
- rpc.call(ctxt, topic,
- {"method": "restore_volume_state",
- "args": {'volume_id': volume_id}})
-
- def restore_volume_state(self, context, volume_id):
- """Restore volume state on migration failure.
-
- :param context: security context
- :param volume_id: nova.db.sqlalchemy.models.Volume.id
- """
- self.volume_manager.remove_compute_volume(context, volume_id)
+ compute_api.remove_volume(ctxt, volume_id, dest)
def periodic_tasks(self, context=None):
"""Tasks to be run at a periodic interval."""