Package org.jclouds.domain

Examples of org.jclouds.domain.LocationBuilder


      Location provider = Iterables.getOnlyElement(justProvider.get());
      Set<String> regions = regionsSupplier.get();
      checkState(regions.size() > 0, "no regions found for provider %s, using supplier %s", provider, regionsSupplier);
      Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get();
      for (String region : regions) {
         LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(region).description(region)
                  .parent(provider);
         if (isoCodesById.containsKey(region))
            builder.iso3166Codes(isoCodesById.get(region).get());
         locations.add(builder.build());
      }
      return locations.build();
   }
View Full Code Here


      if (!Iterables.all(regionsOrJustProvider, LocationPredicates.isProvider()))
         locations.addAll(regionsOrJustProvider);
      for (Map.Entry<String, Location> entry : zoneIdToParent.entrySet()) {
         String zoneId = entry.getKey();
         Location parent = entry.getValue();
         LocationBuilder builder = new LocationBuilder().scope(LocationScope.ZONE).id(zoneId).description(zoneId)
                  .parent(parent);
         if (isoCodesById.containsKey(zoneId))
            builder.iso3166Codes(isoCodesById.get(zoneId).get());
         // be cautious.. only inherit iso codes if the parent is a region
         // regions may be added dynamically, and we prefer to inherit an
         // empty set of codes from a region, then a provider, whose code
         // are likely hard-coded.
         else if (parent.getScope() == LocationScope.REGION)
            builder.iso3166Codes(parent.getIso3166Codes());
         locations.add(builder.build());
      }
      return locations.build();
   }
View Full Code Here

      checkState(zoneIds.size() > 0, "no zones found for provider %s, using supplier %s", provider, zoneIdsSupplier);
      Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get();

      Builder<Location> locations = ImmutableSet.builder();
      for (String zoneId : zoneIds) {
         LocationBuilder builder = new LocationBuilder().scope(LocationScope.ZONE).id(zoneId).description(zoneId)
                  .parent(provider);
         if (isoCodesById.containsKey(zoneId))
            builder.iso3166Codes(isoCodesById.get(zoneId).get());
         locations.add(builder.build());
      }
      return locations.build();
   }
View Full Code Here

      Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get();
      if (regions.size() == 0)
         return locations.add(provider).build();
      else
         for (String region : regions) {
            LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(region).description(region)
                     .parent(provider);
            if (isoCodesById.containsKey(region))
               builder.iso3166Codes(isoCodesById.get(region).get());
            locations.add(builder.build());
         }
      return locations.build();
   }
View Full Code Here

      this.isoCodesSupplier = checkNotNull(isoCodesSupplier, "isoCodes");
   }

   @Override
   public Set<? extends Location> get() {
      return ImmutableSet.of(new LocationBuilder().scope(LocationScope.PROVIDER).id(providerName)
            .description(endpointSupplier.get().toASCIIString()).iso3166Codes(isoCodesSupplier).build());
   }
View Full Code Here

    ClusterControllerFactory factory = mock(ClusterControllerFactory.class);
    ClusterController controller = mock(ClusterController.class);
    when(factory.create((String) any())).thenReturn(controller);

    NodeMetadata node1 = new NodeMetadataBuilder().name("name1").ids("id1")
        .location(new LocationBuilder().scope(LocationScope.PROVIDER)
          .id("location-id1").description("location-desc1").build())
        .imageId("image-id").status(NodeMetadata.Status.RUNNING)
        .publicAddresses(Lists.newArrayList("127.0.0.1"))
        .privateAddresses(Lists.newArrayList("127.0.0.1")).build();

    NodeMetadata node2 = new NodeMetadataBuilder().name("name2").ids("id2")
        .location(new LocationBuilder().scope(LocationScope.PROVIDER)
          .id("location-id2").description("location-desc2").build())
        .imageId("image-id").status(NodeMetadata.Status.RUNNING)
        .publicAddresses(Lists.newArrayList("127.0.0.2"))
        .privateAddresses(Lists.newArrayList("127.0.0.2")).build();
View Full Code Here

      this.provider = checkNotNull(provider, "provider");
   }

   @Override
   public Location apply(Datacenter from) {
      return new LocationBuilder().scope(LocationScope.ZONE).id(from.id + "").description(from.name).parent(
               provider.get().get()).build();
   }
View Full Code Here

      this.provider = checkNotNull(provider, "provider");
   }
  
    @Override
    public Location apply(Datacenter datacenter) {
        return new LocationBuilder().scope(LocationScope.ZONE)
                                    .metadata(ImmutableMap.<String, Object>of())
                                    .description(datacenter.getLongName())
                                    .id(Long.toString(datacenter.getId()))
                                    .iso3166Codes(createIso3166Codes(datacenter.getLocationAddress()))
                                    .parent(Iterables.getOnlyElement(provider.get()))
View Full Code Here

   @Test
   public void test() throws SecurityException, NoSuchMethodException {
      JustProvider fn = new JustProvider("servo", Suppliers.ofInstance(URI.create("http://servo")), ImmutableSet.of("US"));
      assertEquals(
            fn.get(),
            ImmutableSet.of(new LocationBuilder().scope(LocationScope.PROVIDER).id("servo").description("http://servo")
                  .iso3166Codes(ImmutableSet.of("US")).build()));
   }
View Full Code Here

                        "region2", Suppliers.<Set<String>>ofInstance(ImmutableSet.of("US-VA"))
                        ));
      RegionToProvider fn = new RegionToProvider(justProvider, regionIdsSupplier, locationToIsoCodes);
     
      assertEquals(fn.get(), ImmutableSet.of(
               new LocationBuilder().scope(LocationScope.REGION).id("region1").description("region1").iso3166Codes(ImmutableSet.of("US-CA")).parent(provider).build(),
               new LocationBuilder().scope(LocationScope.REGION).id("region2").description("region2").iso3166Codes(ImmutableSet.of("US-VA")).parent(provider).build()
               ));
   }
View Full Code Here

TOP

Related Classes of org.jclouds.domain.LocationBuilder

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.