Examples of ProcessExecution


Examples of org.platformlayer.ops.process.ProcessExecution

    // image_size="${RAW_SIZE}" < disk.raw.gz

    command.addQuoted(glanceUploadUrl);
    command.setTimeout(TimeSpan.FIFTEEN_MINUTES);

    ProcessExecution execution = target.executeCommand(command);

    String imageId;
    // String imageLocation;
    {
      // {"image": {"status": "active", "name": null, "deleted": false,
      // "container_format": null, "created_at":
      // "2011-04-10T00:15:57.563479",
      // "disk_format": null, "updated_at":
      // "2011-04-10T00:21:29.300219", "id": 8, "location":
      // "file:///var/lib/glance/images/8", "checksum":
      // "bfbd641fe10edb3ecea933303e5408ec", "is_public": false,
      // "deleted_at":
      // null, "properties":
      // {}, "size": 8577351680}}

      // {"image": {"status": "active", "name": "image-1324662647963", "deleted": false, "container_format": null,
      // "created_at": "2011-12-23T17:50:48.265346", "disk_format": "qcow2",
      // "updated_at": "2011-12-23T17:51:42.229359", "properties": {}, "min_disk": 0, "id":
      // "f41d4043-f608-ea2f-a642-e7621bec2b66", "checksum": "ffeafdc8757658b481f3b1a3c2a33c98", "owner": null,
      // "is_public": true, "deleted_at": null, "min_ram": 0, "size": 925761536}}
      try {
        JSONObject json = new JSONObject(execution.getStdOut());
        JSONObject image = json.getJSONObject("image");
        // imageLocation = image.getString("location");
        imageId = image.getString("id");
      } catch (JSONException e) {
        log.warn("Image upload returned: " + execution.getStdOut());
        throw new OpsException("Error parsing return value from image upload", e);
      }
    }

    if (tags != null) {
View Full Code Here

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

Examples of org.platformlayer.ops.process.ProcessExecution

  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

Examples of org.platformlayer.ops.process.ProcessExecution

    }

    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

Examples of org.platformlayer.ops.process.ProcessExecution

      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

Examples of org.platformlayer.ops.process.ProcessExecution

            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

Examples of org.platformlayer.ops.process.ProcessExecution

    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

Examples of org.platformlayer.ops.process.ProcessExecution

    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

Examples of org.platformlayer.ops.process.ProcessExecution

    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

Examples of org.platformlayer.ops.process.ProcessExecution

    @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
Copyright © 2018 www.massapi.com. 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.