Examples of StopCommand


Examples of com.cloud.agent.api.StopCommand

    @Test
    public void testSendStopWithOkAnswer() throws Exception {
        VirtualMachineGuru guru = mock(VirtualMachineGuru.class);
        VirtualMachine vm = mock(VirtualMachine.class);
        VirtualMachineProfile profile = mock(VirtualMachineProfile.class);
        StopAnswer answer = new StopAnswer(new StopCommand(vm, false, false), "ok", true);
        when(profile.getVirtualMachine()).thenReturn(vm);
        when(vm.getHostId()).thenReturn(1L);
        when(_agentMgr.send(anyLong(), (Command)any())).thenReturn(answer);

        boolean actual = _vmMgr.sendStop(guru, profile, false, false);
View Full Code Here

Examples of com.cloud.agent.api.StopCommand

    @Test
    public void testSendStopWithFailAnswer() throws Exception {
        VirtualMachineGuru guru = mock(VirtualMachineGuru.class);
        VirtualMachine vm = mock(VirtualMachine.class);
        VirtualMachineProfile profile = mock(VirtualMachineProfile.class);
        StopAnswer answer = new StopAnswer(new StopCommand(vm, false, false), "fail", false);
        when(profile.getVirtualMachine()).thenReturn(vm);
        when(vm.getHostId()).thenReturn(1L);
        when(_agentMgr.send(anyLong(), (Command)any())).thenReturn(answer);

        boolean actual = _vmMgr.sendStop(guru, profile, false, false);
View Full Code Here

Examples of com.cloud.agent.api.StopCommand

                        } else {
                            if (s_logger.isDebugEnabled()) {
                                s_logger.info("The guru did not like the answers so stopping " + vm);
                            }

                            StopCommand cmd = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()), false);
                            StopAnswer answer = (StopAnswer) _agentMgr.easySend(destHostId, cmd);
                            if ( answer != null ) {

                                if (vm.getType() == VirtualMachine.Type.User) {
                                    String platform = answer.getPlatform();
View Full Code Here

Examples of com.cloud.agent.api.StopCommand

        }
    }

    protected boolean sendStop(VirtualMachineGuru guru, VirtualMachineProfile profile, boolean force, boolean checkBeforeCleanup) {
        VirtualMachine vm = profile.getVirtualMachine();
        StopCommand stop = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()), checkBeforeCleanup);
        try {
            StopAnswer answer = (StopAnswer)_agentMgr.send(vm.getHostId(), stop);
            if (answer != null) {
                if (vm.getType() == VirtualMachine.Type.User) {
                    String platform = answer.getPlatform();
                    if (platform != null) {
                        UserVmVO userVm = _userVmDao.findById(vm.getId());
                        _userVmDao.loadDetails(userVm);
                        userVm.setDetail("platform", platform);
                        _userVmDao.saveDetails(userVm);
                    }
                }

                GPUDeviceTO gpuDevice = stop.getGpuDevice();
                if (gpuDevice != null) {
                    _resourceMgr.updateGPUDetails(vm.getHostId(), gpuDevice.getGroupDetails());
                }
                if (!answer.getResult()) {
                    s_logger.debug("Unable to stop VM due to " + answer.getDetails());
View Full Code Here

Examples of com.cloud.agent.api.StopCommand

            throw new CloudRuntimeException("We cannot proceed with stop VM " + vm + " since it is not in 'Stopping' state, current state: " + vm.getState());
        }

        vmGuru.prepareStop(profile);

        StopCommand stop = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()), false);

        boolean stopped = false;
        StopAnswer answer = null;
        try {
            answer = (StopAnswer)_agentMgr.send(vm.getHostId(), stop);
            if (answer != null) {
                if (vm.getType() == VirtualMachine.Type.User) {
                    String platform = answer.getPlatform();
                    if (platform != null) {
                        UserVmVO userVm = _userVmDao.findById(vm.getId());
                        _userVmDao.loadDetails(userVm);
                        userVm.setDetail("platform", platform);
                        _userVmDao.saveDetails(userVm);
                    }
                }
                stopped = answer.getResult();
                if (!stopped) {
                    throw new CloudRuntimeException("Unable to stop the virtual machine due to " + answer.getDetails());
                }
                vmGuru.finalizeStop(profile, answer);
                GPUDeviceTO gpuDevice = stop.getGpuDevice();
                if (gpuDevice != null) {
                    _resourceMgr.updateGPUDetails(vm.getHostId(), gpuDevice.getGroupDetails());
                }
            } else {
                throw new CloudRuntimeException("Invalid answer received in response to a StopCommand on " + vm.instanceName);
View Full Code Here

Examples of com.cloud.agent.api.StopCommand

            throw new CloudRuntimeException("Failed to reboot the vm on host " + dest.getHost());
        }
    }

    public Command cleanup(VirtualMachine vm) {
        return new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()), false);
    }
View Full Code Here

Examples of com.cloud.agent.api.StopCommand

    public Command cleanup(VirtualMachine vm) {
        return new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()), false);
    }

    public Command cleanup(String vmName) {
        return new StopCommand(vmName, getExecuteInSequence(null), false);

    }
View Full Code Here

Examples of com.cloud.agent.api.StopCommand

        Assert.assertTrue(ans.getDetails(), ans.getResult());
    }

    private StopAnswer simpleVmStop() {
        String sampleStop = "{\"isProxy\":false,\"vmName\":\"i-2-17-VM\"," + "\"contextMap\":{},\"wait\":0}";
        StopCommand cmd = s_gson.fromJson(sampleStop, StopCommand.class);
        StopAnswer ans = (StopAnswer)s_hypervresource.executeRequest(cmd);
        return ans;
    }
View Full Code Here

Examples of com.cloud.agent.api.StopCommand

                        } else {
                            if (s_logger.isDebugEnabled()) {
                                s_logger.info("The guru did not like the answers so stopping " + vm);
                            }

                            StopCommand cmd = new StopCommand(vm, _mgmtServer.getExecuteInSequence());
                            StopAnswer answer = (StopAnswer) _agentMgr.easySend(destHostId, cmd);
                           if ( answer != null ) {
                                if (vm.getType() == VirtualMachine.Type.User) {
                                    String platform = answer.getPlatform();
                                    if (platform != null) {
View Full Code Here

Examples of com.cloud.agent.api.StopCommand

        }
    }

    protected <T extends VMInstanceVO> boolean sendStop(VirtualMachineGuru<T> guru, VirtualMachineProfile<T> profile, boolean force) {
        VMInstanceVO vm = profile.getVirtualMachine();
        StopCommand stop = new StopCommand(vm, _mgmtServer.getExecuteInSequence());
        try {
            StopAnswer answer = (StopAnswer) _agentMgr.send(vm.getHostId(), stop);
            if ( answer != null ) {
                if (vm.getType() == VirtualMachine.Type.User) {
                    String platform = answer.getPlatform();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.