Package org.jclouds.trmk.vcloud_0_8.domain

Examples of org.jclouds.trmk.vcloud_0_8.domain.InternetService


   }

   @Override
   public Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIp(VApp vApp, int port, Protocol protocol) {
      logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getHref(), protocol, port);
      InternetService is = client.addInternetServiceToVDC(
            vApp.getVDC().getHref(),
            vApp.getName() + "-" + port,
            protocol,
            port,
            withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(),
                  vApp.getName())));
      PublicIpAddress ip = is.getPublicIpAddress();
      Map<InternetService, PublicIpAddress> result = ImmutableMap.<InternetService, PublicIpAddress> of(is, ip);
      Entry<InternetService, PublicIpAddress> entry = Iterables.getOnlyElement(result.entrySet());
      return entry;
   }
View Full Code Here


   }

   @Override
   public Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIp(VApp vApp, int port, Protocol protocol) {
      logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getHref(), protocol, port);
      InternetService is = null;
      PublicIpAddress ip = null;
      try {
         ip = client.activatePublicIpInVDC(vApp.getVDC().getHref());
      } catch (InsufficientResourcesException e) {
         logger.warn(">> no more ip addresses available, looking for one to re-use");
View Full Code Here

   private int thisDepth;

   @Override
   public InternetService getResult() {
      return new InternetService(serviceName, location, publicIpAddress, port, protocol, enabled, timeout, description);
   }
View Full Code Here

   public String createPublicAddressMappedToPorts(URI vAppId, int... ports) {
      VApp vApp = client.getVApp(vAppId);
      PublicIpAddress ip = null;
      String privateAddress = getLast(vApp.getNetworkToAddresses().values());
      for (int port : ports) {
         InternetService is = null;
         Protocol protocol;
         switch (port) {
         case 22:
            protocol = Protocol.TCP;
            break;
         case 80:
         case 8080:
            protocol = Protocol.HTTP;
            break;
         case 443:
            protocol = Protocol.HTTPS;
            break;
         default:
            protocol = Protocol.HTTP;
            break;
         }
         if (ip == null) {

            Entry<InternetService, PublicIpAddress> entry = internetServiceAndPublicIpAddressSupplier
                  .getNewInternetServiceAndIp(vApp, port, protocol);
            is = entry.getKey();
            ip = entry.getValue();

         } else {
            logger.debug(">> adding InternetService %s:%s:%d", ip.getAddress(), protocol, port);
            is = client.addInternetServiceToExistingIp(
                  ip.getId(),
                  vApp.getName() + "-" + port,
                  protocol,
                  port,
                  withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(),
                        vApp.getName())));
         }
         logger.debug("<< created InternetService(%s) %s:%s:%d", is.getName(), is.getPublicIpAddress().getAddress(),
               is.getProtocol(), is.getPort());
         logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress(), is.getPort(),
               privateAddress, port);
         Node node = client.addNode(is.getId(), privateAddress, vApp.getName() + "-" + port, port);
         logger.debug("<< added Node(%s)", node.getName());
      }
      return ip != null ? ip.getAddress() : null;
   }
View Full Code Here

   public void testCreateInternetServiceMonitorDisabled() throws Exception {
      for (Org org : orgs) {
         for (ReferenceType vdc : org.getVDCs().values()) {
            Set<PublicIpAddress> publicIpAddresses = api.getPublicIpsAssociatedWithVDC(vdc.getHref());
            PublicIpAddress publicIp = publicIpAddresses.iterator().next();
            InternetService service = api.addInternetServiceToExistingIp(publicIp.getId(), PREFIX
                  + "-no-monitoring", Protocol.TCP, 1234, AddInternetServiceOptions.Builder.monitorDisabled());
            api.deleteInternetService(service.getId());
         }
      }
   }
View Full Code Here

   }

   public void test1() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/InternetService.xml");

      InternetService result = factory.create(injector.getInstance(InternetServiceHandler.class))
            .parse(is);
      assertEquals(result, new InternetService("IS_for_Jim", null, new PublicIpAddress("10.1.22.159", null), 80,
            Protocol.HTTP, false, 1, "Some test service"));
   }
View Full Code Here

   }

   public void test2() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/InternetService2.xml");

      InternetService result = factory.create(injector.getInstance(InternetServiceHandler.class))
            .parse(is);
      assertEquals(result, new InternetService("IS_for_Jim2", URI
            .create("https://services.vcloudexpress.terremark.com/api/v0.8/InternetServices/524"), new PublicIpAddress(
            "10.1.22.159", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/4208")), 45,
            Protocol.HTTP, false, 1, "Some test service"));
   }
View Full Code Here

   public void testCreateInternetServiceMonitorDisabled() throws Exception {
      for (Org org : orgs) {
         for (ReferenceType vdc : org.getVDCs().values()) {
            Set<PublicIpAddress> publicIpAddresses = api.getPublicIpsAssociatedWithVDC(vdc.getHref());
            PublicIpAddress publicIp = publicIpAddresses.iterator().next();
            InternetService service = api.addInternetServiceToExistingIp(publicIp.getId(), PREFIX
                  + "-no-monitoring", Protocol.TCP, 1234, AddInternetServiceOptions.Builder.monitorDisabled());
            api.deleteInternetService(service.getId());
         }
      }
   }
View Full Code Here

   }

   public void test1() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/InternetService.xml");

      InternetService result = factory.create(injector.getInstance(InternetServiceHandler.class))
            .parse(is);
      assertEquals(result, new InternetService("IS_for_Jim", null, new PublicIpAddress("10.1.22.159", null), 80,
            Protocol.HTTP, false, 1, "Some test service"));
   }
View Full Code Here

   }

   public void test2() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/InternetService2.xml");

      InternetService result = factory.create(injector.getInstance(InternetServiceHandler.class))
            .parse(is);
      assertEquals(result, new InternetService("IS_for_Jim2", URI
            .create("https://services.vcloudexpress.terremark.com/api/v0.8/InternetServices/524"), new PublicIpAddress(
            "10.1.22.159", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/4208")), 45,
            Protocol.HTTP, false, 1, "Some test service"));
   }
View Full Code Here

TOP

Related Classes of org.jclouds.trmk.vcloud_0_8.domain.InternetService

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.