Search in sources :

Example 1 with NginxService

use of org.openstack.service.nginx.model.NginxService in project platformlayer by platformlayer.

the class NginxBackendFirewall method buildItemTemplate.

@Override
protected ItemBase buildItemTemplate() {
    NginxService nginxService = OpsContext.get().getInstance(NginxService.class);
    NginxBackend nginxBackend = OpsContext.get().getInstance(NginxBackend.class);
    NetworkConnection networkConnection = new NetworkConnection();
    networkConnection.setDestItem(nginxBackend.backend);
    networkConnection.setSourceItem(nginxService.getKey());
    networkConnection.setPort(port);
    networkConnection.setProtocol(protocol.toString());
    Tag parentTag = Tag.buildParentTag(nginxBackend.getKey());
    networkConnection.getTags().add(parentTag);
    Tag uniqueTag = UniqueTag.build(nginxService, nginxBackend);
    networkConnection.getTags().add(uniqueTag);
    String id = nginxBackend.getId();
    if (Strings.isNullOrEmpty(id)) {
        id = "nginx";
    }
    networkConnection.key = PlatformLayerKey.fromId(id);
    return networkConnection;
}
Also used : NginxBackend(org.openstack.service.nginx.model.NginxBackend) NetworkConnection(org.platformlayer.service.network.v1.NetworkConnection) UniqueTag(org.platformlayer.ops.UniqueTag) Tag(org.platformlayer.core.model.Tag) NginxService(org.openstack.service.nginx.model.NginxService)

Example 2 with NginxService

use of org.openstack.service.nginx.model.NginxService in project platformlayer by platformlayer.

the class NginxFrontendDns method buildItemTemplate.

@Override
protected DnsRecord buildItemTemplate() throws OpsException {
    // TODO: Idempotency etc
    // Machine machine = OpsContext.get().getInstance(Machine.class);
    NginxService nginxService = OpsContext.get().getInstance(NginxService.class);
    NginxFrontend nginxFrontend = OpsContext.get().getInstance(NginxFrontend.class);
    Machine machine = instanceHelpers.getMachine(nginxService);
    String address = machine.getNetworkPoint().getBestAddress(NetworkPoint.forPublicInternet());
    DnsRecord record = new DnsRecord();
    record.setDnsName(nginxFrontend.hostname);
    record.getAddress().add(address);
    Tag parentTag = Tag.buildParentTag(nginxFrontend.getKey());
    record.getTags().add(parentTag);
    Tag uniqueTag = UniqueTag.build(nginxService, nginxFrontend);
    record.getTags().add(uniqueTag);
    record.key = PlatformLayerKey.fromId(nginxFrontend.hostname);
    return record;
}
Also used : NginxFrontend(org.openstack.service.nginx.model.NginxFrontend) UniqueTag(org.platformlayer.ops.UniqueTag) Tag(org.platformlayer.core.model.Tag) DnsRecord(org.platformlayer.dns.model.DnsRecord) Machine(org.platformlayer.ops.Machine) NginxService(org.openstack.service.nginx.model.NginxService)

Example 3 with NginxService

use of org.openstack.service.nginx.model.NginxService in project platformlayer by platformlayer.

the class NginxServiceController method addChildren.

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

Aggregations

NginxService (org.openstack.service.nginx.model.NginxService)3 Tag (org.platformlayer.core.model.Tag)2 UniqueTag (org.platformlayer.ops.UniqueTag)2 NginxBackend (org.openstack.service.nginx.model.NginxBackend)1 NginxFrontend (org.openstack.service.nginx.model.NginxFrontend)1 DnsRecord (org.platformlayer.dns.model.DnsRecord)1 Machine (org.platformlayer.ops.Machine)1 InstanceBuilder (org.platformlayer.ops.instances.InstanceBuilder)1 PublicEndpoint (org.platformlayer.ops.networks.PublicEndpoint)1 NetworkConnection (org.platformlayer.service.network.v1.NetworkConnection)1