use of org.openstack.service.nginx.model.NginxBackend 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.NginxBackend in project platformlayer by platformlayer.
the class SiteTemplateData method resolveBackends.
private List<BackendModel> resolveBackends(List<NginxBackend> backends) throws OpsException {
List<BackendModel> resolved = Lists.newArrayList();
for (NginxBackend backend : backends) {
ItemBase backendItem = platformLayer.getItem(backend.backend);
Machine backendMachine = instances.getMachine(backendItem);
int port = 0;
if (port == 0) {
port = 80;
}
// if (address.contains(":")) {
// resolved.addAll(resolvePlatformLayer(address));
// continue;
// }
// TODO: We need to register a dependency on the resolved item
BackendModel model = new BackendModel();
model.address = backendMachine.getNetworkPoint().getBestAddress(NetworkPoint.forTargetInContext());
model.port = port;
resolved.add(model);
}
return resolved;
}
use of org.openstack.service.nginx.model.NginxBackend in project platformlayer by platformlayer.
the class SiteTemplateData method buildTemplateModel.
@Override
public void buildTemplateModel(Map<String, Object> model) throws OpsException {
NginxFrontend nginxFrontend = getNginxFrontend();
model.put("uniqueKey", getUniqueKey());
model.put("hostname", getHostname());
model.put("httpPort", httpPort);
model.put("httpsPort", httpsPort);
model.put("useSsl", false);
List<NginxBackend> backends = getBackends(nginxFrontend.hostname);
List<BackendModel> resolvedBackends = resolveBackends(backends);
model.put("backends", resolvedBackends);
}
Aggregations