'Modify volume to be of new type.'

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

    LOG.debug('Retype    volume    request    %(vol)s    to    be    %(type)s    (host:    %(host)s),    diff    %(diff)s.', {'vol': volume['name'], 'type': new_type, 'host': host, 'diff': diff})
    retyped = False
    migrated = False
    pools = diff['extra_specs'].get('capabilities:storage_pool')
    backends = diff['extra_specs'].get('volume_backend_name')
    hosts = (volume['host'], host['host'])
    if _different(backends):
        (backend1, backend2) = backends
        LOG.debug('Retype    request    is    for    different    backends,    use    migration:    %(backend1)s    %(backend2)s.', {'backend1': backend1, 'backend2': backend1})
        return False
    if _different(pools):
        (old, new) = pools
        LOG.debug('Retype    pool    attribute    from    %(old)s    to    %(new)s.', {'old': old, 'new': new})
        retyped = self._update_volume_storage_pool(self.local_path(volume), new)
    if _different(hosts):
        (source, destination) = hosts
        LOG.debug('Retype    hosts    migrate    from:    %(source)s    to    %(destination)s.', {'source': source, 'destination': destination})
        (migrated, mdl_update) = self._migrate_volume(volume, host)
        if migrated:
            updates = {'host': host['host']}
            self.db.volume_update(context, volume['id'], updates)
    return (retyped or migrated)
