use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class OvmResourceBase method createVbds.
protected void createVbds(OvmVm.Details vm, VirtualMachineTO spec) throws URISyntaxException {
for (DiskTO volume : spec.getDisks()) {
if (volume.getType() == Volume.Type.ROOT) {
VolumeObjectTO vol = (VolumeObjectTO) volume.getData();
OvmDisk.Details root = new OvmDisk.Details();
root.path = vol.getPath();
root.type = OvmDisk.WRITE;
root.isIso = false;
vm.rootDisk = root;
} else if (volume.getType() == Volume.Type.ISO) {
DataTO isoTO = volume.getData();
if (isoTO.getPath() != null) {
TemplateObjectTO template = (TemplateObjectTO) isoTO;
DataStoreTO store = template.getDataStore();
if (!(store instanceof NfsTO)) {
throw new CloudRuntimeException("unsupported protocol");
}
NfsTO nfsStore = (NfsTO) store;
String isoPath = nfsStore.getUrl() + File.separator + template.getPath();
OvmDisk.Details iso = new OvmDisk.Details();
URI path = new URI(isoPath);
iso.path = path.getHost() + ":" + path.getPath();
iso.type = OvmDisk.READ;
iso.isIso = true;
vm.disks.add(iso);
}
} else if (volume.getType() == Volume.Type.DATADISK) {
OvmDisk.Details data = new OvmDisk.Details();
data.path = volume.getData().getPath();
data.type = OvmDisk.SHAREDWRITE;
data.isIso = false;
vm.disks.add(data);
} else {
throw new CloudRuntimeException("Unknow volume type: " + volume.getType());
}
}
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class VmwareStorageManagerImpl method createOvaForTemplate.
@Override
public String createOvaForTemplate(TemplateObjectTO template, int archiveTimeout) {
DataStoreTO storeTO = template.getDataStore();
if (!(storeTO instanceof NfsTO)) {
s_logger.debug("Can only handle NFS storage, while creating OVA from template");
return null;
}
NfsTO nfsStore = (NfsTO) storeTO;
String secStorageUrl = nfsStore.getUrl();
assert (secStorageUrl != null);
String installPath = template.getPath();
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl, nfsStore.getNfsVersion());
String installFullPath = secondaryMountPoint + "/" + installPath;
try {
if (installFullPath.endsWith(".ova")) {
if (new File(installFullPath).exists()) {
s_logger.debug("OVA file found at: " + installFullPath);
} else {
if (new File(installFullPath + ".meta").exists()) {
createOVAFromMetafile(installFullPath + ".meta", archiveTimeout);
} else {
String msg = "Unable to find OVA or OVA MetaFile to prepare template.";
s_logger.error(msg);
throw new Exception(msg);
}
}
return installPath;
}
} catch (Throwable e) {
s_logger.debug("Failed to create OVA: " + e.toString());
}
return null;
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class AncientDataMotionStrategy method copyVolumeFromSnapshot.
protected Answer copyVolumeFromSnapshot(DataObject snapObj, DataObject volObj) {
SnapshotInfo snapshot = (SnapshotInfo) snapObj;
StoragePool pool = (StoragePool) volObj.getDataStore();
String basicErrMsg = "Failed to create volume from " + snapshot.getName() + " on pool " + pool;
DataStore store = snapObj.getDataStore();
DataStoreTO storTO = store.getTO();
DataObject srcData = snapObj;
try {
if (!(storTO instanceof NfsTO)) {
// cache snapshot to zone-wide staging store for the volume to be created
srcData = cacheSnapshotChain(snapshot, new ZoneScope(pool.getDataCenterId()));
}
String value = configDao.getValue(Config.CreateVolumeFromSnapshotWait.toString());
int _createVolumeFromSnapshotWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CreateVolumeFromSnapshotWait.getDefaultValue()));
EndPoint ep = null;
if (srcData.getDataStore().getRole() == DataStoreRole.Primary) {
ep = selector.select(volObj);
} else {
ep = selector.select(srcData, volObj);
}
CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(volObj.getTO()), _createVolumeFromSnapshotWait, VirtualMachineManager.ExecuteInSequence.value());
Answer answer = null;
if (ep == null) {
String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
s_logger.error(errMsg);
answer = new Answer(cmd, false, errMsg);
} else {
answer = ep.sendMessage(cmd);
}
return answer;
} catch (Exception e) {
s_logger.error(basicErrMsg, e);
throw new CloudRuntimeException(basicErrMsg);
} finally {
if (!(storTO instanceof NfsTO)) {
// still keep snapshot on cache which may be migrated from previous secondary storage
releaseSnapshotCacheChain((SnapshotInfo) srcData);
}
}
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class SimulatorStorageProcessor method attachIso.
@Override
public Answer attachIso(AttachCommand cmd) {
DiskTO disk = cmd.getDisk();
TemplateObjectTO isoTO = (TemplateObjectTO) disk.getData();
DataStoreTO store = isoTO.getDataStore();
if (!(store instanceof NfsTO)) {
return new AttachAnswer("unsupported protocol");
}
return new Answer(cmd);
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class SimulatorStorageProcessor method createTemplateFromVolume.
@Override
public Answer createTemplateFromVolume(CopyCommand cmd) {
DataTO destData = cmd.getDestTO();
VolumeObjectTO srcData = (VolumeObjectTO) cmd.getSrcTO();
TemplateObjectTO template = new TemplateObjectTO();
template.setPath(template.getName());
template.setFormat(Storage.ImageFormat.RAW);
template.setSize(srcData.getSize());
DataStoreTO imageStore = destData.getDataStore();
if (!(imageStore instanceof NfsTO)) {
return new CopyCmdAnswer("unsupported protocol");
}
return new CopyCmdAnswer(template);
}
Aggregations