本文整理了Java中org.jclouds.compute.domain.Hardware
类的一些代码示例,展示了Hardware
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hardware
类的具体详情如下:
包路径:org.jclouds.compute.domain.Hardware
类名称:Hardware
[英]Size of a node.
[中]节点的大小。
代码示例来源:origin: org.jclouds/jclouds-vcloud
@Override
public NodeMetadata addNodeWithTag(String tag, String name, Template template) {
InstantiateVAppTemplateOptions options = processorCount((int) getCores(template.getHardware())).memory(
template.getHardware().getRam()).disk(
(long) ((template.getHardware().getVolumes().get(0).getSize()) * 1024 * 1024l));
if (!template.getOptions().shouldBlockUntilRunning())
options.block(false);
VCloudExpressVApp vApp = computeClient.start(URI.create(template.getLocation().getId()),
URI.create(template.getImage().getId()), name, options, template.getOptions().getInboundPorts());
return vAppToNodeMetadata.apply(vApp);
}
代码示例来源:origin: org.apache.jclouds/jclouds-compute
@Override
public AtomicReference<NodeMetadata> call() throws Exception {
NodeMetadata node = null;
logger.debug(">> adding node location(%s) name(%s) image(%s) hardware(%s)", template.getLocation().getId(),
name, MoreObjects.firstNonNull(template.getImage().getProviderId(), template.getImage().getId()),
MoreObjects.firstNonNull(template.getHardware().getProviderId(), template.getHardware().getId()));
node = addNodeWithGroupStrategy.createNodeWithGroupEncodedIntoName(group, name, template);
logger.debug("<< %s node(%s)", formatStatus(node), node.getId());
return new AtomicReference<NodeMetadata>(node);
}
代码示例来源:origin: jclouds/legacy-jclouds
@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());
}
}
代码示例来源:origin: stackoverflow.com
Map<String, Hardware> hardwareMap = new HashMap<>();
for(Hardware h : myList){
Hardware current = hardwareMap.get(h.getName());
if(current == null){
hardwareMap.put(h.getName(), h);
}else{
current.setQuantity(current.getQuantity() + h.getQuantity());
}
}
Collection<Hardware> list = hardwareMap.values();
代码示例来源:origin: stackoverflow.com
List<Hardware> list = new ArrayList<Hardware>();
list.add(new Hardware("Ram", 2));
list.add(new Hardware("Keyboard", 3));
list.add(new Hardware("Mouse", 5));
list.add(new Hardware("Keyboard", 5));
list.add(new Hardware("Mouse", 1));
for (int i = 0; i < list.size(); i++) {
Hardware current = list.get(i);
for (int j = i + 1; j < list.size(); j++) {
Hardware compare = list.get(j);
if (current.getName().equals(compare.getName())) {
current.setQuantity(current.getQuantity() + compare.getQuantity());
list.remove(compare);
j--;
}
}
}
代码示例来源:origin: jclouds/legacy-jclouds
/**
* {@inheritDoc}
*/
@Override
public TemplateBuilder fromHardware(Hardware hardware) {
if (currentLocationWiderThan(hardware.getLocation()))
this.location = hardware.getLocation();
this.minCores = getCores(hardware);
this.minRam = hardware.getRam();
this.minDisk = getSpace(hardware);
this.hypervisor = hardware.getHypervisor();
return this;
}
代码示例来源:origin: jclouds/legacy-jclouds
@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);
}
代码示例来源:origin: apache/jclouds
@Test
public void testTemplateBuilderCanUseImageIdAndHardwareIdAndAZ() {
Template template = view.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5")
.hardwareId(InstanceType.M2_2XLARGE).locationId("us-east-1b").build();
assert template.getImage().getProviderId().startsWith("ami-") : template;
assertEquals(template.getImage().getOperatingSystem().getVersion(), "5.4");
assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
assertEquals(template.getImage().getVersion(), "4.4.10");
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
assertEquals(template.getLocation().getId(), "us-east-1b");
assertEquals(template.getImage().getLocation().getId(), "us-east-1");
assertEquals(getCores(template.getHardware()), 4.0d);
assertEquals(template.getHardware().getId(), InstanceType.M2_2XLARGE);
assertEquals(template.getImage().getOperatingSystem().getArch(), "paravirtual");
}
代码示例来源:origin: apache/jclouds
@Test
public void testTemplateBuilderM1MEDIUMWithNegativeLookaroundDoesntMatchTestImages() {
Template template = view.getComputeService().templateBuilder().hardwareId(InstanceType.M1_MEDIUM)
// need to select versions with double-digits so that lexicographic
// doesn't end up prefering 9.x vs 11.x
.osVersionMatches("1[012].[10][04]")
// negative lookahead for daily and testing, but ensure match
// ubuntu-images
// http://www.regular-expressions.info/lookaround.html
.imageDescriptionMatches("^(?!.*(daily|testing)).*ubuntu-images.*$").osFamily(OsFamily.UBUNTU).build();
assert template.getImage().getProviderId().startsWith("ami-") : template;
assert template.getImage().getDescription().indexOf("test") == -1 : template;
assert template.getImage().getDescription().indexOf("daily") == -1 : template;
assertEquals(template.getImage().getVersion(), "20100224");
assertEquals(template.getImage().getOperatingSystem().getVersion(), "10.04");
assertEquals(template.getImage().getOperatingSystem().is64Bit(), false);
assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
assertEquals(template.getLocation().getId(), "us-east-1");
assertEquals(getCores(template.getHardware()), 1.0d);
assertEquals(template.getHardware().getId(), InstanceType.M1_MEDIUM);
assertEquals(template.getImage().getOperatingSystem().getArch(), "paravirtual");
}
代码示例来源:origin: apache/jclouds
@Test
public void testFastestTemplateBuilder() throws IOException {
Template fastestTemplate = view.getComputeService().templateBuilder().fastest().osFamily(AMZN_LINUX).build();
assert fastestTemplate.getImage().getProviderId().startsWith("ami-") : fastestTemplate;
assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.C4_8XLARGE);
assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), AMZN_LINUX);
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
assertEquals(fastestTemplate.getLocation().getId(), "us-east-1");
assertEquals(getCores(fastestTemplate.getHardware()), 36.0d);
assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "hvm");
}
代码示例来源:origin: jclouds/legacy-jclouds
@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);
}
代码示例来源:origin: jclouds/legacy-jclouds
@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);
}
代码示例来源:origin: apache/jclouds
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"})
public void testAutoGeneratedHardwareWithMinCoresAndMinRam() {
if (view.getComputeService().listHardwareProfiles().isEmpty()) {
Template template = view.getComputeService().templateBuilder()
.minRam(2048).minCores(2).build();
assertThat(AutomaticHardwareIdSpec.isAutomaticId(template.getHardware().getId())).isTrue();
assertThat(template.getHardware().getRam()).isEqualTo(2048);
assertThat(template.getHardware().getProcessors().get(0).getCores()).isEqualTo(2);
}
else {
throw new SkipException("Hardware profile list not empty.");
}
}
代码示例来源:origin: jclouds/legacy-jclouds
/**
* Verifies that {@link TemplateBuilderImpl} would choose the correct size of the instance, based
* on physical attributes (# of cores, ram, etc).
*
* Expected size: CC1_4XLARGE
*/
@Test
public void testTemplateChoiceForInstanceByAttributes() throws Exception {
Template template = newTemplateBuilder().os64Bit(true).minRam(17510).minCores(6.5).smallest().locationId(
"us-east-1").build();
assert template != null : "The returned template was null, but it should have a value.";
assertEquals(template.getHardware().getId(), "cc1.4xlarge");
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testTemplateChoiceForInstanceByCChardwareId() throws Exception {
Template template = newTemplateBuilder().fastest().build();
assert template != null : "The returned template was null, but it should have a value.";
assert CC1_4XLARGE.equals(template.getHardware()) : format(
"Incorrect image determined by the template. Expected: %s. Found: %s.", CC1_4XLARGE.getId(), template
.getHardware().getId());
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testConversionWhereLocationFound() {
UUID id = UUID.randomUUID();
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()));
}
代码示例来源:origin: apache/jclouds
@Test
public void testTemplateChoiceForInstanceByImageIdDoesNotGetAllImages() throws Exception {
@SuppressWarnings("unchecked")
Supplier<Set<? extends Image>> images = createMock(Supplier.class);
replay(images);
final Image image = new ImageBuilder().providerId("bogus-image-provider").name("image").id("us-east-1/bogus-image").location(location)
.operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "bogus", "ubuntu", true))
.description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build())
.status(Image.Status.AVAILABLE)
.build();
Map<RegionAndName, Image> imageMap = ImmutableMap.of(
new RegionAndName(image.getLocation().getId(), "bogus-image"), image);
// weird compilation error means have to declare extra generics for call to build() - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
Supplier<LoadingCache<RegionAndName, ? extends Image>> imageCache = Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(
CacheBuilder.newBuilder().<RegionAndName, Image>build(CacheLoader.from(Functions.forMap(imageMap))));
Template template = newTemplateBuilder(images, imageCache).imageId("us-east-1/bogus-image").build();
assert template != null : "The returned template was null, but it should have a value.";
assertEquals(template.getImage().getId(), "us-east-1/bogus-image");
assertEquals(template.getHardware().getId(), HARDWARE_SUPPORTING_BOGUS.getId());
}
代码示例来源:origin: apache/jclouds
@Test
public void testTemplateChoiceForInstanceByImageId() throws Exception {
Template template = newTemplateBuilder().imageId("us-east-1/bogus-image").build();
assert template != null : "The returned template was null, but it should have a value.";
assertEquals(template.getImage().getId(), "us-east-1/bogus-image");
assertEquals(template.getHardware().getId(), HARDWARE_SUPPORTING_BOGUS.getId());
}
代码示例来源:origin: jclouds/legacy-jclouds
@Override
public NodeAndInitialCredentials<ServerInfo> createNodeWithGroupEncodedIntoName(String tag, String name, Template template) {
long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l);
logger.debug(">> creating boot drive bytes(%d)", bootSize);
DriveInfo drive = client
.createDrive(new Drive.Builder().name(template.getImage().getId()).size(bootSize).build());
logger.debug("<< drive(%s)", drive.getUuid());
logger.debug(">> imaging boot drive source(%s)", template.getImage().getId());
client.imageDrive(template.getImage().getId(), drive.getUuid(), ImageConversionType.GUNZIP);
boolean success = driveNotClaimed.apply(drive);
logger.debug("<< imaged (%s)", success);
if (!success) {
client.destroyDrive(drive.getUuid());
throw new IllegalStateException("could not image drive in time!");
}
Server toCreate = small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam())
.cpu((int) (template.getHardware().getProcessors().get(0).getSpeed()))
.tags(template.getOptions().getTags()).userMetadata(template.getOptions().getUserMetadata()).build();
ServerInfo from = client.createServer(toCreate);
client.startServer(from.getUuid());
from = client.getServerInfo(from.getUuid());
return new NodeAndInitialCredentials<ServerInfo>(from, from.getUuid(), LoginCredentials.builder()
.password(defaultVncPassword).build());
}
代码示例来源:origin: apache/jclouds
@Override
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"})
public void testAutoGeneratedHardwareFromId() {
Template template = view.getComputeService().templateBuilder()
.hardwareId("automatic:cores=2;ram=1024").build();
assertThat(template.getHardware().getId()).isEqualTo(template.getLocation()
.getDescription() + "/machineTypes/custom-2-1024");
assertThat(template.getHardware().getRam()).isEqualTo(1024);
assertThat(template.getHardware().getProcessors().get(0).getCores()).isEqualTo(2);
assertThat(template.getHardware().getUri()).isEqualTo(URI.create(template.getLocation()
.getDescription() + "/machineTypes/custom-2-1024"));
}
内容来源于网络,如有侵权,请联系作者删除!