private void handle(final BackupVolumeSnapshotMsg msg) { final BackupVolumeSnapshotReply reply = new BackupVolumeSnapshotReply(); BackupVolumeSnapshotFromPrimaryStorageToBackupStorageMsg bmsg = new BackupVolumeSnapshotFromPrimaryStorageToBackupStorageMsg(); bmsg.setPrimaryStorageUuid(self.getPrimaryStorageUuid()); bmsg.setBackupStorage(msg.getBackupStorage()); bmsg.setSnapshot(getSelfInventory()); bus.makeTargetServiceIdByResourceUuid(bmsg, PrimaryStorageConstant.SERVICE_ID, self.getPrimaryStorageUuid()); bus.send(bmsg, new CloudBusCallBack(msg) { @Override public void run(MessageReply rsp) { if (!rsp.isSuccess()) { reply.setError(rsp.getError()); } else { BackupVolumeSnapshotFromPrimaryStorageToBackupStorageReply r = rsp.castReply(); VolumeSnapshotBackupStorageRefVO ref = new VolumeSnapshotBackupStorageRefVO(); ref.setInstallPath(r.getBackupStorageInstallPath()); ref.setVolumeSnapshotUuid(self.getUuid()); ref.setBackupStorageUuid(msg.getBackupStorage().getUuid()); dbf.persist(ref); } bus.reply(msg, reply); } }); }
@Override public void run(final FlowTrigger trigger, Map data) { MergeVolumeSnapshotOnPrimaryStorageMsg mmsg = new MergeVolumeSnapshotOnPrimaryStorageMsg(); VolumeSnapshotInventory from = currentLeaf.getParent() == null ? currentLeaf.getInventory() : currentLeaf.getParent().getInventory(); mmsg.setFrom(from); VolumeVO vol = dbf.findByUuid(currentRoot.getVolumeUuid(), VolumeVO.class); mmsg.setTo(VolumeInventory.valueOf(vol)); mmsg.setFullRebase(currentLeaf.getParent() == null); bus.makeTargetServiceIdByResourceUuid(mmsg, PrimaryStorageConstant.SERVICE_ID, currentRoot.getPrimaryStorageUuid()); bus.send(mmsg, new CloudBusCallBack(trigger) { @Override public void run(MessageReply reply) { if (!reply.isSuccess()) { trigger.fail(reply.getError()); } else { trigger.next(); } } }); } });
q.add(PrimaryStorageVO_.uuid, Op.EQ, currentRoot.getPrimaryStorageUuid()); String psType = q.findValue(); paramIn.setPrimaryStorageUuid(currentRoot.getPrimaryStorageUuid()); paramIn.setSnapshot(currentLeaf.getInventory()); paramIn.setImage(ImageInventory.valueOf(dbf.findByUuid(msg.getImageUuid(), ImageVO.class)));
Boolean onCurrentTree = tq.findValue(); boolean needMerge = onCurrentTree && ancestorOfLatest && currentRoot.getPrimaryStorageUuid() != null && VolumeSnapshotConstant.HYPERVISOR_SNAPSHOT_TYPE.toString().equals(currentRoot.getType()); if (needMerge) { chain.then(new NoRollbackFlow() {
public static VolumeSnapshotInventory valueOf(VolumeSnapshotVO vo) { VolumeSnapshotInventory inv = new VolumeSnapshotInventory(); inv.setName(vo.getName()); inv.setCreateDate(vo.getCreateDate()); inv.setDescription(vo.getDescription()); inv.setLastOpDate(vo.getLastOpDate()); inv.setParentUuid(vo.getParentUuid()); inv.setState(vo.getState().toString()); inv.setType(vo.getType()); inv.setVolumeUuid(vo.getVolumeUuid()); inv.setFormat(vo.getFormat()); inv.setUuid(vo.getUuid()); inv.setStatus(vo.getStatus().toString()); inv.setPrimaryStorageUuid(vo.getPrimaryStorageUuid()); inv.setPrimaryStorageInstallPath(vo.getPrimaryStorageInstallPath()); inv.setLatest(vo.isLatest()); inv.setSize(vo.getSize()); inv.setVolumeType(vo.getVolumeType()); inv.setTreeUuid(vo.getTreeUuid()); inv.setBackupStorageRefs(VolumeSnapshotBackupStorageRefInventory.valueOf(vo.getBackupStorageRefs())); return inv; }