protected CopyVolumeAnswer execute(CopyVolumeCommand cmd) {
String volumePath = cmd.getVolumePath();
String secondaryStorageURL = cmd.getSecondaryStorageURL();
int wait = cmd.getWait();
if (wait == 0) {
wait = 7200;
}
try {
URI uri = new URI(secondaryStorageURL);
String secStorageMountPath = uri.getHost() + ":" + uri.getPath();
String volumeFolderOnSecStorage = "volumes/" + String.valueOf(cmd.getVolumeId());
String storagePoolUuid = cmd.getPool().getUuid();
Boolean toSec = cmd.toSecondaryStorage();
String res = OvmStoragePool.copyVolume(_conn, secStorageMountPath, volumeFolderOnSecStorage, volumePath, storagePoolUuid, toSec, wait);
return new CopyVolumeAnswer(cmd, true, null, null, res);
} catch (Exception e) {
s_logger.debug("Copy volume failed", e);
return new CopyVolumeAnswer(cmd, false, e.getMessage(), null, null);
}
}