use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class Ovm3StorageProcessor method execute.
public final Answer execute(final CopyCommand cmd) {
LOGGER.debug("execute: " + cmd.getClass());
DataTO srcData = cmd.getSrcTO();
DataStoreTO srcStore = srcData.getDataStore();
DataTO destData = cmd.getDestTO();
DataStoreTO destStore = destData.getDataStore();
String msg = "Not implemented yet";
try {
/* target and source are NFS and TEMPLATE */
if ((srcStore instanceof NfsTO) && (srcData.getObjectType() == DataObjectType.TEMPLATE) && (destData.getObjectType() == DataObjectType.TEMPLATE)) {
return copyTemplateToPrimaryStorage(cmd);
/* we assume the cache for templates is local */
} else if ((srcData.getObjectType() == DataObjectType.TEMPLATE) && (destData.getObjectType() == DataObjectType.VOLUME)) {
if (srcStore.getUrl().equals(destStore.getUrl())) {
return cloneVolumeFromBaseTemplate(cmd);
} else {
msg = "Primary to Primary doesn't match";
LOGGER.debug(msg);
}
} else if ((srcData.getObjectType() == DataObjectType.SNAPSHOT) && (destData.getObjectType() == DataObjectType.SNAPSHOT)) {
return backupSnapshot(cmd);
} else if ((srcData.getObjectType() == DataObjectType.SNAPSHOT) && (destData.getObjectType() == DataObjectType.TEMPLATE)) {
return createTemplateFromSnapshot(cmd);
} else if ((srcData.getObjectType() == DataObjectType.SNAPSHOT) && (destData.getObjectType() == DataObjectType.VOLUME)) {
return createVolumeFromSnapshot(cmd);
} else {
msg = "Unable to do stuff for " + srcStore.getClass() + ":" + srcData.getObjectType() + " to " + destStore.getClass() + ":" + destData.getObjectType();
LOGGER.debug(msg);
}
} catch (Exception e) {
msg = "Catch Exception " + e.getClass().getName() + " for template due to " + e.toString();
LOGGER.warn(msg, e);
return new CopyCmdAnswer(msg);
}
LOGGER.warn(msg + " " + cmd.getClass());
return new CopyCmdAnswer(msg);
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class Ovm3StorageProcessor method createVolumeFromSnapshot.
/**
* SnapshotObjectTO secondary to VolumeObjectTO primary in xenserver,
*/
@Override
public Answer createVolumeFromSnapshot(CopyCommand cmd) {
LOGGER.debug("execute createVolumeFromSnapshot: " + cmd.getClass());
try {
DataTO srcData = cmd.getSrcTO();
DataStoreTO srcStore = srcData.getDataStore();
NfsTO srcImageStore = (NfsTO) srcStore;
// source, should contain snap dir/filename
SnapshotObjectTO srcSnap = (SnapshotObjectTO) srcData;
String secPoolUuid = pool.setupSecondaryStorage(srcImageStore.getUrl());
String srcFile = config.getAgentSecStoragePath() + "/" + secPoolUuid + "/" + srcSnap.getPath();
// dest
DataTO destData = cmd.getDestTO();
VolumeObjectTO destVol = (VolumeObjectTO) destData;
String primaryPoolUuid = destData.getDataStore().getUuid();
String destFile = getVirtualDiskPath(destVol.getUuid(), ovmObject.deDash(primaryPoolUuid));
Linux host = new Linux(c);
host.copyFile(srcFile, destFile);
VolumeObjectTO newVol = new VolumeObjectTO();
newVol.setUuid(destVol.getUuid());
// newVol.setPath(destFile);
newVol.setPath(destVol.getUuid());
newVol.setFormat(ImageFormat.RAW);
return new CopyCmdAnswer(newVol);
/* we assume the cache for templates is local */
} catch (Ovm3ResourceException e) {
LOGGER.debug("Failed to createVolumeFromSnapshot: ", e);
return new CopyCmdAnswer(e.toString());
}
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class Ovm3StorageProcessorTest method volume.
private VolumeObjectTO volume(final String uuid, final String dsuuid, final String storeUrl, final String path) {
VolumeObjectTO volume = new VolumeObjectTO();
NfsTO nfsDataStore = new NfsTO();
nfsDataStore.setUuid(dsuuid);
nfsDataStore.setUrl(storeUrl);
volume.setDataStore(nfsDataStore);
volume.setPath(path);
volume.setUuid(uuid);
return volume;
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class Ovm3StorageProcessorTest method snapshot.
private SnapshotObjectTO snapshot(final String uuid, final String dsuuid, final String storeUrl, final String path) {
SnapshotObjectTO volume = new SnapshotObjectTO();
NfsTO nfsDataStore = new NfsTO();
nfsDataStore.setUuid(dsuuid);
nfsDataStore.setUrl(storeUrl);
volume.setDataStore(nfsDataStore);
volume.setPath(path);
// volume.setUuid(uuid);
return volume;
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class SimulatorStorageProcessor method backupSnapshot.
@Override
public Answer backupSnapshot(CopyCommand cmd) {
DataTO srcData = cmd.getSrcTO();
DataTO destData = cmd.getDestTO();
SnapshotObjectTO snapshot = (SnapshotObjectTO) srcData;
DataStoreTO imageStore = destData.getDataStore();
if (!(imageStore instanceof NfsTO)) {
return new CopyCmdAnswer("unsupported protocol");
}
int index = snapshot.getPath().lastIndexOf("/");
String snapshotName = snapshot.getPath().substring(index + 1);
String snapshotRelPath = "snapshots";
SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
newSnapshot.setPath(snapshotRelPath + File.separator + snapshotName);
return new CopyCmdAnswer(newSnapshot);
}
Aggregations