@Override public EC2HardwareBuilder providerId(String providerId) { return EC2HardwareBuilder.class.cast(super.providerId(providerId)); }
@Override public EC2HardwareBuilder providerId(String providerId) { return EC2HardwareBuilder.class.cast(super.providerId(providerId)); }
@Override public EC2HardwareBuilder providerId(String providerId) { return EC2HardwareBuilder.class.cast(super.providerId(providerId)); }
@Override public EC2HardwareBuilder providerId(String providerId) { return EC2HardwareBuilder.class.cast(super.providerId(providerId)); }
@Override public EC2HardwareBuilder providerId(String providerId) { return EC2HardwareBuilder.class.cast(super.providerId(providerId)); }
@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(); } }
@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(); } }
@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(); } }
@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(); } }
@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(); } }
@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(); } }
@SuppressWarnings("unchecked") public static HardwareBuilder fromHardware(Hardware in) { return new HardwareBuilder().id(in.getId()).providerId(in.getProviderId()).location(in.getLocation()).name( in.getName()).uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()).processors( List.class.cast(in.getProcessors())).ram(in.getRam()).volumes(List.class.cast(in.getVolumes())) .supportsImage(in.supportsImage()).hypervisor(in.getHypervisor()); } }
@SuppressWarnings("unchecked") public static HardwareBuilder fromHardware(Hardware in) { return new HardwareBuilder().id(in.getId()).providerId(in.getProviderId()).location(in.getLocation()).name( in.getName()).uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()).processors( List.class.cast(in.getProcessors())).ram(in.getRam()).volumes(List.class.cast(in.getVolumes())) .supportsImage(in.supportsImage()).hypervisor(in.getHypervisor()); } }
@SuppressWarnings("unchecked") public static HardwareBuilder fromHardware(Hardware in) { return new HardwareBuilder().id(in.getId()).providerId(in.getProviderId()).location(in.getLocation()).name( in.getName()).uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()).processors( List.class.cast(in.getProcessors())).ram(in.getRam()).volumes(List.class.cast(in.getVolumes())) .supportsImage(in.supportsImage()).hypervisor(in.getHypervisor()); } }
@SuppressWarnings("unchecked") public static HardwareBuilder fromHardware(Hardware in) { return new HardwareBuilder().id(in.getId()).providerId(in.getProviderId()).location(in.getLocation()).name( in.getName()).uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()).processors( List.class.cast(in.getProcessors())).ram(in.getRam()).volumes(List.class.cast(in.getVolumes())) .supportsImage(in.supportsImage()).hypervisor(in.getHypervisor()); } }
@Test public void testConvertSize() { Size size = Size.create("2gb", true, 1.0f, 10f, 0.05f, 2048, 1, 20, ImmutableList.<String> of()); Hardware expected = new HardwareBuilder().id("2gb").providerId("2gb").name("2gb") .processor(new Processor(1.0, 1.0)).ram(2048) .volume(new VolumeBuilder().size(20f).type(Type.LOCAL).build()) .userMetadata(ImmutableMap.of("costPerHour", "0.05", "costPerMonth", "10")).build(); SizeToHardware function = new SizeToHardware(); assertEquals(function.apply(size), expected); } }
@Test public void testWhenNoHardwareOrImageMatchServerScopedIdsImageIdIsStillSet() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/FOOOOOOOO").providerId("FOOOOOOOO") .location(zone).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/FOOOOOOOO") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("FOOOOOOOO").description("foobuntu").location(zone).status(Image.Status.AVAILABLE).build(); checkHardwareAndImageStatus(null, existingHardware, "az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54", null, existingImage); }
@Test public void testWhenNoHardwareOrImageMatchServerScopedIdsImageIdIsStillSet() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/FOOOOOOOO").providerId("FOOOOOOOO") .location(region).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/FOOOOOOOO") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("FOOOOOOOO").description("foobuntu").location(region).status(Image.Status.AVAILABLE).build(); checkHardwareAndImageStatus(null, existingHardware, "az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54", null, existingImage); }
@Test public void testWhenNoHardwareAndImageMatchServerScopedIdsHardwareOperatingSystemAndImageIdAreSet() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd") .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE) .location(zone).build(); checkHardwareAndImageStatus(existingHardware, existingHardware, existingImage.getId(), existingImage.getOperatingSystem(), existingImage); }
@Test public void testWhenNoHardwareAndImageMatchServerScopedIdsHardwareOperatingSystemAndImageIdAreSet() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd") .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE) .location(region).build(); checkHardwareAndImageStatus(existingHardware, existingHardware, existingImage.getId(), existingImage.getOperatingSystem(), existingImage); }