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);
}
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);
}
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);
}
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());
}
}
}
}
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);
}
Aggregations