Package org.platformlayer.ops.instances

Examples of org.platformlayer.ops.instances.InstanceBuilder


    String dnsName = model.dnsName;

    List<Integer> ports = getPorts();

    InstanceBuilder vm;
    {
      vm = InstanceBuilder.build(dnsName, this, model.getTags());
      vm.publicPorts.addAll(ports);
      vm.hostPolicy.configureCluster(template.getPlacementKey());

      // TODO: This needs to be configurable (?)
      vm.minimumMemoryMb = 2048;

      addChild(vm);
    }

    {
      GerritInstall install = vm.addChild(GerritInstall.class);
    }

    // Bootstrap depends on configuration file
    vm.addChild(ManagedDirectory.build(template.getDataDir(), "700").setOwner(template.getUser())
        .setGroup(template.getGroup()));
    vm.addChild(ManagedDirectory.build(new File(template.getDataDir(), "etc"), "700").setOwner(template.getUser())
        .setGroup(template.getGroup()));
    vm.addChild(GerritConfigurationFile.class);

    vm.addChild(GerritBootstrap.class);

    vm.addChild(GerritInstance.class);

    for (int port : ports) {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = port;
      endpoint.backendPort = port;
      endpoint.dnsName = dnsName;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      vm.addChild(endpoint);
    }

    vm.addChild(MetricsInstance.class);
  }
View Full Code Here


  @Override
  protected void addChildren() throws OpsException {
    GitService model = OpsContext.get().getInstance(GitService.class);

    InstanceBuilder vm = InstanceBuilder.build(model.dnsName, this, model.getTags());
    addChild(vm);

    vm.addChild(PackageDependency.build("apache2"));
    // Provides /usr/lib/git-core/git-http-backend
    vm.addChild(PackageDependency.build("git"));

    vm.addChild(ManagedDirectory.build(new File("/var/git"), "0755"));
    vm.addChild(ApacheModule.build("authnz_ldap"));
    vm.addChild(ApacheModule.build("ldap"));

    File apache2ConfDir = new File("/etc/apache2");

    vm.addChild(TemplatedFile.build(this, new File(apache2ConfDir, "conf.d/git")));

    vm.addChild(ManagedService.build("apache2"));

    vm.addChild(MetricsInstance.class);

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = PORT;
      endpoint.backendPort = PORT;
      endpoint.dnsName = model.dnsName;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      vm.addChild(endpoint);
    }
  }
View Full Code Here

  protected void addChildren() throws OpsException {
    if (Strings.isNullOrEmpty(model.dnsName)) {
      throw new IllegalArgumentException("dnsName must be specified");
    }

    InstanceBuilder instance = InstanceBuilder.build(model.dnsName, this, model.getTags());
    addChild(instance);

    instance.addChild(PackageDependency.build("bind9"));
    instance.addChild(ManagedService.build("bind9"));

    instance.addChild(MetricsInstance.class);

    // Debian bind9 sets up a recursive resolver by default :-)

    // TODO: Monit
View Full Code Here

  @Override
  protected void addChildren() throws OpsException {
    LdapService model = OpsContext.get().getInstance(LdapService.class);

    // TODO: Support package pre-configuration??
    InstanceBuilder instance = InstanceBuilder.build(model.dnsName,
        DiskImageRecipeBuilder.loadDiskImageResource(getClass(), "DiskImageRecipe.xml"), model.getTags());
    addChild(instance);

    instance.addChild(MetricsInstance.class);

    instance.addChild(LdapMasterPassword.build(model.ldapServerPassword));

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = PORT;
      endpoint.backendPort = PORT;
      endpoint.dnsName = model.dnsName;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      instance.addChild(endpoint);
    }
  }
View Full Code Here

  @Override
  protected void addChildren() throws OpsException {
    RedisServer model = OpsContext.get().getInstance(RedisServer.class);

    InstanceBuilder vm;

    {
      vm = InstanceBuilder.build(model.dnsName, this, model.getTags());

      // TODO: Memory _really_ needs to be configurable here!
      vm.publicPorts.add(PORT);

      vm.minimumMemoryMb = 1024;

      vm.hostPolicy.allowRunInContainer = true;
      addChild(vm);
    }

    vm.addChild(PackageDependency.build("redis-server"));

    RedisTemplateModel template = injected(RedisTemplateModel.class);

    vm.addChild(TemplatedFile.build(template, new File("/etc/redis/redis.conf")).setFileMode("444"));

    // Collectd not restarting correctly (doesn't appear to be hostname problems??)
    // instance.addChild(CollectdCollector.build());

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = PORT;
      endpoint.backendPort = PORT;
      endpoint.dnsName = model.dnsName;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      vm.addChild(endpoint);
    }

    vm.addChild(ManagedService.build("redis-server"));
  }
