Search in sources :

Example 1 with NginxBackend

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;
}
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 NginxBackend

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;
}
Also used : NginxBackend(org.openstack.service.nginx.model.NginxBackend) ItemBase(org.platformlayer.core.model.ItemBase) Machine(org.platformlayer.ops.Machine) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint)

Example 3 with NginxBackend

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);
}
Also used : NginxFrontend(org.openstack.service.nginx.model.NginxFrontend) NginxBackend(org.openstack.service.nginx.model.NginxBackend)

Aggregations

NginxBackend (org.openstack.service.nginx.model.NginxBackend)3 NginxFrontend (org.openstack.service.nginx.model.NginxFrontend)1 NginxService (org.openstack.service.nginx.model.NginxService)1 ItemBase (org.platformlayer.core.model.ItemBase)1 Tag (org.platformlayer.core.model.Tag)1 Machine (org.platformlayer.ops.Machine)1 UniqueTag (org.platformlayer.ops.UniqueTag)1 NetworkPoint (org.platformlayer.ops.networks.NetworkPoint)1 NetworkConnection (org.platformlayer.service.network.v1.NetworkConnection)1