Package org.platformlayer.ops

Examples of org.platformlayer.ops.OpsTarget


            log.info("Host is terminating; won't allocate to it {}", host.getKey());
            continue;
          }
        }

        OpsTarget target = directHelpers.toTarget(host);
        hosts.add(new DirectCloudHost(host, target));
      }
      this.hosts = hosts;
    }
View Full Code Here


public class MountCgroups extends OpsItemBase {
  @Handler
  public void handler() throws OpsException, IOException {
    // TODO: Only if not installed
    OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);

    File cgroupsFile = new File("/cgroup");
    FilesystemInfo info = target.getFilesystemInfoFile(cgroupsFile);
    if (info != null) {
      // TODO: Better idempotency
      return;
    }

    String fstabLine = "\ncgroup\t/cgroup\tcgroup\tdefaults\t0\t0";
    File fstabFile = new File("/etc/fstab");
    String fstab = target.readTextFile(fstabFile);
    fstab += fstabLine;
    FileUpload.upload(target, fstabFile, fstab);

    target.mkdir(cgroupsFile);

    Command mountCommand = Command.build("mount cgroup");
    target.executeCommand(mountCommand);

    // mkdir /cgroup
    // echo -e "cgroup\t/cgroup\tcgroup\tdefaults\t0\t0" >> /etc/fstab
    // mount cgroup
  }
View Full Code Here

    FileUpload.upload(getTarget(), file, runTemplate("etc.network.interfaces"));
  }

  void setupIpv6Script() throws OpsException {
    File file = new File(getRoot(), "etc/network/if-up.d/ipv6");
    OpsTarget target = getTarget();
    FileUpload.upload(target, file, runTemplate("ipv6"));
    target.chmod(file, "755");
  }
View Full Code Here

        log.warn("Server instance not found: " + machineItem);
        failed = true;
        continue;
      }

      OpsTarget target = machine.getTarget(sshKey);

      try {
        // Execute the children in a scope with the paired item and machine
        BindingScope scope = BindingScope.push(machine, target, machineItem);
        try {
View Full Code Here

    objectClasses.add("olcHdbConfig");
  }

  @Override
  protected boolean alreadyExists() throws OpsException {
    OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);
    FilesystemInfo dirInfo = target.getFilesystemInfoFile(new File(getDataDirectory(), "objectClass.bdb"));

    return dirInfo != null;
  }
View Full Code Here

          drive.id = "0";
          drive.boot = true;
          drive.format = "raw";
          drive.media = "disk";

          OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);
          ProcessExecution fileCommand;
          try {
            fileCommand = target.executeCommand(Command.build("file --brief {0}", getImagePath()));
          } catch (OpsException e) {
            throw new IllegalStateException("Error querying file type", e);
          }
          String fileStdout = fileCommand.getStdOut();
          if (fileStdout.contains("QCOW Image")) {
View Full Code Here

    if (machine == null) {
      throw new OpsException("Server machine not found:" + gitService);
    }

    SshKey sshKey = service.getSshKey();
    OpsTarget target = machine.getTarget(sshKey);

    getRecursionState().pushChildScope(OpsTarget.class, target);
  }
View Full Code Here

  TemplateHelpers templates;

  @Handler
  public void handler() throws OpsException, IOException {
    // TODO: This needs to be idempotent
    OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);

    // Nexus needs a workdir; by default it's in the home directory of the user we're running under
    // With jetty, the jetty user can't create this directory; we do it
    File sonatypeDir = new File("/usr/share/jetty/sonatype-work");
    target.mkdir(sonatypeDir, "750");

    File nexusDir = new File(sonatypeDir, "nexus");
    target.mkdir(nexusDir, "750");

    File confDir = new File(nexusDir, "conf");
    target.mkdir(confDir, "750");
    {
      String contents = ResourceUtils.get(getClass(), "conf/security.xml");
      FileUpload.upload(target, new File(confDir, "security.xml"), contents);
    }

    {
      String contents = ResourceUtils.get(getClass(), "conf/security-configuration.xml");
      FileUpload.upload(target, new File(confDir, "security-configuration.xml"), contents);
    }

    {
      // TODO: Bind with a low-privilege account
      // TODO: Don't hard-code this stuff
      String ldapHost = "192.168.192.67";
      String ldapDomain = "dc=com,dc=fathomscale";
      String ldapUsername = "cn=Manager," + ldapDomain;
      String ldapPassword = "adminsecret";

      Map<String, Object> vars = Maps.newHashMap();
      vars.put("searchBase", ldapDomain);
      vars.put("systemUsername", ldapUsername);
      vars.put("systemPassword", encryptNexusPassword(ldapPassword));
      vars.put("ldapHost", ldapHost);

      // TODO: This is a bit limiting; we should use memberOf
      // Avoids escaping ${username}
      vars.put("groupMemberFormat", "uid=${username},ou=Users,dc=com,dc=fathomscale");

      String resourcePath = templates.toResourcePath(this, "conf/ldap.xml");
      String contents = templates.runTemplate(resourcePath, vars);
      FileUpload.upload(target, new File(confDir, "ldap.xml"), contents);
    }

    target.chown(sonatypeDir, "jetty", "jetty", true, false);
  }
View Full Code Here

    // Serious bootstrapping problem here!!!
    SshKey serviceKey = service.getSshKey();
    PublicKey sshPublicKey = serviceKey.getKeyPair().getPublic();

    OpaqueMachine machine = new OpaqueMachine(NetworkPoint.forPublicHostname(model.dnsName));
    OpsTarget target = machine.getTarget("imagestore", serviceKey.getKeyPair());

    SshAuthorizedKey.ensureSshAuthorization(target, "imagestore", sshPublicKey);

    // addChild(SshAuthorizedKey.build("root", publicKey));
  }
View Full Code Here

    if (url.getScheme().equals("ssh")) {
      String myAddress = url.getHost();
      Machine machine = new OpaqueMachine(NetworkPoint.forPublicHostname(myAddress));
      // This is nasty; we're in the context of another service here...
      SshKey sshKey = sshKeys.findOtherServiceKey(new ServiceType("imagestore"));
      OpsTarget target = machine.getTarget("imagestore", sshKey.getKeyPair());

      DirectImageStore directImageStore = OpsContext.get().getInjector().getInstance(DirectImageStore.class);
      directImageStore.connect(target);
      return directImageStore;
    } else {
View Full Code Here

TOP

Related Classes of org.platformlayer.ops.OpsTarget

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.