Package com.cloud.agent.api

Examples of com.cloud.agent.api.Command


        Map<Long, AgentVmInfo> states = convertToInfos(newStates);

        for (Map.Entry<Long, AgentVmInfo> entry : states.entrySet()) {
            AgentVmInfo info = entry.getValue();
            VMInstanceVO vm = info.vm;
            Command command = null;
            if (vm != null) {
                Host host = _resourceMgr.findHostByGuid(info.getHostUuid());
                long hId = host.getId();

                HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
View Full Code Here


                castedVm = info.guru.findById(vm.getId());
                try {
                    Host host = _hostDao.findByGuid(info.getHostUuid());
                    long hostId = host == null ? (vm.getHostId() == null ? vm.getLastHostId() : vm.getHostId()) : host.getId();
                    HypervisorGuru hvGuru = _hvGuruMgr.getGuru(castedVm.getHypervisorType());
                    Command command = compareState(hostId, castedVm, info, true, hvGuru.trackVmHostChange());
                    if (command != null){
                        Answer answer = _agentMgr.send(hostId, command);
                        if (!answer.getResult()) {
                            s_logger.warn("Failed to update state of the VM due to " + answer.getDetails());
                        }
View Full Code Here

        State agentState = info.state;
        final String agentName = info.name;
        final State serverState = vm.getState();
        final String serverName = vm.getInstanceName();

        Command command = null;
        s_logger.debug("VM " + serverName + ": cs state = " + serverState + " and realState = " + agentState);
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("VM " + serverName + ": cs state = " + serverState + " and realState = " + agentState);
        }
View Full Code Here

      s_logger.info("recieved task of type "+ type.toString() +" to handle in BootStrapTakHandler");
      if (type == Task.Type.DATA)
      {
        final byte[] data = task.getData();
        final Request request = Request.parse(data);
        final Command cmd = request.getCommand();
       
        if (cmd instanceof StartupVMMAgentCommand) {

          StartupVMMAgentCommand vmmCmd = (StartupVMMAgentCommand) cmd;
View Full Code Here

        }
        try {
            /* Now we are last one on host, destroy the bridge with all
             * the tunnels for this network  */
          int key = getGreKey(nw);
            Command cmd = new OvsDestroyBridgeCommand(nw.getId(), key);
            s_logger.debug("Destroying bridge for network " + nw.getId() +
                " on host:" + vm.getHostId());
            Answer ans = _agentMgr.send(vm.getHostId(), cmd);
            handleDestroyBridgeAnswer(ans, vm.getHostId(), nw.getId());
           
View Full Code Here

            s_logger.info("created new BootStrapTakHandler");
        }

        protected void processRequest(final Link link, final Request request) {
            final Command[] cmds = request.getCommands();
            Command cmd = cmds[0];
        }
View Full Code Here

        try {
            final Command[] cmds = request.getCommands();
            final Answer[] answers = new Answer[cmds.length];

            for (int i = 0; i < cmds.length; i++) {
                final Command cmd = cmds[i];
                Answer answer;
                try {
                  if (s_logger.isDebugEnabled()) {
                    if (!requestLogged) // ensures request is logged only once per method call
                    {
                      String requestMsg = request.toString();
                      if (requestMsg != null) {
                        s_logger.debug("Request:" + requestMsg);
                      }
                      requestLogged = true;
                    }
                    s_logger.debug("Processing command: " + cmd.toString());
                  }

                    if (cmd instanceof CronCommand) {
                        final CronCommand watch = (CronCommand) cmd;
                        scheduleWatch(link, request, watch.getInterval() * 1000, watch.getInterval() * 1000);
                        answer = new Answer(cmd, true, null);
                    } else if (cmd instanceof UpgradeCommand) {
                        final UpgradeCommand upgrade = (UpgradeCommand) cmd;
                        answer = upgradeAgent(upgrade.getUpgradeUrl(), upgrade);
                    } else if (cmd instanceof ShutdownCommand) {
                        ShutdownCommand shutdown = (ShutdownCommand) cmd;
                        s_logger.debug("Received shutdownCommand, due to: " + shutdown.getReason());
                        cancelTasks();
                        _reconnectAllowed = false;
                        answer = new Answer(cmd, true, null);
                    } else if (cmd instanceof MaintainCommand) {
                          s_logger.debug("Received maintainCommand" );
                          cancelTasks();
                          _reconnectAllowed = false;
                          answer = new MaintainAnswer((MaintainCommand)cmd);
                    } else if (cmd instanceof AgentControlCommand) {
                        answer = null;
                        synchronized (_controlListeners) {
                            for (IAgentControlListener listener : _controlListeners) {
                                answer = listener.processControlRequest(request, (AgentControlCommand) cmd);
                                if (answer != null) {
                                    break;
                                }
                            }
                        }

                        if (answer == null) {
                            s_logger.warn("No handler found to process cmd: " + cmd.toString());
                            answer = new AgentControlAnswer(cmd);
                        }

                    } else {
                        _inProgress.incrementAndGet();
                        try {
                            answer = _resource.executeRequest(cmd);
                        } finally {
                            _inProgress.decrementAndGet();
                        }
                        if (answer == null) {
                            s_logger.debug("Response: unsupported command" + cmd.toString());
                            answer = Answer.createUnsupportedCommandAnswer(cmd);
                        }
                    }
                } catch (final Throwable th) {
                    s_logger.warn("Caught: ", th);
View Full Code Here

            } catch (final ClosedChannelException e) {
                s_logger.warn("Unable to send request: " + request.toString());
            }
        } else if (obj instanceof Request) {
            final Request req = (Request) obj;
            final Command command = req.getCommand();
            Answer answer = null;
            _inProgress.incrementAndGet();
            try {
                answer = _resource.executeRequest(command);
            } finally {
View Full Code Here

        }

        protected void processRequest(final Link link, final Request request) {
            AgentAttache attache = (AgentAttache) link.attachment();
            final Command[] cmds = request.getCommands();
            Command cmd = cmds[0];
            boolean logD = true;

            Response response = null;
            if (attache == null) {
              request.logD("Processing the first command ");
View Full Code Here

      try {
        HostVO host = _resourceMgr.createHostVOForConnectedAgent(startup);
        if (host != null) {
          attache = createAttacheForConnect(host, link);
        }
        Command cmd;
        for (int i = 0; i < startup.length; i++) {
          cmd = startup[i];
          if ((cmd instanceof StartupRoutingCommand) || (cmd instanceof StartupProxyCommand) || (cmd instanceof StartupSecondaryStorageCommand) || (cmd instanceof StartupStorageCommand)) {
            answers[i] = new StartupAnswer(startup[i], attache.getId(), getPingInterval());
            break;
          }
        }
      }catch (ConnectionException e) {
        Command cmd;
          for (int i = 0; i < startup.length; i++) {
            cmd = startup[i];
            if ((cmd instanceof StartupRoutingCommand) || (cmd instanceof StartupProxyCommand) || (cmd instanceof StartupSecondaryStorageCommand) || (cmd instanceof StartupStorageCommand)) {
            answers[i] = new StartupAnswer(startup[i], e.toString());
            break;
            }
          }
      } catch (IllegalArgumentException e) {
        Command cmd;
          for (int i = 0; i < startup.length; i++) {
            cmd = startup[i];
            if ((cmd instanceof StartupRoutingCommand) || (cmd instanceof StartupProxyCommand) || (cmd instanceof StartupSecondaryStorageCommand) || (cmd instanceof StartupStorageCommand)) {
            answers[i] = new StartupAnswer(startup[i], e.toString());
            break;
            }
          }
      } catch (CloudRuntimeException e) {
        Command cmd;
          for (int i = 0; i < startup.length; i++) {
            cmd = startup[i];
            if ((cmd instanceof StartupRoutingCommand) || (cmd instanceof StartupProxyCommand) || (cmd instanceof StartupSecondaryStorageCommand) || (cmd instanceof StartupStorageCommand)) {
            answers[i] = new StartupAnswer(startup[i], e.toString());
            break;
View Full Code Here

TOP

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

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.