@Transactional(readOnly = true) private List<PrimaryStorageInventory> getPrimaryStorageForHost(String clusterUuid) { String sql = "select p.uuid, p.url, p.mountPath from PrimaryStorageVO p where p.type = :ptype and p.uuid in (select r.primaryStorageUuid from PrimaryStorageClusterRefVO r where r.clusterUuid = :clusterUuid)"; Query query = dbf.getEntityManager().createQuery(sql); query.setParameter("clusterUuid", clusterUuid); query.setParameter("ptype", NfsPrimaryStorageConstant.NFS_PRIMARY_STORAGE_TYPE); List<Object[]> lst = query.getResultList(); List<PrimaryStorageInventory> pss = new ArrayList<PrimaryStorageInventory>(); for (Object[] objs : lst) { PrimaryStorageInventory inv = new PrimaryStorageInventory(); inv.setUuid((String) objs[0]); inv.setUrl((String) objs[1]); inv.setMountPath((String) objs[2]); pss.add(inv); } return pss; }
lsInv.setName("example"); lsInv.setDescription("example"); lsInv.setUuid(uuid()); lsInv.setAttachedClusterUuids(asList(uuid())); lsInv.setAvailableCapacity(SizeUnit.GIGABYTE.toByte(200L)); nfsInv.setName("example"); nfsInv.setDescription("example"); nfsInv.setUuid(uuid); nfsInv.setAttachedClusterUuids(asList(uuid())); nfsInv.setAvailableCapacity(SizeUnit.GIGABYTE.toByte(200L));
protected PrimaryStorageInventory(PrimaryStorageVO vo) { setZoneUuid(vo.getZoneUuid()); setCreateDate(vo.getCreateDate()); setDescription(vo.getDescription()); setLastOpDate(vo.getLastOpDate()); setName(vo.getName()); setState(vo.getState().toString()); setType(vo.getType()); setUrl(vo.getUrl()); setUuid(vo.getUuid()); setMountPath(vo.getMountPath()); setStatus(vo.getStatus().toString()); attachedClusterUuids = new ArrayList<String>(vo.getAttachedClusterRefs().size()); for (PrimaryStorageClusterRefVO ref : vo.getAttachedClusterRefs()) { attachedClusterUuids.add(ref.getClusterUuid()); } if (vo.getCapacity() != null) { setTotalCapacity(vo.getCapacity().getTotalCapacity()); setAvailableCapacity(vo.getCapacity().getAvailableCapacity()); setTotalPhysicalCapacity(vo.getCapacity().getTotalPhysicalCapacity()); setAvailablePhysicalCapacity(vo.getCapacity().getAvailablePhysicalCapacity()); setSystemUsedCapacity(vo.getCapacity().getSystemUsedCapacity()); } }