Package org.jclouds.domain

Examples of org.jclouds.domain.Location


      // notice if we've already parsed this properly here, we can rely on it.
      VirtualGuest guest = new ParseVirtualGuestRunningTest().expected();

      // setup so that we have an expected Location to be parsed from the guest.
      Location expectedLocation = DatacenterToLocationTest.function.apply(guest.getDatacenter());
      Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
            .<Location> of(expectedLocation));

      VirtualGuestToNodeMetadata parser = new VirtualGuestToNodeMetadata(locationSupplier,
            new GetHardwareForVirtualGuestMock(), new GetImageForVirtualGuestMock(), namingConvention);
View Full Code Here


      return buildJustProviderOrVDCs().build();
   }

   protected Builder<Location> buildJustProviderOrVDCs() {
      Builder<Location> locations = ImmutableSet.builder();
      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());
View Full Code Here

      NodeMetadataBuilder builder = new NodeMetadataBuilder();
      builder.ids(from.getHref().toASCIIString());
      builder.uri(from.getHref());
      builder.name(from.getName());
      builder.hostname(from.getName());
      Location vdcLocation = findLocationForResourceInVDC.apply(from.getVDC());
      builder.location(vdcLocation);
      if (from.getOsType() != null && OSType.fromValue(from.getOsType()) != OSType.UNRECOGNIZED) {
         builder.operatingSystem(new CIMOperatingSystem(OSType.fromValue(from.getOsType()), "", null, from
                  .getOperatingSystemDescription()));
      } else if (from.getOperatingSystemDescription() != null) {
View Full Code Here

   
    @Override
    public Set<NodeMetadata> call() throws Exception {
      Map<String, String> userMetadata = Maps.newHashMap();
      Map<String, Object> locationMetadata = Maps.newHashMap();
      Location location = new LocationImpl(LocationScope.ZONE, "loc", "test location",
        null, new ArrayList<String>(), locationMetadata);
      Set<String> addresses = Sets.newHashSet();
      addresses.add("10.0.0.1");
      Credentials loginCredentials = new Credentials("id", "cred");
View Full Code Here

      DigitalOceanProviderMetadata metadata = new DigitalOceanProviderMetadata();
      JustProvider locationsSupplier = new JustProvider(metadata.getId(), Suppliers.<URI> ofInstance(URI
            .create(metadata.getEndpoint())), ImmutableSet.<String> of());

      Region region = new Region(1, "Region 1", "reg1");
      Location expected = new LocationBuilder().id("reg1").description("1/Region 1")
            .parent(getOnlyElement(locationsSupplier.get())).scope(LocationScope.REGION).build();

      RegionToLocation function = new RegionToLocation(locationsSupplier);
      assertEquals(function.apply(region), expected);
   }
View Full Code Here

      Supplier<Map<Integer, Datacenter>> regionMap = mockRegionMap();
      VirtualDatacenterToLocation function = new VirtualDatacenterToLocation(dcToLocation, regionMap);

      VirtualDatacenter vdc = mockVirtualDatacenter();

      Location location = function.apply(vdc);

      verify(regionMap);
      verify(dcToLocation);

      assertEquals(location.getId(), "5");
      assertEquals(location.getScope(), LocationScope.ZONE);
   }
View Full Code Here

      for (VSystem system : api.getVirtualDCApi().listVirtualSystems()) {

         VSystemWithDetails systemWithDetails = api.getVirtualSystemApi().getDetails(system.getId());

         Location systemLocation = new LocationBuilder().scope(LocationScope.SYSTEM)
               .parent(Iterables.getOnlyElement(regionProvider.get())).description(system.getName()).id(system.getId())
               .build();

         for (VNet net : systemWithDetails.getNetworks()) {
View Full Code Here

      return virtualMachineTemplateToHardware;
   }

   private VirtualDatacenterToLocation virtualDatacenterToLocation() {
      VirtualDatacenterToLocation datacenterToLocation = EasyMock.createMock(VirtualDatacenterToLocation.class);
      Location location = EasyMock.createMock(Location.class);

      expect(location.getId()).andReturn("1");
      expect(location.getDescription()).andReturn("Mock Location");

      expect(datacenterToLocation.apply(anyObject(VirtualDatacenter.class))).andReturn(location);

      replay(location);
      replay(datacenterToLocation);
View Full Code Here

      ApiContext<AbiquoApi> context = EasyMock.createMock(ApiContext.class);
      DatacenterToLocation function = new DatacenterToLocation();

      Datacenter datacenter = Datacenter.builder(context).name("dc").location("New York").build();
      datacenter.unwrap().setId(5);
      Location location = function.apply(datacenter);

      assertEquals(location.getId(), "5");
      assertEquals(location.getScope(), LocationScope.REGION);
   }
View Full Code Here

   @Override
   public Location apply(Network from) {
      Matcher matcher = netPattern.matcher(from.getHref().toASCIIString());
      if (matcher.find()) {
         Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id(providerName).description(
                  endpoint.get().toASCIIString()).iso3166Codes(isoCodes).build();

         Org org = api.getBrowsingApi().getOrg(matcher.group(1));

         Location orgLocation = new LocationBuilder().scope(LocationScope.REGION).id(org.getId()).description(
                  org.getDescription()).parent(provider).build();

         VDC vdc = api.getBrowsingApi().getVDCInOrg(org.getId(), matcher.group(2));

         Location vdcLocation = new LocationBuilder().scope(LocationScope.ZONE).id(vdc.getId()).description(
                  vdc.getDescription()).parent(orgLocation).build();

         return new LocationBuilder().scope(LocationScope.NETWORK).id(from.getId()).description(from.getName()).parent(
                  vdcLocation).build();
      } else {
View Full Code Here

TOP

Related Classes of org.jclouds.domain.Location

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.