Package org.platformlayer.ops

Examples of org.platformlayer.ops.CommandEnvironment


      TemplatedFile nat = addChild(TemplatedFile.build(template, scriptPath));
      nat.setFileMode("0755");

      // Simulate an ifup run
      Command command = Command.build(scriptPath);
      CommandEnvironment env = new CommandEnvironment();
      env.put("IFACE", template.getPublicInterface());
      env.put("MODE", "start");
      env.put("ADDRFAM", "inet");
      command.setEnvironment(env);

      nat.setUpdateAction(command);
    }
  }
View Full Code Here


    apt.update(target, true);

    // We need to install curl first so we can detect the performance of our proxies
    apt.install(target, "curl"); // Needed for proxy testing at least

    CommandEnvironment httpProxyEnv = httpProxies.getHttpProxyEnvironment(target, Usage.SoftwarePackages, null);

    // For now, we assume that this image doesn't have debootstrap pre-installed
    apt.install(target, "debootstrap");

    // For transferring the file to a direct image server
View Full Code Here

  public void install(OpsTarget target, String... packageNames) throws OpsException {
    install(target, Arrays.asList(packageNames));
  }

  public void upgrade(OpsTarget target) throws OpsException {
    CommandEnvironment commandEnvironment = buildEnvironmentWithProxy(target);

    Command command = Command.build("apt-get --yes upgrade");
    target.executeCommand(command.setEnvironment(commandEnvironment).setTimeout(TimeSpan.TEN_MINUTES));

    flushCache(target);
View Full Code Here

    flushCache(target);
  }

  public void clean(OpsTarget target) throws OpsException {
    CommandEnvironment commandEnvironment = buildEnvironmentWithProxy(target);

    Command command = Command.build("apt-get clean");
    target.executeCommand(command.setEnvironment(commandEnvironment).setTimeout(TimeSpan.TEN_MINUTES));
  }
View Full Code Here

    }
    return packages;
  }

  private CommandEnvironment buildEnvironmentWithProxy(OpsTarget target) throws OpsException {
    CommandEnvironment commandEnvironment = null;

    if (!haveCurl(target)) {
      log.warn("We don't yet have curl; can't detect best proxy so won't use a proxy");
    } else {
      commandEnvironment = httpProxies.getHttpProxyEnvironment(target, Usage.SoftwarePackages, null);
    }

    if (commandEnvironment == null) {
      commandEnvironment = new CommandEnvironment();
    }

    return commandEnvironment;
  }
View Full Code Here

    return commandEnvironment;
  }

  public void install(OpsTarget target, Iterable<String> packageNames) throws OpsException {
    CommandEnvironment commandEnvironment = buildEnvironmentWithProxy(target);
    commandEnvironment.put("DEBIAN_FRONTEND", "noninteractive");

    log.info("Installing APT packages: " + Joiner.on(",").join(packageNames));

    Command command = Command.build("apt-get install --yes");
    for (String packageName : packageNames) {
View Full Code Here

      return;
    }

    log.info("Updating apt repositories");

    CommandEnvironment commandEnvironment = buildEnvironmentWithProxy(target);

    Command command = Command.build("apt-get --yes update");
    command = command.setEnvironment(commandEnvironment).setTimeout(TimeSpan.TEN_MINUTES);
    executeAptCommand(target, command);
View Full Code Here

      return;
    }
  }

  private void doDpkgConfigure(OpsTarget target) throws OpsException {
    CommandEnvironment commandEnvironment = buildEnvironmentWithProxy(target);
    Command command = Command.build("dpkg --configure -a");
    command = command.setEnvironment(commandEnvironment).setTimeout(TimeSpan.TEN_MINUTES);
    target.executeCommand(command);
  }
View Full Code Here

  CommandEnvironment httpProxyEnvironment = null;

  public CommandEnvironment getHttpProxyEnvironment(OpsTarget target, Usage usage, URI uri) throws OpsException {
    if (httpProxyEnvironment == null) {
      List<String> proxies = findHttpProxies(target, uri);
      httpProxyEnvironment = new CommandEnvironment();

      String proxy = chooseProxy(target, proxies);
      if (proxy != null) {
        log.info("Will use http proxy: " + proxy);
        httpProxyEnvironment.put("http_proxy", proxy);
View Full Code Here

    command.addQuoted("--username=", username);
    command.addQuoted("--host=", hostname);

    command.addArgument(Argument.buildQuoted("--command=", sql).setMasked("--command=" + Command.MASKED));

    CommandEnvironment env = new CommandEnvironment();
    env.put("PGPASSWORD", password.plaintext());

    command.setEnvironment(env);
    return target.executeCommand(command);
  }
View Full Code Here

TOP

Related Classes of org.platformlayer.ops.CommandEnvironment

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.