Package org.platformlayer.ops.instances

Examples of org.platformlayer.ops.instances.InstanceBuilder


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

    InstanceBuilder vm;

    {
      vm = InstanceBuilder.build(model.dnsName, this, model.getTags());
      vm.minimumMemoryMb = 2048;
      addChild(vm);
    }

    vm.addChild(NexusBootstrap.build());

    JettyInstance jetty = vm.addChild(injected(JettyInstance.class));
    jetty.addApp(NexusApp.build());

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


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

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

    instance.addChild(JavaVirtualMachine.buildJava6());

    instance.addChild(PackageDependency.build("libtcnative-1"));
    instance.addChild(PackageDependency.build("tomcat6"));
    // tomcat6-admin contains the 'manager' app for remote deploys
    instance.addChild(PackageDependency.build("tomcat6-admin"));

    instance.addChild(TomcatUsers.build());

    instance.addChild(TomcatServerBootstrap.build());

    instance.addChild(MetricsInstance.class);

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

  protected void addChildren() throws OpsException {
    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);
    }

    vm.addChild(JettyInstall.class);

    vm.addChild(JettyInstance.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();

      endpoint.transport = model.transport;

      vm.addChild(endpoint);
    }

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

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

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

    instance.publicPorts.add(3306);

    instance.minimumMemoryMb = 2048;

    instance.hostPolicy.allowRunInContainer = true;
    addChild(instance);

    {
      PackageDependency serverPackage = instance.addChild(PackageDependency.build("mysql-server"));
      // mysql-server-5.1 mysql-server/root_password_again password
      // mysql-server-5.1 mysql-server/root_password password
      // mysql-server-5.1 mysql-server-5.1/start_on_boot boolean true
      // mysql-server-5.1 mysql-server-5.1/postrm_remove_databases boolean false
      // mysql-server-5.1 mysql-server/error_setting_password error
      // mysql-server-5.1 mysql-server-5.1/nis_warning note
      // mysql-server-5.1 mysql-server-5.1/really_downgrade boolean false
      // mysql-server-5.1 mysql-server/password_mismatch error
      // mysql-server-5.1 mysql-server/no_upgrade_when_using_ndb error

      // We need to install with a default password, which we then change
      String plaintextPassword = DEFAULT_BOOTSTRAP_PASSWORD.plaintext();
      serverPackage.addConfiguration("mysql-server-5.1", "mysql-server/root_password", "password",
          plaintextPassword);
      serverPackage.addConfiguration("mysql-server-5.1", "mysql-server/root_password_again", "password",
          plaintextPassword);
    }

    // TODO: Is there a window of vulnerability when first booting a machine?
    // Do we need to secure it so that mysql doesn't listen remotely initially (or isn't running)?
    // Maybe use mysql-server-5.1 mysql-server-5.1/start_on_boot boolean true

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

    instance.addChild(MysqlServerBootstrap.build());

    instance.addChild(SimpleFile.build(getClass(), new File("/etc/mysql/conf.d/bind_all.cnf")));
    instance.addChild(SimpleFile.build(getClass(), new File("/etc/mysql/conf.d/skip_name_resolve.cnf")));

    // 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 = 3306;
      endpoint.backendPort = 3306;
      endpoint.dnsName = model.dnsName;

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

      instance.addChild(endpoint);
    }

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

    AptCacheService model = OpsContext.get().getInstance(AptCacheService.class);

    // TODO: Create endpoint with default port; maybe default to closed?
    // model.dnsName

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

    instance.addChild(PackageDependency.build("squid3"));

    instance.addChild(SimpleFile.build(getClass(), new File("/etc/squid3/squid.conf")));

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

    // instance.addChild(CollectdCollector.build());

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      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 {
    WordpressService model = OpsContext.get().getInstance(WordpressService.class);

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

    instance.addChild(PackageDependency.build("wordpress"));

    instance.addChild(ApacheBootstrap.build());

    {
      PlatformLayerFirewallEntry net = injected(PlatformLayerFirewallEntry.class);

      net.destItem = model.databaseItem;
      net.port = 3306;
      net.uniqueId = getFirewallUniqueId();

      PlatformLayerKey sourceKey = model.getKey();
      net.sourceItemKey = sourceKey;

      instance.addChild(net);
    }

    WordpressTemplateData templateData = Injection.getInstance(WordpressTemplateData.class);

    MysqlConnection mysql = instance.addChild(MysqlConnection.build(model.databaseItem));
    mysql.password = model.databasePassword;

    {
      MysqlDatabase db = injected(MysqlDatabase.class);
      db.databaseName = templateData.getDatabaseName();
      mysql.addChild(db);
    }

    {
      MysqlUser db = injected(MysqlUser.class);
      db.databaseName = templateData.getDatabaseName();
      db.databaseUser = templateData.getDatabaseUser();
      db.databasePassword = templateData.getDatabasePassword();
      mysql.addChild(db);
    }

    instance.addChild(WordpressBootstrap.build());
    instance.addChild(WordpressAdminUser.build());

    instance.addChild(WordpressApacheSite.build());

    // instance.addChild(CollectdCollector.build());

    // TODO: How do we bring up wordpress securely??
    // We don't have the tables until we run install.php
    // Maybe we could POST to the install.php form

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = 80;
      endpoint.backendPort = 80;

      // We expect nginx to front-end us, so we don't put the dnsName
      // endpoint.dnsName = model.dnsName;

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

      instance.addChild(endpoint);
    }

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

  protected void addChildren() throws OpsException {
    // int port = PORT;

    // String dnsName = model.dnsName;

    InstanceBuilder vm;
    {
      vm = InstanceBuilder.build(model.dnsName, this, model.getTags());
      // vm.publicPorts.add(port);
      vm.hostPolicy.configureCluster(template.getPlacementKey());

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

      addChild(vm);
    }

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

    {
      SystemAuthInstance service = vm.addChild(SystemAuthInstance.class);
    }

    {
      PublicEndpoint endpoint = vm.addChild(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = BACKEND_PORT;
      endpoint.backendPort = BACKEND_PORT;
      // endpoint.dnsName = dnsName;
View Full Code Here

  @Override
  protected void addChildren() throws OpsException {

    String dnsName = model.dnsName;

    InstanceBuilder vm;
    {
      vm = InstanceBuilder.build(dnsName, this, model.getTags());
      // vm.publicPorts.add(port);
      vm.hostPolicy.configureCluster(template.getPlacementKey());

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

      addChild(vm);
    }

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

    {
      UserAuthInstance service = vm.addChild(UserAuthInstance.class);
    }

    {
      PublicEndpoint endpoint = vm.addChild(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = BACKEND_PORT;
      endpoint.backendPort = BACKEND_PORT;
      // endpoint.dnsName = dnsName;
      endpoint.transport = Transport.Ipv6;
View Full Code Here

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

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

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

    instance.minimumMemoryMb = 1024;

    instance.hostPolicy.allowRunInContainer = true;
    addChild(instance);

    instance.addChild(PackageDependency.build("memcached"));

    MemcacheTemplateModel template = injected(MemcacheTemplateModel.class);

    instance.addChild(TemplatedFile.build(template, new File("/etc/memcached.conf")));

    // 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 = MEMCACHE_PORT;
      endpoint.backendPort = MEMCACHE_PORT;
      endpoint.dnsName = model.dnsName;

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

      instance.addChild(endpoint);
    }

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

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

    InstanceBuilder instance = InstanceBuilder.build(model.dnsName, this, model.getTags());
    instance.hostPolicy.allowRunInContainer = true;
    instance.publicPorts.add(80);
    instance.publicPorts.add(443);
    addChild(instance);

    instance.addChild(PackageDependency.build("nginx"));

    instance.addChild(NginxServerBootstrap.build());

    // Can't restart collectd
    // instance.addChild(CollectdCollector.build());

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

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      endpoint.publicPort = 80;
      endpoint.backendPort = 80;
      endpoint.dnsName = model.dnsName;

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

      instance.addChild(endpoint);
    }

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      endpoint.publicPort = 443;
      endpoint.backendPort = 443;
      endpoint.dnsName = model.dnsName;

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

      instance.addChild(endpoint);
    }

    addChild(injected(NginxBackendConfiguration.class));
    addChild(injected(NginxSites.class));
  }
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.