'Convert the volume to be of the new type.'

def retype(self, ctxt, volume, new_type, diff, host):

    LOG.debug('Enter    retype:    id=%(id)s,    new_type=%(new_type)s,    diff=%(diff)s,    host=%(host)s.', {'id': volume.id, 'new_type': new_type, 'diff': diff, 'host': host})
    self._check_volume_exist_on_array(volume, constants.VOLUME_NOT_EXISTS_RAISE)
    (migration, change_opts, lun_id) = self.determine_changes_when_retype(volume, new_type, host)
    model_update = {}
    replica_enabled_change = change_opts.get('replication_enabled')
    replica_type_change = change_opts.get('replication_type')
    if (replica_enabled_change and (replica_enabled_change[0] == 'true')):
        try:
            self.replica.delete_replica(volume)
            model_update.update({'replication_status': 'disabled', 'replication_driver_data': None})
        except exception.VolumeBackendAPIException:
            LOG.exception('Retype    volume    error.    Delete    replication    failed.')
            return False
    try:
        if migration:
            LOG.debug('Begin    to    migrate    LUN(id:    %(lun_id)s)    with    change    %(change_opts)s.', {'lun_id': lun_id, 'change_opts': change_opts})
            if (not self._migrate_volume(volume, host, new_type)):
                LOG.warning('Storage-assisted    migration    failed    during    retype.')
                return False
        else:
            self.modify_lun(lun_id, change_opts)
    except exception.VolumeBackendAPIException:
        LOG.exception('Retype    volume    error.')
        return False
    if (replica_enabled_change and (replica_enabled_change[1] == 'true')):
        try:
            lun_info = self.client.get_lun_info(lun_id)
            replica_info = self.replica.create_replica(lun_info, replica_type_change[1])
            model_update.update(replica_info)
        except exception.VolumeBackendAPIException:
            LOG.exception('Retype    volume    error.    Create    replication    failed.')
            return False
    return (True, model_update)
