public static UnsupportedAnswer createUnsupportedCommandAnswer(final Command cmd) { return new UnsupportedAnswer(cmd, "Unsupported command issued: " + cmd.toString() + ". Are you sure you got the right type of server?"); }
@Override public Answer sendMessage(Command cmd) { if ((cmd instanceof CopyCommand) || (cmd instanceof DownloadCommand)) { return resource.executeRequest(cmd); } // TODO Auto-generated method stub return new Answer(cmd, false, "unsupported command:" + cmd.toString()); }
@Override public Answer executeRequest(final Command cmd) { final NuageVspRequestWrapper wrapper = NuageVspRequestWrapper.getInstance(); try { return wrapper.execute(cmd, this); } catch (final Exception e) { if (s_logger.isDebugEnabled()) { s_logger.debug("Received unsupported command " + cmd.toString(), e); } return Answer.createUnsupportedCommandAnswer(cmd); } }
@Override public Answer executeRequest(Command cmd) { if (cmd instanceof CheckNetworkCommand) { return new CheckNetworkAnswer((CheckNetworkCommand)cmd, true, null); } System.out.println("Received Command: " + cmd.toString()); Answer answer = new Answer(cmd, !_negative, "response"); System.out.println("Replying with: " + answer.toString()); return answer; }
@Override public Answer executeRequest(final Command cmd) { final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance(); try { return wrapper.execute(cmd, this); } catch (final Exception e) { s_logger.debug("Received unsupported command " + cmd.toString()); return Answer.createUnsupportedCommandAnswer(cmd); } }
private Answer[] sendRebalanceCommand(final long peer, final long agentId, final long currentOwnerId, final long futureOwnerId, final Event event) { final TransferAgentCommand transfer = new TransferAgentCommand(agentId, currentOwnerId, futureOwnerId, event); final Commands commands = new Commands(Command.OnError.Stop); commands.addCommand(transfer); final Command[] cmds = commands.toCommands(); try { if (s_logger.isDebugEnabled()) { s_logger.debug("Forwarding " + cmds[0].toString() + " to " + peer); } final String peerName = Long.toString(peer); final String cmdStr = _gson.toJson(cmds); final String ansStr = _clusterMgr.execute(peerName, agentId, cmdStr, true); final Answer[] answers = _gson.fromJson(ansStr, Answer[].class); return answers; } catch (final Exception e) { s_logger.warn("Caught exception while talking to " + currentOwnerId, e); return null; } }
@Override public void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback) { try { long newHostId = _hvGuruMgr.getGuruProcessedCommandTargetHost(hostId, cmd); if (newHostId != hostId) { // update endpoint with new host if changed setId(newHostId); } if (s_logger.isDebugEnabled()) { s_logger.debug("Sending command " + cmd.toString() + " to host: " + newHostId); } agentMgr.send(newHostId, new Commands(cmd), new CmdRunner(callback)); } catch (AgentUnavailableException e) { throw new CloudRuntimeException("Unable to send message", e); } } }
public Answer executeRequest(Command cmd, int numRetries) { if (cmd instanceof ReadyCommand) { return executeRequest((ReadyCommand)cmd); } else if (cmd instanceof MaintainCommand) { return executeRequest((MaintainCommand)cmd); } else if (cmd instanceof CreateNetworkCommand) { return executeRequest((CreateNetworkCommand)cmd, numRetries); } else if (cmd instanceof AssociateMacToNetworkCommand) { return executeRequest((AssociateMacToNetworkCommand)cmd, numRetries); } else if (cmd instanceof DisassociateMacFromNetworkCommand) { return executeRequest((DisassociateMacFromNetworkCommand)cmd, numRetries); } else if (cmd instanceof DeleteNetworkCommand) { return executeRequest((DeleteNetworkCommand)cmd, numRetries); } s_logger.debug("Received unsupported command " + cmd.toString()); return Answer.createUnsupportedCommandAnswer(cmd); }
public final void testStartupCommand() { StartupRoutingCommand defaultStartRoutCmd = new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.Hyperv, RouterPrivateIpStrategy.HostLocal); // Identity within the data centre is decided by CloudStack kernel, // and passed via ServerResource.configure() defaultStartRoutCmd.setDataCenter("1"); defaultStartRoutCmd.setPod("1"); defaultStartRoutCmd.setCluster("1"); defaultStartRoutCmd.setGuid("1"); defaultStartRoutCmd.setName("1"); defaultStartRoutCmd.setPrivateIpAddress("1"); defaultStartRoutCmd.setStorageIpAddress("1"); defaultStartRoutCmd.setCpus(12); // TODO: does version need to be hard coded. defaultStartRoutCmd.setVersion("4.2.0"); StartupCommand scmd = defaultStartRoutCmd; Command[] cmds = {scmd}; String cmdsStr = s_gson.toJson(cmds); s_logger.debug("Commands[] toJson is " + cmdsStr); Command[] result = s_gson.fromJson(cmdsStr, Command[].class); s_logger.debug("Commands[] fromJson is " + s_gson.toJson(result)); s_logger.debug("Commands[] first element has type" + result[0].toString()); }
return executeRequest((GetControllerDataCommand)cmd, numRetries); s_logger.debug("Received unsupported command " + cmd.toString()); return Answer.createUnsupportedCommandAnswer(cmd);