@Override protected void scripts() { List<DiskOfferingInventory> diskOfferingInventories = action.getParentIssuerContext(); sql(VolumeVO.class).set(VolumeVO_.diskOfferingUuid, null) .in(VolumeVO_.uuid, diskOfferingInventories.stream().map(DiskOfferingInventory::getUuid).collect(Collectors.toList())) .update(); } }.execute();
private void handle(APIDeleteNotificationsMsg msg) { APIDeleteNotificationsEvent evt = new APIDeleteNotificationsEvent(msg.getId()); SQL.New(NotificationVO.class).in(NotificationVO_.uuid, msg.getUuids()).delete(); bus.publish(evt); }
@Override protected void scripts() { String psUuid = q(VolumeSnapshotVO.class) .select(VolumeSnapshotVO_.primaryStorageUuid) .eq(VolumeSnapshotVO_.uuid, currentRoot.getUuid()) .findValue(); if (psUuid != null) { ret.value = false; return; } // the snapshot is on neither primary storage, delete it and descendants List<String> uuids = currentLeaf.getDescendants().stream().map(VolumeSnapshotInventory::getUuid).collect(Collectors.toList()); if (!uuids.isEmpty()) { sql(VolumeSnapshotVO.class).in(VolumeSnapshotVO_.uuid, uuids).hardDelete(); } if (!q(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.treeUuid, currentRoot.getTreeUuid()).isExists()) { logger.debug(String.format("volume snapshot tree[uuid:%s] has no leaf, delete it", currentRoot.getTreeUuid())); sql(VolumeSnapshotTreeVO.class).eq(VolumeSnapshotTreeVO_.uuid, currentRoot.getTreeUuid()).hardDelete(); } ret.value = true; } }.execute();
@Override protected void scripts() { List<String> huuids = Q.New(HostVO.class).select(HostVO_.uuid) .eq(HostVO_.clusterUuid, clusterUuid) .listValues(); SQL.New(PrimaryStorageHostRefVO.class) .eq(PrimaryStorageHostRefVO_.primaryStorageUuid, inventory.getUuid()) .in(PrimaryStorageHostRefVO_.hostUuid, huuids) .hardDelete(); } }.execute();
private void handle(APIRemovePolicyStatementsFromRoleMsg msg) { SQL.New(RolePolicyStatementVO.class).eq(RolePolicyStatementVO_.roleUuid, self.getUuid()) .in(RolePolicyStatementVO_.uuid, msg.getPolicyStatementUuids()).hardDelete(); bus.publish(new APIRemovePolicyStatementsFromRoleEvent(msg.getId())); }
private void handle(APIUpdateNotificationsStatusMsg msg) { APIUpdateNotificationsStatusEvent evt = new APIUpdateNotificationsStatusEvent(msg.getId()); SQL.New(NotificationVO.class).set(NotificationVO_.status, NotificationStatus.valueOf(msg.getStatus())) .in(NotificationVO_.uuid, msg.getUuids()).update(); bus.publish(evt); }
@Override protected void scripts() { if (!q(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).isExists()) { return; } List<String> treeUuids = q(VolumeSnapshotVO.class).select(VolumeSnapshotVO_.treeUuid).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).listValues(); sql(VolumeSnapshotTreeVO.class).in(VolumeSnapshotTreeVO_.uuid, treeUuids).delete(); sql(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).delete(); } }.execute();
@Override public void deleteHook() { List<String> poolNameLists = list( getDefaultRootVolumePoolName(), getDefaultDataVolumePoolName(), getDefaultImageCachePoolName() ); SQL.New(CephPrimaryStoragePoolVO.class) .in(CephPrimaryStoragePoolVO_.poolName, poolNameLists).delete(); if (CephGlobalConfig.PRIMARY_STORAGE_DELETE_POOL.value(Boolean.class)) { DeletePoolCmd cmd = new DeletePoolCmd(); cmd.poolNames = poolNameLists; FutureReturnValueCompletion completion = new FutureReturnValueCompletion(null); httpCall(DELETE_POOL_PATH, cmd, DeletePoolRsp.class, completion); completion.await(TimeUnit.MINUTES.toMillis(30)); if (!completion.isSuccess()) { throw new OperationFailureException(completion.getErrorCode()); } } String fsid = getSelf().getFsid(); new SQLBatch(){ @Override protected void scripts() { if(Q.New(CephBackupStorageVO.class).eq(CephBackupStorageVO_.fsid, fsid).find() == null){ SQL.New(CephCapacityVO.class).eq(CephCapacityVO_.fsid, fsid).delete(); } } }.execute(); dbf.removeCollection(getSelf().getMons(), CephPrimaryStorageMonVO.class); }