Search in sources :

Example 36 with NfsTO

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());
        }
    }
}
Also used : DataStoreTO(com.cloud.agent.api.to.DataStoreTO) DataTO(com.cloud.agent.api.to.DataTO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) OvmDisk(com.cloud.ovm.object.OvmDisk) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) NfsTO(com.cloud.agent.api.to.NfsTO) URI(java.net.URI) DiskTO(com.cloud.agent.api.to.DiskTO)

Example 37 with NfsTO

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;
}
Also used : DataStoreTO(com.cloud.agent.api.to.DataStoreTO) NfsTO(com.cloud.agent.api.to.NfsTO) DatastoreFile(com.cloud.hypervisor.vmware.mo.DatastoreFile) File(java.io.File) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 38 with NfsTO

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);
        }
    }
}
Also used : PrimaryDataStoreTO(org.apache.cloudstack.storage.to.PrimaryDataStoreTO) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) StoragePool(com.cloud.storage.StoragePool) CopyCommand(org.apache.cloudstack.storage.command.CopyCommand) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(org.apache.cloudstack.storage.RemoteHostEndPoint) NfsTO(com.cloud.agent.api.to.NfsTO) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) RemoteHostEndPoint(org.apache.cloudstack.storage.RemoteHostEndPoint) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ZoneScope(org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope) Answer(com.cloud.agent.api.Answer) MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) SnapshotInfo(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo) DataObject(org.apache.cloudstack.engine.subsystem.api.storage.DataObject) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore)

Example 39 with NfsTO

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);
}
Also used : CreateObjectAnswer(org.apache.cloudstack.storage.command.CreateObjectAnswer) ResignatureAnswer(org.apache.cloudstack.storage.command.ResignatureAnswer) Answer(com.cloud.agent.api.Answer) DettachAnswer(org.apache.cloudstack.storage.command.DettachAnswer) SnapshotAndCopyAnswer(org.apache.cloudstack.storage.command.SnapshotAndCopyAnswer) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) NfsTO(com.cloud.agent.api.to.NfsTO) DiskTO(com.cloud.agent.api.to.DiskTO) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer)

Example 40 with NfsTO

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

Aggregations

NfsTO (com.cloud.agent.api.to.NfsTO)142 DataStoreTO (com.cloud.agent.api.to.DataStoreTO)110 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)79 DataTO (com.cloud.agent.api.to.DataTO)71 InternalErrorException (com.cloud.exception.InternalErrorException)58 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)52 PrimaryDataStoreTO (org.apache.cloudstack.storage.to.PrimaryDataStoreTO)39 TemplateObjectTO (org.apache.cloudstack.storage.to.TemplateObjectTO)38 XmlRpcException (org.apache.xmlrpc.XmlRpcException)37 XenAPIException (com.xensource.xenapi.Types.XenAPIException)36 URI (java.net.URI)36 Connection (com.xensource.xenapi.Connection)34 SR (com.xensource.xenapi.SR)34 VDI (com.xensource.xenapi.VDI)34 CopyCmdAnswer (com.cloud.storage.command.CopyCmdAnswer)32 VolumeObjectTO (org.apache.cloudstack.storage.to.VolumeObjectTO)32 Answer (com.cloud.agent.api.Answer)29 IOException (java.io.IOException)28 File (java.io.File)27 PrimaryDataStoreTO (com.cloud.storage.to.PrimaryDataStoreTO)26