Examples of InstanceBuilder


Examples of org.platformlayer.ops.instances.InstanceBuilder

  @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

Examples of org.platformlayer.ops.instances.InstanceBuilder

    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

Examples of org.platformlayer.ops.instances.InstanceBuilder

  @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

Examples of org.platformlayer.ops.instances.InstanceBuilder

  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

Examples of org.platformlayer.ops.instances.InstanceBuilder

  @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

Examples of org.platformlayer.ops.instances.InstanceBuilder

  @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

Examples of org.platformlayer.ops.instances.InstanceBuilder

  @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

Examples of org.platformlayer.ops.instances.InstanceBuilder

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

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

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

        instance.addChild(CollectdCollector.build());

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

Examples of org.platformlayer.ops.instances.InstanceBuilder

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

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

    instance.hostPolicy.allowRunInContainer = true;
    instance.minimumMemoryMb = 4096;

    addChild(instance);

    {
      RecipeOperatingSystem os = injected(RecipeOperatingSystem.class);
      os.operatingSystem = new OperatingSystemRecipe();
      os.operatingSystem.setDistribution("debian");
      os.operatingSystem.setVersion("wheezy");
      instance.addChild(os);
    }

    // We use curl for backups
    instance.addChild(PackageDependency.build("curl"));

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

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

      instance.addChild(endpoint);
    }

    // {
    // BackupDirectory backup = injected(BackupDirectory.class);
    // backup.itemKey = model.getKey();
View Full Code Here

Examples of org.platformlayer.ops.instances.InstanceBuilder

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

    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);
    }

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

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

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

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

      if (model.transport != null) {
        endpoint.transport = EnumUtils.valueOfCaseInsensitive(Transport.class, model.transport);
      } else {
        endpoint.transport = Transport.Ipv6;
      }

      vm.addChild(endpoint);
    }

    if (model.dnsName != null) {
      loadBalancing.addHttpSite(this, model, model.dnsName, template.getSslKeyPath(), SslMode.Terminate);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.