Package org.jclouds.trmk.vcloud_0_8.domain

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


public class PublicIpAddressHandlerTest extends BaseHandlerTest {

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

      PublicIpAddress result = factory.create(injector.getInstance(PublicIpAddressHandler.class)).parse(is);
      assertEquals(result, new PublicIpAddress("204.51.112.91", URI
            .create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/8720")));
   }
View Full Code Here


            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");
         Set<PublicIpAddress> publicIps = client.getPublicIpsAssociatedWithVDC(vApp.getVDC().getHref());
         for (PublicIpAddress existingIp : publicIps) {
            Set<InternetService> services = client.getInternetServicesOnPublicIp(existingIp.getId());
            if (services.size() == 0) {
               ip = existingIp;
               break;
            }
         }
         if (ip == null)
            throw new InsufficientResourcesException(
                     "no more ip addresses available and existing ips all have services attached: " + publicIps, e
                              .getCause());
      }
      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())));
      Map<InternetService, PublicIpAddress> result = ImmutableMap.<InternetService, PublicIpAddress> of(is, ip);
      Entry<InternetService, PublicIpAddress> entry = Iterables.getOnlyElement(result.entrySet());
      return entry;
View Full Code Here

   public void endElement(String uri, String name, String qName) {
      depth--;
      if (equalsOrSuffix(qName, "PublicIpAddress")) {
         inPublicIpAddress = false;
         publicIpAddress = new PublicIpAddress(address, addressLocation);
         address = null;
         addressLocation = null;
      } else {
         String value = currentOrNull(currentText);
         if (value != null && !value.equals("")) {
View Full Code Here

      return startAndReturnCredentials(VDC, templateId, name, options, portsToOpen).getNode();
   }

   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

      return returnVal.equals("") ? null : returnVal;
   }

   @Override
   public PublicIpAddress getResult() {
      return new PublicIpAddress(address, location);
   }
View Full Code Here

   @Test
   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

      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 test1() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/PublicIpAddresses.xml");

      Set<PublicIpAddress> result = factory.create(injector.getInstance(PublicIpAddressesHandler.class)).parse(is);
      assertEquals(result, ImmutableSet.of(new PublicIpAddress("204.51.112.91", URI
            .create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/8720")), new PublicIpAddress(
            "204.51.114.79", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/14965"))));

   }
View Full Code Here

TOP

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

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.