Tabnine Logo
SshEffectorTasks.ssh
Code IndexAdd Tabnine to your IDE (free)

How to use
ssh
method
in
org.apache.brooklyn.core.effector.ssh.SshEffectorTasks

Best Java code snippets using org.apache.brooklyn.core.effector.ssh.SshEffectorTasks.ssh (Showing top 20 results out of 315)

origin: org.apache.brooklyn/brooklyn-software-cm-chef

public static TaskFactory<?> installChef(String chefDirectory, boolean force) {
  // TODO check on entity whether it is chef _server_
  String installCmd = cdAndRun(chefDirectory, ChefBashCommands.INSTALL_FROM_OPSCODE);
  if (!force) installCmd = BashCommands.alternatives("which chef-solo", installCmd);
  return SshEffectorTasks.ssh(installCmd).summary("install chef");
}
origin: org.apache.brooklyn/brooklyn-software-base

public static TaskFactory<?> runChef(String runDir, String phase) {
  // TODO chef server
  return SshEffectorTasks.ssh(cdAndRun(runDir, "sudo chef-solo -c "+phase+".rb -j "+phase+".json -ldebug")).
      summary("run chef for "+phase).requiringExitCodeZero();
}

origin: io.brooklyn.clocker/brooklyn-clocker-docker

  @Override
  public void customize(JcloudsLocation location, ComputeService computeService, JcloudsMachineLocation machine) {
    JcloudsSshMachineLocation ssh = (JcloudsSshMachineLocation) machine;
    String name = ssh.getOptionalNode().get().getName();

    List<String> commands = ImmutableList.of(
        String.format("echo %s | ( %s )", name, BashCommands.sudo("tee /etc/hostname")),
        String.format("echo 127.0.0.1 localhost | ( %s )", BashCommands.sudo("tee /etc/hosts")));
    DynamicTasks.queue(SshEffectorTasks.ssh(commands)
        .machine(ssh)
        .requiringExitCodeZero()).block();
    LOG.debug("Set {} hostname to {}", new Object[] { ssh, name });
  }
}
origin: org.apache.brooklyn/brooklyn-software-base

  protected ProcessTaskWrapper<Integer> exec(SshMachineLocation machine, boolean asRoot, String... cmds) {
    SshEffectorTaskFactory<Integer> taskFactory = SshEffectorTasks.ssh(machine, cmds);
    if (asRoot) taskFactory.runAsRoot();
    ProcessTaskWrapper<Integer> result = DynamicTasks.queue(taskFactory).block();
    if (result.get() != 0) {
      throw new IllegalStateException("SetHostnameCustomizer got exit code "+result.get()+" executing on machine "+machine
          +"; cmds="+Arrays.asList(cmds)+"; stdout="+result.getStdout()+"; stderr="+result.getStderr());
    }
    return result;
  }
}
origin: org.apache.brooklyn/brooklyn-software-cm-chef

/** see {@link ChefConfig#CHEF_RUN_CONVERGE_TWICE} for background on why 'twice' is available */
public static TaskFactory<?> runChef(String runDir, String phase, Boolean twice) {
  String cmd = "sudo chef-solo -c "+phase+".rb -j "+phase+".json -ldebug";
  if (twice!=null && twice) cmd = BashCommands.alternatives(cmd, cmd);
  return SshEffectorTasks.ssh(cdAndRun(runDir, cmd)).
      summary("run chef for "+phase).requiringExitCodeZero();
}

origin: org.apache.brooklyn/brooklyn-software-base

/** see {@link ChefConfig#CHEF_RUN_CONVERGE_TWICE} for background on why 'twice' is available */
public static TaskFactory<?> runChef(String runDir, String phase, Boolean twice) {
  String cmd = "sudo chef-solo -c "+phase+".rb -j "+phase+".json -ldebug";
  if (twice!=null && twice) cmd = BashCommands.alternatives(cmd, cmd);
  return SshEffectorTasks.ssh(cdAndRun(runDir, cmd)).
      summary("run chef for "+phase).requiringExitCodeZero();
}

origin: org.apache.brooklyn/brooklyn-software-cm-chef

