当前位置: 首页>>代码示例>>Java>>正文


Java UserVmVO.getLastHostId方法代码示例

本文整理汇总了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();
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:20,代码来源:VolumeApiServiceImpl.java

示例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();
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:20,代码来源:VolumeApiServiceImpl.java

示例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();
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:37,代码来源:VMSnapshotHelperImpl.java

示例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();
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:35,代码来源:VMSnapshotHelperImpl.java


注:本文中的com.cloud.vm.UserVmVO.getLastHostId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。