use of com.cloud.agent.api.to.NfsTO in project cosmic by MissionCriticalCloud.
the class CloudStackImageStoreDriverImpl method getStoreTO.
@Override
public DataStoreTO getStoreTO(final DataStore store) {
final ImageStoreImpl nfsStore = (ImageStoreImpl) store;
final NfsTO nfsTO = new NfsTO();
nfsTO.setRole(store.getRole());
nfsTO.setUrl(nfsStore.getUri());
return nfsTO;
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class RequestTest method testSerDeserTO.
public void testSerDeserTO() {
s_logger.info("Testing serializing and deserializing interface TO works as expected");
NfsTO nfs = new NfsTO("nfs://192.168.56.10/opt/storage/secondary", DataStoreRole.Image);
// SecStorageSetupCommand cmd = new SecStorageSetupCommand(nfs, "nfs://192.168.56.10/opt/storage/secondary", null);
ListTemplateCommand cmd = new ListTemplateCommand(nfs);
Request sreq = new Request(2, 3, cmd, true);
sreq.setSequence(892403718);
byte[] bytes = sreq.getBytes();
assert Request.getSequence(bytes) == 892403718;
assert Request.getManagementServerId(bytes) == 3;
assert Request.getAgentId(bytes) == 2;
assert Request.getViaAgentId(bytes) == 2;
Request creq = null;
try {
creq = Request.parse(bytes);
} catch (ClassNotFoundException e) {
s_logger.error("Unable to parse bytes: ", e);
} catch (UnsupportedVersionException e) {
s_logger.error("Unable to parse bytes: ", e);
}
assert creq != null : "Couldn't get the request back";
compareRequest(creq, sreq);
assertEquals("nfs://192.168.56.10/opt/storage/secondary", ((NfsTO) ((ListTemplateCommand) creq.getCommand()).getDataStore()).getUrl());
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class RequestTest method testDownload.
public void testDownload() {
s_logger.info("Testing Download answer");
VirtualMachineTemplate template = Mockito.mock(VirtualMachineTemplate.class);
Mockito.when(template.getId()).thenReturn(1L);
Mockito.when(template.getFormat()).thenReturn(ImageFormat.QCOW2);
Mockito.when(template.getName()).thenReturn("templatename");
Mockito.when(template.getTemplateType()).thenReturn(TemplateType.USER);
Mockito.when(template.getDisplayText()).thenReturn("displayText");
Mockito.when(template.getHypervisorType()).thenReturn(HypervisorType.KVM);
Mockito.when(template.getUrl()).thenReturn("url");
NfsTO nfs = new NfsTO("secUrl", DataStoreRole.Image);
TemplateObjectTO to = new TemplateObjectTO(template);
to.setImageDataStore(nfs);
DownloadCommand cmd = new DownloadCommand(to, 30000000l);
Request req = new Request(1, 1, cmd, true);
req.logD("Debug for Download");
DownloadAnswer answer = new DownloadAnswer("jobId", 50, "errorString", Status.ABANDONED, "filesystempath", "installpath", 10000000, 20000000, "chksum");
Response resp = new Response(req, answer);
resp.logD("Debug for Download");
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class VmwareStorageManagerImpl method createOvaForVolume.
//Fang: new command added;
// Important! we need to sync file system before we can safely use tar to work around a linux kernal bug(or feature)
public String createOvaForVolume(VolumeObjectTO volume) {
DataStoreTO storeTO = volume.getDataStore();
if (!(storeTO instanceof NfsTO)) {
s_logger.debug("can only handle nfs storage, when create ova from volume");
return null;
}
NfsTO nfsStore = (NfsTO) storeTO;
String secStorageUrl = nfsStore.getUrl();
assert (secStorageUrl != null);
//Note the volume path is volumes/accountId/volumeId/uuid/, the actual volume is uuid/uuid.vmdk
String installPath = volume.getPath();
int index = installPath.lastIndexOf(File.separator);
String volumeUuid = installPath.substring(index + 1);
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl, _nfsVersion);
//The real volume path
String volumePath = installPath + File.separator + volumeUuid + ".ova";
String installFullPath = secondaryMountPoint + "/" + installPath;
try {
if (new File(secondaryMountPoint + File.separator + volumePath).exists()) {
s_logger.debug("ova already exists:" + volumePath);
return volumePath;
} else {
Script commandSync = new Script(true, "sync", 0, s_logger);
commandSync.execute();
Script command = new Script(false, "tar", 0, s_logger);
command.setWorkDir(installFullPath);
command.add("-cf", volumeUuid + ".ova");
// OVF file should be the first file in OVA archive
command.add(volumeUuid + ".ovf");
command.add(volumeUuid + "-disk0.vmdk");
command.execute();
return volumePath;
}
} catch (Throwable e) {
s_logger.info("Exception for createVolumeOVA");
}
return null;
}
use of com.cloud.agent.api.to.NfsTO in project cloudstack by apache.
the class TemplateManagerImpl method prepareIso.
// for ISO, we need to consider whether to copy to cache storage or not if it is not on NFS, since our hypervisor resource always assumes that they are in NFS
@Override
public TemplateInfo prepareIso(long isoId, long dcId) {
TemplateInfo tmplt = _tmplFactory.getTemplate(isoId, DataStoreRole.Image, dcId);
if (tmplt == null || tmplt.getFormat() != ImageFormat.ISO) {
s_logger.warn("ISO: " + isoId + " does not exist in vm_template table");
return null;
}
if (tmplt.getDataStore() != null && !(tmplt.getDataStore().getTO() instanceof NfsTO)) {
// if it is s3, need to download into cache storage first
Scope destScope = new ZoneScope(dcId);
TemplateInfo cacheData = (TemplateInfo) cacheMgr.createCacheObject(tmplt, destScope);
if (cacheData == null) {
s_logger.error("Failed in copy iso from S3 to cache storage");
return null;
}
return cacheData;
} else {
return tmplt;
}
}
Aggregations