コード例 #1
0
  /** @return The snapshots to add to the disk */
  private static ArrayList<DiskImage> mockSnapshots() {
    Guid snapshotGuid = Guid.newGuid();
    DiskImage expectedSnapshot = new DiskImage();
    expectedSnapshot.setImageId(snapshotGuid);
    ArrayList<DiskImage> snapshots = new ArrayList<DiskImage>(1);
    snapshots.add(expectedSnapshot);

    return snapshots;
  }
コード例 #2
0
  /** @return A disk to add to the VM */
  private static DiskImage mockDisk() {
    // Prepare the disk
    Guid diskGuid = Guid.newGuid();
    Guid itGuid = Guid.newGuid();
    final DiskImage expectedDisk = new DiskImage();
    expectedDisk.setImageId(diskGuid);
    expectedDisk.setImageTemplateId(itGuid);

    return expectedDisk;
  }
コード例 #3
0
  /** <exception>VdcDAL.IrsBrokerIRSErrorException. */
  public DiskImage buildImageEntity(Map<String, Object> xmlRpcStruct) {
    DiskImage newImage = new DiskImage();
    try {
      newImage.setImageId(new Guid((String) xmlRpcStruct.get(IrsProperties.uuid)));

      newImage.setParentId(new Guid((String) xmlRpcStruct.get(IrsProperties.parent)));
      newImage.setDescription((String) xmlRpcStruct.get(IrsProperties.description));
      newImage.setImageStatus(
          EnumUtils.valueOf(
              ImageStatus.class, (String) xmlRpcStruct.get(IrsProperties.ImageStatus), true));
      if (xmlRpcStruct.containsKey(IrsProperties.size)) {
        newImage.setSize(Long.parseLong(xmlRpcStruct.get(IrsProperties.size).toString()) * 512);
      }
      if (xmlRpcStruct.containsKey("capacity")) {
        newImage.setSize(Long.parseLong(xmlRpcStruct.get("capacity").toString()));
      }
      if (xmlRpcStruct.containsKey("truesize")) {
        newImage.setActualSizeInBytes(Long.parseLong(xmlRpcStruct.get("truesize").toString()));
      }
      if (xmlRpcStruct.containsKey("ctime")) {
        long secsSinceEpoch = Long.parseLong(xmlRpcStruct.get("ctime").toString());
        newImage.setCreationDate(MakeDTFromCTime(secsSinceEpoch));
      }
      if (xmlRpcStruct.containsKey("mtime")) {
        long secsSinceEpoch = Long.parseLong(xmlRpcStruct.get("mtime").toString());
        newImage.setLastModifiedDate(MakeDTFromCTime(secsSinceEpoch));
      }
      if (xmlRpcStruct.containsKey("domain")) {
        newImage.setStorageIds(
            new ArrayList<Guid>(Arrays.asList(new Guid(xmlRpcStruct.get("domain").toString()))));
      }
      if (xmlRpcStruct.containsKey("image")) {
        newImage.setimage_group_id(new Guid(xmlRpcStruct.get("image").toString()));
      }
      if (xmlRpcStruct.containsKey("type")) {
        newImage.setVolumeType(
            EnumUtils.valueOf(VolumeType.class, xmlRpcStruct.get("type").toString(), true));
      }
      if (xmlRpcStruct.containsKey("format")) {
        newImage.setvolumeFormat(
            EnumUtils.valueOf(VolumeFormat.class, xmlRpcStruct.get("format").toString(), true));
      }
    } catch (RuntimeException ex) {
      log.errorFormat("irsBroker::buildImageEntity::Failed building DIskImage");
      printReturnValue();
      log.error(ex.getMessage(), ex);
      newImage = null;
    }

    return newImage;
  }
コード例 #4
0
 private static DiskImage addTestDisk(VM vm, Guid snapshotId) {
   Guid imageId = Guid.newGuid();
   DiskImage disk = new DiskImage();
   disk.setImageId(imageId);
   disk.setId(Guid.newGuid());
   disk.setVolumeType(VolumeType.Sparse);
   disk.setvolumeFormat(VolumeFormat.COW);
   disk.setDiskInterface(DiskInterface.VirtIO);
   disk.setStoragePoolId(vm.getStoragePoolId());
   disk.setActive(Boolean.TRUE);
   disk.setPlugged(Boolean.TRUE);
   disk.setReadOnly(Boolean.FALSE);
   disk.setVmSnapshotId(snapshotId);
   disk.setImageStatus(ImageStatus.OK);
   disk.setAppList("");
   disk.setDescription("");
   vm.getDiskList().add(disk);
   vm.getDiskMap().put(imageId, disk);
   return disk;
 }