Examples of PublicIPAddress


Examples of org.jclouds.cloudstack.domain.PublicIPAddress

      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

Examples of org.jclouds.cloudstack.domain.PublicIPAddress

          if (templateOptions.shouldSetupStaticNat()) {
             Capabilities capabilities = client.getConfigurationApi().listCapabilities();
             // TODO: possibly not all network ids, do we want to do this
             for (String networkId : options.getNetworkIds()) {
                logger.debug(">> creating static NAT for virtualMachine(%s) in network(%s)", vm.getId(), networkId);
                PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm);
                logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
                vm = client.getVirtualMachineApi().getVirtualMachine(vm.getId());
                List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
                if (capabilities.getCloudStackVersion().startsWith("2")) {
                   logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
                   Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
                   logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
                } else {
                   logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
                   Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
                   logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
                }
             }
          }
      } catch (RuntimeException re) {
          logger.error("-- exception after node has been created, trying to destroy the created virtualMachine(%s)", vm.getId());
View Full Code Here

Examples of org.jclouds.cloudstack.domain.PublicIPAddress

      if (templateOptions.shouldSetupStaticNat()) {
         Capabilities capabilities = client.getConfigurationClient().listCapabilities();
         // TODO: possibly not all network ids, do we want to do this
         for (String networkId : options.getNetworkIds()) {
            logger.debug(">> creating static NAT for virtualMachine(%s) in network(%s)", vm.getId(), networkId);
            PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm);
            logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
            vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
            List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
            if (capabilities.getCloudStackVersion().startsWith("2")) {
               logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
               Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
               logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
            } else {
               logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
               Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
               logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
            }
         }
      }
      return new NodeAndInitialCredentials<VirtualMachine>(vm, vm.getId() + "", credentials);
   }
View Full Code Here

Examples of org.jclouds.cloudstack.domain.PublicIPAddress

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

Examples of org.jclouds.cloudstack.domain.PublicIPAddress

   @Override
   public PublicIPAddress apply(Network input) {
      try {
         logger.debug(">> looking for existing address in network(%s)", input.getId());
         PublicIPAddress returnVal = findAvailableAndAssociatedWithNetwork(input.getId(), client.getAddressApi());
         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

Examples of org.jclouds.cloudstack.domain.PublicIPAddress

      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

Examples of org.jclouds.cloudstack.domain.PublicIPAddress

      if (templateOptions.shouldSetupStaticNat()) {
         Capabilities capabilities = client.getConfigurationApi().listCapabilities();
         // TODO: possibly not all network ids, do we want to do this
         for (String networkId : options.getNetworkIds()) {
            logger.debug(">> creating static NAT for virtualMachine(%s) in network(%s)", vm.getId(), networkId);
            PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm);
            logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
            vm = client.getVirtualMachineApi().getVirtualMachine(vm.getId());
            List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
            if (capabilities.getCloudStackVersion().startsWith("2")) {
               logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
               Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
               logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
            } else {
               logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
               Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
               logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
            }
         }
      }
      return new NodeAndInitialCredentials<VirtualMachine>(vm, vm.getId() + "", credentialsBuilder.build());
   }
View Full Code Here

Examples of org.jclouds.cloudstack.domain.PublicIPAddress

*/
@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

Examples of org.jclouds.cloudstack.domain.PublicIPAddress

      assert available().apply(address);

   }

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

      assert !available().apply(address);

   }
View Full Code Here

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
TOP
Copyright © 2018 www.massapi.com. 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.