protected boolean tryCheckStartWindowsService() {
  if (getWindowsServiceName()==null) return false;
  
  // if it's still up after 5s assume we are good (default behaviour)
  Time.sleep(Duration.FIVE_SECONDS);
  if (!((Integer)0).equals(DynamicTasks.queue(SshEffectorTasks.ssh("sc query \""+getWindowsServiceName()+"\" | find \"RUNNING\"").runAsCommand()).get())) {
    throw new IllegalStateException("The process for "+entity()+" appears not to be running (windowsService "+getWindowsServiceName()+")");
  }
  return true;
}
origin: org.apache.brooklyn/brooklyn-software-base

protected boolean tryCheckStartService() {
  if (getServiceName()==null) return false;
  
  // if it's still up after 5s assume we are good (default behaviour)
  Time.sleep(Duration.FIVE_SECONDS);
  if (!((Integer)0).equals(DynamicTasks.queue(SshEffectorTasks.ssh("/etc/init.d/"+getServiceName()+" status").runAsRoot()).get())) {
    throw new IllegalStateException("The process for "+entity()+" appears not to be running (service "+getServiceName()+")");
  }
  return true;
}
origin: org.apache.brooklyn/brooklyn-software-base

protected boolean tryCheckStartWindowsService() {
  if (getWindowsServiceName()==null) return false;
  
  // if it's still up after 5s assume we are good (default behaviour)
  Time.sleep(Duration.FIVE_SECONDS);
  if (!((Integer)0).equals(DynamicTasks.queue(SshEffectorTasks.ssh("sc query \""+getWindowsServiceName()+"\" | find \"RUNNING\"").runAsCommand()).get())) {
    throw new IllegalStateException("The process for "+entity()+" appears not to be running (windowsService "+getWindowsServiceName()+")");
  }
  return true;
}
origin: io.brooklyn.ambari/brooklyn-ambari

  @Override
  public Task<Integer> sshTaskApply(AmbariAgent ambariAgent) {
    return SshEffectorTasks
        .ssh(installPackageOr(ImmutableMap.of(), "mysql-connector-java", installPackageOrFail(ImmutableMap.of(), "libmysql-java")))
        .summary("Initialise Ranger requirements on " + ambariAgent.getId())
        .machine(EffectorTasks.getSshMachine(ambariAgent))
        .newTask()
        .asTask();
  }
}
origin: org.apache.brooklyn/brooklyn-software-cm-chef

protected boolean tryCheckStartService() {
  if (getServiceName()==null) return false;
  
  // if it's still up after 5s assume we are good (default behaviour)
  Time.sleep(Duration.FIVE_SECONDS);
  if (!((Integer)0).equals(DynamicTasks.queue(SshEffectorTasks.ssh("/etc/init.d/"+getServiceName()+" status").runAsRoot()).get())) {
    throw new IllegalStateException("The process for "+entity()+" appears not to be running (service "+getServiceName()+")");
  }
  return true;
}
origin: io.brooklyn.ambari/brooklyn-ambari

  @Override
  public Task<Integer> sshTaskApply(AmbariServer ambariServer) {
    return SshEffectorTasks
        .ssh(
            installPackageOr(ImmutableMap.of(), "mysql-connector-java", installPackageOrFail(ImmutableMap.of(), "libmysql-java")),
            sudo("ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar"))
        .summary("Initialise Ranger requirements on " + ambariServer.getId())
        .machine(EffectorTasks.getSshMachine(ambariServer))
        .newTask()
        .asTask();
  }
}
origin: org.apache.brooklyn/brooklyn-software-cm-chef

@Override
protected Integer getPid(Entity mysql) {
  ProcessTaskWrapper<Integer> t = Entities.submit(mysql, SshEffectorTasks.ssh("sudo cat "+ChefSoloDriverToyMySqlEntity.PID_FILE));
  return Integer.parseInt(t.block().getStdout().trim());
}

origin: org.apache.brooklyn/brooklyn-software-base

@Override
protected Integer getPid(Entity mysql) {
  ProcessTaskWrapper<Integer> t = Entities.submit(mysql, SshEffectorTasks.ssh("sudo cat "+ChefSoloDriverToyMySqlEntity.PID_FILE));
  return Integer.parseInt(t.block().getStdout().trim());
}

origin: org.apache.brooklyn/brooklyn-core

