Package org.jclouds.openstack.nova.v2_0.domain

Examples of org.jclouds.openstack.nova.v2_0.domain.FloatingIP$ConcreteBuilder


   public static class Builder extends BaseProviderMetadata.Builder {

      protected Builder(){
         id("rackspace-cloudservers-uk")
         .name("Rackspace Next Generation Cloud Servers UK")
         .apiMetadata(new NovaApiMetadata().toBuilder()
                  .identityName("${userName}")
                  .credentialName("${apiKey}")
                  .version("2")
                  .defaultEndpoint("https://lon.identity.api.rackspacecloud.com/v2.0/")
                  .endpointName("identity service url ending in /v2.0/")
View Full Code Here


     
      builder.put(getSecurityGroup, getSecurityGroupResponse);

      NovaApi apiCanCreateSecurityGroup = requestsSendResponses(builder.build());

      CreateSecurityGroupIfNeeded fn = new CreateSecurityGroupIfNeeded(apiCanCreateSecurityGroup);

      // we can find it
      assertEquals(fn.apply(
               new ZoneSecurityGroupNameAndPorts("az-1.region-a.geo-1", "jclouds_mygroup", ImmutableSet.of(22, 8080)))
               .toString(), new SecurityGroupInZone(new ParseComputeServiceTypicalSecurityGroupTest().expected(),
               "az-1.region-a.geo-1").toString());

   }
View Full Code Here

      builder.put(list, listResponse);

      NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(builder.build());

      CreateSecurityGroupIfNeeded fn = new CreateSecurityGroupIfNeeded(apiWhenSecurityGroupsExist);

      // we can find it
      assertEquals(fn.apply(
               new ZoneSecurityGroupNameAndPorts("az-1.region-a.geo-1", "jclouds_mygroup", ImmutableSet.of(22, 8080)))
               .toString(), new SecurityGroupInZone(new ParseComputeServiceTypicalSecurityGroupTest().expected(),
               "az-1.region-a.geo-1").toString());

   }
View Full Code Here

      return SecurityGroup.builder().description("jclouds_mygroup").id("2769").tenantId("37936628937291").rules(securityGroupRules)
            .name("jclouds_mygroup").build();
   }
   protected Injector injector() {
      return Guice.createInjector(new NovaParserModule(), new GsonModule());
   }
View Full Code Here

   @Test
   public void testReturnsPublicIpOnMatch() throws Exception {
      NovaApi api = createMock(NovaApi.class);
      FloatingIPApi ipApi = createMock(FloatingIPApi.class);
      FloatingIP testIp = FloatingIP.builder().id("1").ip("1.1.1.1").fixedIp("10.1.1.1").instanceId("i-blah").build();

      expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
      expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(testIp)))
               .atLeastOnce();
View Full Code Here

      ip = Iterables.getLast(unassignedIps).getIp();
    }

    // if no unassigned IP is available, we'll try to allocate an IP.
    if (ip == null || ip.isEmpty()) {
      FloatingIP allocatedFloatingIP = floatingIp.create();
      if (allocatedFloatingIP == null) {
        String msg = "Failed to allocate an IP address.";
        log.error(msg);
        throw new CloudControllerException(msg);
      }
      ip = allocatedFloatingIP.getIp();
    }

    // wait till the fixed IP address gets assigned - this is needed before
    // we associate a public IP
View Full Code Here

      ip = Iterables.getLast(unassignedIps).getIp();
    }

    // if no unassigned IP is available, we'll try to allocate an IP.
    if (ip == null || ip.isEmpty()) {
      FloatingIP allocatedFloatingIP = floatingIp.create();
      if (allocatedFloatingIP == null) {
        String msg = "Failed to allocate an IP address.";
        log.error(msg);
        throw new CloudControllerException(msg);
      }
      ip = allocatedFloatingIP.getIp();
    }

    // wait till the fixed IP address gets assigned - this is needed before
    // we associate a public IP
    while (node.getPrivateAddresses() == null) {
View Full Code Here

    }
    if (freeFloatingIps.isEmpty()) {
      throw new FloatingIpAddressException(
          "no floating IP address(es) available");
    }
    FloatingIP ipToAllocate = Iterables.getLast(freeFloatingIps);
    String ip = ipToAllocate.getIp();
    LOG.debug("assigning floating ip {} to server {}", ip, server.getId());
    floatingIPApi.addToServer(ip, server.getId());
    return ip;
  }
View Full Code Here

   @Test
   public void testReturnsPublicIpOnMatch() throws Exception {
      NovaApi api = createMock(NovaApi.class);
      FloatingIPApi ipApi = createMock(FloatingIPApi.class);
      FloatingIP testIp = FloatingIP.builder().id("1").ip("1.1.1.1").fixedIp("10.1.1.1").instanceId("i-blah").build();

      expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
      expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(testIp)))
               .atLeastOnce();
View Full Code Here

      NodeMetadata node = input.get();
      // node's location is a host
      String zoneId = node.getLocation().getParent().getId();
      FloatingIPApi floatingIpApi = novaApi.getFloatingIPExtensionForZone(zoneId).get();

      FloatingIP ip = null;
      try {
         logger.debug(">> allocating or reassigning floating ip for node(%s)", node.getId());
         ip = floatingIpApi.create();
      } catch (InsufficientResourcesException e) {
         logger.trace("<< [%s] allocating a new floating ip for node(%s)", e.getMessage(), node.getId());
         logger.trace(">> searching for existing, unassigned floating ip for node(%s)", node.getId());
         ArrayList<FloatingIP> unassignedIps = Lists.newArrayList(Iterables.filter(floatingIpApi.list(),
                  new Predicate<FloatingIP>() {

                     @Override
                     public boolean apply(FloatingIP arg0) {
                        return arg0.getFixedIp() == null;
                     }

                  }));
         // try to prevent multiple parallel launches from choosing the same ip.
         Collections.shuffle(unassignedIps);
         ip = Iterables.getLast(unassignedIps);
      }
      logger.debug(">> adding floatingIp(%s) to node(%s)", ip.getIp(), node.getId());

      floatingIpApi.addToServer(ip.getIp(), node.getProviderId());
      input.set(NodeMetadataBuilder.fromNodeMetadata(node).publicAddresses(ImmutableSet.of(ip.getIp())).build());
      floatingIpCache.invalidate(ZoneAndId.fromSlashEncoded(node.getId()));
      return input;
   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.domain.FloatingIP$ConcreteBuilder

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.