use of com.cloud.hypervisor.ovm3.objects.StoragePlugin in project cloudstack by apache.
the class Ovm3StorageProcessor method backupSnapshot.
/**
* use the cache, or the normal nfs, also delete the leftovers for us
* also contains object store storage in xenserver.
*/
@Override
public CopyCmdAnswer backupSnapshot(CopyCommand cmd) {
LOGGER.debug("execute backupSnapshot: " + cmd.getClass());
try {
DataTO srcData = cmd.getSrcTO();
DataTO destData = cmd.getDestTO();
SnapshotObjectTO src = (SnapshotObjectTO) srcData;
SnapshotObjectTO dest = (SnapshotObjectTO) destData;
// src.getPath contains the uuid of the snapshot.
String srcFile = getVirtualDiskPath(src.getPath(), src.getDataStore().getUuid());
// destination
String storeUrl = dest.getDataStore().getUrl();
String secPoolUuid = pool.setupSecondaryStorage(storeUrl);
String destDir = config.getAgentSecStoragePath() + "/" + secPoolUuid + "/" + dest.getPath();
String destFile = destDir + "/" + src.getPath();
destFile = destFile.concat(".raw");
// copy
Linux host = new Linux(c);
CloudstackPlugin csp = new CloudstackPlugin(c);
csp.ovsMkdirs(destDir);
LOGGER.debug("CopyFrom: " + srcData.getObjectType() + "," + srcFile + " to " + destData.getObjectType() + "," + destFile);
host.copyFile(srcFile, destFile);
StoragePlugin sp = new StoragePlugin(c);
sp.storagePluginDestroy(secPoolUuid, srcFile);
SnapshotObjectTO newSnap = new SnapshotObjectTO();
// newSnap.setPath(destFile);
// damnit frickin crap, no reference whatsoever... could use parent ?
newSnap.setPath(dest.getPath() + "/" + src.getPath() + ".raw");
newSnap.setParentSnapshotPath(null);
return new CopyCmdAnswer(newSnap);
} catch (Ovm3ResourceException e) {
String msg = "Error backupSnapshot: " + e.getMessage();
LOGGER.info(msg);
return new CopyCmdAnswer(msg);
}
}
use of com.cloud.hypervisor.ovm3.objects.StoragePlugin in project cloudstack by apache.
the class Ovm3StorageProcessor method deleteVolume.
@Override
public Answer deleteVolume(DeleteCommand cmd) {
LOGGER.debug("execute deleteVolume: " + cmd.getClass());
DataTO data = cmd.getData();
VolumeObjectTO volume = (VolumeObjectTO) data;
try {
String poolUuid = data.getDataStore().getUuid();
String uuid = volume.getUuid();
String path = getVirtualDiskPath(uuid, poolUuid);
StoragePlugin sp = new StoragePlugin(c);
sp.storagePluginDestroy(poolUuid, path);
LOGGER.debug("Volume deletion success: " + path);
} catch (Ovm3ResourceException e) {
LOGGER.info("Volume deletion failed: " + e.toString(), e);
return new CreateObjectAnswer(e.toString());
}
return new Answer(cmd);
}
use of com.cloud.hypervisor.ovm3.objects.StoragePlugin in project cloudstack by apache.
the class Ovm3StorageProcessor method execute.
public CreateAnswer execute(CreateCommand cmd) {
LOGGER.debug("execute: " + cmd.getClass());
StorageFilerTO primaryStorage = cmd.getPool();
DiskProfile disk = cmd.getDiskCharacteristics();
/* disk should have a uuid */
// should also be replaced with getVirtualDiskPath ?
String fileName = UUID.randomUUID().toString() + ".raw";
String dst = primaryStorage.getPath() + "/" + primaryStorage.getUuid() + "/" + fileName;
try {
StoragePlugin store = new StoragePlugin(c);
if (cmd.getTemplateUrl() != null) {
LOGGER.debug("CreateCommand " + cmd.getTemplateUrl() + " " + dst);
Linux host = new Linux(c);
host.copyFile(cmd.getTemplateUrl(), dst);
} else {
/* this is a dup with the createVolume ? */
LOGGER.debug("CreateCommand " + dst);
store.storagePluginCreate(primaryStorage.getUuid(), primaryStorage.getHost(), dst, disk.getSize(), false);
}
FileProperties fp = store.storagePluginGetFileInfo(primaryStorage.getUuid(), primaryStorage.getHost(), dst);
VolumeTO volume = new VolumeTO(cmd.getVolumeId(), disk.getType(), primaryStorage.getType(), primaryStorage.getUuid(), primaryStorage.getPath(), fileName, fp.getName(), fp.getSize(), null);
return new CreateAnswer(cmd, volume);
} catch (Exception e) {
LOGGER.debug("CreateCommand failed", e);
return new CreateAnswer(cmd, e.getMessage());
}
}
use of com.cloud.hypervisor.ovm3.objects.StoragePlugin in project cloudstack by apache.
the class Ovm3StoragePool method setupNfsStorage.
/**
* Sets up NFS Storage
*
* @param uri
* @param uuid
* @return
* @throws Ovm3ResourceException
*/
private String setupNfsStorage(URI uri, String uuid) throws Ovm3ResourceException {
String fsUri = "nfs";
String msg = "";
String mountPoint = config.getAgentSecStoragePath() + "/" + uuid;
Linux host = new Linux(c);
Map<String, Linux.FileSystem> fsList = host.getFileSystemMap(fsUri);
Linux.FileSystem fs = fsList.get(uuid);
if (fs == null || !fs.getRemoteDir().equals(mountPoint)) {
try {
StoragePlugin sp = new StoragePlugin(c);
sp.storagePluginMountNFS(uri.getHost(), uri.getPath(), uuid, mountPoint);
msg = "Nfs storage " + uri + " mounted on " + mountPoint;
return uuid;
} catch (Ovm3ResourceException ec) {
msg = "Nfs storage " + uri + " mount on " + mountPoint + " FAILED " + ec.getMessage();
LOGGER.error(msg);
throw ec;
}
} else {
msg = "NFS storage " + uri + " already mounted on " + mountPoint;
return uuid;
}
}
use of com.cloud.hypervisor.ovm3.objects.StoragePlugin in project cloudstack by apache.
the class Ovm3StorageProcessor method execute.
/* Destroy a volume (image) */
public Answer execute(DestroyCommand cmd) {
LOGGER.debug("execute: " + cmd.getClass());
VolumeTO vol = cmd.getVolume();
String vmName = cmd.getVmName();
try {
StoragePlugin store = new StoragePlugin(c);
store.storagePluginDestroy(vol.getPoolUuid(), vol.getPath());
return new Answer(cmd, true, "Success");
} catch (Ovm3ResourceException e) {
LOGGER.debug("Destroy volume " + vol.getName() + " failed for " + vmName + " ", e);
return new Answer(cmd, false, e.getMessage());
}
}
Aggregations