private Answer execute(final CopyCommand cmd) { URI agentUri = null; try { final String cmdName = cmd.getClass().getName(); agentUri = new URI("https", null, _agentIp, _port, "/api/HypervResource/" + cmdName, null, null); } catch (final URISyntaxException e) { final String errMsg = "Could not generate URI for Hyper-V agent"; s_logger.error(errMsg, e); return null; } cleanPassword(cmd.getSrcTO().getDataStore()); cleanPassword(cmd.getDestTO().getDataStore()); // Send the cmd to hyperv agent. final String ansStr = postHttpRequest(s_gson.toJson(cmd), agentUri); if (ansStr == null) { return Answer.createUnsupportedCommandAnswer(cmd); } final Answer[] result = s_gson.fromJson(ansStr, Answer[].class); final String logResult = cleanPassword(s_gson.toJson(result)); s_logger.debug("executeRequest received response " + logResult); if (result.length > 0) { return result[0]; } return null; }
@Override public Pair<Boolean, Long> getCommandHostDelegation(long hostId, Command cmd) { if (cmd instanceof CopyCommand) { CopyCommand c = (CopyCommand) cmd; boolean inSeq = true; if (c.getSrcTO().getObjectType() == DataObjectType.SNAPSHOT || c.getDestTO().getObjectType() == DataObjectType.SNAPSHOT) { inSeq = false; } else if (c.getDestTO().getDataStore().getRole() == DataStoreRole.Image || c.getDestTO().getDataStore().getRole() == DataStoreRole.ImageCache) { inSeq = false; } c.setExecuteInSequence(inSeq); } if (cmd instanceof StorageSubSystemCommand) { StorageSubSystemCommand c = (StorageSubSystemCommand)cmd; c.setExecuteInSequence(false); } return new Pair<Boolean, Long>(false, new Long(hostId)); }
protected Answer copyFromNfsToImage(CopyCommand cmd) { DataTO destData = cmd.getDestTO(); DataStoreTO destDataStore = destData.getDataStore(); if (destDataStore instanceof S3TO) { return copyFromNfsToS3(cmd); } else if (destDataStore instanceof SwiftTO) { return copyFromNfsToSwift(cmd); } else { return new CopyCmdAnswer("unsupported "); } }
DataTO destData = cmd.getDestTO(); String primaryStorageNameLabel = destData.getDataStore().getUuid();
@Override public Answer copyVolumeFromImageCacheToPrimary(final CopyCommand cmd) { final Connection conn = hypervisorResource.getConnection(); final DataTO srcData = cmd.getSrcTO(); final DataTO destData = cmd.getDestTO(); final int wait = cmd.getWait(); final VolumeObjectTO srcVolume = (VolumeObjectTO) srcData; final VolumeObjectTO destVolume = (VolumeObjectTO) destData; final DataStoreTO srcStore = srcVolume.getDataStore(); if (srcStore instanceof NfsTO) { final NfsTO nfsStore = (NfsTO) srcStore; try { final SR primaryStoragePool = hypervisorResource.getStorageRepository(conn, destVolume.getDataStore().getUuid()); final String srUuid = primaryStoragePool.getUuid(conn); final URI uri = new URI(nfsStore.getUrl()); final String volumePath = uri.getHost() + ":" + uri.getPath() + nfsStore.getPathSeparator() + srcVolume.getPath(); final String uuid = copy_vhd_from_secondarystorage(conn, volumePath, srUuid, wait); final VolumeObjectTO newVol = new VolumeObjectTO(); newVol.setPath(uuid); newVol.setSize(srcVolume.getSize()); return new CopyCmdAnswer(newVol); } catch (final Exception e) { final String msg = "Catch Exception " + e.getClass().getName() + " due to " + e.toString(); s_logger.warn(msg, e); return new CopyCmdAnswer(e.toString()); } } s_logger.debug("unsupported protocol"); return new CopyCmdAnswer("unsupported protocol"); }
protected Answer copyToObjectStore(final CopyCommand cmd) { final DataTO srcData = cmd.getSrcTO(); final DataTO destData = cmd.getDestTO(); final DataStoreTO imageStore = destData.getDataStore(); final NfsTO srcStore = (NfsTO)srcData.getDataStore();
final Connection conn = hypervisorResource.getConnection(); final DataTO srcData = cmd.getSrcTO(); final DataTO destData = cmd.getDestTO(); final VolumeObjectTO volume = (VolumeObjectTO) destData; VDI vdi = null;
final Connection conn = hypervisorResource.getConnection(); final VolumeObjectTO srcVolume = (VolumeObjectTO) cmd.getSrcTO(); final VolumeObjectTO destVolume = (VolumeObjectTO) cmd.getDestTO(); final int wait = cmd.getWait(); final DataStoreTO destStore = destVolume.getDataStore();
srcFile = srcFile.replace(config.getVirtualDiskDir(), config.getTemplateDir()); DataTO destData = cmd.getDestTO(); VolumeObjectTO dest = (VolumeObjectTO) destData; String destFile = getVirtualDiskPath(dest.getUuid(), dest.getDataStore().getUuid());
protected Answer copyFromNfsToS3(CopyCommand cmd) { final DataTO srcData = cmd.getSrcTO(); final DataTO destData = cmd.getDestTO(); DataStoreTO srcDataStore = srcData.getDataStore(); NfsTO srcStore = (NfsTO)srcDataStore;
final DataTO srcData = cmd.getSrcTO(); final SnapshotObjectTO snapshot = (SnapshotObjectTO)srcData; final DataTO destData = cmd.getDestTO(); final PrimaryDataStoreTO pool = (PrimaryDataStoreTO)destData.getDataStore(); final DataStoreTO imageStore = srcData.getDataStore();
try { DataTO srcData = cmd.getSrcTO(); DataTO destData = cmd.getDestTO(); SnapshotObjectTO src = (SnapshotObjectTO) srcData; SnapshotObjectTO dest = (SnapshotObjectTO) destData;
DataTO destData = cmd.getDestTO(); VolumeObjectTO destVol = (VolumeObjectTO) destData; String primaryPoolUuid = destData.getDataStore().getUuid();
protected Answer backupSnapshotForObjectStore(final CopyCommand cmd) { final DataTO destData = cmd.getDestTO(); final DataStoreTO imageStore = destData.getDataStore(); final DataTO cacheData = cmd.getCacheTO(); if (cacheData == null) { return new CopyCmdAnswer("Failed to copy to object store without cache store"); } final DataStoreTO cacheStore = cacheData.getDataStore(); ((SnapshotObjectTO)destData).setDataStore(cacheStore); final CopyCmdAnswer answer = (CopyCmdAnswer)backupSnapshot(cmd); if (!answer.getResult()) { return answer; } final SnapshotObjectTO snapshotOnCacheStore = (SnapshotObjectTO)answer.getNewData(); snapshotOnCacheStore.setDataStore(cacheStore); ((SnapshotObjectTO)destData).setDataStore(imageStore); final CopyCommand newCpyCmd = new CopyCommand(snapshotOnCacheStore, destData, cmd.getWaitInMillSeconds(), cmd.executeInSequence()); return copyToObjectStore(newCpyCmd); }
+ srcSnap.getPath(); DataTO destData = cmd.getDestTO(); TemplateObjectTO destTemplate = (TemplateObjectTO) destData; String secPoolUuidTemplate = pool.setupSecondaryStorage(destData.getDataStore().getUrl());
protected Answer execute(CopyCommand cmd) { DataTO srcData = cmd.getSrcTO(); DataTO destData = cmd.getDestTO(); DataStoreTO srcDataStore = srcData.getDataStore(); DataStoreTO destDataStore = destData.getDataStore(); if (srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) { return createTemplateFromSnapshot(cmd); } if (destDataStore instanceof NfsTO && destDataStore.getRole() == DataStoreRole.ImageCache) { NfsTO destImageStore = (NfsTO)destDataStore; if (srcDataStore instanceof S3TO) { S3TO s3 = (S3TO)srcDataStore; return copyFromS3ToNfs(cmd, srcData, s3, destData, destImageStore); } else if (srcDataStore instanceof SwiftTO) { return copyFromSwiftToNfs(cmd, srcData, (SwiftTO)srcDataStore, destData, destImageStore); } } if (srcDataStore.getRole() == DataStoreRole.ImageCache && destDataStore.getRole() == DataStoreRole.Image) { return copyFromNfsToImage(cmd); } return Answer.createUnsupportedCommandAnswer(cmd); }
protected Answer createTemplateFromSnapshot(CopyCommand cmd) { DataTO srcData = cmd.getSrcTO(); DataTO destData = cmd.getDestTO(); DataStoreTO srcDataStore = srcData.getDataStore(); DataStoreTO destDataStore = destData.getDataStore();
@Override public Answer cloneVolumeFromBaseTemplate(final CopyCommand cmd) { final DataTO srcData = cmd.getSrcTO(); final DataTO destData = cmd.getDestTO(); final TemplateObjectTO template = (TemplateObjectTO)srcData; final DataStoreTO imageStore = template.getDataStore();
@Override public Answer copyVolumeFromPrimaryToSecondary(final CopyCommand cmd) { final DataTO srcData = cmd.getSrcTO(); final DataTO destData = cmd.getDestTO(); final VolumeObjectTO srcVol = (VolumeObjectTO)srcData; final VolumeObjectTO destVol = (VolumeObjectTO)destData;
protected Answer execute(CopyCommand cmd) { DataTO srcData = cmd.getSrcTO(); DataTO destData = cmd.getDestTO(); DataStoreTO srcDataStore = srcData.getDataStore(); DataStoreTO destDataStore = destData.getDataStore();