use of org.apache.cloudstack.storage.to.TemplateObjectTO in project cloudstack by apache.
the class Ovm3StorageProcessorTest method copyCommandTemplateToTemplateTest.
/**
* Copy template from secondary to primary template
*
* @throws ConfigurationException
*/
@Test
public void copyCommandTemplateToTemplateTest() throws ConfigurationException {
con = prepare();
con.setMethodResponse("storage_plugin_mount", results.simpleResponseWrapWrapper(storageplugin.getNfsFileSystemInfo()));
/*
* because the template requires a reference to the name for the uuid...
* -sigh-
*/
String templateid = ovmObject.newUuid();
String targetid = ovmObject.newUuid();
String templatedir = "template/tmpl/1/11" + templateid + ".raw";
String storeUrl = "nfs://" + linux.getRemoteHost() + "/" + linux.getRemoteDir();
TemplateObjectTO src = template(templateid, linux.getRepoId(), storeUrl, templatedir);
TemplateObjectTO dest = template(targetid, linux.getRepoId(), linux.getRepoId(), linux.getTemplatesDir());
CopyCommand copy = new CopyCommand(src, dest, 0, true);
CopyCmdAnswer ra = (CopyCmdAnswer) hypervisor.executeRequest(copy);
TemplateObjectTO vol = (TemplateObjectTO) ra.getNewData();
results.basicStringTest(vol.getUuid(), targetid);
results.basicStringTest(vol.getPath(), targetid);
results.basicBooleanTest(ra.getResult());
}
use of org.apache.cloudstack.storage.to.TemplateObjectTO in project cloudstack by apache.
the class Ovm3StorageProcessorTest method template.
/* these could all actually be condensed to a DiskTO */
private TemplateObjectTO template(final String uuid, final String dsuuid, final String storeUrl, final String path) {
TemplateObjectTO template = new TemplateObjectTO();
NfsTO nfsDataStore = new NfsTO();
nfsDataStore.setUuid(dsuuid);
nfsDataStore.setUrl(storeUrl);
template.setDataStore(nfsDataStore);
template.setPath(path);
template.setUuid(uuid);
return template;
}
use of org.apache.cloudstack.storage.to.TemplateObjectTO in project cloudstack by apache.
the class Ovm3StorageProcessorTest method disk.
private DiskTO disk(final String uuid, final String dsuuid, final String storeUrl, final String path, Volume.Type type) {
DiskTO disk = new DiskTO();
disk.setType(type);
disk.setPath("");
TemplateObjectTO template = template(uuid, dsuuid, storeUrl, path);
disk.setData(template);
return disk;
}
use of org.apache.cloudstack.storage.to.TemplateObjectTO in project cloudstack by apache.
the class Ovm3StorageProcessorTest method copyCommandTemplateToVolumeTest.
/**
* Copy template from primary to primary volume
*
* @throws ConfigurationException
*/
@Test
public void copyCommandTemplateToVolumeTest() throws ConfigurationException {
con = prepare();
String voluuid = ovmObject.newUuid();
TemplateObjectTO src = template(ovmObject.newUuid(), ovmObject.newUuid(), linux.getRepoId(), linux.getTemplatesDir());
VolumeObjectTO dest = volume(voluuid, ovmObject.newUuid(), linux.getRepoId(), linux.getVirtualDisksDir());
CopyCommand copy = new CopyCommand(src, dest, 0, true);
CopyCmdAnswer ra = (CopyCmdAnswer) hypervisor.executeRequest(copy);
VolumeObjectTO vol = (VolumeObjectTO) ra.getNewData();
results.basicStringTest(vol.getUuid(), voluuid);
results.basicStringTest(vol.getPath(), voluuid);
results.basicBooleanTest(ra.getResult());
}
use of org.apache.cloudstack.storage.to.TemplateObjectTO in project cloudstack by apache.
the class TemplateManagerImpl method prepareIsoForVmProfile.
@Override
public void prepareIsoForVmProfile(VirtualMachineProfile profile) {
UserVmVO vm = _userVmDao.findById(profile.getId());
if (vm.getIsoId() != null) {
TemplateInfo template = prepareIso(vm.getIsoId(), vm.getDataCenterId());
if (template == null) {
s_logger.error("Failed to prepare ISO on secondary or cache storage");
throw new CloudRuntimeException("Failed to prepare ISO on secondary or cache storage");
}
if (template.isBootable()) {
profile.setBootLoaderType(BootloaderType.CD);
}
GuestOSVO guestOS = _guestOSDao.findById(template.getGuestOSId());
String displayName = null;
if (guestOS != null) {
displayName = guestOS.getDisplayName();
}
TemplateObjectTO iso = (TemplateObjectTO) template.getTO();
iso.setGuestOsType(displayName);
DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
profile.addDisk(disk);
} else {
TemplateObjectTO iso = new TemplateObjectTO();
iso.setFormat(ImageFormat.ISO);
DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
profile.addDisk(disk);
}
}
Aggregations