本文整理汇总了Java中com.cloud.vm.UserVmVO.getLastHostId方法的典型用法代码示例。如果您正苦于以下问题:Java UserVmVO.getLastHostId方法的具体用法?Java UserVmVO.getLastHostId怎么用?Java UserVmVO.getLastHostId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cloud.vm.UserVmVO
的用法示例。
在下文中一共展示了UserVmVO.getLastHostId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMaxDataVolumesSupported
import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
private int getMaxDataVolumesSupported(final UserVmVO vm) {
Long hostId = vm.getHostId();
if (hostId == null) {
hostId = vm.getLastHostId();
}
final HostVO host = _hostDao.findById(hostId);
Integer maxDataVolumesSupported = null;
if (host != null) {
_hostDao.loadDetails(host);
maxDataVolumesSupported = _hypervisorCapabilitiesDao.getMaxDataVolumesLimit(host.getHypervisorType(), host.getDetail("product_version"));
}
if (maxDataVolumesSupported == null) {
maxDataVolumesSupported = 6; // 6 data disks by default if nothing
// is specified in
// 'hypervisor_capabilities' table
}
return maxDataVolumesSupported.intValue();
}
示例2: getMaxDataVolumesSupported
import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
private int getMaxDataVolumesSupported(UserVmVO vm) {
Long hostId = vm.getHostId();
if (hostId == null) {
hostId = vm.getLastHostId();
}
HostVO host = _hostDao.findById(hostId);
Integer maxDataVolumesSupported = null;
if (host != null) {
_hostDao.loadDetails(host);
maxDataVolumesSupported = _hypervisorCapabilitiesDao.getMaxDataVolumesLimit(host.getHypervisorType(), host.getDetail("product_version"));
}
if (maxDataVolumesSupported == null || maxDataVolumesSupported.intValue() <= 0) {
maxDataVolumesSupported = 6; // 6 data disks by default if nothing
// is specified in
// 'hypervisor_capabilities' table
}
return maxDataVolumesSupported.intValue();
}
示例3: pickRunningHost
import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
@Override
public Long pickRunningHost(final Long vmId) {
final UserVmVO vm = userVmDao.findById(vmId);
// use VM's host if VM is running
if (vm.getState() == VirtualMachine.State.Running) {
return vm.getHostId();
}
// check if lastHostId is available
if (vm.getLastHostId() != null) {
final HostVO lastHost = hostDao.findByIdIncludingRemoved(vm.getLastHostId());
if (lastHost.getStatus() == com.cloud.host.Status.Up && !lastHost.isInMaintenanceStates()) {
return lastHost.getId();
}
}
final List<VolumeVO> listVolumes = volumeDao.findByInstance(vmId);
if (listVolumes == null || listVolumes.size() == 0) {
throw new InvalidParameterValueException("vmInstance has no volumes");
}
final VolumeVO volume = listVolumes.get(0);
final Long poolId = volume.getPoolId();
if (poolId == null) {
throw new InvalidParameterValueException("pool id is not found");
}
final StoragePoolVO storagePool = primaryDataStoreDao.findById(poolId);
if (storagePool == null) {
throw new InvalidParameterValueException("storage pool is not found");
}
final List<HostVO> listHost =
hostDao.listAllUpAndEnabledNonHAHosts(Host.Type.Routing, storagePool.getClusterId(), storagePool.getPodId(), storagePool.getDataCenterId(), null);
if (listHost == null || listHost.size() == 0) {
throw new InvalidParameterValueException("no host in up state is found");
}
return listHost.get(0).getId();
}
示例4: pickRunningHost
import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
@Override
public Long pickRunningHost(Long vmId) {
UserVmVO vm = userVmDao.findById(vmId);
// use VM's host if VM is running
if (vm.getState() == VirtualMachine.State.Running)
return vm.getHostId();
// check if lastHostId is available
if (vm.getLastHostId() != null) {
HostVO lastHost = hostDao.findByIdIncludingRemoved(vm.getLastHostId());
if (lastHost.getStatus() == com.cloud.host.Status.Up && !lastHost.isInMaintenanceStates())
return lastHost.getId();
}
List<VolumeVO> listVolumes = volumeDao.findByInstance(vmId);
if (listVolumes == null || listVolumes.size() == 0) {
throw new InvalidParameterValueException("vmInstance has no volumes");
}
VolumeVO volume = listVolumes.get(0);
Long poolId = volume.getPoolId();
if (poolId == null) {
throw new InvalidParameterValueException("pool id is not found");
}
StoragePoolVO storagePool = primaryDataStoreDao.findById(poolId);
if (storagePool == null) {
throw new InvalidParameterValueException("storage pool is not found");
}
List<HostVO> listHost =
hostDao.listAllUpAndEnabledNonHAHosts(Host.Type.Routing, storagePool.getClusterId(), storagePool.getPodId(), storagePool.getDataCenterId(), null);
if (listHost == null || listHost.size() == 0) {
throw new InvalidParameterValueException("no host in up state is found");
}
return listHost.get(0).getId();
}