static VmCdRomVO getEmptyCdRom(String vmUuid) { VmCdRomVO cdRomVO = Q.New(VmCdRomVO.class) .eq(VmCdRomVO_.vmInstanceUuid, vmUuid) .isNull(VmCdRomVO_.isoUuid) .orderBy(VmCdRomVO_.deviceId, SimpleQuery.Od.ASC) .limit(1) .find(); return cdRomVO; }
private void validateIpRangeOverlapWithVm(String l3NetworkUuid, String vmInstanceUuid) { List<VmNicVO> vmNicVOS = Q.New(VmNicVO.class).eq(VmNicVO_.vmInstanceUuid, vmInstanceUuid).list(); List<IpRangeVO> newIpRangeVOS = Q.New(IpRangeVO.class).eq(IpRangeVO_.l3NetworkUuid, l3NetworkUuid).list(); if (newIpRangeVOS == null || newIpRangeVOS.isEmpty()) { throw new ApiMessageInterceptionException(operr("no ip ranges attached with l3 network[uuid:%s]", l3NetworkUuid)); } for (VmNicVO vmNicVO: vmNicVOS) { List<IpRangeVO> ipRangeVOS = Q.New(IpRangeVO.class).eq(IpRangeVO_.l3NetworkUuid, vmNicVO.getL3NetworkUuid()).limit(1).list(); if (ipRangeVOS != null && !ipRangeVOS.isEmpty()) { if (NetworkUtils.isCidrOverlap(ipRangeVOS.get(0).getNetworkCidr(), newIpRangeVOS.get(0).getNetworkCidr())) { throw new ApiMessageInterceptionException(operr("unable to attach a L3 network. The cidr of l3[%s] to attach overlapped with l3[%s] already attached to vm", l3NetworkUuid, vmNicVO.getL3NetworkUuid())); } } } }
@Override public void afterAllocateDhcpServerIP(String L3NetworkUuid, String dhcpSererIp) { /* skip adding host route for network without host route service */ NetworkServiceL3NetworkRefVO ref = Q.New(NetworkServiceL3NetworkRefVO.class).eq(NetworkServiceL3NetworkRefVO_.l3NetworkUuid, L3NetworkUuid) .eq(NetworkServiceL3NetworkRefVO_.networkServiceType, NetworkServiceType.HostRoute.toString()).find(); if (ref == null) { logger.debug(String.format("L3 Network doesn't has %s service", NetworkServiceType.HostRoute.toString())); return; } IpRangeVO rangeVO = Q.New(IpRangeVO.class).eq(IpRangeVO_.l3NetworkUuid, L3NetworkUuid).limit(1).find(); if (rangeVO == null) { return; } updateMetadataRoute(L3NetworkUuid, dhcpSererIp); }
.notNull(VmNicVO_.metaData).limit(1).find(); if (rnic == null) { l3Uuids.addAll(vipPeerL3Uuids);
.eq(PrimaryStorageVO_.type, NfsPrimaryStorageConstant.NFS_PRIMARY_STORAGE_TYPE) .like(PrimaryStorageVO_.url, String.format("%s:/%%", hostIp)) .limit(1) .findValue(); if (psUuid == null || psUuid.equals("")) {
private void takeOverLongJob() { logger.debug("Starting to take over long jobs"); final int group = 1000; long amount = dbf.count(LongJobVO.class); int times = (int) ((amount + group - 1)/group); int start = 0; for (int i = 0; i < times; i++) { List<String> uuids = Q.New(LongJobVO.class) .select(LongJobVO_.uuid) .isNull(LongJobVO_.managementNodeUuid) .limit(group).start(start).listValues(); for (String uuid : uuids) { if (destinationMaker.isManagedByUs(uuid)) { retryTakeOverLongJob(uuid); } } start += group; } }
public void fireVolumeStatusChangedEvent(VolumeStatus oldStatus, VolumeInventory vol) { String accountUuid = null; boolean volumeAccountExists = Q.New(AccountResourceRefVO.class).eq(AccountResourceRefVO_.resourceUuid, vol.getUuid()).isExists(); if (volumeAccountExists) { accountUuid = Q.New(AccountResourceRefVO.class) .select(AccountResourceRefVO_.ownerAccountUuid) .eq(AccountResourceRefVO_.resourceUuid, vol.getUuid()).limit(1).findValue(); } VolumeCanonicalEvents.VolumeStatusChangedData d = new VolumeCanonicalEvents.VolumeStatusChangedData(); d.setInventory(vol); d.setDate(new Date()); d.setNewStatus(vol.getStatus()); d.setOldStatus(oldStatus == null ? null : oldStatus.toString()); d.setVolumeUuid(vol.getUuid()); d.setAccountUuid(accountUuid); evtf.fire(VolumeCanonicalEvents.VOLUME_STATUS_CHANGED_PATH, d); }
.notNull(VmNicVO_.metaData).limit(1).find(); if (rnic != null) { List<String> vrAttachedL3Uuids = Q.New(VmNicVO.class)
.eq(CephPrimaryStoragePoolVO_.primaryStorageUuid, primaryStorageUuid) .eq(CephPrimaryStoragePoolVO_.type, CephPrimaryStoragePoolType.Root.toString()) .limit(1) .findValue();
.eq(LoadBalancerListenerCertificateRefVO_.certificateUuid, msg.getCertificateUuid()).limit(1).find(); final LoadBalancerListenerCertificateRefVO original_ref = ref; if (ref == null) {
.eq(LoadBalancerListenerCertificateRefVO_.certificateUuid, msg.getCertificateUuid()).limit(1).find(); if (ref != null) { LoadBalancerListenerInventory inv = LoadBalancerListenerInventory.valueOf(dbf.findByUuid(msg.getListenerUuid(), LoadBalancerListenerVO.class));