Package org.jclouds.cloudstack.domain

Examples of org.jclouds.cloudstack.domain.PublicIPAddress


      assert !available().apply(address);

   }

   public void testIsNotAvailableWhenAssignedToVM() {
      PublicIPAddress address = PublicIPAddress.builder().state(PublicIPAddress.State.ALLOCATED).virtualMachineId("1")
            .id("204").build();

      assert !available().apply(address);

   }
View Full Code Here


      assert !available().apply(address);

   }

   public void testIsNotAvailableWhenSourceNAT() {
      PublicIPAddress address = PublicIPAddress.builder().state(PublicIPAddress.State.ALLOCATED).isSourceNAT(true)
            .id("204").build();

      assert !available().apply(address);

   }
View Full Code Here

      assert !available().apply(address);

   }

   public void testIsNotAvailableWhenStaticNAT() {
      PublicIPAddress address = PublicIPAddress.builder().state(PublicIPAddress.State.ALLOCATED).isStaticNAT(true)
            .id("204").build();

      assert !available().apply(address);

   }
View Full Code Here

   public static PublicIPAddress associateIPAddressInNetwork(Network network, CloudStackClient client,
         BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult) {
      AsyncCreateResponse job = client.getAddressClient().associateIPAddressInZone(network.getZoneId(),
            networkId(network.getId()));
      PublicIPAddress ip = blockUntilJobCompletesAndReturnResult.<PublicIPAddress> apply(job);
      assert ip.getZoneId().equals(network.getZoneId());
      return ip;
   }
View Full Code Here

   @Override
   public PublicIPAddress apply(Network input) {
      try {
         logger.debug(">> looking for existing address in network(%s)", input.getId());
         PublicIPAddress returnVal = findAvailableAndAssociatedWithNetwork(input.getId(), client.getAddressClient());
         logger.debug("<< reused address(%s)", returnVal.getId());
         return returnVal;
      } catch (NoSuchElementException e) {
         logger.debug(">> associating new address in network(%s)", input.getId());
         PublicIPAddress returnVal = associateIPAddressInNetwork(input, client, blockUntilJobCompletesAndReturnResult);
         logger.debug("<< associated address(%s)", returnVal.getId());
         return returnVal;
      }
   }
View Full Code Here

      this.reuseOrAssociate = checkNotNull(reuseOrAssociate, "reuseOrAssociate");
      this.network = checkNotNull(network, "network");
   }

   public PublicIPAddress apply(VirtualMachine vm) {
      PublicIPAddress ip;
      for (ip = reuseOrAssociate.apply(network); !ip.isStaticNAT() || ip.getVirtualMachineId() != vm.getId(); ip = reuseOrAssociate
            .apply(network)) {
         // check to see if someone already grabbed this ip
         if (ip.getVirtualMachineId() != null && ip.getVirtualMachineId() != vm.getId())
            continue;
         try {
            logger.debug(">> static NATing IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
            client.getNATClient().enableStaticNATForVirtualMachine(vm.getId(), ip.getId());
            ip = client.getAddressClient().getPublicIPAddress(ip.getId());
            if (ip.isStaticNAT() && ip.getVirtualMachineId().equals(vm.getId()))
               break;
         } catch (IllegalStateException e) {
            // very likely an ip conflict, so retry;
         }
         return ip;
View Full Code Here

         return;
      Set<PublicIPAddress> response = client.getAddressClient().listPublicIPAddresses();
      assert null != response;
      assertTrue(response.size() >= 0);
      for (PublicIPAddress ip : response) {
         PublicIPAddress newDetails = getOnlyElement(client.getAddressClient().listPublicIPAddresses(
               ListPublicIPAddressesOptions.Builder.id(ip.getId())));
         assertEquals(ip.getId(), newDetails.getId());
         checkIP(ip);
      }
   }
View Full Code Here

      this.reuseOrAssociate = checkNotNull(reuseOrAssociate, "reuseOrAssociate");
      this.network = checkNotNull(network, "network");
   }

   public PublicIPAddress apply(VirtualMachine vm) {
      PublicIPAddress ip;
      for (ip = reuseOrAssociate.apply(network); !ip.isStaticNAT() || ip.getVirtualMachineId() != vm.getId(); ip = reuseOrAssociate
            .apply(network)) {
         // check to see if someone already grabbed this ip
         if (ip.getVirtualMachineId() != null && ip.getVirtualMachineId() != vm.getId())
            continue;
         try {
            logger.debug(">> static NATing IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
            client.getNATApi().enableStaticNATForVirtualMachine(vm.getId(), ip.getId());
            ip = client.getAddressApi().getPublicIPAddress(ip.getId());
            if (ip.isStaticNAT() && ip.getVirtualMachineId().equals(vm.getId()))
               break;
         } catch (IllegalStateException e) {
            // very likely an ip conflict, so retry;
         }
         return ip;
View Full Code Here

         return;
      Set<PublicIPAddress> response = client.getAddressApi().listPublicIPAddresses();
      assert null != response;
      assertTrue(response.size() >= 0);
      for (PublicIPAddress ip : response) {
         PublicIPAddress newDetails = getOnlyElement(client.getAddressApi().listPublicIPAddresses(
               ListPublicIPAddressesOptions.Builder.id(ip.getId())));
         assertEquals(ip.getId(), newDetails.getId());
         checkIP(ip);
      }
   }
View Full Code Here

@Test(groups = "unit")
public class PublicIPAddressPredicatesTest {

   public void testIsAvailableWhenAllocated() {
      PublicIPAddress address = PublicIPAddress.builder().state(PublicIPAddress.State.ALLOCATED).id("204").build();

      assert available().apply(address);

   }
View Full Code Here

TOP

Related Classes of org.jclouds.cloudstack.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.