Package org.platformlayer.ops

Examples of org.platformlayer.ops.Command$Argument


  private boolean haveCurl(OpsTarget target) throws OpsException {
    return target.getFilesystemInfoFile(new File("/usr/bin/curl")) != null;
  }

  public void addRepositoryKeyUrl(OpsTarget target, String url) throws OpsException {
    Command command = Command.build("wget -q -O - {0} | apt-key add -", url);
    target.executeCommand(command);

    flushCache(target);
  }
View Full Code Here


  public List<String> getInstalledPackageInfo(OpsTarget target) throws OpsException {
    AptInfoCache cached = getCache(target);

    if (cached.installedPackages == null) {
      Command command = Command.build("/usr/bin/dpkg --get-selections");
      ProcessExecution execution = target.executeCommand(command);

      final List<String> packages = Lists.newArrayList();
      for (String line : Splitter.on("\n").split(execution.getStdOut())) {
        line = line.trim();
View Full Code Here

  //
  // server.simpleRun(command, new TimeSpan("15m"));
  // }

  public List<String> findOutOfDatePackages(OpsTarget target) throws OpsException {
    Command command = Command.build("apt-get -q -q --simulate dist-upgrade");
    ProcessExecution execution = target.executeCommand(command);

    final List<String> packages = Lists.newArrayList();
    for (String line : Splitter.on("\n").split(execution.getStdOut())) {
      line = line.trim();
View Full Code Here

    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) {
      command.addQuoted(packageName);
    }
    target.executeCommand(command.setEnvironment(commandEnvironment).setTimeout(TimeSpan.TEN_MINUTES));

    flushCache(target);
  }
View Full Code Here

    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);

    flushCache(target);
  }
View Full Code Here

    }
  }

  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

    List<String> outOfDatePackage = apt.findOutOfDatePackages(target);

    if (!outOfDatePackage.isEmpty()) {
      // Pre-download any out-of-date files; will make any maintenance window smaller
      Command command = Command.build("apt-get --yes --download-only dist-upgrade");
      target.executeCommand(command);
    }

    Deviations.assertEquals(Collections.emptyList(), outOfDatePackage, "Packaged out of date");
  }
View Full Code Here

        .buildDownloadRequest();

    CurlRequest curlRequest = session.toCurlRequest(request);
    curlRequest.bareRequest = true;

    Command curlCommand = curlRequest.toCommand();
    curlCommand.addLiteral(">");
    curlCommand.addFile(targetPath);

    ProcessExecution execution = target.executeCommand(curlCommand);

    // CurlResult curlResult = curlRequest.parseResponse(execution);
    //
View Full Code Here

  public void doOperation() throws OpsException {
    OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);

    // TODO: Only if user not found
    {
      Command command = Command.build("adduser");
      command.addLiteral("--system");
      command.addLiteral("--no-create-home");

      if (shell != null) {
        command.addLiteral("--shell").addFile(shell);
      }

      if (!Strings.isNullOrEmpty(primaryGroup)) {
        command.addLiteral("--ingroup");
        command.addQuoted(primaryGroup);
      }

      command.addQuoted(userName);

      target.executeCommand(command);
    }

    for (String secondaryGroup : secondaryGroups) {
      Command command = Command.build("adduser");

      command.addQuoted(userName);
      command.addQuoted(secondaryGroup);

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

    addExtraFiles();

    {
      StandardService service = addChild(StandardService.class);

      Command command = template.getCommand();
      service.command = OpsProvider.of(command);

      Map<String, String> env = template.getEnvironment();
      service.environment = Providers.of(env);
View Full Code Here

TOP

Related Classes of org.platformlayer.ops.Command$Argument

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.