Search in sources :

Example 1 with UniqueTag

use of org.platformlayer.ops.UniqueTag in project platformlayer by platformlayer.

the class OwnedEndpoint method buildItemTemplate.

@Override
protected PublicEndpointBase buildItemTemplate() throws OpsException {
    InstanceBase instance = OpsContext.get().getInstance(InstanceBase.class);
    PlatformLayerKey instanceKey = instance.getKey();
    PublicEndpointBase publicEndpoint = platformLayerCloudHelpers.createPublicEndpoint(instance, parentItem);
    // publicEndpoint.network = network;
    publicEndpoint.publicPort = publicPort;
    publicEndpoint.publicPortCluster = publicPortCluster;
    publicEndpoint.backendPort = backendPort;
    publicEndpoint.instance = instanceKey;
    publicEndpoint.key = PlatformLayerKey.fromId(instance.getId() + "_" + publicPort);
    if (transport != null) {
        publicEndpoint.transport = transport.toString();
    }
    // publicEndpoint.getTags().add(OpsSystem.get().createParentTag(instance));
    Tag uniqueTag = UniqueTag.build(instance, String.valueOf(publicPort));
    publicEndpoint.getTags().add(uniqueTag);
    return publicEndpoint;
}
Also used : PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) UniqueTag(org.platformlayer.ops.UniqueTag) Tag(org.platformlayer.core.model.Tag) PublicEndpointBase(org.platformlayer.core.model.PublicEndpointBase) InstanceBase(org.platformlayer.core.model.InstanceBase)

Example 2 with UniqueTag

use of org.platformlayer.ops.UniqueTag 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 3 with UniqueTag

use of org.platformlayer.ops.UniqueTag 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)

Aggregations

Tag (org.platformlayer.core.model.Tag)3 UniqueTag (org.platformlayer.ops.UniqueTag)3 NginxService (org.openstack.service.nginx.model.NginxService)2 NginxBackend (org.openstack.service.nginx.model.NginxBackend)1 NginxFrontend (org.openstack.service.nginx.model.NginxFrontend)1 InstanceBase (org.platformlayer.core.model.InstanceBase)1 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)1 PublicEndpointBase (org.platformlayer.core.model.PublicEndpointBase)1 DnsRecord (org.platformlayer.dns.model.DnsRecord)1 Machine (org.platformlayer.ops.Machine)1 NetworkConnection (org.platformlayer.service.network.v1.NetworkConnection)1