com.cloud.storage.Volume.getInstanceId()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(164)

本文整理了Java中com.cloud.storage.Volume.getInstanceId()方法的一些代码示例,展示了Volume.getInstanceId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Volume.getInstanceId()方法的具体详情如下:
包路径:com.cloud.storage.Volume
类名称:Volume
方法名:getInstanceId

Volume.getInstanceId介绍

暂无

代码示例

代码示例来源:origin: apache/cloudstack

private HypervisorType getHypervisorType(Volume volume) {
  Long instanceId = volume.getInstanceId();
  VMInstanceVO vmInstance = _vmInstanceDao.findById(instanceId);
  if (vmInstance != null) {
    return vmInstance.getHypervisorType();
  }
  return null;
}

代码示例来源:origin: apache/cloudstack

@Override
public String getVmNameOnVolume(Volume volume) {
  Long vmId = volume.getInstanceId();
  if (vmId != null) {
    VirtualMachine vm = _entityMgr.findById(VirtualMachine.class, vmId);
    if (vm == null) {
      return null;
    }
    return vm.getInstanceName();
  }
  return null;
}

代码示例来源:origin: apache/cloudstack

@Override
public boolean volumeInactive(Volume volume) {
  Long vmId = volume.getInstanceId();
  if (vmId == null) {
    return true;
  }
  UserVm vm = _entityMgr.findById(UserVm.class, vmId);
  if (vm == null) {
    return true;
  }
  State state = vm.getState();
  if (state.equals(State.Stopped) || state.equals(State.Destroyed)) {
    return true;
  }
  return false;
}

代码示例来源:origin: apache/cloudstack

@Override
public Long getHostIdForSnapshotOperation(Volume vol) {
  VMInstanceVO vm = _vmDao.findById(vol.getInstanceId());
  if (vm != null) {
    if (vm.getHostId() != null) {
      return vm.getHostId();
    } else if (vm.getLastHostId() != null) {
      return vm.getLastHostId();
    }
  }
  return null;
}

代码示例来源:origin: apache/cloudstack

StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(storagePool.getId(), DataStoreRole.Primary);
if (volume.getInstanceId() != vm.getId()) {
  throw new CloudRuntimeException("Volume " + volume + " that has to be migrated doesn't belong to the" + " instance " + vm);

代码示例来源:origin: apache/cloudstack

that.getAccountId(),
that.getDomainId(),
that.getInstanceId(),
that.getFolder(),
that.getPath(),

代码示例来源: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

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

代码示例来源:origin: apache/cloudstack

Long instanceId = volume.getInstanceId();

相关文章