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

Examples of org.jclouds.openstack.nova.v2_0.domain.Flavor$Builder


   public void testGetFlavorById() throws Exception {
      for (String zoneId : zones) {
         FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
         Set<? extends Flavor> response = flavorApi.listInDetail().concat().toSet();
         for (Flavor flavor : response) {
            Flavor details = flavorApi.get(flavor.getId());
            assertNotNull(details);
            assertEquals(details.getId(), flavor.getId());
            assertEquals(details.getName(), flavor.getName());
            assertEquals(details.getLinks(), flavor.getLinks());
            assertEquals(details.getRam(), flavor.getRam());
            assertEquals(details.getDisk(), flavor.getDisk());
            assertEquals(details.getVcpus(), flavor.getVcpus());
         }
      }
   }
View Full Code Here


      FlavorInZone flavorInZoneToConvert = new FlavorInZone(Flavor.builder().id(id.toString())
               .name("Test Flavor " + id).ram(262144).disk(10000).vcpus(16).build(), "az-1.region-a.geo-1");

      Hardware converted = new FlavorInZoneToHardware(locationIndex).apply(flavorInZoneToConvert);

      Flavor flavorToConvert = flavorInZoneToConvert.getFlavor();
      assertEquals(converted.getName(), flavorToConvert.getName());
      assertEquals(converted.getId(), flavorInZoneToConvert.slashEncode());
      assertEquals(converted.getProviderId(), flavorToConvert.getId());
      assertEquals(converted.getLocation(), locationIndex.get().get("az-1.region-a.geo-1"));

      assertEquals(converted.getRam(), flavorToConvert.getRam());

      assertNotNull(converted.getProcessors());
      assertFalse(converted.getProcessors().isEmpty());
      assertEquals(converted.getProcessors().iterator().next().getCores(), (double) flavorToConvert.getVcpus());

      assertNotNull(converted.getVolumes());
      assertFalse(converted.getVolumes().isEmpty());
      assertEquals(converted.getVolumes().iterator().next().getSize(), Float.valueOf(flavorToConvert.getDisk()));

   }
View Full Code Here

   @Override
   public Hardware apply(FlavorInZone flavorInZone) {
      Location location = locationIndex.get().get(flavorInZone.getZone());
      checkState(location != null, "location %s not in locationIndex: %s", flavorInZone.getZone(), locationIndex.get());
      Flavor flavor = flavorInZone.getFlavor();
      return new HardwareBuilder().id(flavorInZone.slashEncode()).providerId(flavor.getId()).name(flavor.getName())
               .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume(
                        new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build();
   }
View Full Code Here

   @Override
   public Hardware apply(FlavorInRegion flavorInRegion) {
      Location location = locationIndex.get().get(flavorInRegion.getRegion());
      checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get());
      Flavor flavor = flavorInRegion.getFlavor();
      return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName())
               .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume(
                        new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build();
   }
View Full Code Here

      FlavorInRegion flavorInRegionToConvert = new FlavorInRegion(Flavor.builder().id(id.toString())
               .name("Test Flavor " + id).ram(262144).disk(10000).vcpus(16).build(), "az-1.region-a.geo-1");

      Hardware converted = new FlavorInRegionToHardware(locationIndex).apply(flavorInRegionToConvert);

      Flavor flavorToConvert = flavorInRegionToConvert.getFlavor();
      assertEquals(converted.getName(), flavorToConvert.getName());
      assertEquals(converted.getId(), flavorInRegionToConvert.slashEncode());
      assertEquals(converted.getProviderId(), flavorToConvert.getId());
      assertEquals(converted.getLocation(), locationIndex.get().get("az-1.region-a.geo-1"));

      assertEquals(converted.getRam(), flavorToConvert.getRam());

      assertNotNull(converted.getProcessors());
      assertFalse(converted.getProcessors().isEmpty());
      assertEquals(converted.getProcessors().iterator().next().getCores(), (double) flavorToConvert.getVcpus());

      assertNotNull(converted.getVolumes());
      assertFalse(converted.getVolumes().isEmpty());
      assertEquals(converted.getVolumes().iterator().next().getSize(), Float.valueOf(flavorToConvert.getDisk()));

   }
View Full Code Here

   public void testGetFlavorById() throws Exception {
      for (String regionId : regions) {
         FlavorApi flavorApi = api.getFlavorApi(regionId);
         Set<? extends Flavor> response = flavorApi.listInDetail().concat().toSet();
         for (Flavor flavor : response) {
            Flavor details = flavorApi.get(flavor.getId());
            assertNotNull(details);
            assertEquals(details.getId(), flavor.getId());
            assertEquals(details.getName(), flavor.getName());
            assertEquals(details.getLinks(), flavor.getLinks());
            assertEquals(details.getRam(), flavor.getRam());
            assertEquals(details.getDisk(), flavor.getDisk());
            assertEquals(details.getVcpus(), flavor.getVcpus());
         }
      }
   }
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

            .<String, Location> of("az-1.region-a.geo-1", zone));
  
   @Test
   public void testConversionWhereLocationFound() {
      UUID id = UUID.randomUUID();
      Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).status(Image.Status.DELETED).build();
      OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86",
               "My Test OS", true);
      ImageInZoneToImage converter = new ImageInZoneToImage(NovaComputeServiceContextModule.toPortableImageStatus,
               constant(operatingSystem), locationIndex);

      ImageInZone novaImageInZoneToConvert = new ImageInZone(novaImageToConvert, "az-1.region-a.geo-1");

      org.jclouds.compute.domain.Image convertedImage = converter.apply(novaImageInZoneToConvert);

      assertEquals(convertedImage.getId(), novaImageInZoneToConvert.slashEncode());
      assertEquals(convertedImage.getProviderId(), novaImageToConvert.getId());
      assertEquals(convertedImage.getLocation(), locationIndex.get().get("az-1.region-a.geo-1"));

      assertEquals(convertedImage.getName(), novaImageToConvert.getName());
      assertEquals(convertedImage.getStatus(), org.jclouds.compute.domain.Image.Status.DELETED);
      assertEquals(convertedImage.getOperatingSystem(), operatingSystem);
   }
View Full Code Here

   }

   @Test(expectedExceptions = IllegalStateException.class)
   public void testConversionWhereLocationNotFound() {
      UUID id = UUID.randomUUID();
      Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).build();
      OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86",
               "My Test OS", true);
      ImageInZoneToImage converter = new ImageInZoneToImage(NovaComputeServiceContextModule.toPortableImageStatus,
               constant(operatingSystem), locationIndex);
View Full Code Here

   }

   public void createGetAndDeleteSecurityGroup() throws Exception {
      for (String zoneId : api.getConfiguredZones()) {
         SecurityGroupApi securityGroupApi = api.getSecurityGroupExtensionForZone(zoneId).get();
         SecurityGroup securityGroup = null;
         String id;
         try {
            securityGroup = securityGroupApi
                     .createWithDescription(SECURITY_GROUP_NAME, "test security group");
            assertNotNull(securityGroup);
            id = securityGroup.getId();
            SecurityGroup theGroup = securityGroupApi.get(id);
            assertNotNull(theGroup);
         } finally {
            if (securityGroup != null) {
               securityGroupApi.delete(securityGroup.getId());
            }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.domain.Flavor$Builder

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.