本文整理了Java中com.cloud.storage.Volume.getId()
方法的一些代码示例,展示了Volume.getId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Volume.getId()
方法的具体详情如下:
包路径:com.cloud.storage.Volume
类名称:Volume
方法名:getId
暂无
代码示例来源:origin: apache/cloudstack
@Override
public boolean canOperateOnVolume(Volume volume) {
List<SnapshotVO> snapshots = _snapshotDao.listByStatus(volume.getId(), Snapshot.State.Creating, Snapshot.State.CreatedOnPrimary, Snapshot.State.BackingUp);
if (snapshots.size() > 0) {
return false;
}
return true;
}
代码示例来源:origin: apache/cloudstack
@Override
public List<VolumeJoinVO> newVolumeView(Volume vol) {
SearchCriteria<VolumeJoinVO> sc = volIdSearch.create();
sc.setParameters("id", vol.getId());
return searchIncludingRemoved(sc, null, null, false);
}
代码示例来源:origin: apache/cloudstack
@ReflectionUse
private Pair<JobInfo.Status, String> orchestrateDetachVolumeFromVM(VmWorkDetachVolume work) throws Exception {
Volume vol = orchestrateDetachVolumeFromVM(work.getVmId(), work.getVolumeId());
return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(new Long(vol.getId())));
}
代码示例来源:origin: apache/cloudstack
@ReflectionUse
private Pair<JobInfo.Status, String> orchestrateAttachVolumeToVM(VmWorkAttachVolume work) throws Exception {
Volume vol = orchestrateAttachVolumeToVM(work.getVmId(), work.getVolumeId(), work.getDeviceId());
return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(new Long(vol.getId())));
}
代码示例来源:origin: apache/cloudstack
@Override
public void destroyVolume(Volume volume) {
try {
// Mark volume as removed if volume has not been created on primary
if (volume.getState() == Volume.State.Allocated) {
_volsDao.remove(volume.getId());
stateTransitTo(volume, Volume.Event.DestroyRequested);
} else {
volService.destroyVolume(volume.getId());
}
// FIXME - All this is boiler plate code and should be done as part of state transition. This shouldn't be part of orchestrator.
// publish usage event for the volume
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), Volume.class.getName(),
volume.getUuid(), volume.isDisplayVolume());
_resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.volume, volume.isDisplay());
_resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, volume.isDisplay(), new Long(volume.getSize()));
} catch (Exception e) {
s_logger.debug("Failed to destroy volume" + volume.getId(), e);
throw new CloudRuntimeException("Failed to destroy volume" + volume.getId(), e);
}
}
代码示例来源:origin: apache/cloudstack
@DB
protected Volume liveMigrateVolume(Volume volume, StoragePool destPool) {
VolumeInfo vol = volFactory.getVolume(volume.getId());
AsyncCallFuture<VolumeApiResult> future = volService.migrateVolume(vol, (DataStore)destPool);
try {
VolumeApiResult result = future.get();
if (result.isFailed()) {
s_logger.debug("migrate volume failed:" + result.getResult());
return null;
}
return result.getVolume();
} catch (InterruptedException e) {
s_logger.debug("migrate volume failed", e);
return null;
} catch (ExecutionException e) {
s_logger.debug("migrate volume failed", e);
return null;
}
}
代码示例来源:origin: apache/cloudstack
private Volume orchestrateMigrateVolume(VolumeVO volume, StoragePool destPool, boolean liveMigrateVolume, DiskOfferingVO newDiskOffering) {
Volume newVol = null;
try {
if (liveMigrateVolume) {
newVol = liveMigrateVolume(volume, destPool);
} else {
newVol = _volumeMgr.migrateVolume(volume, destPool);
}
if (newDiskOffering != null) {
_volsDao.updateDiskOffering(newVol.getId(), newDiskOffering.getId());
}
} catch (StorageUnavailableException e) {
s_logger.debug("Failed to migrate volume", e);
throw new CloudRuntimeException(e.getMessage());
} catch (Exception e) {
s_logger.debug("Failed to migrate volume", e);
throw new CloudRuntimeException(e.getMessage());
}
return newVol;
}
代码示例来源:origin: apache/cloudstack
@Override
public void updateDisplay(Volume volume, Boolean displayVolume) {
// 1. Resource limit changes
updateResourceCount(volume, displayVolume);
// 2. generate usage event if not in destroyed state
saveUsageEvent(volume, displayVolume);
// 3. Set the flag
if (displayVolume != null && displayVolume != volume.isDisplayVolume()) {
// FIXME - Confused - typecast for now.
((VolumeVO)volume).setDisplayVolume(displayVolume);
_volsDao.update(volume.getId(), (VolumeVO)volume);
}
}
代码示例来源:origin: apache/cloudstack
volumeMap.put(volFactory.getVolume(volume.getId()), (DataStore)destPool);
代码示例来源:origin: apache/cloudstack
@Override
public void create() throws ResourceAllocationException {
Volume volume = _volumeService.allocVolume(this);
if (volume != null) {
setEntityId(volume.getId());
setEntityUuid(volume.getUuid());
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create volume");
}
}
代码示例来源:origin: apache/cloudstack
@DB
protected Volume liveMigrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException {
VolumeInfo vol = volFactory.getVolume(volume.getId());
DataStore dataStoreTarget = dataStoreMgr.getDataStore(destPool.getId(), DataStoreRole.Primary);
AsyncCallFuture<VolumeApiResult> future = volService.migrateVolume(vol, dataStoreTarget);
try {
VolumeApiResult result = future.get();
if (result.isFailed()) {
s_logger.debug("migrate volume failed:" + result.getResult());
throw new StorageUnavailableException("Migrate volume failed: " + result.getResult(), destPool.getId());
}
return result.getVolume();
} catch (InterruptedException e) {
s_logger.debug("migrate volume failed", e);
throw new CloudRuntimeException(e.getMessage());
} catch (ExecutionException e) {
s_logger.debug("migrate volume failed", e);
throw new CloudRuntimeException(e.getMessage());
}
}
代码示例来源:origin: apache/cloudstack
private void saveUsageEvent(Volume volume, Boolean displayVolume) {
// Update only when the flag has changed && only when volume in a non-destroyed state.
if ((displayVolume != null && displayVolume != volume.isDisplayVolume()) && !isVolumeDestroyed(volume)) {
if (displayVolume) {
// flag turned 1 equivalent to freshly created volume
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), volume.getDiskOfferingId(),
volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid());
} else {
// flag turned 0 equivalent to deleting a volume
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), Volume.class.getName(),
volume.getUuid());
}
}
}
代码示例来源:origin: apache/cloudstack
private long getDataObjectSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool pool) {
DataStoreProvider storeProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName());
DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
if (storeDriver instanceof PrimaryDataStoreDriver) {
PrimaryDataStoreDriver primaryStoreDriver = (PrimaryDataStoreDriver)storeDriver;
VolumeInfo volumeInfo = volFactory.getVolume(volume.getId());
return primaryStoreDriver.getDataObjectSizeIncludingHypervisorSnapshotReserve(volumeInfo, pool);
}
return volume.getSize();
}
代码示例来源:origin: apache/cloudstack
@ReflectionUse
private Pair<JobInfo.Status, String> orchestrateResizeVolume(VmWorkResizeVolume work) throws Exception {
Volume vol = orchestrateResizeVolume(work.getVolumeId(), work.getCurrentSize(), work.getNewSize(), work.getNewMinIops(), work.getNewMaxIops(), work.getNewHypervisorSnapshotReserve(),
work.getNewServiceOfferingId(), work.isShrinkOk());
return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(new Long(vol.getId())));
}
代码示例来源:origin: apache/cloudstack
public DiskProfile(Volume vol, DiskOffering offering, HypervisorType hyperType) {
this(vol.getId(),
vol.getVolumeType(),
vol.getName(),
offering.getId(),
vol.getSize(),
offering.getTagsArray(),
offering.isUseLocalStorage(),
offering.isCustomized(),
null);
this.hyperType = hyperType;
this.provisioningType = offering.getProvisioningType();
}
代码示例来源:origin: apache/cloudstack
protected DiskProfile toDiskProfile(Volume vol, DiskOffering offering) {
return new DiskProfile(vol.getId(), vol.getVolumeType(), vol.getName(), offering.getId(), vol.getSize(), offering.getTagsArray(), offering.isUseLocalStorage(), offering.isRecreatable(),
vol.getTemplateId());
}
代码示例来源:origin: apache/cloudstack
@ReflectionUse
private Pair<JobInfo.Status, String> orchestrateMigrateVolume(VmWorkMigrateVolume work) throws Exception {
VolumeVO volume = _volsDao.findById(work.getVolumeId());
StoragePoolVO targetStoragePool = _storagePoolDao.findById(work.getDestPoolId());
DiskOfferingVO newDiskOffering = _diskOfferingDao.findById(work.getNewDiskOfferingId());
Volume newVol = orchestrateMigrateVolume(volume, targetStoragePool, work.isLiveMigrate(), newDiskOffering);
return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(newVol.getId()));
}
代码示例来源:origin: apache/cloudstack
public VolumeTO(Volume volume, StoragePool pool) {
this.id = volume.getId();
this.name = volume.getName();
this.path = volume.getPath();
this.size = volume.getSize();
this.type = volume.getVolumeType();
this.storagePoolType = pool.getPoolType();
this.storagePoolUuid = pool.getUuid();
this.mountPoint = volume.getFolder();
this.chainInfo = volume.getChainInfo();
this.chainSize = volume.getVmSnapshotChainSize();
if (volume.getDeviceId() != null)
this.deviceId = volume.getDeviceId();
}
代码示例来源:origin: apache/cloudstack
@Override
public boolean postStateTransitionEvent(StateMachine2.Transition<State, Event> transition, Volume vol, boolean status, Object opaque) {
pubishOnEventBus(transition.getEvent().name(), "postStateTransitionEvent", vol, transition.getCurrentState(), transition.getToState());
if(transition.isImpacted(StateMachine2.Transition.Impact.USAGE)) {
Long instanceId = vol.getInstanceId();
VMInstanceVO vmInstanceVO = null;
if(instanceId != null) {
vmInstanceVO = _vmInstanceDao.findById(instanceId);
}
if(instanceId == null || vmInstanceVO.getType() == VirtualMachine.Type.User) {
if (transition.getToState() == State.Ready) {
if (transition.getCurrentState() == State.Resizing) {
// Log usage event for volumes belonging user VM's only
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_RESIZE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(),
vol.getDiskOfferingId(), vol.getTemplateId(), vol.getSize(), Volume.class.getName(), vol.getUuid());
} else {
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(), vol.getDiskOfferingId(), null, vol.getSize(),
Volume.class.getName(), vol.getUuid(), vol.isDisplayVolume());
}
} else if (transition.getToState() == State.Destroy && vol.getVolumeType() != Volume.Type.ROOT) { //Do not Publish Usage Event for ROOT Disk as it would have been published already while destroying a VM
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(),
Volume.class.getName(), vol.getUuid(), vol.isDisplayVolume());
} else if (transition.getToState() == State.Uploaded) {
//Currently we are not capturing Usage for Secondary Storage so Usage for this operation will be captured when it is moved to primary storage
}
}
}
return true;
}
代码示例来源:origin: apache/cloudstack
@Override
public VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType)
throws ConcurrentOperationException, StorageUnavailableException {
// Find a destination storage pool with the specified criteria
DiskOffering diskOffering = _entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId());
DiskProfile dskCh = new DiskProfile(volume.getId(), volume.getVolumeType(), volume.getName(), diskOffering.getId(), diskOffering.getDiskSize(), diskOffering.getTagsArray(),
diskOffering.isUseLocalStorage(), diskOffering.isRecreatable(), null);
dskCh.setHyperType(dataDiskHyperType);
storageMgr.setDiskProfileThrottling(dskCh, null, diskOffering);
DataCenter destPoolDataCenter = _entityMgr.findById(DataCenter.class, destPoolDcId);
Pod destPoolPod = _entityMgr.findById(Pod.class, destPoolPodId);
StoragePool destPool = findStoragePool(dskCh, destPoolDataCenter, destPoolPod, destPoolClusterId, null, null, new HashSet<StoragePool>());
if (destPool == null) {
throw new CloudRuntimeException("Failed to find a storage pool with enough capacity to move the volume to.");
}
Volume newVol = migrateVolume(volume, destPool);
return volFactory.getVolume(newVol.getId());
}
内容来源于网络,如有侵权,请联系作者删除!