public static SessionInventory getSession(String uuid) { SessionInventory s = sessions.get(uuid); if (s == null) { SessionVO vo = Q.New(SessionVO.class).eq(SessionVO_.uuid, uuid).find(); if (vo == null) { return null; } s = SessionInventory.valueOf(vo); sessions.put(s.getUuid(), s); } return s; } }
@Override public Integer getL2NetworkVni(String l2NetworkUuid) { VxlanNetworkVO vxlanNetworkVO = Q.New(VxlanNetworkVO.class).eq(VxlanNetworkVO_.uuid, l2NetworkUuid).find(); return vxlanNetworkVO.getVni(); }
@Override public LdapAccountRefVO findLdapAccountRefVO(String ldapDn){ LdapAccountRefVO ldapAccountRefVO = Q.New(LdapAccountRefVO.class) .eq(LdapAccountRefVO_.ldapUid, ldapDn).find(); if(ldapAccountRefVO != null){ return ldapAccountRefVO; } ldapAccountRefVO = findLdapAccountRefByAffiliatedGroup(ldapDn); return ldapAccountRefVO; }
@Override public Integer getL2NetworkVni(String l2NetworkUuid) { L2VlanNetworkVO l2VlanNetworkVO = Q.New(L2VlanNetworkVO.class).eq(L2VlanNetworkVO_.uuid, l2NetworkUuid).find(); return l2VlanNetworkVO.getVlan(); }
private Boolean isCephPrimaryStorageVolume(String volumeUuid) { VolumeVO volumeVO = Q.New(VolumeVO.class).eq(VolumeVO_.uuid, volumeUuid).find(); PrimaryStorageVO primaryStorageVO = Q.New(PrimaryStorageVO.class) .eq(PrimaryStorageVO_.uuid, volumeVO.getPrimaryStorageUuid()).find(); return primaryStorageVO.getType().equals(type.toString()); } }
public static Integer getIsoDeviceId(String vmUuid, String isoUuid) { VmCdRomVO vmCdRomVO = Q.New(VmCdRomVO.class) .eq(VmCdRomVO_.vmInstanceUuid, vmUuid) .eq(VmCdRomVO_.isoUuid, isoUuid) .find(); if (vmCdRomVO == null) { return null; } return vmCdRomVO.getDeviceId(); }
private LdapTemplateContextSource readLdapServerConfiguration() { LdapServerVO ldapServerVO = Q.New(LdapServerVO.class).find(); LdapServerInventory ldapServerInventory = LdapServerInventory.valueOf(ldapServerVO); return new LdapUtil().loadLdap(ldapServerInventory); }
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; }
@Override protected void scripts() { if(Q.New(CephPrimaryStorageVO.class).eq(CephPrimaryStorageVO_.fsid, fsid).find() == null){ SQL.New(CephCapacityVO.class).eq(CephCapacityVO_.fsid, fsid).delete(); } } }.execute();
private void validate(APIAttachL3NetworkToVmMsg msg) { VmInstanceVO vmInstanceVO = Q.New(VmInstanceVO.class).eq(VmInstanceVO_.uuid, msg.getVmInstanceUuid()).find(); if (vmInstanceVO.getType().equals(ApplianceVmConstant.APPLIANCE_VM_TYPE)){ validateIpRangeOverlapWithVm(msg.getL3NetworkUuid(), msg.getVmInstanceUuid()); } }
@Override public SessionInventory doAuth(RestAuthenticationParams params) throws RestException { SessionVO vo = Q.New(SessionVO.class).eq(SessionVO_.uuid, params.authKey).find(); if (vo != null) { return SessionInventory.valueOf(vo); } /* invalid session error should be raised in ApiMessageProcessorImpl */ SessionInventory session = new SessionInventory(); session.setUuid(params.authKey); return session; } }
private void validate(APIDeleteVniRangeMsg msg) { VniRangeVO vo = Q.New(VniRangeVO.class).eq(VniRangeVO_.uuid, msg.getUuid()).find(); msg.setL2NetworkUuid(vo.getL2NetworkUuid()); }
@Override public void deleteSystemTag(String uuid) { SystemTagVO vo = Q.New(SystemTagVO.class).eq(SystemTagVO_.uuid, uuid).find(); if (vo == null) { return; } preTagDeleted(SystemTagInventory.valueOf(vo)); dbf.remove(vo); fireTagDeleted(Collections.singletonList(SystemTagInventory.valueOf(vo))); }
private void validate(APIUpdateVniRangeMsg msg) { VniRangeVO vo = Q.New(VniRangeVO.class).eq(VniRangeVO_.uuid, msg.getUuid()).find(); msg.setL2NetworkUuid(vo.getL2NetworkUuid()); }
private void validate(APICreateL2VxlanNetworkMsg msg) { VxlanNetworkPoolVO vo = Q.New(VxlanNetworkPoolVO.class).eq(VxlanNetworkPoolVO_.uuid, msg.getPoolUuid()).find(); if (msg.getZoneUuid() != null && !msg.getZoneUuid().equals(vo.getZoneUuid())) { throw new ApiMessageInterceptionException(Platform.err(SysErrors.INVALID_ARGUMENT_ERROR, String.format("the zone uuid provided not equals to zone uuid of pool [%s], please correct it or do not fill it", msg.getPoolUuid()) )); } else if (msg.getZoneUuid() == null ) { msg.setZoneUuid(vo.getZoneUuid()); } }
private IpAllocatorType getIpAllocatorType(AllocateIpMsg msg) { if (msg.getAllocatorStrategy() != null) { return IpAllocatorType.valueOf(msg.getAllocatorStrategy()); } L3NetworkVO l3Vo = Q.New(L3NetworkVO.class).eq(L3NetworkVO_.uuid, msg.getL3NetworkUuid()).find(); if (l3Vo.getIpVersion() == IPv6Constants.IPv4) { return RandomIpAllocatorStrategy.type; } return RandomIpv6AllocatorStrategy.type; }
@Override public StorageTrashSpec getTrash(String storageUuid, Long trashId) { JsonLabelVO lable = Q.New(JsonLabelVO.class).eq(JsonLabelVO_.resourceUuid, storageUuid).eq(JsonLabelVO_.id, trashId).find(); if (lable == null) { return null; } StorageTrashSpec spec = JSONObjectUtil.toObject(lable.getLabelValue(), StorageTrashSpec.class); spec.setTrashId(trashId); spec.setCreateDate(lable.getCreateDate()); if (spec.getTrashType() == null) { spec.setTrashType(lable.getLabelKey().split("-")[0]); } return spec; }
@Override protected void scripts() { if (!q(LdapServerVO.class).eq(LdapServerVO_.uuid, msg.getUuid()).isExists()) { return; } LdapServerVO vo = q(LdapServerVO.class).eq(LdapServerVO_.uuid, msg.getUuid()).find(); remove(vo); flush(); } }.execute();
private void handle(final APIUpdateVniRangeMsg msg) { VniRangeVO vo = Q.New(VniRangeVO.class).eq(VniRangeVO_.uuid, msg.getUuid()).find(); vo.setName(msg.getName()); vo = dbf.updateAndRefresh(vo); APIUpdateVniRangeEvent event = new APIUpdateVniRangeEvent(msg.getId()); event.setInventory(new VniRangeInventory(vo)); bus.publish(event); logger.info(String.format("update l2 vxlan vni range[%s] name[%s]", msg.getUuid(), msg.getName())); }
@Override public void success() { logger.debug(String.format("successfully acquired vip[uuid:%s, name:%s, ip:%s] on service[%s]", self.getUuid(), self.getName(), self.getIp(), s.getServiceProvider())); VipUseForList useForList = new VipUseForList(self.getUseFor()); useForList.add(s.getUseFor()); VipVO vo = Q.New(VipVO.class).eq(VipVO_.uuid, self.getUuid()).find(); vo.setUseFor(useForList.toString()); dbf.updateAndRefresh(vo); addPeerL3NetworkUuid(s.getPeerL3NetworkUuid()); completion.success(); }