'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.'

def bdm_update_or_create_at_top(self, message, bdm, create):

    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):
        LOG.debug('Calling    db.block_device_mapping_update_or_create    from    API    cell    with    values:    %s', bdm)
        self.db.block_device_mapping_update_or_create(message.ctxt, bdm, legacy=False)
        return
    elif (create is True):
        LOG.debug('Calling    db.block_device_mapping_create    from    API    cell    with    values:    %s', bdm)
        self.db.block_device_mapping_create(message.ctxt, bdm, legacy=False)
        return
    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.warning('No    match    when    trying    to    update    BDM:    %(bdm)s', dict(bdm=bdm))
        return
    LOG.debug('Calling    db.block_device_mapping_update    from    API    cell    with    bdm    id    %s    and    values:    %s', instance_bdm['id'], bdm)
    self.db.block_device_mapping_update(message.ctxt, instance_bdm['id'], bdm, legacy=False)
