private VolumeSnapshotInventory getSelfInventory() { return VolumeSnapshotInventory.valueOf(currentRoot); }
protected VolumeSnapshotInventory getSelfInventory() { return VolumeSnapshotInventory.valueOf(self); }
public static List<VolumeSnapshotInventory> valueOf(Collection<VolumeSnapshotVO> vos) { List<VolumeSnapshotInventory> invs = new ArrayList<VolumeSnapshotInventory>(); for (VolumeSnapshotVO vo : vos) { invs.add(VolumeSnapshotInventory.valueOf(vo)); } return invs; }
public static VolumeSnapshotTree fromVOs(List<VolumeSnapshotVO> vos) { return fromInventories(VolumeSnapshotInventory.valueOf(vos)); }
@Override @Transactional(readOnly = true) public VolumeSnapshotInventory call() { String sql = "select sp from VolumeSnapshotVO sp, VolumeSnapshotTreeVO tree where sp.treeUuid = tree.uuid" + " and tree.current = :c and sp.latest = :l and tree.volumeUuid = :volUuid"; TypedQuery<VolumeSnapshotVO> q = dbf.getEntityManager().createQuery(sql, VolumeSnapshotVO.class); q.setParameter("c", true); q.setParameter("l", true); q.setParameter("volUuid", vol.getUuid()); if(q.getResultList().isEmpty()){ return null; } VolumeSnapshotVO vo = q.getSingleResult(); return VolumeSnapshotInventory.valueOf(vo); } }.call();
private List<VolumeSnapshotInventory> fromAction(CascadeAction action) { List<VolumeSnapshotInventory> ret = null; if (VolumeVO.class.getSimpleName().equals(action.getParentIssuer())) { List<VolumeDeletionStruct> vols = action.getParentIssuerContext(); List<String> volUuids = CollectionUtils.transformToList(vols, new Function<String, VolumeDeletionStruct>() { @Override public String call(VolumeDeletionStruct arg) { return arg.getInventory().getUuid(); } }); if (volUuids.isEmpty()) { return null; } SimpleQuery<VolumeSnapshotVO> q = dbf.createQuery(VolumeSnapshotVO.class); q.add(VolumeSnapshotVO_.volumeUuid, Op.IN, volUuids); List<VolumeSnapshotVO> vos = q.list(); if (!vos.isEmpty()) { ret = VolumeSnapshotInventory.valueOf(vos); } } else if (NAME.equals(action.getParentIssuer())) { ret = action.getParentIssuerContext(); } return ret; }
@Override public void handle(Map data) { reportProgress("90"); casf.asyncCascadeFull(CascadeConstant.DELETION_CLEANUP_CODE, issuer, ctx, new NopeCompletion()); new FireSnapShotCanonicalEvent() .fireSnapShotStatusChangedEvent(currentRoot.getStatus(), VolumeSnapshotInventory.valueOf(currentRoot)); completion.success(); } }).error(new FlowErrorHandler(msg) {
@Transactional private VolumeSnapshotStruct newChain(VolumeSnapshotVO vo, boolean fullsnapshot) { VolumeSnapshotTreeVO chain = new VolumeSnapshotTreeVO(); chain.setCurrent(true); chain.setVolumeUuid(vo.getVolumeUuid()); chain.setUuid(Platform.getUuid()); chain = dbf.getEntityManager().merge(chain); logger.debug(String.format("created new volume snapshot tree[tree uuid:%s, volume uuid:%s, full snapshot uuid:%s]", chain.getUuid(), vo.getVolumeUuid(), vo.getUuid())); vo.setTreeUuid(chain.getUuid()); vo.setDistance(fullsnapshot ? 0 : 1); vo.setParentUuid(null); vo.setLatest(true); vo.setFullSnapshot(fullsnapshot); dbf.getEntityManager().persist(vo); dbf.getEntityManager().flush(); dbf.getEntityManager().refresh(vo); VolumeSnapshotStruct struct = new VolumeSnapshotStruct(); struct.setCurrent(VolumeSnapshotInventory.valueOf(vo)); struct.setFullSnapshot(fullsnapshot); return struct; }
private void handle(APIUpdateVolumeSnapshotMsg msg) { VolumeSnapshotVO self = dbf.findByUuid(msg.getUuid(), VolumeSnapshotVO.class); boolean update = false; if (msg.getName() != null) { self.setName(msg.getName()); update = true; } if (msg.getDescription() != null) { self.setDescription(msg.getDescription()); update = true; } if (update) { self = dbf.updateAndRefresh(self); } APIUpdateVolumeSnapshotEvent evt = new APIUpdateVolumeSnapshotEvent(msg.getId()); evt.setInventory(VolumeSnapshotInventory.valueOf(self)); bus.publish(evt); }
allSnapshots = VolumeSnapshotInventory.valueOf(vos);