private boolean isNfsUnmounted(String psUuid) { long count = Q.New(PrimaryStorageClusterRefVO.class) .eq(PrimaryStorageClusterRefVO_.primaryStorageUuid, psUuid).count(); return count == 0; }
private void eliminateErrors() { String time = ElaborateGlobalConfig.ELIMILATE_TIME.value(); long count = Q.New(ElaborationVO.class).eq(ElaborationVO_.matched, false).lt(ElaborationVO_.lastOpDate, new Timestamp(new Date().getTime() - TimeUtils.parseTimeInMillis(time))).count(); if (count > 0) { logger.debug(String.format("clean [%s] records which are not matched error code in db", count)); UpdateQuery.New(ElaborationVO.class).eq(ElaborationVO_.matched, false).lt(ElaborationVO_.lastOpDate, new Timestamp(new Date().getTime() - TimeUtils.parseTimeInMillis(time))).delete(); } }
public boolean isUnmounted() { long count = Q.New(PrimaryStorageClusterRefVO.class) .eq(PrimaryStorageClusterRefVO_.primaryStorageUuid, this.self.getUuid()).count(); return count == 0; }
@Override public ServiceReference getServiceReference(String vipUuid) { long count = Q.New(PortForwardingRuleVO.class).eq(PortForwardingRuleVO_.vipUuid, vipUuid).count(); return new VipGetServiceReferencePoint.ServiceReference(PortForwardingConstant.PORTFORWARDING_NETWORK_SERVICE_TYPE, count); } }
@Override public ServiceReference getServiceReference(String vipUuid) { long count = Q.New(LoadBalancerVO.class).eq(LoadBalancerVO_.vipUuid, vipUuid).count(); return new VipGetServiceReferencePoint.ServiceReference(LoadBalancerConstants.LB_NETWORK_SERVICE_TYPE_STRING, count); } }
BigInteger end = IPv6NetworkUtils.ipv6AddressToBigInteger(vo.getEndIp()); long cnt = Q.New(UsedIpVO.class).eq(UsedIpVO_.ipRangeUuid, vo.getUuid()).count(); BigInteger num = start.add(new BigInteger(String.valueOf(cnt))); if (num.compareTo(end) > 0) {
@Transactional(readOnly = true) private boolean noStorageAccessible(String hostUuid){ // detach ps will delete PrimaryStorageClusterRefVO first. List<String> attachedPsUuids = SQL.New("select distinct ref.primaryStorageUuid" + " from PrimaryStorageClusterRefVO ref, HostVO h" + " where h.uuid =:hostUuid" + " and ref.clusterUuid = h.clusterUuid", String.class) .param("hostUuid", hostUuid) .list(); long attachedPsCount = attachedPsUuids.size(); long inaccessiblePsCount = attachedPsCount == 0 ? 0 : Q.New(PrimaryStorageHostRefVO.class) .eq(PrimaryStorageHostRefVO_.hostUuid, hostUuid) .eq(PrimaryStorageHostRefVO_.status, PrimaryStorageHostStatus.Disconnected) .in(PrimaryStorageHostRefVO_.primaryStorageUuid, attachedPsUuids) .count(); return inaccessiblePsCount == attachedPsCount && attachedPsCount > 0; }
static void checkAttachIsoToVm(String vmUuid, String isoUuid) { List<String> isoList = getIsoUuidByVmUuid(vmUuid); if (isoList.contains(isoUuid)) { throw new OperationFailureException(operr("VM[uuid:%s] has attached ISO[uuid:%s]", vmUuid, isoUuid)); } long emptyCdRomNum = Q.New(VmCdRomVO.class) .eq(VmCdRomVO_.vmInstanceUuid, vmUuid) .isNull(VmCdRomVO_.isoUuid) .count(); if (emptyCdRomNum == 0) { throw new OperationFailureException(operr("All vm[uuid:%s] CD-ROMs have mounted ISO", vmUuid)); } }
@Transactional(readOnly = true) private boolean noStorageAccessible(){ // detach ps will delete PrimaryStorageClusterRefVO first. List<String> attachedPsUuids = Q.New(PrimaryStorageClusterRefVO.class) .select(PrimaryStorageClusterRefVO_.primaryStorageUuid) .eq(PrimaryStorageClusterRefVO_.clusterUuid, self.getClusterUuid()) .listValues(); long attachedPsCount = attachedPsUuids.size(); long inaccessiblePsCount = attachedPsCount == 0 ? 0 : Q.New(PrimaryStorageHostRefVO.class) .eq(PrimaryStorageHostRefVO_.hostUuid, self.getUuid()) .eq(PrimaryStorageHostRefVO_.status, PrimaryStorageHostStatus.Disconnected) .in(PrimaryStorageHostRefVO_.primaryStorageUuid, attachedPsUuids) .count(); return inaccessiblePsCount == attachedPsCount && attachedPsCount > 0; }
@Override protected SessionInventory scripts() { if (q(SessionVO.class).eq(SessionVO_.accountUuid, accountUuid) .eq(SessionVO_.userUuid, userUuid).count() > IdentityGlobalConfig.MAX_CONCURRENT_SESSION.value(Integer.class)) { throw new OperationFailureException(operr("Login sessions hit limit of max allowed concurrent login sessions")); } SessionVO vo = new SessionVO(); vo.setUuid(Platform.getUuid()); vo.setAccountUuid(accountUuid); vo.setUserUuid(userUuid); long expiredTime = getCurrentSqlDate().getTime() + TimeUnit.SECONDS.toMillis(IdentityGlobalConfig.SESSION_TIMEOUT.value(Long.class)); vo.setExpiredDate(new Timestamp(expiredTime)); persist(vo); reload(vo); SessionInventory inv = SessionInventory.valueOf(vo); sessions.put(inv.getUuid(), inv); return inv; } }.execute();
private void validate(APICreateVxlanVtepMsg msg) { long count = Q.New(VtepVO.class).eq(VtepVO_.hostUuid, msg.getHostUuid()).eq(VtepVO_.poolUuid, msg.getPoolUuid()).count(); if (count > 0) { throw new ApiMessageInterceptionException(argerr("vxlan vtep address for host [uuid : %s] and pool [uuid : %s] pair already existed", msg.getHostUuid(), msg.getPoolUuid()) ); } }
private void check(APIRecoverDataVolumeMsg msg, Map<String, Quota.QuotaPair> pairs) { String resourceTargetOwnerUuid = new QuotaUtil().getResourceOwnerAccountUuid(msg.getVolumeUuid()); long cnt = Q.New(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, msg.getVolumeUuid()).count(); checkVolumeSnapshotNumQuota(msg.getSession().getAccountUuid(), resourceTargetOwnerUuid, cnt, pairs); }
.eq(HostVO_.clusterUuid, msg.getUuid()) .eq(HostVO_.state, HostState.PreMaintenance) .count(); if (premaintain != 0) { throw new ApiMessageInterceptionException(Platform.argerr( .eq(HostVO_.clusterUuid, msg.getUuid()) .notEq(HostVO_.status, HostStatus.Connected) .count(); if (notConnected != 0) { throw new ApiMessageInterceptionException(Platform.argerr(
.eq(L2NetworkClusterRefVO_.l2NetworkUuid, msg.getL2NetworkUuid()).count(); if (count != 0) { evt.setInventory(self.toInventory());
.eq(VolumeVO_.vmInstanceUuid, inv.getUuid()).count(); if (count != 0) { capabilities.setSupportVolumeMigration(false);
private void doCreateVmCdRom(CreateVmCdRomMsg msg, ReturnValueCompletion<VmCdRomInventory> completion) { long vmCdRomNum = Q.New(VmCdRomVO.class) .eq(VmCdRomVO_.vmInstanceUuid, msg.getVmInstanceUuid()) .count(); int max = VmGlobalConfig.MAXIMUM_CD_ROM_NUM.value(Integer.class); if (max <= vmCdRomNum) {
count = Q.New(VolumeVO.class).eq(VolumeVO_.type, VolumeType.Data).eq(VolumeVO_.vmInstanceUuid, msg.getVmInstanceUuid()).count(); if (count + 1 > maxDataVolumeNum) { throw new ApiMessageInterceptionException(operr("hypervisor[%s] only allows max %s data volumes to be attached to a single vm; there have been %s data volumes attached to vm[uuid:%s]",
.eq(VolumeVO_.vmInstanceUuid,vol.getVmInstanceUuid()).count(); if (count != 0) { throw new ApiMessageInterceptionException(operr("the volume[uuid:%s] is the root volume of the vm[uuid:%s]. Currently the vm still" +