コード例 #1
0
  @Override
  public Hardware apply(VAppTemplate from) {
    checkNotNull(from, "VAppTemplate");

    if (!from.isOvfDescriptorUploaded()) {
      logger.warn("cannot parse hardware as ovf descriptor for %s is not uploaded", from);
      return null;
    }

    Envelope ovf = client.getOvfEnvelopeForVAppTemplate(from.getHref());
    if (ovf == null) {
      logger.warn("cannot parse hardware as no ovf envelope found for %s", from);
      return null;
    }
    if (ovf.getVirtualSystem().getVirtualHardwareSections().size() == 0) {
      logger.warn("cannot parse hardware for %s as no hardware sections exist in ovf %s", ovf);
      return null;
    }
    if (ovf.getVirtualSystem().getVirtualHardwareSections().size() > 1) {
      logger.warn("multiple hardware choices found. using first", ovf);
    }
    VirtualHardwareSection hardware =
        Iterables.get(ovf.getVirtualSystem().getVirtualHardwareSections(), 0);
    HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getItems());
    builder.location(findLocationForResource.apply(checkNotNull(parent, "parent")));
    builder
        .ids(from.getHref().toASCIIString())
        .name(from.getName())
        .supportsImage(ImagePredicates.idEquals(from.getHref().toASCIIString()));
    return builder.build();
  }
コード例 #2
0
  @Override
  public Image apply(VAppTemplate from) {
    checkNotNull(from, "VAppTemplate");
    Envelope ovf = templateToEnvelope.apply(from);

    ImageBuilder builder = new ImageBuilder();
    builder.ids(from.getHref().toASCIIString());
    builder.uri(from.getHref());
    builder.name(from.getName());
    if (from.getVDC() != null) {
      builder.location(findLocationForResource.apply(from.getVDC()));
    } else {
      // otherwise, it could be in a public catalog, which is not assigned to a VDC
    }
    builder.description(from.getDescription() != null ? from.getDescription() : from.getName());
    builder.operatingSystem(CIMOperatingSystem.toComputeOs(ovf));
    builder.status(toPortableImageStatus.get(from.getStatus()));
    return builder.build();
  }