use of com.cloud.storage.VolumeVO 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);
}
use of com.cloud.storage.VolumeVO in project cloudstack by apache.
the class PrimaryDataStoreImpl method getVolumes.
@Override
public List<VolumeInfo> getVolumes() {
List<VolumeVO> volumes = volumeDao.findByPoolId(getId());
List<VolumeInfo> volumeInfos = new ArrayList<VolumeInfo>();
for (VolumeVO volume : volumes) {
volumeInfos.add(VolumeObject.getVolumeObject(this, volume));
}
return volumeInfos;
}
use of com.cloud.storage.VolumeVO in project cloudstack by apache.
the class PrimaryDataStoreImpl method getVolume.
@Override
public VolumeInfo getVolume(long id) {
VolumeVO volumeVO = volumeDao.findById(id);
VolumeObject vol = VolumeObject.getVolumeObject(this, volumeVO);
return vol;
}
use of com.cloud.storage.VolumeVO in project cloudstack by apache.
the class VolumeServiceImpl method canVolumeBeRemoved.
// check if a volume is expunged on both primary and secondary
private boolean canVolumeBeRemoved(long volumeId) {
VolumeVO vol = volDao.findById(volumeId);
if (vol == null) {
// already removed from volumes table
return false;
}
VolumeDataStoreVO volumeStore = _volumeStoreDao.findByVolume(volumeId);
if ((vol.getState() == State.Expunged || (vol.getPodId() == null && vol.getState() == State.Destroy)) && volumeStore == null) {
// volume is expunged from primary, as well as on secondary
return true;
} else {
return false;
}
}
use of com.cloud.storage.VolumeVO in project cloudstack by apache.
the class SolidFireHostListener method getTargets.
private List<Map<String, String>> getTargets(long clusterId, long storagePoolId) {
List<Map<String, String>> targets = new ArrayList<>();
StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId);
// If you do not pass in null for the second parameter, you only get back applicable ROOT disks.
List<VolumeVO> volumes = _volumeDao.findByPoolId(storagePoolId, null);
if (volumes != null) {
for (VolumeVO volume : volumes) {
Long instanceId = volume.getInstanceId();
if (instanceId != null) {
VMInstanceVO vmInstance = _vmDao.findById(instanceId);
Long hostIdForVm = vmInstance.getHostId() != null ? vmInstance.getHostId() : vmInstance.getLastHostId();
if (hostIdForVm != null) {
HostVO hostForVm = _hostDao.findById(hostIdForVm);
if (hostForVm.getClusterId().equals(clusterId)) {
Map<String, String> details = new HashMap<>();
details.put(ModifyTargetsCommand.IQN, volume.get_iScsiName());
details.put(ModifyTargetsCommand.STORAGE_HOST, storagePool.getHostAddress());
details.put(ModifyTargetsCommand.STORAGE_PORT, String.valueOf(storagePool.getPort()));
targets.add(details);
}
}
}
}
}
return targets;
}
Aggregations