Package org.platformlayer.ops

Examples of org.platformlayer.ops.Command


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

    // We probably want psql -A -t -c "command"

    Command command = Command.build("psql");
    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


    return transport;
  }

  @Override
  public Command buildIptablesAddCommand() {
    Command command = SimpleIptablesRules.buildCommand(transport, chain);
    command.addLiteral(ruleSpec);
    return command;
  }
View Full Code Here

  public String localPrivateAddress;

  @Handler
  public void handler(OpsTarget target) throws OpsException {
    // ip tunnel add netb mode gre remote 184.173.172.26 local 209.105.243.38 ttl 255
    Command addTunnel = Command.build("ip tunnel add {0} mode gre remote {1} local {2} ttl 255", tunnelName,
        remoteTunnelAddress, localTunnelAddress);
    target.executeCommand(addTunnel);

    // ip addr add fdfd:fdfd:fdfd:1::/64 dev netb
    Command tunnelAddAddress = Command.build("ip addr add {0} dev {1}", localPrivateAddress, tunnelName);
    target.executeCommand(tunnelAddAddress);

    // ip route add fdfd:fdfd:fdfd:1::/64 dev netb
    Command tunnelAddRoute = Command.build("ip route add {0} dev {1}", remotePrivateNetwork, tunnelName);
    target.executeCommand(tunnelAddRoute);

    Command tunnelUp = Command.build("ip link set {0} up", tunnelName);
    target.executeCommand(tunnelUp);
  }
View Full Code Here

    return command;
  }

  @Override
  public Command buildIptablesDeleteCommand() {
    Command command = SimpleIptablesRules.buildCommand(transport, chain);
    command.addLiteral(convertToDeleteSpec());
    return command;
  }
View Full Code Here

    return new ZookeeperResponse(response);
  }

  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

  public void handler(OpsTarget target) throws OpsException {
    // Make sure openssh-server is manually installed (i.e. not through task-ssh-server)
    target.executeCommand("apt-get install openssh-server");

    // Only for wheezy? Squeeze has a depencency of install-info -> findutils
    Command command = Command
        .build("apt-get remove --yes aptitude tasksel tasksel-data man-db manpages libxapian22 libboost-iostreams1.49.0 info ");
    target.executeCommand(command);

    // Maybe:
View Full Code Here

public class SimpleIptablesRules implements Iterable<SimpleIptablesRule> {
  List<SimpleIptablesRule> rules = Lists.newArrayList();

  public static Command buildCommand(Transport transport, IptablesChain chain) {
    Command command;
    switch (transport) {
    case Ipv4:
      command = Command.build("iptables");
      break;
    case Ipv6:
      command = Command.build("ip6tables");
      break;
    default:
      throw new IllegalStateException();
    }

    command.addLiteral("-t").addQuoted(chain.toString().toLowerCase());
    return command;
  }
View Full Code Here

    if (InetAddressUtils.isPublic(host)) {
      CurlRequest curlRequest = new CurlRequest(uri);
      curlRequest.bareRequest = true;
      CommandEnvironment commandEnvironment = httpProxies.getHttpProxyEnvironment(target, Usage.General, uri);

      Command curlCommand = curlRequest.toCommand();
      curlCommand.addLiteral(">");
      curlCommand.addFile(remoteFilePath);
      curlCommand.setEnvironment(commandEnvironment);
      curlCommand.setTimeout(TimeSpan.FIVE_MINUTES);

      target.executeCommand(curlCommand);
    } else {
      log.warn("Address was not public: " + host + ", doing copy via ops system");
View Full Code Here

  }

  public static SimpleIptablesRules listRules(OpsTarget target, Transport transport, IptablesChain chain)
      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);
View Full Code Here

    String imageId = UUID.randomUUID().toString();

    final File targetImageFile = getImageFile(imageId, null);

    if (srcImageHost.equals(target)) {
      Command copyCommand = Command.build("cp", srcImageFile, targetImageFile);
      target.executeCommand(copyCommand.setTimeout(TimeSpan.TEN_MINUTES));
    } else {
      PeerToPeerCopy peerToPeerCopy = Injection.getInstance(PeerToPeerCopy.class);
      peerToPeerCopy.copy(srcImageHost, srcImageFile, target, targetImageFile);
    }
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.