Search in sources :

Example 21 with InstanceBuilder

use of org.platformlayer.ops.instances.InstanceBuilder in project platformlayer by platformlayer.

the class AptCacheServiceController method addChildren.

@Override
protected void addChildren() throws OpsException {
    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);
    }
}
Also used : AptCacheService(org.platformlayer.service.aptcache.model.AptCacheService) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) File(java.io.File) SimpleFile(org.platformlayer.ops.filesystem.SimpleFile) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 22 with InstanceBuilder

use of org.platformlayer.ops.instances.InstanceBuilder in project platformlayer by platformlayer.

the class CollectdServiceController method addChildren.

@Override
protected void addChildren() throws OpsException {
    CollectdService model = OpsContext.get().getInstance(CollectdService.class);
    if (Strings.isNullOrEmpty(model.dnsName)) {
        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());
    // Make sure we have a bit more RAM, so that we can queue up a fair amount of
    instance.minimumMemoryMb = 512;
    // 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"));
}
Also used : CollectdService(org.platformlayer.service.collectd.model.CollectdService) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 23 with InstanceBuilder

use of org.platformlayer.ops.instances.InstanceBuilder in project platformlayer by platformlayer.

the class DnsResolverServiceController method addChildren.

@Override
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
// TODO: Configure /etc/resolv.conf on servers
// TODO: Refresh all our servers so that they use this resolver??
}
Also used : InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 24 with InstanceBuilder

use of org.platformlayer.ops.instances.InstanceBuilder in project platformlayer by platformlayer.

the class MysqlServerController method addChildren.

@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"));
}
Also used : PackageDependency(org.platformlayer.ops.packages.PackageDependency) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) File(java.io.File) SimpleFile(org.platformlayer.ops.filesystem.SimpleFile) MysqlServer(org.platformlayer.service.mysql.model.MysqlServer) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 25 with InstanceBuilder

use of org.platformlayer.ops.instances.InstanceBuilder in project platformlayer by platformlayer.

the class MemcacheServerController method addChildren.

@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"));
}
Also used : PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) MemcacheServer(org.platformlayer.service.memcache.model.MemcacheServer) TemplatedFile(org.platformlayer.ops.filesystem.TemplatedFile) File(java.io.File) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Aggregations

InstanceBuilder (org.platformlayer.ops.instances.InstanceBuilder)26 PublicEndpoint (org.platformlayer.ops.networks.PublicEndpoint)19 File (java.io.File)9 TemplatedFile (org.platformlayer.ops.filesystem.TemplatedFile)4 SimpleFile (org.platformlayer.ops.filesystem.SimpleFile)3 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)2 NetworkPoint (org.platformlayer.ops.networks.NetworkPoint)2 PackageDependency (org.platformlayer.ops.packages.PackageDependency)2 NginxService (org.openstack.service.nginx.model.NginxService)1 ManagedItemId (org.platformlayer.ids.ManagedItemId)1 OperatingSystemRecipe (org.platformlayer.images.model.OperatingSystemRecipe)1 Repository (org.platformlayer.images.model.Repository)1 RepositoryKey (org.platformlayer.images.model.RepositoryKey)1 OpsException (org.platformlayer.ops.OpsException)1 BackupDirectory (org.platformlayer.ops.backups.BackupDirectory)1 RecipeOperatingSystem (org.platformlayer.ops.packages.RecipeOperatingSystem)1 PosixGroup (org.platformlayer.ops.users.PosixGroup)1 PosixUser (org.platformlayer.ops.users.PosixUser)1 IpsecForPort (org.platformlayer.ops.vpn.IpsecForPort)1 IpsecPresharedKey (org.platformlayer.ops.vpn.IpsecPresharedKey)1