Package org.platformlayer.ops

Examples of org.platformlayer.ops.Command


    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

            TimeSpan.FIVE_MINUTES));
        break;
      }

      case DiskRaw: {
        Command expand = Command.build("gunzip -c {0} | cp --sparse=always /proc/self/fd/0 {1}", rawImage,
            imageFile);
        target.executeCommand(expand.setTimeout(TimeSpan.FIVE_MINUTES));
        break;
      }

      case DiskQcow2: {
        Command expand = Command.build("cp {0} {1}", rawImage, imageFile);
        target.executeCommand(expand.setTimeout(TimeSpan.FIVE_MINUTES));
        break;
      }

      default:
        throw new OpsException("Unknown image format: " + imageFormat);
View Full Code Here

  public URI getUrl() {
    return url;
  }

  public CurlResult executeRequest(OpsTarget target) throws OpsException {
    Command command = toCommand();

    ProcessExecution execution = target.executeCommand(command);

    return parseResponse(execution);
  }
View Full Code Here

      escaped.add("%{" + tag + "}");
    }

    String format = metadataDelimiter.replace("\n", "\\n") + Joiner.on("\\n").join(escaped);

    Command command = Command.build("curl");
    if (!bareRequest) {
      command.addLiteral("--include");
      command.addLiteral("--write-out");
      command.addQuoted(format);
    }

    if (proxy != null) {
      command.addLiteral("--proxy");
      command.addQuoted(proxy);
    }

    if (timeout != null) {
      command.addLiteral("--max-time");
      command.addQuoted(Long.toString(timeout.getTotalSeconds() + 1));
    }

    for (Entry<String, String> entry : headers.entries()) {
      command.addLiteral("-H");
      command.addQuoted(entry.getKey() + ": " + entry.getValue());
    }

    if (body != null) {
      command.addLiteral("--data");
      command.addQuoted(body);
    }

    if (bodyFromStdin) {
      command.addLiteral("--data-binary");
      command.addLiteral("@-");
    }

    if (method != null) {
      command.addLiteral("--request");
      command.addQuoted(method);
    }

    command.addQuoted(getUrl().toString());
    return command;
  }
View Full Code Here

  }

  public void changePassword(Secret newPassword) throws OpsException {
    OpsTarget target = getOpsTarget();

    Command command = Command.build("mysqladmin");
    command.addQuoted("--user=", username);
    command.addQuoted("--host=", hostname);
    command.addQuoted("--password=", password);
    command.addLiteral("password");
    command.addQuoted(newPassword);

    target.executeCommand(command);

    password = newPassword;
  }
View Full Code Here

  }

  public ProcessExecution execute(String sql, String maskedSql) throws OpsException {
    OpsTarget target = getOpsTarget();

    Command command = Command.build("mysql");
    command.addQuoted("--user=", username);
    command.addQuoted("--host=", hostname);
    command.addQuoted("--password=", password);

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

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

    }
    glanceUploadUrl += "images";

    String imageName = "image-" + System.currentTimeMillis();

    Command command = Command.build("curl");
    command.addLiteral("--fail");
    command.addLiteral("--upload-file").addFile(imageFile);
    command.addLiteral("-X").addLiteral("POST");

    command.addLiteral("-H").addQuoted("X-Auth-Token: " + tokenId);

    command.addLiteral("-H").addQuoted("Content-Type: application/octet-stream");
    command.addLiteral("-H").addQuoted("X-Image-Meta-Name: " + imageName);
    command.addLiteral("-H").addQuoted("X-Image-Meta-Is-Public: True");

    // if (isQcow2) {
    // command.addLiteral("-H").addQuoted("X-Image-Meta-Disk-Format: qcow2");
    // } else {
    if (diskFormat != null) {
      command.addLiteral("-H").addQuoted("X-Image-Meta-Disk-Format: " + diskFormat);
    }

    command.addLiteral("-H").addQuoted("X-Image-Meta-Container-Format: bare");
    // }
    // command.addLiteral("-H").addQuoted("X-Image-Meta-Min-Disk: 0");
    // command.addLiteral("-H").addQuoted("X-Image-Meta-Min-Ram: 0");
    // command.addLiteral("-H").addQuoted("X-Image-Meta-Image-Size: " + rawImageFileSize);
    command.addLiteral("-H").addQuoted("X-Image-Meta-Size: " + rawImageFileSize);

    // image_meta = {'name': fields.pop('name'),
    // 'is_public': utils.bool_from_string(
    // fields.pop('is_public', False)),
    // 'disk_format': fields.pop('disk_format', 'raw'),
    // 'min_disk': fields.pop('min_disk', 0),
    // 'min_ram': fields.pop('min_ram', 0),
    // 'container_format': fields.pop('container_format', 'ovf')}

    // glance add name=DebianSqueeze is_public=True disk_format=raw container_format=bare
    // system_id="http://org.platformlayer/service/imagefactory/v1.0:bootstrap"
    // image_size="${RAW_SIZE}" < disk.raw.gz

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

    ProcessExecution execution = target.executeCommand(command);

    String imageId;
    // String imageLocation;
View Full Code Here

TOP

Related Classes of org.platformlayer.ops.Command

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.