Search in sources :

Example 36 with VolumeObjectTO

use of org.apache.cloudstack.storage.to.VolumeObjectTO in project cloudstack by apache.

the class SimulatorStorageProcessor method copyVolumeFromImageCacheToPrimary.

@Override
public Answer copyVolumeFromImageCacheToPrimary(CopyCommand cmd) {
    VolumeObjectTO volume = new VolumeObjectTO();
    volume.setPath(UUID.randomUUID().toString());
    volume.setSize(100);
    volume.setFormat(Storage.ImageFormat.RAW);
    return new CopyCmdAnswer(volume);
}
Also used : VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer)

Example 37 with VolumeObjectTO

use of org.apache.cloudstack.storage.to.VolumeObjectTO 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)

Example 38 with VolumeObjectTO

use of org.apache.cloudstack.storage.to.VolumeObjectTO in project cloudstack by apache.

the class SimulatorStorageProcessor method createVolume.

@Override
public Answer createVolume(CreateObjectCommand cmd) {
    VolumeObjectTO volume = (VolumeObjectTO) cmd.getData();
    VolumeObjectTO newVol = new VolumeObjectTO();
    newVol.setPath(volume.getName());
    return new CreateObjectAnswer(newVol);
}
Also used : CreateObjectAnswer(org.apache.cloudstack.storage.command.CreateObjectAnswer) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO)

Example 39 with VolumeObjectTO

use of org.apache.cloudstack.storage.to.VolumeObjectTO in project cloudstack by apache.

the class VirtualMachineManagerImpl method syncDiskChainChange.

private void syncDiskChainChange(final StartAnswer answer) {
    final VirtualMachineTO vmSpec = answer.getVirtualMachine();
    for (final DiskTO disk : vmSpec.getDisks()) {
        if (disk.getType() != Volume.Type.ISO) {
            final VolumeObjectTO vol = (VolumeObjectTO) disk.getData();
            final VolumeVO volume = _volsDao.findById(vol.getId());
            // returned null instead of an actual path (because it was out of date with the DB).
            if (vol.getPath() != null) {
                volumeMgr.updateVolumeDiskChain(vol.getId(), vol.getPath(), vol.getChainInfo());
            } else {
                volumeMgr.updateVolumeDiskChain(vol.getId(), volume.getPath(), vol.getChainInfo());
            }
        }
    }
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) DiskTO(com.cloud.agent.api.to.DiskTO)

Example 40 with VolumeObjectTO

use of org.apache.cloudstack.storage.to.VolumeObjectTO in project cloudstack by apache.

the class VolumeObject method processEventOnly.

@Override
public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer) {
    try {
        if (dataStore.getRole() == DataStoreRole.Primary) {
            if (answer instanceof CopyCmdAnswer) {
                CopyCmdAnswer cpyAnswer = (CopyCmdAnswer) answer;
                VolumeVO vol = volumeDao.findById(getId());
                VolumeObjectTO newVol = (VolumeObjectTO) cpyAnswer.getNewData();
                vol.setPath(newVol.getPath());
                if (newVol.getSize() != null) {
                    vol.setSize(newVol.getSize());
                }
                vol.setPoolId(getDataStore().getId());
                volumeDao.update(vol.getId(), vol);
            } else if (answer instanceof CreateObjectAnswer) {
                CreateObjectAnswer createAnswer = (CreateObjectAnswer) answer;
                VolumeObjectTO newVol = (VolumeObjectTO) createAnswer.getData();
                VolumeVO vol = volumeDao.findById(getId());
                vol.setPath(newVol.getPath());
                if (newVol.getSize() != null) {
                    vol.setSize(newVol.getSize());
                }
                vol.setPoolId(getDataStore().getId());
                volumeDao.update(vol.getId(), vol);
            }
        } else {
            // image store or imageCache store
            if (answer instanceof DownloadAnswer) {
                DownloadAnswer dwdAnswer = (DownloadAnswer) answer;
                VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
                volStore.setInstallPath(dwdAnswer.getInstallPath());
                volStore.setChecksum(dwdAnswer.getCheckSum());
                volumeStoreDao.update(volStore.getId(), volStore);
            } else if (answer instanceof CopyCmdAnswer) {
                CopyCmdAnswer cpyAnswer = (CopyCmdAnswer) answer;
                VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
                VolumeObjectTO newVol = (VolumeObjectTO) cpyAnswer.getNewData();
                volStore.setInstallPath(newVol.getPath());
                if (newVol.getSize() != null) {
                    volStore.setSize(newVol.getSize());
                }
                volumeStoreDao.update(volStore.getId(), volStore);
            }
        }
    } catch (RuntimeException ex) {
        if (event == ObjectInDataStoreStateMachine.Event.OperationFailed) {
            objectInStoreMgr.deleteIfNotReady(this);
        }
        throw ex;
    }
    this.processEventOnly(event);
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VolumeVO(com.cloud.storage.VolumeVO) CreateObjectAnswer(org.apache.cloudstack.storage.command.CreateObjectAnswer) VolumeDataStoreVO(org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) DownloadAnswer(com.cloud.agent.api.storage.DownloadAnswer) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer)

Aggregations

VolumeObjectTO (org.apache.cloudstack.storage.to.VolumeObjectTO)108 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)59 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)45 DataStoreTO (com.cloud.agent.api.to.DataStoreTO)36 PrimaryDataStoreTO (org.apache.cloudstack.storage.to.PrimaryDataStoreTO)36 DataTO (com.cloud.agent.api.to.DataTO)31 NfsTO (com.cloud.agent.api.to.NfsTO)31 InternalErrorException (com.cloud.exception.InternalErrorException)27 TemplateObjectTO (org.apache.cloudstack.storage.to.TemplateObjectTO)20 Connection (com.xensource.xenapi.Connection)19 VDI (com.xensource.xenapi.VDI)17 IOException (java.io.IOException)17 Answer (com.cloud.agent.api.Answer)16 DiskTO (com.cloud.agent.api.to.DiskTO)16 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)16 RemoteException (java.rmi.RemoteException)16 ArrayList (java.util.ArrayList)16 SnapshotObjectTO (org.apache.cloudstack.storage.to.SnapshotObjectTO)16 VmwareHypervisorHost (com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost)14 UnsupportedEncodingException (java.io.UnsupportedEncodingException)14