Search in sources :

Example 1 with GoogleCloudPublicEndpoint

use of org.platformlayer.service.cloud.google.model.GoogleCloudPublicEndpoint in project platformlayer by platformlayer.

the class GoogleCloudPublicEndpointController method addChildren.

@Override
protected void addChildren() throws OpsException {
    final GoogleCloudPublicEndpoint model = OpsContext.get().getInstance(GoogleCloudPublicEndpoint.class);
    GoogleCloudInstance instance = client.getItem(model.instance, GoogleCloudInstance.class);
    CloudInstanceMapper instanceMapper;
    {
        instanceMapper = injected(CloudInstanceMapper.class);
        instanceMapper.instance = instance;
        addChild(instanceMapper);
    }
    final EnsureFirewallIngress ingress;
    {
        ingress = injected(EnsureFirewallIngress.class);
        ingress.model = model;
        instanceMapper.addChild(ingress);
    }
    {
        OpsProvider<TagChanges> tagChanges = new OpsProvider<TagChanges>() {

            @Override
            public TagChanges get() {
                TagChanges tagChanges = new TagChanges();
                String address = ingress.getPublicAddress();
                if (Strings.isNullOrEmpty(address)) {
                    throw new IllegalStateException();
                }
                EndpointInfo endpoint = new EndpointInfo(address, model.publicPort);
                tagChanges.addTags.add(endpoint.toTag());
                return tagChanges;
            }
        };
        Tagger tagger = injected(Tagger.class);
        tagger.platformLayerKey = model.getKey();
        tagger.tagChangesProvider = tagChanges;
        instanceMapper.addChild(tagger);
        Tagger tagInstance = injected(Tagger.class);
        tagInstance.platformLayerKey = null;
        tagInstance.platformLayerKey = model.instance;
        tagInstance.tagChangesProvider = tagChanges;
        instanceMapper.addChild(tagInstance);
    }
}
Also used : EndpointInfo(org.platformlayer.core.model.EndpointInfo) OpsProvider(org.platformlayer.ops.OpsProvider) Tagger(org.platformlayer.ops.tagger.Tagger) GoogleCloudPublicEndpoint(org.platformlayer.service.cloud.google.model.GoogleCloudPublicEndpoint) TagChanges(org.platformlayer.core.model.TagChanges) GoogleCloudInstance(org.platformlayer.service.cloud.google.model.GoogleCloudInstance)

Aggregations

EndpointInfo (org.platformlayer.core.model.EndpointInfo)1 TagChanges (org.platformlayer.core.model.TagChanges)1 OpsProvider (org.platformlayer.ops.OpsProvider)1 Tagger (org.platformlayer.ops.tagger.Tagger)1 GoogleCloudInstance (org.platformlayer.service.cloud.google.model.GoogleCloudInstance)1 GoogleCloudPublicEndpoint (org.platformlayer.service.cloud.google.model.GoogleCloudPublicEndpoint)1