def promote_replica(self, ctxt, volume_id):
    'Promote volume replica secondary to be the primary volume.'
    volume = self.db.volume_get(ctxt, volume_id)
    model_update = None
    try:
        utils.require_driver_initialized(self.driver)
    except exception.DriverNotInitialized:
        with excutils.save_and_reraise_exception():
            LOG.exception(_LE('Promote volume replica failed.'), resource=volume)
    try:
        model_update = self.driver.promote_replica(ctxt, volume)
    except exception.CinderException:
        err_msg = _('Error promoting secondary volume to primary')
        raise exception.ReplicationError(reason=err_msg, volume_id=volume_id)
    try:
        if model_update:
            volume = self.db.volume_update(ctxt, volume_id, model_update)
    except exception.CinderException:
        err_msg = (_('Failed updating model with driver provided model %(model)s') % {'model': model_update})
        raise exception.ReplicationError(reason=err_msg, volume_id=volume_id)
    LOG.info(_LI('Promote volume replica completed successfully.'), resource=volume)
Promote volume replica secondary to be the primary volume.
def promote_replica(self, ctxt, volume_id):
    
    volume = self.db.volume_get(ctxt, volume_id)
    model_update = None
    try:
        utils.require_driver_initialized(self.driver)
    except exception.DriverNotInitialized:
        with excutils.save_and_reraise_exception():
            LOG.exception(_LE('Promote volume replica failed.'), resource=volume)
    try:
        model_update = self.driver.promote_replica(ctxt, volume)
    except exception.CinderException:
        err_msg = _('Error promoting secondary volume to primary')
        raise exception.ReplicationError(reason=err_msg, volume_id=volume_id)
    try:
        if model_update:
            volume = self.db.volume_update(ctxt, volume_id, model_update)
    except exception.CinderException:
        err_msg = (_('Failed updating model with driver provided model %(model)s') % {'model': model_update})
        raise exception.ReplicationError(reason=err_msg, volume_id=volume_id)
    LOG.info(_LI('Promote volume replica completed successfully.'), resource=volume)