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