View Full Code Here

  @Override
  protected void addChildren() throws OpsException {
    GitlabService model = OpsContext.get().getInstance(GitlabService.class);

    InstanceBuilder instance = InstanceBuilder.build(model.dnsName, this, model.getTags());
    addChild(instance);

    instance.addChildren(PackageDependency
        .build(Splitter
            .on(" ")
            .split("sudo git-core wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip sendmail")));

    {
      PosixGroup group = injected(PosixGroup.class);
      group.groupName = "git";
      instance.addChild(group);
    }

    {
      PosixUser user = injected(PosixUser.class);
      user.userName = "git";
      user.primaryGroup = "git";
      instance.addChild(user);
    }

    {
      PosixUser user = injected(PosixUser.class);
      user.userName = "gitlab";
      user.secondaryGroups.add("sudo");
      user.secondaryGroups.add("git");
      instance.addChild(user);
    }

    // sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa

    instance.addChild(PackageDependency.build("ruby1.9.1"));

    {
      GitCheckout checkout = injected(GitCheckout.class);
      checkout.targetDir = new File("/opt/gitlabhq");
      checkout.source = "https://github.com/gitlabhq/gitlabhq.git";
      instance.addChild(checkout);
    }

    {
      GitCheckout checkout = injected(GitCheckout.class);
      checkout.targetDir = new File("/opt/gitolite");
      checkout.source = "https://github.com/gitlabhq/gitolite.git";
      instance.addChild(checkout);
    }

    // Eeek... we have to run a gitolite install script.
    // I don't fancy picking it apart right now...
View Full Code Here

    // addChild(SshAuthorizedKey.build("root", publicKey));
  }

  protected void addChildrenGlance(ImageStore model) throws OpsException {
    InstanceBuilder instance = InstanceBuilder.build(model.dnsName, this, model.getTags());
    addChild(instance);

    // We’ll stick with glance using SQLite (for now)
    instance.addChild(PackageDependency.build("glance"));
    instance.addChild(ManagedService.build("glance"));

    instance.addChild(MetricsInstance.class);
  }
View Full Code Here

      throw new IllegalArgumentException("dnsName must be specified");
    }

    // We'd like to auto-gen the disk image, but we have to fix the problems involving pre-installing collectd (see
    // below)
    InstanceBuilder instance = InstanceBuilder.build(model.dnsName,
        DiskImageRecipeBuilder.loadDiskImageResource(getClass(), "DiskImageRecipe.xml"), model.getTags());
    instance.minimumMemoryMb = 512; // Make sure we have a bit more RAM, so that we can queue up a fair amount of
                    // RRD data
    addChild(instance);

    // We have some problems using collectd with debootstrap; I think it's when we're using FQDN and we can't
    // resolve the hostname
    // See http://thegrebs.com/irc/debian/2011/04/01

    instance.addChild(PackageDependency.build("librrd4"));
    instance.addChild(PackageDependency.build("rrdcached"));

    // collectd is a bit fussy, so we have problems bundling it into the disk image
    // TODO: This sucks - collectd is pretty big...
    instance.addChild(PackageDependency.build("collectd"));

    // collectd has collectdmon to keep it alive; don't use monit (for now)

    instance.addChild(CollectdSink.build());

    instance.addChild(ManagedService.build("collectd"));
  }
View Full Code Here

  @Override
  protected void addChildren() throws OpsException {
    PostgresqlTemplateVariables template = injected(PostgresqlTemplateVariables.class);

    InstanceBuilder instance = InstanceBuilder.build(model.dnsName, this, model.getTags());
    // TODO: Memory _really_ needs to be configurable here!
    instance.publicPorts.add(5432);

    instance.minimumMemoryMb = 2048;
    addChild(instance);

    instance.addChild(PackageDependency.build("postgresql"));
    instance.addChild(PackageDependency.build("postgresql-client"));

    String postgresVersion = template.getPostgresVersion();

    if (postgresVersion.equals("8.4")) {
      instance.addChild(TemplatedFile.build(template, new File("/etc/postgresql/8.4/main/pg_hba.conf"),
          "8_4_pg_hba.conf"));
      instance.addChild(TemplatedFile.build(template, new File("/etc/postgresql/8.4/main/postgresql.conf"),
          "8_4_postgresql.conf"));
    } else if (postgresVersion.equals("9.1")) {
      instance.addChild(TemplatedFile.build(template, new File("/etc/postgresql/9.1/main/pg_hba.conf"),
          "9_1_pg_hba.conf"));
      instance.addChild(TemplatedFile.build(template, new File("/etc/postgresql/9.1/main/postgresql.conf"),
          "9_1_postgresql.conf"));
    } else {
      throw new OpsException("Unsupported postgres version: " + postgresVersion);
    }

    instance.addChild(PostgresqlServerBootstrap.build());

    instance.addChild(MetricsInstance.class);

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = 5432;
      endpoint.backendPort = 5432;
      endpoint.dnsName = model.dnsName;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      instance.addChild(endpoint);
    }

    instance.addChild(ManagedService.build("postgresql"));

    instance.addChild(injected(PostgresqlServerBackup.class));
  }
View Full Code Here

  protected void addChildren() throws OpsException {
    SolrServer model = OpsContext.get().getInstance(SolrServer.class);

    int port = SolrConstants.API_PORT;

    InstanceBuilder vm;

    {
      vm = InstanceBuilder.build(model.dnsName, this, model.getTags());
      vm.publicPorts.add(port);

      vm.hostPolicy.allowRunInContainer = true;

      // TODO: This needs to be configurable...
      vm.minimumMemoryMb = 2048;

      addChild(vm);
    }

    {
      SolrInstall install = injected(SolrInstall.class);
      vm.addChild(install);
    }

    {
      SolrInstance service = injected(SolrInstance.class);
      vm.addChild(service);
    }

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = port;
      endpoint.backendPort = port;
      endpoint.dnsName = model.dnsName;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      vm.addChild(endpoint);
    }
  }
View Full Code Here

TOP

Related Classes of org.platformlayer.ops.instances.InstanceBuilder

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.