See bug 13034 for background. start-instance/create-instance/delete-instance all need to do roughly the following:
Steps 5+6 have the most complexity. Each command does them slight differently. I propose we create a new method (possibly in a new class: NodeRunner): public int executeCommandOnNode(Node node, StringBuilder ouput, String command, String... args) throws SSHCommandExecutionException, ProcessManagerException, IllegalArgumentException usage wold be like command = new ArrayList(); humanVersionOfCommand = new ArrayList(); node = Nodes.getNodeByName(name); // Build commands as needed command.add("--node"); humanVersionOfCommand.add("--node"); command.add("n1"); humanVersionOfCommand.add("--node"); //. . . RemoteCommandHelper rch = new NodeRunner(Habitat habitat, Logger logger); output = new StringBuilder(); try { int status = rch.executeCommandOnNode(node, output, "asadmin", command.toArray()); if (status != 0) { // handle logging and return status } } catch (SSHCommandExecutionException e) { Throwable cause = ExceptionUtil.getRootCause(e); // handle it } catch (ProcessManagerException e) { Throwable cause = ExceptionUtil.getRootCause(e); // handle it } catch (IllegalArgumentException e) { // handle it } There is also a smattering of utility methods that should be formalized and shared – I think as DuckTypes on the Node or Nodes config bean:
|