Package com.cloud.agent.api

Examples of com.cloud.agent.api.StopAnswer


                    }
                }
            }

            state = State.Stopped;
            return new StopAnswer(cmd, result, true);
        } catch (LibvirtException e) {
            return new StopAnswer(cmd, e.getMessage(), false);
        } finally {
            synchronized (_vms) {
                if (state != null) {
                    _vms.put(vmName, state);
                } else {
View Full Code Here


                            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()));
                            StopAnswer answer = (StopAnswer) _agentMgr.easySend(destHostId, cmd);
                            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);
                                    }
                                }
                            }

                            if (answer == null || !answer.getResult()) {
                                s_logger.warn("Unable to stop " + vm + " due to " + (answer != null ? answer.getDetails() : "no answers"));
                                _haMgr.scheduleStop(vm, destHostId, WorkType.ForceStop);
                                throw new ExecutionException("Unable to stop " + vm + " so we are unable to retry the start operation");
                            }
                            throw new ExecutionException("Unable to start " + vm + " due to error in finalizeStart, not retrying");
                        }
View Full Code Here

    protected boolean sendStop(VirtualMachineGuru guru, VirtualMachineProfile profile, boolean force) {
        VirtualMachine vm = profile.getVirtualMachine();
        StopCommand stop = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()));
        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);
                    }
                }
            }
            if (!answer.getResult()) {
                s_logger.debug("Unable to stop VM due to " + answer.getDetails());
                return false;
            }

            guru.finalizeStop(profile, answer);
        } catch (AgentUnavailableException e) {
View Full Code Here

        }

        vmGuru.prepareStop(profile);
        StopCommand stop = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()));
        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);

        } catch (AgentUnavailableException e) {
            s_logger.warn("Unable to stop vm, agent unavailable: " + e.toString());
View Full Code Here

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

                            StopCommand cmd = new StopCommand(vm.getInstanceName());
                            StopAnswer answer = (StopAnswer) _agentMgr.easySend(destHostId, cmd);
                            if (answer == null || !answer.getResult()) {
                                s_logger.warn("Unable to stop " + vm + " due to " + (answer != null ? answer.getDetails() : "no answers"));
                                _haMgr.scheduleStop(vm, destHostId, WorkType.ForceStop);
                                throw new ExecutionException("Unable to stop " + vm + " so we are unable to retry the start operation");
                            }
                            throw new ExecutionException("Unable to start " + vm + " due to error in finalizeStart, not retrying");
                        }
View Full Code Here

        vmGuru.prepareStop(profile);

        StopCommand stop = new StopCommand(vm, vm.getInstanceName(), null);
        boolean stopped = false;
        StopAnswer answer = null;
        try {
            answer = (StopAnswer) _agentMgr.send(vm.getHostId(), stop);
            stopped = answer.getResult();
            if (!stopped) {
                throw new CloudRuntimeException("Unable to stop the virtual machine due to " + answer.getDetails());
            }
            vmGuru.finalizeStop(profile, answer);

        } catch (AgentUnavailableException e) {
            s_logger.warn("Unable to stop vm, agent unavailable: " + e.toString());
View Full Code Here

  }

  protected synchronized StopAnswer execute(StopCommand cmd) {

    StopAnswer answer = null;
    String vmName = cmd.getVmName();

    State state = null;
    synchronized (_vms) {
      state = _vms.get(vmName);
      _vms.put(vmName, State.Stopping);
    }
    try {
        Answer result = _simMgr.simulate(cmd, hostGuid);

        if (!result.getResult()) {
            return new StopAnswer(cmd, result.getDetails(), false);
        }

      answer = new StopAnswer(cmd, null, 0, true);
      Pair<Long, Long> data = _runningVms.get(vmName);
      if (data != null) {
        this.usedCpu -= data.first();
        this.usedMem -= data.second();
      }
View Full Code Here

TOP

Related Classes of com.cloud.agent.api.StopAnswer

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.