Fixes nova volumes. The async commands yield properly. Simplified the call to create volume in cloud. Added some notes

This commit is contained in:
Vishvananda Ishaya
2010-07-30 18:32:12 -07:00
parent c5754b0cd8
commit 9b11290b7d

View File

@@ -295,17 +295,16 @@ class CloudController(object):
return v return v
@rbac.allow('projectmanager', 'sysadmin') @rbac.allow('projectmanager', 'sysadmin')
@defer.inlineCallbacks
def create_volume(self, context, size, **kwargs): def create_volume(self, context, size, **kwargs):
# TODO(vish): refactor this to create the volume object here and tell service to create it # TODO(vish): refactor this to create the volume object here and tell service to create it
res = rpc.call(FLAGS.volume_topic, {"method": "create_volume", result = yield rpc.call(FLAGS.volume_topic, {"method": "create_volume",
"args" : {"size": size, "args" : {"size": size,
"user_id": context.user.id, "user_id": context.user.id,
"project_id": context.project.id}}) "project_id": context.project.id}})
def _format_result(result): # NOTE(vish): rpc returned value is in the result key in the dictionary
volume = self._get_volume(context, result['result']) volume = self._get_volume(context, result['result'])
return {'volumeSet': [self.format_volume(context, volume)]} defer.returnValue({'volumeSet': [self.format_volume(context, volume)]})
res.addCallback(_format_result)
return res
def _get_address(self, context, public_ip): def _get_address(self, context, public_ip):
# FIXME(vish) this should move into network.py # FIXME(vish) this should move into network.py