summaryrefslogtreecommitdiffstats
path: root/nova/volume/api.py
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2012-08-29 09:21:03 +0100
committerMark McLoughlin <markmc@redhat.com>2012-08-29 12:06:36 +0100
commit8cf635b08a57a9e3be2bef980ef38cf857b6525a (patch)
treedb4eb0485f03c6445db8e61274022dc43da26b50 /nova/volume/api.py
parent6727b259af491177514f075a3db91d55810c66e4 (diff)
downloadnova-8cf635b08a57a9e3be2bef980ef38cf857b6525a.tar.gz
nova-8cf635b08a57a9e3be2bef980ef38cf857b6525a.tar.xz
nova-8cf635b08a57a9e3be2bef980ef38cf857b6525a.zip
Stop using scheduler RPC API magic
If a scheduler RPC message isn't handled directly by a SchedulerManager method, the __getattr__() fallback passes the message to a driver method in the form of schedule_${method}() and, if that doesn't exist, instead calls the schedule() method supplying the topic and method args. This is pretty bizarre stuff and we appear to only use it in two cases: 1) live_migration - this is how the schedule_live_migration() method in the driver gets called, but the side-effect is that we require the client to pass a topic argument which is never used. This would be much more sanely handled with an explicit SchedulerManager.live_migration() method. 2) create_volume - the volume API asks the scheduler to pick a target host for create_volume() using this method. This would be easily handled with an SchedulerManager.create_volume() method. Change-Id: I1047489d85ac51d8d36fea1c4eb858df638ce349
Diffstat (limited to 'nova/volume/api.py')
-rw-r--r--nova/volume/api.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/nova/volume/api.py b/nova/volume/api.py
index bbb3149b0..3b8c62e11 100644
--- a/nova/volume/api.py
+++ b/nova/volume/api.py
@@ -31,6 +31,7 @@ from nova.openstack.common import rpc
from nova.openstack.common import timeutils
import nova.policy
from nova import quota
+from nova.scheduler import rpcapi as scheduler_rpcapi
volume_host_opt = cfg.BoolOpt('snapshot_same_host',
default=True,
@@ -72,6 +73,10 @@ def check_policy(context, action, target_obj=None):
class API(base.Base):
"""API for interacting with the volume manager."""
+ def __init__(self, **kwargs):
+ self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
+ super(API, self).__init__(**kwargs)
+
def create(self, context, size, name, description, snapshot=None,
volume_type=None, metadata=None, availability_zone=None):
check_policy(context, 'create')
@@ -172,13 +177,8 @@ class API(base.Base):
"args": {"volume_id": volume_id,
"snapshot_id": snapshot_id}})
else:
- rpc.cast(context,
- FLAGS.scheduler_topic,
- {"method": "create_volume",
- "args": {"topic": FLAGS.volume_topic,
- "volume_id": volume_id,
- "snapshot_id": snapshot_id,
- "reservations": reservations}})
+ self.scheduler_rpcapi.create_volume(
+ context, volume_id, snapshot_id, reservations)
@wrap_check_policy
def delete(self, context, volume):