private void deleteVmCdRom(String cdRomUuid, Completion completion) { boolean exist = dbf.isExist(cdRomUuid, VmCdRomVO.class); if (!exist) { completion.success(); return; } dbf.removeByPrimaryKey(cdRomUuid, VmCdRomVO.class); completion.success(); }
private void validate(APIDeleteVolumeSnapshotMsg msg) { if (!dbf.isExist(msg.getUuid(), VolumeSnapshotVO.class)) { APIDeleteVolumeSnapshotEvent evt = new APIDeleteVolumeSnapshotEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } } }
private void validate(APIDeleteGCJobMsg msg) { if (!dbf.isExist(msg.getUuid(), GarbageCollectorVO.class)) { APIDeleteGCJobEvent evt = new APIDeleteGCJobEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } }
private void validate(APIDeleteHostMsg msg) { if (!dbf.isExist(msg.getUuid(), HostVO.class)) { APIDeleteHostEvent evt = new APIDeleteHostEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } }
private void validate(APIDeletePortForwardingRuleMsg msg) { if (!dbf.isExist(msg.getUuid(), PortForwardingRuleVO.class)) { bus.publish(new APIDeletePortForwardingRuleEvent(msg.getId())); throw new StopRoutingException(); } } }
private void validate(APIDeleteClusterMsg msg) { if (!dbf.isExist(msg.getUuid(), ClusterVO.class)) { APIDeleteClusterEvent evt = new APIDeleteClusterEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } } }
private void validate(APIDeleteZoneMsg msg) { if (!dbf.isExist(msg.getUuid(), ZoneVO.class)) { APIDeleteZoneEvent evt = new APIDeleteZoneEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } } }
private void validate(APIDeleteL2NetworkMsg msg) { if (!dbf.isExist(msg.getUuid(), L2NetworkVO.class)) { APIDeleteL2NetworkEvent evt = new APIDeleteL2NetworkEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } }
private void validate(APIDeleteSecurityGroupMsg msg) { if (!dbf.isExist(msg.getUuid(), SecurityGroupVO.class)) { APIDeleteSecurityGroupEvent evt = new APIDeleteSecurityGroupEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } }
private void validate(APIDeleteBackupStorageMsg msg) { if (!dbf.isExist(msg.getUuid(), BackupStorageVO.class)) { APIDeleteBackupStorageEvent evt = new APIDeleteBackupStorageEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } }
private void validate(APIDeleteEipMsg msg) { if (!dbf.isExist(msg.getUuid(), EipVO.class)) { APIDeleteEipEvent evt = new APIDeleteEipEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } }
private void validate(APIDestroyVmInstanceMsg msg) { if (!dbf.isExist(msg.getUuid(), VmInstanceVO.class)) { APIDestroyVmInstanceEvent evt = new APIDestroyVmInstanceEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } }
private void validate(APIDeleteDiskOfferingMsg msg) { if (!dbf.isExist(msg.getUuid(), DiskOfferingVO.class)) { APIDeleteDiskOfferingEvent evt = new APIDeleteDiskOfferingEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } }
private void validate(APIDeleteL3NetworkMsg msg) { if (!dbf.isExist(msg.getUuid(), L3NetworkVO.class)) { APIDeleteL3NetworkEvent evt = new APIDeleteL3NetworkEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } }
private void validate(APIDeletePrimaryStorageMsg msg) { if (!dbf.isExist(msg.getUuid(), PrimaryStorageVO.class)) { APIDeletePrimaryStorageEvent evt = new APIDeletePrimaryStorageEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } SimpleQuery<PrimaryStorageClusterRefVO> sq = dbf.createQuery(PrimaryStorageClusterRefVO.class); sq.add(PrimaryStorageClusterRefVO_.primaryStorageUuid, Op.EQ, msg.getPrimaryStorageUuid()); List<PrimaryStorageClusterRefVO> pscRefs = sq.list(); if (!pscRefs.isEmpty()) { String clusterUuidsString = pscRefs.stream() .map(PrimaryStorageClusterRefVO::getClusterUuid) .collect(Collectors.joining(", ")); throw new ApiMessageInterceptionException(operr("primary storage[uuid:%s] cannot be deleted for still " + "being attached to cluster[uuid:%s].", msg.getPrimaryStorageUuid(), clusterUuidsString)); } } }
@Override public void validateSystemTag(String resourceUuid, Class resourceType, String systemTag) { String uuid = PrimaryStorageSystemTags.PRIMARY_STORAGE_ALLOCATOR_UUID_TAG.getTokenByTag( systemTag, PrimaryStorageSystemTags.PRIMARY_STORAGE_ALLOCATOR_UUID_TAG_TOKEN); if (!StringDSL.isZStackUuid(uuid)) { throw new ApiMessageInterceptionException(argerr("%s is invalid. %s is not a valid zstack uuid", systemTag, uuid)); } if (!dbf.isExist(uuid, PrimaryStorageVO.class)) { throw new ApiMessageInterceptionException(argerr("no primary storage[uuid:%s] found", resourceUuid)); } } });
@Override public void handle(Map data) { final VirtualRouterVmInventory vr = (VirtualRouterVmInventory) data.get(VirtualRouterConstant.Param.VR.toString()); if (!dbf.isExist(vip.getUuid(), VirtualRouterVipVO.class)) { VirtualRouterVipVO vrvip = new VirtualRouterVipVO(); vrvip.setUuid(vip.getUuid()); vrvip.setVirtualRouterVmUuid(vr.getUuid()); dbf.persist(vrvip); } completion.success(); } }).error(new FlowErrorHandler(completion) {
private void validate(APIDeleteTagMsg msg) { SimpleQuery<SystemTagVO> q = dbf.createQuery(SystemTagVO.class); q.add(SystemTagVO_.uuid, Op.EQ, msg.getUuid()); q.add(SystemTagVO_.inherent, Op.EQ, true); if (q.isExists()) { throw new ApiMessageInterceptionException(operr("tag[uuid:%s] is an inherent system tag, can not be removed", msg.getUuid())); } boolean userTag = dbf.isExist(msg.getUuid(), UserTagVO.class); boolean sysTag = dbf.isExist(msg.getUuid(), SystemTagVO.class); boolean tagPattern = dbf.isExist(msg.getUuid(), TagPatternVO.class); if (!new QuotaUtil().isAdminAccount(msg.getSession().getAccountUuid())) { if (userTag) { checkAccountForUserTag(msg); } else if (sysTag) { checkAccountForSystemTag(msg); } else if (tagPattern) { checkAccountForTagPattern(msg); } } }
@Override public void success() { if (!dbf.isExist(vip.getUuid(), VirtualRouterVipVO.class)) { VirtualRouterVipVO vrvip = new VirtualRouterVipVO(); vrvip.setUuid(vip.getUuid()); vrvip.setVirtualRouterVmUuid(vr.getUuid()); dbf.persist(vrvip); } completion.success(); }
private void validate(APIDeleteDataVolumeMsg msg) { if (!dbf.isExist(msg.getUuid(), VolumeVO.class)) { APIDeleteDataVolumeEvent evt = new APIDeleteDataVolumeEvent(msg.getId()); bus.publish(evt); throw new StopRoutingException(); } SimpleQuery<VolumeVO> q = dbf.createQuery(VolumeVO.class); q.select(VolumeVO_.type, VolumeVO_.status); q.add(VolumeVO_.uuid, Op.EQ, msg.getVolumeUuid()); Tuple t = q.findTuple(); VolumeType type = t.get(0, VolumeType.class); if (type == VolumeType.Root) { throw new ApiMessageInterceptionException(argerr("volume[uuid:%s] is Root volume, can't be deleted", msg.getVolumeUuid())); } VolumeStatus status = t.get(1, VolumeStatus.class); if (status == VolumeStatus.Deleted) { throw new ApiMessageInterceptionException(operr("volume[uuid:%s] is already in status of deleted", msg.getVolumeUuid())); } }