diff options
| author | Chris Behrens <cbehrens@codestud.com> | 2013-06-03 20:02:21 +0000 |
|---|---|---|
| committer | Chris Behrens <cbehrens@codestud.com> | 2013-06-11 21:47:42 +0000 |
| commit | 39e8f5bd3bc976603c5a0a2dd4ada3dd6b79258d (patch) | |
| tree | 9755a3827d0259c9b34c188523bf02c77a51d286 /nova/cells | |
| parent | 9b5e206027149861de86585690bc3d5141ec240e (diff) | |
| download | nova-39e8f5bd3bc976603c5a0a2dd4ada3dd6b79258d.tar.gz nova-39e8f5bd3bc976603c5a0a2dd4ada3dd6b79258d.tar.xz nova-39e8f5bd3bc976603c5a0a2dd4ada3dd6b79258d.zip | |
Cells: Add support for global cinder
Implements cinder support for compute cells when cinder is a global
installation. Adds syncing of the block device mapping table between
child cells and API cells.
Implements blueprint cells-cinder-support
Change-Id: Ife5be9922db0742c8ee4f970517396be86597cce
Diffstat (limited to 'nova/cells')
| -rw-r--r-- | nova/cells/manager.py | 13 | ||||
| -rw-r--r-- | nova/cells/messaging.py | 76 | ||||
| -rw-r--r-- | nova/cells/rpcapi.py | 34 |
3 files changed, 121 insertions, 2 deletions
diff --git a/nova/cells/manager.py b/nova/cells/manager.py index f776c542e..4dc9f2d82 100644 --- a/nova/cells/manager.py +++ b/nova/cells/manager.py @@ -64,7 +64,7 @@ class CellsManager(manager.Manager): Scheduling requests get passed to the scheduler class. """ - RPC_API_VERSION = '1.9' + RPC_API_VERSION = '1.10' def __init__(self, *args, **kwargs): # Mostly for tests. @@ -390,3 +390,14 @@ class CellsManager(manager.Manager): def get_capacities(self, ctxt, cell_name): return self.state_manager.get_capacities(cell_name) + + def bdm_update_or_create_at_top(self, ctxt, bdm, create=None): + """BDM was created/updated in this cell. Tell the API cells.""" + self.msg_runner.bdm_update_or_create_at_top(ctxt, bdm, create=create) + + def bdm_destroy_at_top(self, ctxt, instance_uuid, device_name=None, + volume_id=None): + """BDM was destroyed for instance in this cell. Tell the API cells.""" + self.msg_runner.bdm_destroy_at_top(ctxt, instance_uuid, + device_name=device_name, + volume_id=volume_id) diff --git a/nova/cells/messaging.py b/nova/cells/messaging.py index 319067836..0d47bce02 100644 --- a/nova/cells/messaging.py +++ b/nova/cells/messaging.py @@ -848,7 +848,8 @@ class _BroadcastMessageMethods(_BaseMessageMethods): except exception.NotFound: # FIXME(comstud): Strange. Need to handle quotas here, # if we actually want this code to remain.. - self.db.instance_create(message.ctxt, instance) + self.db.instance_create(message.ctxt, instance, + legacy=False) if info_cache: try: self.db.instance_info_cache_update( @@ -959,6 +960,60 @@ class _BroadcastMessageMethods(_BaseMessageMethods): self.consoleauth_rpcapi.delete_tokens_for_instance(message.ctxt, instance_uuid) + def bdm_update_or_create_at_top(self, message, bdm, create): + """Create or update a block device mapping in API cells. If + create is True, only try to create. If create is None, try to + update but fall back to create. If create is False, only attempt + to update. This maps to nova-conductor's behavior. + """ + if not self._at_the_top(): + return + items_to_remove = ['id'] + for key in items_to_remove: + bdm.pop(key, None) + if create is None: + self.db.block_device_mapping_update_or_create(message.ctxt, + bdm, + legacy=False) + return + elif create is True: + self.db.block_device_mapping_create(message.ctxt, bdm, + legacy=False) + return + # Unfortunately this update call wants BDM ID... but we don't know + # what it is in this cell. Search for it.. try matching either + # device_name or volume_id. + dev_name = bdm['device_name'] + vol_id = bdm['volume_id'] + instance_bdms = self.db.block_device_mapping_get_all_by_instance( + message.ctxt, bdm['instance_uuid']) + for instance_bdm in instance_bdms: + if dev_name and instance_bdm['device_name'] == dev_name: + break + if vol_id and instance_bdm['volume_id'] == vol_id: + break + else: + LOG.warn(_("No match when trying to update BDM: %(bdm)s"), + dict(bdm=bdm)) + return + self.db.block_device_mapping_update(message.ctxt, + instance_bdm['id'], bdm, + legacy=False) + + def bdm_destroy_at_top(self, message, instance_uuid, device_name, + volume_id): + """Destroy a block device mapping in API cells by device name + or volume_id. device_name or volume_id can be None, but not both. + """ + if not self._at_the_top(): + return + if device_name: + self.db.block_device_mapping_destroy_by_instance_and_device( + message.ctxt, instance_uuid, device_name) + elif volume_id: + self.db.block_device_mapping_destroy_by_instance_and_volume( + message.ctxt, instance_uuid, volume_id) + _CELL_MESSAGE_TYPE_TO_MESSAGE_CLS = {'targeted': _TargetedMessage, 'broadcast': _BroadcastMessage, @@ -1344,6 +1399,25 @@ class MessageRunner(object): cell_name, need_response=True) return message.process() + def bdm_update_or_create_at_top(self, ctxt, bdm, create=None): + """Update/Create a BDM at top level cell.""" + message = _BroadcastMessage(self, ctxt, + 'bdm_update_or_create_at_top', + dict(bdm=bdm, create=create), + 'up', run_locally=False) + message.process() + + def bdm_destroy_at_top(self, ctxt, instance_uuid, device_name=None, + volume_id=None): + """Destroy a BDM at top level cell.""" + method_kwargs = dict(instance_uuid=instance_uuid, + device_name=device_name, + volume_id=volume_id) + message = _BroadcastMessage(self, ctxt, 'bdm_destroy_at_top', + method_kwargs, + 'up', run_locally=False) + message.process() + @staticmethod def get_message_types(): return _CELL_MESSAGE_TYPE_TO_MESSAGE_CLS.keys() diff --git a/nova/cells/rpcapi.py b/nova/cells/rpcapi.py index dd757c818..c03c9afea 100644 --- a/nova/cells/rpcapi.py +++ b/nova/cells/rpcapi.py @@ -26,9 +26,11 @@ from oslo.config import cfg from nova import exception from nova.openstack.common import jsonutils +from nova.openstack.common import log as logging from nova.openstack.common.rpc import proxy as rpc_proxy +LOG = logging.getLogger(__name__) CONF = cfg.CONF CONF.import_opt('enable', 'nova.cells.opts', group='cells') CONF.import_opt('topic', 'nova.cells.opts', group='cells') @@ -52,6 +54,7 @@ class CellsAPI(rpc_proxy.RpcProxy): 1.7 - Adds service_update() 1.8 - Adds build_instances(), deprecates schedule_run_instance() 1.9 - Adds get_capacities() + 1.10 - Adds bdm_update_or_create_at_top(), and bdm_destroy_at_top() ''' BASE_RPC_API_VERSION = '1.0' @@ -298,3 +301,34 @@ class CellsAPI(rpc_proxy.RpcProxy): return self.call(ctxt, self.make_msg('get_capacities', cell_name=cell_name), version='1.9') + + def bdm_update_or_create_at_top(self, ctxt, bdm, create=None): + """Create or update a block device mapping in API cells. If + create is True, only try to create. If create is None, try to + update but fall back to create. If create is False, only attempt + to update. This maps to nova-conductor's behavior. + """ + if not CONF.cells.enable: + return + try: + self.cast(ctxt, self.make_msg('bdm_update_or_create_at_top', + bdm=bdm, create=create), + version='1.10') + except Exception: + LOG.exception(_("Failed to notify cells of BDM update/create.")) + + def bdm_destroy_at_top(self, ctxt, instance_uuid, device_name=None, + volume_id=None): + """Broadcast upwards that a block device mapping was destroyed. + One of device_name or volume_id should be specified. + """ + if not CONF.cells.enable: + return + try: + self.cast(ctxt, self.make_msg('bdm_destroy_at_top', + instance_uuid=instance_uuid, + device_name=device_name, + volume_id=volume_id), + version='1.10') + except Exception: + LOG.exception(_("Failed to notify cells of BDM destroy.")) |
