Search in sources :

Example 1 with NetworkConnection

use of org.platformlayer.service.network.v1.NetworkConnection 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 NetworkConnection

use of org.platformlayer.service.network.v1.NetworkConnection in project platformlayer by platformlayer.

the class PlatformLayerTestContext method openFirewall.

public NetworkConnection openFirewall(ItemBase item, int port) throws OpsException, IOException {
    NetworkConnection firewallRule = new NetworkConnection();
    firewallRule.setSourceCidr("0.0.0.0/0");
    firewallRule.setDestItem(item.getKey());
    firewallRule.setPort(port);
    String id = item.getId() + "-global";
    firewallRule = putItem(id, firewallRule);
    waitForHealthy(firewallRule);
    return firewallRule;
}
Also used : NetworkConnection(org.platformlayer.service.network.v1.NetworkConnection)

Aggregations

NetworkConnection (org.platformlayer.service.network.v1.NetworkConnection)2 NginxBackend (org.openstack.service.nginx.model.NginxBackend)1 NginxService (org.openstack.service.nginx.model.NginxService)1 Tag (org.platformlayer.core.model.Tag)1 UniqueTag (org.platformlayer.ops.UniqueTag)1