Package org.platformlayer.ops.process

Examples of org.platformlayer.ops.process.ProcessExecution


        SshKey adminSshKey = new SshKey(null, adminUser, KeyPairUtils.deserialize(privateKeyData));

        OpsTarget adminTarget = machine.getTarget(adminSshKey);
        {
            ProcessExecution execution = adminTarget.executeCommand("ssh-keyscan 127.0.0.1");
            File knownHosts = new File(adminSshDir, "known_hosts");
            adminTarget.setFileContents(knownHosts, execution.getStdOut());
        }

        // adminTarget.executeCommand("git clone gitosis@127.0.0.1:gitosis-admin.git /home/gitadmin/gitosis-admin");

        // adminSshKey.
View Full Code Here


  public static ZookeeperResponse sendCommand(OpsTarget target, InetSocketAddress socketAddress, String zkCommand)
      throws OpsException {
    Command command = Command.build("echo {0} | nc {1} {2}", zkCommand,
        socketAddress.getAddress().getHostAddress(), socketAddress.getPort());

    ProcessExecution execution = target.executeCommand(command);

    return new ZookeeperResponse(execution.getStdOut());
  }
View Full Code Here

    }

    FileUpload.upload(target, new File("/etc/hostname"), hostname);

    {
      ProcessExecution execution = target.executeCommand("hostname");
      String currentHostname = execution.getStdOut().trim();
      if (!currentHostname.equals(hostname)) {
        if (!DetectVirtualization.isLxc(target)) {
          // This actually can't be done within an LXC instance, which is why we go to extraordinary lengths
          // to
          // set it on creation
View Full Code Here

      throws OpsException {

    Command command = buildCommand(transport, chain);
    command.addLiteral("--list-rules");

    ProcessExecution iptablesExecution = target.executeCommand(command);
    SimpleIptablesRules ret = new SimpleIptablesRules();
    for (String line : Splitter.on("\n").split(iptablesExecution.getStdOut())) {
      SimpleIptablesRule rule = new SimpleIptablesRule(line);
      ret.rules.add(rule);
    }
    return ret;
  }
View Full Code Here

            boolean pushedOkay = false;
            try {
              pushFile.call();
              pushedOkay = true;
            } catch (Exception e) {
              ProcessExecution pushExecution = null;
              if (e instanceof ProcessExecutionException) {
                pushExecution = ((ProcessExecutionException) e).getExecution();
              }

              if (pushExecution != null && pushExecution.getExitCode() == 1
                  && pushExecution.getStdErr().contains("Connection refused")) {
                log.info("Got connection refused on push; will retry");
              } else {
                throw new OpsException("Error pushing file", e);
              }
            }

            if (pushedOkay) {
              try {
                listenFileFuture.get(5, TimeUnit.SECONDS);
              } catch (TimeoutException e) {
                log.info("Timeout while waiting for receive to complete");
              } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                throw new OpsException("Interrupted during file receive", e);
              } catch (ExecutionException e) {
                throw new OpsException("Error during file receive", e);
              }
            }
          }

          if (listenFileFuture.isDone()) {
            try {
              ProcessExecution listenExecution = listenFileFuture.get();
              log.warn("File receiving exited: " + listenExecution);
              break;
            } catch (ExecutionException e) {
              throw new OpsException("Error receiving file", e);
            } catch (InterruptedException e) {
View Full Code Here

    return new InetAddressPair(srcAddress, targetAddress);
  }

  private Inet6Address findIpv6(OpsTarget target) throws OpsException {
    Command command = Command.build("cat /proc/net/if_inet6");
    ProcessExecution execution = target.executeCommand(command);
    String inet6 = execution.getStdOut();

    // This didn't work for some reason (??)
    // String inet6 = target.readTextFile(new File("/proc/net/if_inet6"));

    List<Inet6Address> addresses = Lists.newArrayList();
View Full Code Here

    Command command = getIptablesCommand(transport);
    command.addLiteral("--list-rules");

    List<FirewallRecord> records = Lists.newArrayList();

    ProcessExecution execution = target.executeCommand(command);
    String stdout = execution.getStdOut();
    for (String line : stdout.split("\n")) {
      parseAndAdd(records, line);
    }
    return records;
  }
View Full Code Here

    return locales;
  }

  private List<String> getGeneratedLocales(OpsTarget target) throws OpsException {
    Command listLocales = Command.build("localedef --list-archive");
    ProcessExecution execution = target.executeCommand(listLocales);

    List<String> locales = Lists.newArrayList();
    for (String line : Splitter.on("\n").split(execution.getStdOut())) {
      line = line.trim();
      if (line.isEmpty()) {
        continue;
      }
      locales.add(normalize(line));
View Full Code Here

    @Override
    public VirtualizationType apply(OpsTarget target) throws OpsException {
      // Proc files cannot be scp-ed, because the length is zero
      // byte[] data = target.readBinaryFile(new File("/proc/1/environ"));
      ProcessExecution execution = target.executeCommand("cat /proc/1/environ");

      byte[] data = execution.getBinaryStdOut();

      int start = 0;
      while (start < data.length) {
        int end = start;
        while (end < data.length) {
View Full Code Here

TOP

Related Classes of org.platformlayer.ops.process.ProcessExecution

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.