Package com.cloud.vm

Examples of com.cloud.vm.VMInstanceVO


        if(detailsInVm != null) {
            details.putAll(detailsInVm);
        }
        to.setDetails(details);
        // Workaround to make sure the TO has the UUID we need for Niciri integration
        VMInstanceVO vmInstance = _virtualMachineDao.findById(to.getId());
        // check if XStools/VMWare tools are present in the VM and dynamic scaling feature is enabled (per zone/global)
        Boolean isDynamicallyScalable = vmInstance.isDynamicallyScalable() && Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(), Config.ConfigurationParameterScope.zone.toString(), vm.getDataCenterId()));
        to.setEnableDynamicallyScaleVm(isDynamicallyScalable);
        to.setUuid(vmInstance.getUuid());

        //
        return to;
    }
View Full Code Here


            ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
        if (vm.getType() != Type.User || vm.getHypervisorType() != HypervisorType.BareMetal) {
            return false;
        }
       
        VMInstanceVO vo = _vmDao.findById(vm.getId());
        if (vo.getLastHostId() == null) {
            Transaction txn = Transaction.currentTxn();
            txn.start();
            nic.setMacAddress(dest.getHost().getPrivateMacAddress());
            NicVO nicVo = _nicDao.findById(nic.getId());
            assert vo != null : "Where ths nic " + nic.getId() + " going???";
View Full Code Here

    public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
            AsyncCompletionCallback<CopyCommandResult> callback) {
        Answer answer = null;
        String errMsg = null;
        try {
            VMInstanceVO instance = instanceDao.findById(vmTo.getId());
            if (instance != null) {
                if (srcHost.getClusterId() == destHost.getClusterId()) {
                    answer = migrateVmWithVolumesWithinCluster(instance, vmTo, srcHost, destHost, volumeMap);
                } else {
                    answer = migrateVmWithVolumesAcrossCluster(instance, vmTo, srcHost, destHost, volumeMap);
View Full Code Here

    public void checkWhenDcInAvoidList() throws InsufficientServerCapacityException {
        DataCenterVO mockDc = mock(DataCenterVO.class);
        ExcludeList avoids = mock(ExcludeList.class);
        @SuppressWarnings("unchecked")
        VirtualMachineProfileImpl<VMInstanceVO> vmProfile = mock(VirtualMachineProfileImpl.class);
        VMInstanceVO vm = mock(VMInstanceVO.class);
        DataCenterDeployment plan = mock(DataCenterDeployment.class);

        when(avoids.shouldAvoid(mockDc)).thenReturn(true);
        when(vmProfile.getVirtualMachine()).thenReturn(vm);
        when(vm.getDataCenterId()).thenReturn(1L);
        when(dcDao.findById(1L)).thenReturn(mockDc);

        List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
        assertTrue("Cluster list should be null/empty if the dc is in avoid list",
                (clusterList == null || clusterList.isEmpty()));
View Full Code Here

        assertTrue("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
    }

    private void initializeForTest(VirtualMachineProfileImpl<VMInstanceVO> vmProfile, DataCenterDeployment plan) {
        DataCenterVO mockDc = mock(DataCenterVO.class);
        VMInstanceVO vm = mock(VMInstanceVO.class);
        UserVmVO userVm = mock(UserVmVO.class);
        ServiceOfferingVO offering = mock(ServiceOfferingVO.class);

        AccountVO account = mock(AccountVO.class);
        when(account.getId()).thenReturn(accountId);
        when(account.getAccountId()).thenReturn(accountId);
        when(vmProfile.getOwner()).thenReturn(account);
        when(vmProfile.getVirtualMachine()).thenReturn(vm);
        when(vmProfile.getId()).thenReturn(12L);
        when(vmDao.findById(12L)).thenReturn(userVm);
        when(userVm.getAccountId()).thenReturn(accountId);

        when(vm.getDataCenterId()).thenReturn(dataCenterId);
        when(dcDao.findById(1L)).thenReturn(mockDc);
        when(plan.getDataCenterId()).thenReturn(dataCenterId);
        when(plan.getClusterId()).thenReturn(null);
        when(plan.getPodId()).thenReturn(null);
        when(configDao.getValue(anyString())).thenReturn("false").thenReturn("CPU");
View Full Code Here

                List<Long> groupVMIds = _affinityGroupVMMapDao.listVmIdsByAffinityGroup(group.getId());
                groupVMIds.remove(vm.getId());

                for (Long groupVMId : groupVMIds) {
                    VMInstanceVO groupVM = _vmInstanceDao.findById(groupVMId);
                    if (groupVM != null && !groupVM.isRemoved()) {
                        if (groupVM.getHostId() != null) {
                            avoid.addHost(groupVM.getHostId());
                            if (s_logger.isDebugEnabled()) {
                                s_logger.debug("Added host " + groupVM.getHostId() + " to avoid set, since VM "
                                        + groupVM.getId() + " is present on the host");
                            }
                        } else if (VirtualMachine.State.Stopped.equals(groupVM.getState())
                                && groupVM.getLastHostId() != null) {
                            long secondsSinceLastUpdate = (DateUtil.currentGMTTime().getTime() - groupVM.getUpdateTime().getTime()) / 1000;
                            if (secondsSinceLastUpdate < _vmCapacityReleaseInterval) {
                                avoid.addHost(groupVM.getLastHostId());
                                if (s_logger.isDebugEnabled()) {
                                    s_logger.debug("Added host " + groupVM.getLastHostId() + " to avoid set, since VM "
                                            + groupVM.getId() + " is present on the host, in Stopped state but has reserved capacity");
                                }
                            }
                        }
                    }
                }
View Full Code Here

        when(srcHost.getClusterId()).thenReturn(1L);
        when(destHost.getClusterId()).thenReturn(1L);
        Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
        VirtualMachineTO to = mock(VirtualMachineTO.class);
        when(to.getId()).thenReturn(6L);
        VMInstanceVO instance = mock(VMInstanceVO.class);
        when(instanceDao.findById(6L)).thenReturn(instance);

        MockContext<CommandResult> context = new MockContext<CommandResult>(null, null, volumeMap);
        AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
        caller.setCallback(caller.getTarget().mockCallBack(null, null)).setContext(context);
View Full Code Here

        when(srcHost.getClusterId()).thenReturn(1L);
        when(destHost.getClusterId()).thenReturn(1L);
        Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
        VirtualMachineTO to = mock(VirtualMachineTO.class);
        when(to.getId()).thenReturn(6L);
        VMInstanceVO instance = mock(VMInstanceVO.class);
        when(instanceDao.findById(6L)).thenReturn(instance);

        MockContext<CommandResult> context = new MockContext<CommandResult>(null, null, volumeMap);
        AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
        caller.setCallback(caller.getTarget().mockCallBack(null, null)).setContext(context);
View Full Code Here

        when(srcHost.getClusterId()).thenReturn(1L);
        when(destHost.getClusterId()).thenReturn(2L);
        Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
        VirtualMachineTO to = mock(VirtualMachineTO.class);
        when(to.getId()).thenReturn(6L);
        VMInstanceVO instance = mock(VMInstanceVO.class);
        when(instanceDao.findById(6L)).thenReturn(instance);

        MockContext<CommandResult> context = new MockContext<CommandResult>(null, null, volumeMap);
        AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
        caller.setCallback(caller.getTarget().mockCallBack(null, null)).setContext(context);
View Full Code Here

        when(srcHost.getClusterId()).thenReturn(1L);
        when(destHost.getClusterId()).thenReturn(2L);
        Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
        VirtualMachineTO to = mock(VirtualMachineTO.class);
        when(to.getId()).thenReturn(6L);
        VMInstanceVO instance = mock(VMInstanceVO.class);
        when(instanceDao.findById(6L)).thenReturn(instance);

        MockContext<CommandResult> context = new MockContext<CommandResult>(null, null, volumeMap);
        AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
        caller.setCallback(caller.getTarget().mockCallBack(null, null)).setContext(context);
View Full Code Here

TOP

Related Classes of com.cloud.vm.VMInstanceVO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.