Search in sources :

Example 41 with TemplateObjectTO

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());
}
Also used : CopyCommand(org.apache.cloudstack.storage.command.CopyCommand) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) LinuxTest(com.cloud.hypervisor.ovm3.objects.LinuxTest) Test(org.junit.Test) XenTest(com.cloud.hypervisor.ovm3.objects.XenTest) StoragePluginTest(com.cloud.hypervisor.ovm3.objects.StoragePluginTest) Ovm3SupportTest(com.cloud.hypervisor.ovm3.support.Ovm3SupportTest) XmlTestResultTest(com.cloud.hypervisor.ovm3.objects.XmlTestResultTest) Ovm3ConfigurationTest(com.cloud.hypervisor.ovm3.resources.helpers.Ovm3ConfigurationTest)

Example 42 with TemplateObjectTO

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;
}
Also used : TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) NfsTO(com.cloud.agent.api.to.NfsTO)

Example 43 with TemplateObjectTO

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;
}
Also used : TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) DiskTO(com.cloud.agent.api.to.DiskTO)

Example 44 with TemplateObjectTO

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());
}
Also used : CopyCommand(org.apache.cloudstack.storage.command.CopyCommand) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) LinuxTest(com.cloud.hypervisor.ovm3.objects.LinuxTest) Test(org.junit.Test) XenTest(com.cloud.hypervisor.ovm3.objects.XenTest) StoragePluginTest(com.cloud.hypervisor.ovm3.objects.StoragePluginTest) Ovm3SupportTest(com.cloud.hypervisor.ovm3.support.Ovm3SupportTest) XmlTestResultTest(com.cloud.hypervisor.ovm3.objects.XmlTestResultTest) Ovm3ConfigurationTest(com.cloud.hypervisor.ovm3.resources.helpers.Ovm3ConfigurationTest)

Example 45 with TemplateObjectTO

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);
    }
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) GuestOSVO(com.cloud.storage.GuestOSVO) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) DiskTO(com.cloud.agent.api.to.DiskTO)

Aggregations

TemplateObjectTO (org.apache.cloudstack.storage.to.TemplateObjectTO)57 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)40 NfsTO (com.cloud.agent.api.to.NfsTO)34 DataStoreTO (com.cloud.agent.api.to.DataStoreTO)28 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)26 DataTO (com.cloud.agent.api.to.DataTO)22 VolumeObjectTO (org.apache.cloudstack.storage.to.VolumeObjectTO)20 InternalErrorException (com.cloud.exception.InternalErrorException)19 PrimaryDataStoreTO (org.apache.cloudstack.storage.to.PrimaryDataStoreTO)19 DiskTO (com.cloud.agent.api.to.DiskTO)13 XmlRpcException (org.apache.xmlrpc.XmlRpcException)12 XenAPIException (com.xensource.xenapi.Types.XenAPIException)11 SnapshotObjectTO (org.apache.cloudstack.storage.to.SnapshotObjectTO)11 Answer (com.cloud.agent.api.Answer)10 VDI (com.xensource.xenapi.VDI)10 Connection (com.xensource.xenapi.Connection)9 SR (com.xensource.xenapi.SR)9 URI (java.net.URI)9 ConfigurationException (javax.naming.ConfigurationException)9 IOException (java.io.IOException)8