private static int getBootableDeviceType(Hardware hardware) { List<? extends Volume> volumes = hardware.getVolumes(); Optional<? extends Volume> optionalBootableVolume = tryFind(volumes, new Predicate<Volume>() { @Override public boolean apply(Volume volume) { return volume.getDevice().equals(BOOTABLE_DEVICE); } }); if (!optionalBootableVolume.isPresent()) { return Type.LOCAL.ordinal(); } return optionalBootableVolume.get().getType().ordinal(); }
private static int getBootableDeviceType(Hardware hardware) { List<? extends Volume> volumes = hardware.getVolumes(); Optional<? extends Volume> optionalBootableVolume = tryFind(volumes, new Predicate<Volume>() { @Override public boolean apply(Volume volume) { return volume.getDevice().equals(BOOTABLE_DEVICE); } }); if (!optionalBootableVolume.isPresent()) { return Type.LOCAL.ordinal(); } return optionalBootableVolume.get().getType().ordinal(); }
private static int getBootableDeviceType(Hardware hardware) { List<? extends Volume> volumes = hardware.getVolumes(); Optional<? extends Volume> optionalBootableVolume = tryFind(volumes, new Predicate<Volume>() { @Override public boolean apply(Volume volume) { return volume.getDevice().equals(BOOTABLE_DEVICE); } }); if (!optionalBootableVolume.isPresent()) { return Type.LOCAL.ordinal(); } return optionalBootableVolume.get().getType().ordinal(); }
private int getBootableDeviceType(Hardware hardware) { List<? extends Volume> volumes = hardware.getVolumes(); Optional<? extends Volume> optionalBootableVolume = tryFind(volumes, new Predicate<Volume>() { @Override public boolean apply(Volume volume) { return volume.getDevice().equals(BOOTABLE_DEVICE); } }); if(!optionalBootableVolume.isPresent()) { return Type.LOCAL.ordinal(); } return optionalBootableVolume.get().getType().ordinal(); }
private void mapDevices(EC2TemplateOptions ec2TemplateOptions, Template template, String user) { String mkfsOptions = simulatorProperties.get("INSTANCE_STORAGE_MKFS_OPTIONS", DEFAULT_MKFS_OPTIONS); String mountOptions = simulatorProperties.get("INSTANCE_STORAGE_MOUNT_OPTIONS", DEFAULT_MOUNT_OPTIONS); int ephemeralCounter = 0; for (Volume volume : template.getHardware().getVolumes()) { if (!volume.isBootDevice() && LOCAL.equals(volume.getType())) { String device = volume.getDevice(); LOGGER.info(format("Mapping device %s (%d GB)", device, round(volume.getSize()))); ec2TemplateOptions.mapEphemeralDeviceToDeviceName(device, "ephemeral" + ephemeralCounter++); mountDevice(device, mkfsOptions, mountOptions, user); } } }
public static Volume fromVolume(Volume in) { return new VolumeImpl(in.getId(), in.getType(), in.getSize(), in.getDevice(), in.isBootDevice(), in.isDurable()); } }
public static Volume fromVolume(Volume in) { return new VolumeImpl(in.getId(), in.getType(), in.getSize(), in.getDevice(), in.isBootDevice(), in.isDurable()); } }
public static Volume fromVolume(Volume in) { return new VolumeImpl(in.getId(), in.getType(), in.getSize(), in.getDevice(), in.isBootDevice(), in.isDurable()); } }
public static Volume fromVolume(Volume in) { return new VolumeImpl(in.getId(), in.getType(), in.getSize(), in.getDevice(), in.isBootDevice(), in.isDurable()); } }
@Test public void testFastestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().fastest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 1); assertEquals(getSpace(template.getHardware()), 25.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testBiggestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 16); assertEquals(getSpace(template.getHardware()), 100.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = view.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "12.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); assertEquals(defaultTemplate.getHardware().getRam(), 1); assertEquals(getSpace(defaultTemplate.getHardware()), 25.0d); assertEquals(defaultTemplate.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); // test that we bound the correct templateoptions in guice assertEquals(defaultTemplate.getOptions().getClass(), SoftLayerTemplateOptions.class); }
@Test public void testFastestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().fastest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 1 * 1024); assertEquals(getSpace(template.getHardware()), 25.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testBiggestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), MAX_RAM); assertEquals(getSpace(template.getHardware()), 100.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Override public Volume apply(@Nullable org.jclouds.compute.domain.Volume input) { if (input == null) { return null; } return Volume.builder().id(input.getId()).size(input.getSize()).type(input.getType().name()).device(input.getDevice()) .durable(input.isDurable()).bootDevice(input.isBootDevice()).build(); } }
@Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = view.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "14.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); assertEquals(defaultTemplate.getHardware().getRam(), 1 * 1024); assertEquals(getSpace(defaultTemplate.getHardware()), 25.0d); assertEquals(defaultTemplate.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); // test that we bound the correct templateoptions in guice assertEquals(defaultTemplate.getOptions().getClass(), SoftLayerTemplateOptions.class); }
@Test public void testDefaultTemplateBuilderWhenPrivateNetwork() throws IOException { ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?"); context = createView(overrides, setupModules()); Template template = context.getComputeService().templateBuilder().build(); assertEquals(getCores(template.getHardware()), 1.0d); assertEquals(template.getHardware().getRam(), 1); assertEquals(getSpace(template.getHardware()), 25.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); } finally { if (context != null) context.close(); } }
@Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = view.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getId(), "Ubuntu 12.04 x64"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "12.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); assertEquals(defaultTemplate.getHardware().getRam(), 768); assertEquals(defaultTemplate.getHardware().getHypervisor(), "Xen"); assertEquals(getSpace(defaultTemplate.getHardware()), 5.0d); assertEquals(defaultTemplate.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); // test that we bound the correct templateoptions in guice assertEquals(defaultTemplate.getOptions().getClass(), GleSYSTemplateOptions.class); }
@Test public void testBiggestTemplateBuilderWhenPrivateNetwork() throws IOException { ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?"); context = createView(overrides, setupModules()); Template template = context.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 8.0d); assertEquals(template.getHardware().getRam(), 16); assertEquals(getSpace(template.getHardware()), 100.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); } finally { if (context != null) context.close(); } }
@Test public void testHardware() { Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem)); assertEquals("123,456,789", hardware.getId()); List<? extends Processor> processors = hardware.getProcessors(); assertEquals(1, processors.size()); assertEquals(2.0, processors.get(0).getCores()); assertEquals(2, hardware.getRam()); List<? extends Volume> volumes = hardware.getVolumes(); assertEquals(1, volumes.size()); Volume volume = volumes.get(0); assertEquals(100F, volume.getSize()); assertEquals(Volume.Type.SAN, volume.getType()); assertEquals(true, volume.isBootDevice()); }