Search in sources :

Example 11 with InstanceBuilder

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

the class LdapServiceController method addChildren.

@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);
    }
}
Also used : PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) LdapService(org.platformlayer.service.openldap.model.LdapService) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 12 with InstanceBuilder

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

the class JettyServiceController method addChildren.

@Override
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);
}
Also used : PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 13 with InstanceBuilder

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

the class NexusServiceController method addChildren.

@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);
}
Also used : NexusService(org.platformlayer.service.nexus.model.NexusService) JettyInstance(org.platformlayer.service.jetty.ops.JettyInstance) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 14 with InstanceBuilder

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

the class ZookeeperServerController method addChildren.

@Override
protected void addChildren() throws OpsException {
    int port = ZookeeperConstants.ZK_PUBLIC_PORT;
    // A per-instance name (for convenience)
    String dnsName = ZookeeperUtils.buildDnsName(model);
    InstanceBuilder vm = InstanceBuilder.build(dnsName, this, model.getTags());
    // vm.publicPorts.add(port);
    // vm.publicPorts.add(ZookeeperConstants.ZK_SYSTEM_PORT_1);
    // vm.publicPorts.add(ZookeeperConstants.ZK_SYSTEM_PORT_2);
    vm.hostPolicy.configureSpread(template.getClusterGroupId());
    vm.addChild(IpsecInstall.class);
    {
        IpsecPresharedKey psk = vm.addChild(IpsecPresharedKey.class);
        psk.id = IpsecPresharedKey.SHAREDKEY_USER_FQDN;
        psk.secret = ipsec.getIpsecSecret();
    }
    // so need to be opened early
    for (int systemPort : ZookeeperConstants.SYSTEM_PORTS) {
        PublicEndpoint endpoint = injected(PublicEndpoint.class);
        // endpoint.network = null;
        endpoint.publicPort = systemPort;
        endpoint.backendPort = systemPort;
        endpoint.dnsName = dnsName;
        // We expect this to be used by IPv6 capable client
        endpoint.transport = Transport.Ipv6;
        endpoint.tagItem = model.getKey();
        endpoint.parentItem = model.getKey();
        vm.addChild(endpoint);
        {
            IpsecForPort ipsecForPort = vm.addChild(IpsecForPort.class);
            ipsecForPort.port = systemPort;
        }
    }
    vm.hostPolicy.allowRunInContainer = true;
    // TODO: This needs to be configurable...
    vm.minimumMemoryMb = 2048;
    addChild(vm);
    {
        ZookeeperInstall install = vm.addChild(ZookeeperInstall.class);
    }
    {
        ZookeeperInstance service = vm.addChild(ZookeeperInstance.class);
    }
    {
        PublicEndpoint endpoint = vm.addChild(PublicEndpoint.class);
        // endpoint.network = null;
        endpoint.publicPort = port;
        endpoint.backendPort = port;
        endpoint.dnsName = dnsName;
        // We expect this to be used by IPv6 capable client
        endpoint.transport = Transport.Ipv6;
        endpoint.tagItem = model.getKey();
        endpoint.parentItem = model.getKey();
        {
            IpsecForPort ipsecForPort = vm.addChild(IpsecForPort.class);
            ipsecForPort.port = port;
        }
    }
    vm.addChild(ZookeeperStatusChecker.class);
// TODO: Establish round-robin style DNS on clusterDnsName
// TODO: Is some form of geo-direction possible?
}
Also used : IpsecForPort(org.platformlayer.ops.vpn.IpsecForPort) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) IpsecPresharedKey(org.platformlayer.ops.vpn.IpsecPresharedKey) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 15 with InstanceBuilder

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

the class WordpressServiceController method addChildren.

@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"));
}
Also used : PlatformLayerFirewallEntry(org.platformlayer.service.network.ops.PlatformLayerFirewallEntry) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) WordpressService(org.platformlayer.service.wordpress.model.WordpressService) 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