def swap_volume(self, old_connection_info, new_connection_info, instance, mountpoint, resize_to):
    instance_name = instance['name']
    virt_dom = self._lookup_by_name(instance_name)
    disk_dev = mountpoint.rpartition('/')[2]
    xml = self._get_disk_xml(virt_dom.XMLDesc(0), disk_dev)
    if (not xml):
        raise exception.DiskNotFound(location=disk_dev)
    disk_info = {'dev': disk_dev, 'bus': blockinfo.get_disk_bus_for_disk_dev(CONF.libvirt.virt_type, disk_dev), 'type': 'disk'}
    conf = self._connect_volume(new_connection_info, disk_info)
    if (not conf.source_path):
        self._disconnect_volume(new_connection_info, disk_dev)
        raise NotImplementedError(_('Swap only supports host devices'))
    self._swap_volume(virt_dom, disk_dev, conf.source_path, resize_to)
    self._disconnect_volume(old_connection_info, disk_dev)
def swap_volume(self, old_connection_info, new_connection_info, instance, mountpoint, resize_to):
    instance_name = instance['name']
    virt_dom = self._lookup_by_name(instance_name)
    disk_dev = mountpoint.rpartition('/')[2]
    xml = self._get_disk_xml(virt_dom.XMLDesc(0), disk_dev)
    if (not xml):
        raise exception.DiskNotFound(location=disk_dev)
    disk_info = {'dev': disk_dev, 'bus': blockinfo.get_disk_bus_for_disk_dev(CONF.libvirt.virt_type, disk_dev), 'type': 'disk'}
    conf = self._connect_volume(new_connection_info, disk_info)
    if (not conf.source_path):
        self._disconnect_volume(new_connection_info, disk_dev)
        raise NotImplementedError(_('Swap only supports host devices'))
    self._swap_volume(virt_dom, disk_dev, conf.source_path, resize_to)
    self._disconnect_volume(old_connection_info, disk_dev)