org.jclouds.compute.domain.Hardware.getName()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(14.1k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中org.jclouds.compute.domain.Hardware.getName()方法的一些代码示例,展示了Hardware.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hardware.getName()方法的具体详情如下:
包路径:org.jclouds.compute.domain.Hardware
类名称:Hardware
方法名:getName

Hardware.getName介绍

暂无

代码示例

代码示例来源:origin: org.jclouds.labs/fgcp

@Override
 public boolean apply(Hardware input) {
   return input.getName().equals(type);
 }
}

代码示例来源:origin: io.cloudsoft.jclouds.labs/fgcp

@Override
 public boolean apply(Hardware input) {
   return input.getName().equals(type);
 }
}

代码示例来源:origin: org.apache.jclouds.labs/fgcp

@Override
 public boolean apply(Hardware input) {
   return input.getName().equals(type);
 }
}

代码示例来源: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: io.cloudsoft.jclouds.labs.representations/representations-codec

@Override
  public Hardware apply(@Nullable org.jclouds.compute.domain.Hardware input) {
   if (input == null) {
     return null;
   }
   return Hardware.builder().id(input.getId()).name(input.getName()).hypervisor(input.getHypervisor())
           .ram(input.getRam())
           //Transformation is lazy and doesn't serialize well, so let's wrap the processor list
           .processors(ImmutableList.<Processor>builder().addAll(transform(input.getProcessors(), ToProcessor.INSTANCE)).build())

           //Transformation is lazy and doesn't serialize well, so let's wrap the volume list
           .volumes(ImmutableList.<Volume>builder().addAll(transform(input.getVolumes(), ToVolume.INSTANCE)).build())
           .build();
  }
}

代码示例来源: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: jenkinsci/jclouds-plugin

public ListBoxModel doFillHardwareIdItems(
    @RelativePath("..") @QueryParameter String providerName, @RelativePath("..") @QueryParameter String cloudCredentialsId,
    @RelativePath("..") @QueryParameter String endPointUrl, @RelativePath("..") @QueryParameter String zones) {
  ListBoxModel m = new ListBoxModel();
  if (prepareListBoxModel(providerName, cloudCredentialsId, m)) {
    return m;
  }
  try (ComputeServiceContext ctx = getCtx(providerName, cloudCredentialsId, endPointUrl, zones)) {
    ArrayList<Hardware> hws = newArrayList(ctx.getComputeService().listHardwareProfiles());
    Collections.sort(hws);
    for (Hardware hardware : hws) {
      m.add(String.format("%s (%s)", hardware.getId(), hardware.getName()), hardware.getId());
    }
  } catch (Exception ex) {
    LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
  }
  return m;
}

代码示例来源:origin: apache/jclouds

@Test
public void testConversionWhereLocationFound() {
 UUID id = UUID.randomUUID();
 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()));
}

代码示例来源: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: 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: io.cloudsoft.jclouds/jclouds-compute

@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: org.apache.jclouds/jclouds-compute

@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: apache/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: io.brooklyn/brooklyn-locations-jclouds

@Override
public Map<String, String> toMetadataRecord() {
  Hardware hardware = node.getHardware();
  List<? extends Processor> processors = (hardware != null) ? hardware.getProcessors() : null;
  
  ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
  builder.putAll(super.toMetadataRecord());
  putIfNotNull(builder, "provider", getParent().getProvider());
  putIfNotNull(builder, "account", getParent().getIdentity());
  putIfNotNull(builder, "serverId", node.getProviderId());
  putIfNotNull(builder, "imageId", node.getImageId());
  putIfNotNull(builder, "instanceTypeName", (hardware != null ? hardware.getName() : null));
  putIfNotNull(builder, "instanceTypeId", (hardware != null ? hardware.getProviderId() : null));
  putIfNotNull(builder, "ram", "" + (hardware != null ? hardware.getRam() : null));
  putIfNotNull(builder, "cpus", "" + (processors != null ? processors.size() : null));
  putIfNotNull(builder, "osName", getOsDetails().getName());
  putIfNotNull(builder, "osArch", getOsDetails().getArch());
  putIfNotNull(builder, "64bit", getOsDetails().is64bit() ? "true" : "false");
  return builder.build();
}

代码示例来源:origin: io.cloudsoft.jclouds.labs/fgcp

/**
* {@inheritDoc}
*/
@Override
public NodeAndInitialCredentials<VServerMetadata> createNodeWithGroupEncodedIntoName(
   String group, String name, Template template) {
 String id = api.getVirtualSystemApi().createServer(name,
    template.getHardware().getName(), template.getImage().getId(),
    template.getLocation().getId());
 // wait until fully created (i.e. transitions to stopped status)
 checkState(serverCreated.apply(id), "node %s not reaching STOPPED state after creation", id);
 resumeNode(id);
 // don't wait until fully started, template "optionToNotBlock" takes care of that
 VServerMetadata server = getNode(id);
 // do we need this?
 server.setTemplate(template);
 String user = template.getImage().getOperatingSystem().getFamily() == OsFamily.WINDOWS ? "Administrator" : "root";
 return new NodeAndInitialCredentials<VServerMetadata>(server, id, LoginCredentials.builder().identity(user)
    .password(server.getInitialPassword()).build());
}

代码示例来源:origin: org.apache.jclouds.labs/fgcp