@Test(groups="Integration")
public void testSshEchoHello() {
  ProcessTaskWrapper<Integer> t = submit(SshEffectorTasks.ssh("sleep 1 ; echo hello world"));
  Assert.assertFalse(t.isDone());
  Assert.assertEquals(t.get(), (Integer)0);
  Assert.assertEquals(t.getTask().getUnchecked(), (Integer)0);
  Assert.assertEquals(t.getStdout().trim(), "hello world");
}
origin: org.apache.brooklyn/brooklyn-software-cm-chef

protected boolean tryStopWindowsService() {
  if (getWindowsServiceName()==null) return false;
      int result = DynamicTasks.queue(SshEffectorTasks.ssh("sc query \""+getWindowsServiceName()+"\"").runAsCommand()).get();
  if (0==result) return true;
  if (entity().getAttribute(Attributes.SERVICE_STATE_ACTUAL)!=Lifecycle.RUNNING)
    return true;
  throw new IllegalStateException("The process for "+entity()+" appears could not be stopped (exit code "+result+" to service stop)");
}
origin: org.apache.brooklyn/brooklyn-software-database

  @Override
  public String call(ConfigBag parameters) {
    return DynamicTasks.queue(SshEffectorTasks.ssh(
        BashCommands.pipeTextTo(
          parameters.get(SCRIPT),
          BashCommands.sudoAsUser("postgres", "psql --file -")))
        .requiringExitCodeZero()).getStdout();
  }
}
origin: org.apache.brooklyn/brooklyn-software-database

@Override
public void changePassword(String oldPass, String newPass) {
  DynamicTasks.queue(
    SshEffectorTasks.ssh(
      "cd "+getRunDir(),
      getBaseDir()+"/bin/mysqladmin --defaults-file="+getConfigFile()+" --password=" + oldPass + " password "+newPass)
    .summary("setting password")
    .requiringExitCodeZero());
}
origin: org.apache.brooklyn/brooklyn-software-database

public ProcessTaskWrapper<Integer> executeScriptFromInstalledFileAsync(String filenameAlreadyInstalledAtServer) {
  return DynamicTasks.queue(
    SshEffectorTasks.ssh(
      "cd "+getRunDir(),
      sudoAsUser("postgres", getInstallDir() + "/bin/psql -p " + entity.getAttribute(PostgreSqlNode.POSTGRESQL_PORT) + " -v ON_ERROR_STOP=1 --file " + filenameAlreadyInstalledAtServer))
        .requiringExitCodeZero()
      .summary("executing datastore script "+filenameAlreadyInstalledAtServer));
}
origin: org.apache.brooklyn/brooklyn-software-base

protected boolean tryCheckStartPid() {
  if (getPidFile()==null) return false;
  
  // if it's still up after 5s assume we are good (default behaviour)
  Time.sleep(Duration.FIVE_SECONDS);
  if (!DynamicTasks.queue(SshEffectorTasks.isPidFromFileRunning(getPidFile()).runAsRoot()).get()) {
    throw new IllegalStateException("The process for "+entity()+" appears not to be running (pid file "+getPidFile()+")");
  }
  // and set the PID
  entity().sensors().set(Attributes.PID, 
      Integer.parseInt(DynamicTasks.queue(SshEffectorTasks.ssh("cat "+getPidFile()).runAsRoot()).block().getStdout().trim()));
  return true;
}
org.apache.brooklyn.core.effector.sshSshEffectorTasksssh

Popular methods of SshEffectorTasks

  • put
  • isPidFromFileRunning
    as #codePidFromFileRunning(String) but returning boolean
  • codePidRunning
    task which returns 0 if pid is running
  • isPidRunning
    as #codePidRunning(Integer) but returning boolean
  • codePidFromFileRunning
    task which returns 0 if pid in the given file is running; method accepts wildcards so long as they m
  • getSshFlags
    extracts the values for the main brooklyn.ssh.config.* config keys (i.e. those declared in ConfigKey
  • requirePidRunning
    task which fails if the given PID is not running
  • fetch
  • requirePidFromFileRunning
    task which fails if the pid in the given file is not running (or if there is no such PID file); meth

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setRequestProperty (URLConnection)
  • compareTo (BigDecimal)
  • startActivity (Activity)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • JList (javax.swing)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now