self.tgtadm.remove_iscsi_target(iscsi_target, 0, volume['id'])
+ def migrate_volume(self, ctxt, volume, host):
+ """Optimize the migration if the destination is on the same server.
+
+ If the specified host is another back-end on the same server, and
+ the volume is not attached, we can do the migration locally without
+ going through iSCSI.
+ """
+ false_ret = (False, None)
+ if 'location_info' not in host['capabilities']:
+ return false_ret
+ info = host['capabilities']['location_info']
+ try:
+ (dest_type, dest_hostname, dest_vg) = info.split(':')
+ except ValueError:
+ return false_ret
+ if (dest_type != 'LVMVolumeDriver' or dest_hostname != self.hostname):
+ return false_ret
+
+ self.remove_export(ctxt, volume)
+ self._create_volume(volume['name'],
+ self._sizestr(volume['size']),
+ dest_vg)
+ volutils.copy_volume(self.local_path(volume),
+ self.local_path(volume, vg=dest_vg),
+ volume['size'],
+ execute=self._execute)
+ self._delete_volume(volume)
+ model_update = self._create_export(ctxt, volume, vg=dest_vg)
+
+ return (True, model_update)
+
+ def rename_volume(self, volume, orig_name):
+ self._execute('lvrename', self.configuration.volume_group,
+ orig_name, volume['name'],
+ run_as_root=True)
+
def get_volume_stats(self, refresh=False):
- """Get volume status.
+ """Get volume stats.
If 'refresh' is True, run update the stats first.
"""