/**
* {@inheritDoc}
*/
@Override
public NodeAndInitialCredentials<VServerMetadata> createNodeWithGroupEncodedIntoName(
   String group, String name, Template template) {
 String id = api.getVirtualSystemApi().createServer(name,
    template.getHardware().getName(), template.getImage().getId(),
    template.getLocation().getId());
 // wait until fully created (i.e. transitions to stopped status)
 checkState(serverCreated.apply(id), "node %s not reaching STOPPED state after creation", id);
 resumeNode(id);
 // don't wait until fully started, template "optionToNotBlock" takes care of that
 VServerMetadata server = getNode(id);
 // do we need this?
 server.setTemplate(template);
 String user = template.getImage().getOperatingSystem().getFamily() == OsFamily.WINDOWS ? "Administrator" : "root";
 return new NodeAndInitialCredentials<VServerMetadata>(server, id, LoginCredentials.builder().identity(user)
    .password(server.getInitialPassword()).build());
}

代码示例来源:origin: jclouds/jclouds-labs

private void applyAndAssert(BaseImage baseImage) {
 final Hardware hardware = baseImageToHardware.apply(baseImage);
 assertEquals(baseImage.memoryGb() * 1024, hardware.getRam());
 assertEquals("vmx", hardware.getHypervisor());
 assertEquals(baseImage.id(), hardware.getId());
 assertEquals(baseImage.id(), hardware.getProviderId());
 assertEquals(baseImage.name(), hardware.getName());
 assertEquals(baseImage.disks().size(), hardware.getVolumes().size());
 assertEquals(Float.valueOf(baseImage.disks().get(0).sizeGb()), hardware.getVolumes().get(0).getSize());
 assertEquals(Volume.Type.LOCAL, hardware.getVolumes().get(0).getType());
 assertEquals(baseImage.disks().get(0).id(), hardware.getVolumes().get(0).getId());
 assertEquals(baseImage.disks().get(0).scsiId().toString(), hardware.getVolumes().get(0).getDevice());
 assertEquals(baseImage.cpu().count(), hardware.getProcessors().size());
 assertEquals(Double.valueOf(baseImage.cpu().coresPerSocket()), hardware.getProcessors().get(0).getCores());
 assertEquals(CpuSpeed.STANDARD.getSpeed(), hardware.getProcessors().get(0).getSpeed());
}

代码示例来源:origin: jclouds/jclouds-labs

private void applyAndAssert(Server server) {
 final Hardware hardware = serverToHardware.apply(server);
 assertEquals(server.memoryGb() * 1024, hardware.getRam());
 assertEquals("vmx", hardware.getHypervisor());
 assertEquals(server.id(), hardware.getId());
 assertEquals(server.id(), hardware.getProviderId());
 assertEquals(server.name(), hardware.getName());
 assertEquals(server.disks().size(), hardware.getVolumes().size());
 assertEquals(Float.valueOf(server.disks().get(0).sizeGb()), hardware.getVolumes().get(0).getSize());
 assertEquals(Volume.Type.LOCAL, hardware.getVolumes().get(0).getType());
 assertEquals(server.disks().get(0).id(), hardware.getVolumes().get(0).getId());
 assertEquals(server.disks().get(0).scsiId().toString(), hardware.getVolumes().get(0).getDevice());
 assertEquals(server.cpu().count(), hardware.getProcessors().size());
 assertEquals(Double.valueOf(server.cpu().coresPerSocket()), hardware.getProcessors().get(0).getCores());
 assertEquals(CpuSpeed.STANDARD.getSpeed(), hardware.getProcessors().get(0).getSpeed());
}

代码示例来源:origin: org.apache.jclouds.labs/azurecompute

.sourceImageName(OSImageToImage.fromGeoName(template.getImage().getId())[0])
.mediaLink(createMediaLink(storageAccountName, name))
.size(RoleSize.Type.fromString(template.getHardware().getName()))
.externalEndpoints(externalEndpoints)
.virtualNetworkName(templateOptions.getVirtualNetworkName())

代码示例来源:origin: org.jclouds.labs/fgcp

/**
* {@inheritDoc}
*/
@Override
public NodeAndInitialCredentials<VServerMetadata> createNodeWithGroupEncodedIntoName(
   String group, String name, Template template) {
 // Find vsys (how? create new? default to first found?)
 // Target network DMZ/SECURE1/SECURE2 (how? default to DMZ?)
 // Determine remaining params: [vserverType,diskImageId,networkId]
 // what if no vsys exists yet? Location.AU(.contractId) creates 3? tier
 // skeleton vsys and DMZ is picked?
 String id = api.getVirtualSystemApi().createServer(name,
    template.getHardware().getName(), template.getImage().getId(),
    template.getLocation().getId());
 // wait until fully created (i.e. transitions to stopped status)
 serverCreated.apply(id);
 resumeNode(id);
 VServerMetadata server = getNode(id);
 //do we need this?
 server.setTemplate(template);
 String user = template.getImage().getOperatingSystem().getFamily() == OsFamily.WINDOWS ? "Administrator"
    : "root";
 return new NodeAndInitialCredentials<VServerMetadata>(server,
    id, LoginCredentials.builder().identity(user)
       .password(server.getInitialPassword()).build());
}

相关文章