@Override public void attachVolume(long volumeId, long vmId, long deviceId) { VolumeVO volume = createForUpdate(volumeId); volume.setInstanceId(vmId); volume.setDeviceId(deviceId); volume.setUpdated(new Date()); volume.setAttached(new Date()); if (deviceId == 0L) { volume.setVolumeType(Type.ROOT); } update(volumeId, volume); }
@Override public void detachVolume(long volumeId) { VolumeVO volume = createForUpdate(volumeId); volume.setInstanceId(null); volume.setDeviceId(null); volume.setUpdated(new Date()); volume.setAttached(null); if (findById(volumeId).getVolumeType() == Type.ROOT) { volume.setVolumeType(Type.DATADISK); } update(volumeId, volume); }
protected VolumeVO duplicateVolumeOnAnotherStorage(Volume volume, StoragePool pool) { Long lastPoolId = volume.getPoolId(); String folder = pool.getPath(); // For SMB, pool credentials are also stored in the uri query string. We trim the query string // part here to make sure the credentials do not get stored in the db unencrypted. if (pool.getPoolType() == StoragePoolType.SMB && folder != null && folder.contains("?")) { folder = folder.substring(0, folder.indexOf("?")); } VolumeVO newVol = new VolumeVO(volume); newVol.setInstanceId(null); newVol.setChainInfo(null); newVol.setPath(null); newVol.setFolder(folder); newVol.setPodId(pool.getPodId()); newVol.setPoolId(pool.getId()); newVol.setLastPoolId(lastPoolId); newVol.setPodId(pool.getPodId()); return volDao.persist(newVol); }
private VolumeVO duplicateVolumeOnAnotherStorage(Volume volume, StoragePoolVO storagePoolVO) { Long lastPoolId = volume.getPoolId(); VolumeVO newVol = new VolumeVO(volume); newVol.setInstanceId(null); newVol.setChainInfo(null); newVol.setPath(null); newVol.setFolder(null); newVol.setPodId(storagePoolVO.getPodId()); newVol.setPoolId(storagePoolVO.getId()); newVol.setLastPoolId(lastPoolId); return _volumeDao.persist(newVol); }
volume.setMinIops(minIops); volume.setMaxIops(maxIops); volume.setInstanceId(null); volume.setUpdated(new Date()); volume.setDisplayVolume(displayVolume);
@Override @DB public boolean updateUuid(long srcVolId, long destVolId) { TransactionLegacy txn = TransactionLegacy.currentTxn(); txn.start(); try { VolumeVO srcVol = findById(srcVolId); VolumeVO destVol = findById(destVolId); String uuid = srcVol.getUuid(); Long instanceId = srcVol.getInstanceId(); srcVol.setUuid(null); destVol.setUuid(uuid); destVol.setInstanceId(instanceId); update(srcVolId, srcVol); update(destVolId, destVol); _tagsDao.updateResourceId(srcVolId, destVolId, ResourceObjectType.Volume); } catch (Exception e) { throw new CloudRuntimeException("Unable to persist the sequence number for this host"); } txn.commit(); return true; }
volume.setInstanceId(null); volume.setUpdated(new Date()); volume.setDomainId((owner == null) ? Domain.ROOT_DOMAIN : owner.getDomainId());
public VolumeVO allocateDuplicateVolumeVO(Volume oldVol, Long templateId) { VolumeVO newVol = new VolumeVO(oldVol.getVolumeType(), oldVol.getName(), oldVol.getDataCenterId(), oldVol.getDomainId(), oldVol.getAccountId(), oldVol.getDiskOfferingId(), oldVol.getProvisioningType(), oldVol.getSize(), oldVol.getMinIops(), oldVol.getMaxIops(), oldVol.get_iScsiName()); if (templateId != null) { newVol.setTemplateId(templateId); } else { newVol.setTemplateId(oldVol.getTemplateId()); } newVol.setDeviceId(oldVol.getDeviceId()); newVol.setInstanceId(oldVol.getInstanceId()); newVol.setRecreatable(oldVol.isRecreatable()); newVol.setFormat(oldVol.getFormat()); return _volsDao.persist(newVol); }
vol.setFormat(getSupportedImageFormatForCluster(template.getHypervisorType())); if (vm != null) { vol.setInstanceId(vm.getId());
vol.setInstanceId(vm.getId());