@Override public TemplateOptions runAsRoot(boolean runAsRoot) { return TemplateOptions.class.cast(super.runAsRoot(runAsRoot)); }
@Override public TemplateOptions runAsRoot(boolean runAsRoot) { return TemplateOptions.class.cast(super.runAsRoot(runAsRoot)); }
@Override public TemplateOptions runAsRoot(boolean runAsRoot) { return TemplateOptions.class.cast(super.runAsRoot(runAsRoot)); }
@Override public TemplateOptions runAsRoot(boolean runAsRoot) { return TemplateOptions.class.cast(super.runAsRoot(runAsRoot)); }
public static RunScriptOptions runAsRoot(boolean value) { RunScriptOptions options = new RunScriptOptions(); return options.runAsRoot(value); }
public static RunScriptOptions runAsRoot(boolean value) { RunScriptOptions options = new RunScriptOptions(); return options.runAsRoot(value); }
public static RunScriptOptions runAsRoot(boolean value) { RunScriptOptions options = new RunScriptOptions(); return options.runAsRoot(value); }
public static RunScriptOptions runAsRoot(boolean value) { RunScriptOptions options = new RunScriptOptions(); return options.runAsRoot(value); }
public static RunScriptOptions recipeScriptOptions(RunScriptOptions options) { return options.wrapInInitScript(true).runAsRoot(true); }
public static RunScriptOptions recipeScriptOptions(RunScriptOptions options) { return options.wrapInInitScript(true).runAsRoot(true); }
private void mapSecurityGroupRuleToIpTables(ComputeService computeService, NodeMetadata node, LoginCredentials credentials, String networkInterface, Iterable<Integer> ports) { for (Integer port : ports) { String insertIptableRule = IptablesCommands.insertIptablesRule(Chain.INPUT, networkInterface, Protocol.TCP, port, Policy.ACCEPT); Statement statement = Statements.newStatementList(exec(insertIptableRule)); ExecResponse response = computeService.runScriptOnNode(node.getId(), statement, overrideLoginCredentials(credentials).runAsRoot(false)); if (response.getExitStatus() != 0) { String msg = String.format("Cannot insert the iptables rule for port %d. Error: %s", port, response.getError()); LOG.error(msg); throw new RuntimeException(msg); } } }
public void testCanRunCommandAsCurrentUser() throws Exception { Map<? extends NodeMetadata, ExecResponse> responses = context.getComputeService().runScriptOnNodesMatching( Predicates.<NodeMetadata> alwaysTrue(), exec("id"), wrapInInitScript(false).runAsRoot(false)); for (Entry<? extends NodeMetadata, ExecResponse> response : responses.entrySet()) assert response.getValue().getOutput().trim().contains(System.getProperty("user.name")) : response.getKey() + ": " + response.getValue(); }
public Boolean call() { Statement statement = Statements.newStatementList(exec("hostname")); // NB this assumes passwordless sudo ! ExecResponse response = computeService.runScriptOnNode(nodeRef.getId(), statement, overrideLoginCredentials(expectedCredentialsRef).runAsRoot(false)); return response.getExitStatus() == 0; }}) .limitTimeTo(delayMs, MILLISECONDS)
public void simpleTest() { RunScriptOnNodeUsingSsh testMe = new RunScriptOnNodeUsingSsh(sshFactory, eventBus, node, exec("echo $USER\necho $USER"), wrapInInitScript(false).runAsRoot(false)); testMe.init(); sshClient.connect(); expect(sshClient.getUsername()).andReturn("tester"); expect(sshClient.getHostAddress()).andReturn("somewhere.example.com"); expect(sshClient.exec("echo $USER\n" + "echo $USER\n")).andReturn(new ExecResponse("tester\ntester\n", null, 0)); sshClient.disconnect(); replay(sshClient); testMe.call(); }
public void simpleTest() { RunScriptOnNodeUsingSsh testMe = new RunScriptOnNodeUsingSsh(sshFactory, eventBus, node, exec("echo $USER\necho $USER"), wrapInInitScript(false).runAsRoot(false)); testMe.init(); sshClient.connect(); expect(sshClient.getUsername()).andReturn("tester"); expect(sshClient.getHostAddress()).andReturn("somewhere.example.com"); expect(sshClient.exec("echo $USER\n" + "echo $USER\n")).andReturn(new ExecResponse("tester\ntester\n", null, 0)); sshClient.disconnect(); replay(sshClient); testMe.call(); }
public void simpleRootTest() { RunScriptOnNodeUsingSsh testMe = new RunScriptOnNodeUsingSsh(sshFactory, eventBus, node, exec("echo $USER\necho $USER"), wrapInInitScript(false).runAsRoot(true)); testMe.init(); sshClient.connect(); expect(sshClient.getUsername()).andReturn("tester"); expect(sshClient.getHostAddress()).andReturn("somewhere.example.com"); expect( sshClient.exec("sudo sh <<'RUN_SCRIPT_AS_ROOT_SSH'\n" + "echo $USER\n" + "echo $USER\n" + "RUN_SCRIPT_AS_ROOT_SSH\n")).andReturn(new ExecResponse("root\nroot\n", null, 0)); sshClient.disconnect(); replay(sshClient); testMe.call(); }
public RunScriptOptions defaultRunScriptOptionsForSpec(ClusterSpec spec) { LoginCredentials credentials = LoginCredentials.builder() .user(spec.getClusterUser()).privateKey(spec.getPrivateKey()).build(); return overrideLoginCredentials(credentials).wrapInInitScript(false) .runAsRoot(false); }
public void simpleRootTest() { RunScriptOnNodeUsingSsh testMe = new RunScriptOnNodeUsingSsh(sshFactory, eventBus, node, exec("echo $USER\necho $USER"), wrapInInitScript(false).runAsRoot(true)); testMe.init(); sshClient.connect(); expect(sshClient.getUsername()).andReturn("tester"); expect(sshClient.getHostAddress()).andReturn("somewhere.example.com"); expect( sshClient.exec("sudo sh <<'RUN_SCRIPT_AS_ROOT_SSH'\n" + "echo $USER\n" + "echo $USER\n" + "RUN_SCRIPT_AS_ROOT_SSH\n")).andReturn(new ExecResponse("root\nroot\n", null, 0)); sshClient.disconnect(); replay(sshClient); testMe.call(); }
public RunScriptOptions defaultRunScriptOptionsForSpec(ClusterSpec spec) { LoginCredentials credentials = LoginCredentials.builder() .user(spec.getClusterUser()).privateKey(spec.getPrivateKey()).build(); return overrideLoginCredentials(credentials).wrapInInitScript(false) .runAsRoot(false); }
/** * Run set of queued commands now */ public static void executeOnNodes(List<Statement> commands, boolean runAsRoot, String clustername, ComputeService compute, String username, String sshKeyName) throws RunScriptOnNodesException, InterruptedException, ExecutionException, TimeoutException { compute.runScriptOnNodesMatching( NodePredicates.runningInGroup(clustername), new StatementList(commands), new RunScriptOptions() .nameTask("Setup") .overrideLoginCredentials(Tools.getPrivateKeyCredentials(username, sshKeyName)) .wrapInInitScript(true) .overrideLoginUser(username) .blockOnComplete(true) .runAsRoot(runAsRoot)); }