Example #1
0
  @Override
  public void preRecoverDataVolume(VolumeInventory vol) {
    if (vol.getPrimaryStorageUuid() == null) {
      return;
    }

    SimpleQuery<PrimaryStorageVO> q = dbf.createQuery(PrimaryStorageVO.class);
    q.select(PrimaryStorageVO_.type);
    q.add(PrimaryStorageVO_.uuid, Op.EQ, vol.getPrimaryStorageUuid());
    String type = q.findValue();
    if (!LocalStorageConstants.LOCAL_STORAGE_TYPE.equals(type)) {
      return;
    }

    SimpleQuery<LocalStorageResourceRefVO> rq = dbf.createQuery(LocalStorageResourceRefVO.class);
    rq.add(LocalStorageResourceRefVO_.resourceUuid, Op.EQ, vol.getUuid());
    rq.add(LocalStorageResourceRefVO_.resourceType, Op.EQ, VolumeVO.class.getSimpleName());
    if (!rq.isExists()) {
      throw new OperationFailureException(
          errf.stringToOperationError(
              String.format(
                  "the data volume[name:%s, uuid:%s] is on the local storage[uuid:%s]; however,"
                      + "the host on which the data volume is has been deleted. Unable to recover this volume",
                  vol.getName(), vol.getUuid(), vol.getPrimaryStorageUuid())));
    }
  }
Example #2
0
 public boolean hasTag(String resourceUuid, Class resourceClass) {
   SimpleQuery<SystemTagVO> q = dbf.createQuery(SystemTagVO.class);
   q.add(SystemTagVO_.resourceType, Op.EQ, resourceClass.getSimpleName());
   q.add(SystemTagVO_.resourceUuid, Op.EQ, resourceUuid);
   q.add(SystemTagVO_.tag, useOp(), useTagFormat());
   return q.isExists();
 }
Example #3
0
 private boolean isRootVolumeOnLocalStorage(String rootVolumeUuid) {
   SimpleQuery<LocalStorageResourceRefVO> q = dbf.createQuery(LocalStorageResourceRefVO.class);
   q.add(LocalStorageResourceRefVO_.resourceUuid, Op.EQ, rootVolumeUuid);
   return q.isExists();
 }