Package org.platformlayer.service.cloud.raw.model

Examples of org.platformlayer.service.cloud.raw.model.RawPublicEndpoint


    return rawMachine;
  }

  @Override
  public PublicEndpointBase buildEndpointTemplate() {
    return new RawPublicEndpoint();
  }
View Full Code Here


  @Override
  protected void addChildren() throws OpsException {
    // We can't actually do anything; we can tag it to mark that the port is open

    final RawPublicEndpoint model = OpsContext.get().getInstance(RawPublicEndpoint.class);

    if (model.publicPort != model.backendPort) {
      throw new OpsException("Port remapping not supported by raw cloud");
    }

    {
      Tagger tagger = injected(Tagger.class);

      OpsProvider<TagChanges> tagChanges = new OpsProvider<TagChanges>() {
        @Override
        public TagChanges get() throws OpsException {
          RawInstance instance = platformLayerClient.getItem(model.instance, RawInstance.class);

          InetAddressChooser chooser = InetAddressChooser.preferIpv4();
          InetAddress publicAddress = chooser.choose(Tag.NETWORK_ADDRESS.find(instance.getTags()));

          if (publicAddress == null) {
            throw new OpsException("Cannot find address for instance: " + model.instance);
          }

          TagChanges tagChanges = new TagChanges();
          EndpointInfo endpoint = new EndpointInfo(publicAddress, model.publicPort);
          tagChanges.addTags.add(endpoint.toTag());

          return tagChanges;
        }
      };
      tagger.platformLayerKey = model.getKey();
      tagger.tagChangesProvider = tagChanges;

      addChild(tagger);
    }
  }
View Full Code Here

TOP

Related Classes of org.platformlayer.service.cloud.raw.model.RawPublicEndpoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.