Package org.jclouds.domain

Examples of org.jclouds.domain.LocationBuilder


      this.justProvider = checkNotNull(justProvider, "justProvider cannot be null");
   }

   @Override
   public Location apply(Region input) {
      LocationBuilder builder = new LocationBuilder();
      builder.id(input.getSlug());
      builder.description(input.getId() + "/" + input.getName());
      builder.scope(LocationScope.REGION);
      builder.parent(getOnlyElement(justProvider.get()));
      builder.iso3166Codes(ImmutableSet.<String> of());
      return builder.build();
   }
View Full Code Here


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

   @Override
   public Location apply(final VirtualDatacenter vdc) {
      LocationBuilder builder = new LocationBuilder();
      builder.id(vdc.getId().toString());
      builder.description(vdc.getName());
      builder.metadata(ImmutableMap.<String, Object> of());
      builder.scope(LocationScope.ZONE);
      builder.iso3166Codes(ImmutableSet.<String> of());

      Datacenter parent = regionMap.get().get(vdc.unwrap().getIdFromLink(ParentLinkName.DATACENTER));
      builder.parent(datacenterToLocation.apply(parent));

      return builder.build();
   }
View Full Code Here

@Singleton
public class DatacenterToLocation implements Function<Datacenter, Location> {

   @Override
   public Location apply(final Datacenter datacenter) {
      LocationBuilder builder = new LocationBuilder();
      builder.id(datacenter.getId().toString());
      builder.description(datacenter.getName() + " [" + datacenter.getLocation() + "]");
      builder.metadata(ImmutableMap.<String, Object> of());
      builder.scope(LocationScope.REGION);
      builder.iso3166Codes(ImmutableSet.<String> of());

      builder.parent(new LocationBuilder().scope(LocationScope.PROVIDER).id("abiquo").description("abiquo").build());

      return builder.build();
   }
View Full Code Here

*/
public class RegionToLocation implements Function<Region, Location> {

   @Override
   public Location apply(Region input) {
      return new LocationBuilder()
              .description(input.getDescription().orNull())
              .metadata(ImmutableMap.of("selfLink", (Object) checkNotNull(input.getSelfLink(), "region URI")))
              .id(input.getName())
              .scope(LocationScope.REGION)
              .parent(GOOGLE_PROVIDER_LOCATION)
View Full Code Here

*/
public class ZoneToLocation implements Function<Zone, Location> {

   @Override
   public Location apply(Zone input) {
      return new LocationBuilder()
              .description(input.getDescription().orNull())
              .metadata(ImmutableMap.of("selfLink", (Object) checkNotNull(input.getSelfLink(), "zone URI")))
              .id(input.getName())
              .scope(LocationScope.ZONE)
              .parent(GOOGLE_PROVIDER_LOCATION)
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").state(NodeState.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").state(NodeState.RUNNING)
        .publicAddresses(Lists.newArrayList("127.0.0.2"))
        .privateAddresses(Lists.newArrayList("127.0.0.2")).build();
View Full Code Here

      this.roles = roles;
    }
   
    @Override
    public Set<NodeMetadata> call() throws Exception {
      Location location = new LocationBuilder().scope(LocationScope.ZONE)
            .id("loc").description("test location").build();
      Set<String> addresses = Sets.newHashSet();
      addresses.add("10.0.0.1");
      LoginCredentials loginCredentials = LoginCredentials.builder().user("id").privateKey("cred").build();
View Full Code Here

      this.roles = roles;
    }
   
    @Override
    public Set<NodeMetadata> call() throws Exception {
      Location location = new LocationBuilder().scope(LocationScope.ZONE)
            .id("loc").description("test location").build();
      Set<String> addresses = Sets.newHashSet();
      addresses.add("10.0.0.1");
      LoginCredentials loginCredentials = LoginCredentials.builder().user("id").privateKey("cred").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

      Location provider = Iterables.getOnlyElement(super.get());
      if (orgNameToResource.get().size() == 0)
         return locations.add(provider);
      Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get();
      for (ReferenceType org : orgNameToResource.get().values()) {
         LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(org.getHref().toASCIIString())
                  .description(org.getName()).parent(provider);
         if (isoCodesById.containsKey(org.getHref().toASCIIString()))
            builder.iso3166Codes(isoCodesById.get(org.getHref().toASCIIString()).get());
         Location orgL = builder.build();
         for (ReferenceType vdc : orgNameToVDCResource.get().get(org.getName()).getVDCs().values()) {
            builder = new LocationBuilder().scope(LocationScope.ZONE).id(vdc.getHref().toASCIIString()).description(
                     vdc.getName()).parent(orgL);
            if (isoCodesById.containsKey(vdc.getHref().toASCIIString()))
               builder.iso3166Codes(isoCodesById.get(vdc.getHref().toASCIIString()).get());
            locations.add(builder.build());
         }
      }
      return locations;
   }
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.