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


Java UserVmVO.getHypervisorType方法代码示例

本文整理汇总了Java中com.cloud.vm.UserVmVO.getHypervisorType方法的典型用法代码示例。如果您正苦于以下问题:Java UserVmVO.getHypervisorType方法的具体用法?Java UserVmVO.getHypervisorType怎么用?Java UserVmVO.getHypervisorType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.cloud.vm.UserVmVO的用法示例。


在下文中一共展示了UserVmVO.getHypervisorType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateRootVolumeDetachAttach

import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
private void validateRootVolumeDetachAttach(final VolumeVO volume, final UserVmVO vm) {
    if (!(vm.getHypervisorType() == HypervisorType.XenServer || vm.getHypervisorType() == HypervisorType.KVM)) {
        throw new InvalidParameterValueException("Root volume detach is not supported for hypervisor type " + vm.getHypervisorType());
    }
    if (!(vm.getState() == State.Stopped) || vm.getState() == State.Destroyed) {
        throw new InvalidParameterValueException("Root volume detach can happen only when vm is in states: " + State.Stopped.toString() + " or " + State.Destroyed.toString());
    }

    if (volume.getPoolId() != null) {
        final StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId());
        if (pool.isManaged()) {
            throw new InvalidParameterValueException("Root volume detach is not supported for Managed DataStores");
        }
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:16,代码来源:VolumeApiServiceImpl.java

示例2: validateRootVolumeDetachAttach

import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
private void validateRootVolumeDetachAttach(VolumeVO volume, UserVmVO vm) {
    if (!(vm.getHypervisorType() == HypervisorType.XenServer || vm.getHypervisorType() == HypervisorType.VMware || vm.getHypervisorType() == HypervisorType.KVM || vm.getHypervisorType() == HypervisorType.Simulator)) {
        throw new InvalidParameterValueException("Root volume detach is not supported for hypervisor type " + vm.getHypervisorType() );
    }
    if (!(vm.getState() == State.Stopped) || (vm.getState() == State.Destroyed)) {
        throw new InvalidParameterValueException("Root volume detach can happen only when vm is in states: " + State.Stopped.toString() + " or " + State.Destroyed.toString());
    }

    if (volume.getPoolId() != null) {
        StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId());
        if (pool.isManaged()) {
            throw new InvalidParameterValueException("Root volume detach is not supported for Managed DataStores");
        }
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:16,代码来源:VolumeApiServiceImpl.java

示例3: attachIso

import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
@Override
@ActionEvent(eventType = EventTypes.EVENT_ISO_ATTACH, eventDescription = "attaching ISO", async = true)
public boolean attachIso(final long isoId, final long vmId) {
    final Account caller = CallContext.current().getCallingAccount();
    final Long userId = CallContext.current().getCallingUserId();

    // Verify input parameters
    final UserVmVO vm = _userVmDao.findById(vmId);
    if (vm == null) {
        throw new InvalidParameterValueException("Unable to find a virtual machine with id " + vmId);
    }

    final VMTemplateVO iso = _tmpltDao.findById(isoId);
    if (iso == null || iso.getRemoved() != null) {
        throw new InvalidParameterValueException("Unable to find an ISO with id " + isoId);
    }

    // check permissions
    // check if caller has access to VM and ISO
    // and also check if the VM's owner has access to the ISO.

    _accountMgr.checkAccess(caller, null, false, iso, vm);

    final Account vmOwner = _accountDao.findById(vm.getAccountId());
    _accountMgr.checkAccess(vmOwner, null, false, iso, vm);

    final State vmState = vm.getState();
    if (vmState != State.Running && vmState != State.Stopped) {
        throw new InvalidParameterValueException("Please specify a VM that is either Stopped or Running.");
    }

    if ("xen-pv-drv-iso".equals(iso.getDisplayText()) && vm.getHypervisorType() != Hypervisor.HypervisorType.XenServer) {
        throw new InvalidParameterValueException("Cannot attach Xenserver PV drivers to incompatible hypervisor " + vm.getHypervisorType());
    }

    final boolean result = attachISOToVM(vmId, userId, isoId, true);
    if (result) {
        return result;
    } else {
        throw new CloudRuntimeException("Failed to attach iso");
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:43,代码来源:TemplateManagerImpl.java

示例4: supportedByHypervisor

import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
private boolean supportedByHypervisor(final VolumeInfo volume) {
    final HypervisorType hypervisorType;
    final StoragePoolVO storagePool = _storagePoolDao.findById(volume.getDataStore().getId());
    final ScopeType scope = storagePool.getScope();
    if (scope.equals(ScopeType.ZONE)) {
        hypervisorType = storagePool.getHypervisor();
    } else {
        hypervisorType = volume.getHypervisorType();
    }

    if (hypervisorType.equals(HypervisorType.KVM)) {
        List<HostVO> hosts = null;
        if (scope.equals(ScopeType.CLUSTER)) {
            final ClusterVO cluster = _clusterDao.findById(storagePool.getClusterId());
            hosts = _resourceMgr.listAllHostsInCluster(cluster.getId());
        } else if (scope.equals(ScopeType.ZONE)) {
            hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType, volume.getDataCenterId());
        }
        if (hosts != null && !hosts.isEmpty()) {
            final HostVO host = hosts.get(0);
            if (!hostSupportSnapsthotForVolume(host, volume)) {
                throw new CloudRuntimeException("KVM Snapshot is not supported: " + host.getId());
            }
        }
    }

    // if volume is attached to a vm in destroyed or expunging state; disallow
    if (volume.getInstanceId() != null) {
        final UserVmVO userVm = _vmDao.findById(volume.getInstanceId());
        if (userVm != null) {
            if (userVm.getState().equals(State.Destroyed) || userVm.getState().equals(State.Expunging)) {
                throw new CloudRuntimeException("Creating snapshot failed due to volume:" + volume.getId() + " is associated with vm:" + userVm.getInstanceName() +
                        " is in " + userVm.getState().toString() + " state");
            }

            if (userVm.getHypervisorType() == HypervisorType.KVM) {
                final List<SnapshotVO> activeSnapshots =
                        _snapshotDao.listByInstanceId(volume.getInstanceId(), Snapshot.State.Creating, Snapshot.State.CreatedOnPrimary, Snapshot.State.BackingUp);
                if (activeSnapshots.size() > 0) {
                    throw new InvalidParameterValueException("There is other active snapshot tasks on the instance to which the volume is attached, please try again later");
                }
            }

            final List<VMSnapshotVO> activeVMSnapshots =
                    _vmSnapshotDao.listByInstanceId(userVm.getId(), VMSnapshot.State.Creating, VMSnapshot.State.Reverting, VMSnapshot.State.Expunging);
            if (activeVMSnapshots.size() > 0) {
                throw new CloudRuntimeException("There is other active vm snapshot tasks on the instance to which the volume is attached, please try again later");
            }
        }
    }

    return true;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:54,代码来源:SnapshotManagerImpl.java

示例5: attachIso

import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
@Override
@ActionEvent(eventType = EventTypes.EVENT_ISO_ATTACH, eventDescription = "attaching ISO", async = true)
public boolean attachIso(long isoId, long vmId) {
    Account caller = CallContext.current().getCallingAccount();
    Long userId = CallContext.current().getCallingUserId();

    // Verify input parameters
    UserVmVO vm = _userVmDao.findById(vmId);
    if (vm == null) {
        throw new InvalidParameterValueException("Unable to find a virtual machine with id " + vmId);
    }

    VMTemplateVO iso = _tmpltDao.findById(isoId);
    if (iso == null || iso.getRemoved() != null) {
        throw new InvalidParameterValueException("Unable to find an ISO with id " + isoId);
    }

    // check permissions
    // check if caller has access to VM and ISO
    // and also check if the VM's owner has access to the ISO.

    _accountMgr.checkAccess(caller, null, false, iso, vm);

    Account vmOwner = _accountDao.findById(vm.getAccountId());
    _accountMgr.checkAccess(vmOwner, null, false, iso, vm);

    State vmState = vm.getState();
    if (vmState != State.Running && vmState != State.Stopped) {
        throw new InvalidParameterValueException("Please specify a VM that is either Stopped or Running.");
    }

    if ("xen-pv-drv-iso".equals(iso.getDisplayText()) && vm.getHypervisorType() != Hypervisor.HypervisorType.XenServer) {
        throw new InvalidParameterValueException("Cannot attach Xenserver PV drivers to incompatible hypervisor " + vm.getHypervisorType());
    }

    if ("vmware-tools.iso".equals(iso.getName()) && vm.getHypervisorType() != Hypervisor.HypervisorType.VMware) {
        throw new InvalidParameterValueException("Cannot attach VMware tools drivers to incompatible hypervisor " + vm.getHypervisorType());
    }
    boolean result = attachISOToVM(vmId, userId, isoId, true);
    if (result) {
        return result;
    } else {
        throw new CloudRuntimeException("Failed to attach iso");
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:46,代码来源:TemplateManagerImpl.java

示例6: supportedByHypervisor

import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
private boolean supportedByHypervisor(VolumeInfo volume) {
    HypervisorType hypervisorType;
    StoragePoolVO storagePool = _storagePoolDao.findById(volume.getDataStore().getId());
    ScopeType scope = storagePool.getScope();
    if (scope.equals(ScopeType.ZONE)) {
        hypervisorType = storagePool.getHypervisor();
    } else {
        hypervisorType = volume.getHypervisorType();
    }

    if (hypervisorType.equals(HypervisorType.Ovm)) {
        throw new InvalidParameterValueException("Ovm won't support taking snapshot");
    }

    if (hypervisorType.equals(HypervisorType.KVM)) {
        List<HostVO> hosts = null;
        if (scope.equals(ScopeType.CLUSTER)) {
            ClusterVO cluster = _clusterDao.findById(storagePool.getClusterId());
            hosts = _resourceMgr.listAllHostsInCluster(cluster.getId());
        } else if (scope.equals(ScopeType.ZONE)) {
            hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType, volume.getDataCenterId());
        }
        if (hosts != null && !hosts.isEmpty()) {
            HostVO host = hosts.get(0);
            if (!hostSupportSnapsthotForVolume(host, volume)) {
                throw new CloudRuntimeException("KVM Snapshot is not supported: " + host.getId());
            }
        }
    }

    // if volume is attached to a vm in destroyed or expunging state; disallow
    if (volume.getInstanceId() != null) {
        UserVmVO userVm = _vmDao.findById(volume.getInstanceId());
        if (userVm != null) {
            if (userVm.getState().equals(State.Destroyed) || userVm.getState().equals(State.Expunging)) {
                throw new CloudRuntimeException("Creating snapshot failed due to volume:" + volume.getId() + " is associated with vm:" + userVm.getInstanceName() +
                    " is in " + userVm.getState().toString() + " state");
            }

            if (userVm.getHypervisorType() == HypervisorType.VMware || userVm.getHypervisorType() == HypervisorType.KVM) {
                List<SnapshotVO> activeSnapshots =
                    _snapshotDao.listByInstanceId(volume.getInstanceId(), Snapshot.State.Creating, Snapshot.State.CreatedOnPrimary, Snapshot.State.BackingUp);
                if (activeSnapshots.size() > 0) {
                    throw new InvalidParameterValueException("There is other active snapshot tasks on the instance to which the volume is attached, please try again later");
                }
            }

            List<VMSnapshotVO> activeVMSnapshots =
                _vmSnapshotDao.listByInstanceId(userVm.getId(), VMSnapshot.State.Creating, VMSnapshot.State.Reverting, VMSnapshot.State.Expunging);
            if (activeVMSnapshots.size() > 0) {
                throw new CloudRuntimeException("There is other active vm snapshot tasks on the instance to which the volume is attached, please try again later");
            }
        }
    }

    return true;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:58,代码来源:SnapshotManagerImpl.java


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