public static String getMemberKey(){ String ldapServerUuid = Q.New(LdapServerVO.class).select(LdapServerVO_.uuid).findValue(); String type = LdapSystemTags.LDAP_SERVER_TYPE.getTokenByResourceUuid(ldapServerUuid, LdapSystemTags.LDAP_SERVER_TYPE_TOKEN); if(LdapConstant.WindowsAD.TYPE.equals(type)){ return LdapConstant.WindowsAD.MEMBER_KEY; } if(LdapConstant.OpenLdap.TYPE.equals(type)){ return LdapConstant.OpenLdap.MEMBER_KEY; } // default WindowsAD return LdapConstant.WindowsAD.MEMBER_KEY; }
public static boolean isLocalStorage(String psUuid){ String psType = Q.New(PrimaryStorageVO.class) .select(PrimaryStorageVO_.type) .eq(PrimaryStorageVO_.uuid, psUuid) .findValue(); return LocalStorageConstants.LOCAL_STORAGE_TYPE.equals(psType); } }
private String getAvailableHostUuidForOperation() { List<String> hostUuids = Q.New(PrimaryStorageHostRefVO.class). eq(PrimaryStorageHostRefVO_.primaryStorageUuid, self.getUuid()).select(PrimaryStorageHostRefVO_.hostUuid).listValues(); if (hostUuids == null || hostUuids.size() == 0) { return null; } return hostUuids.get(0); }
public Tracker(String uuid) { super(TimeUnit.SECONDS, HostGlobalConfig.PING_HOST_INTERVAL.value(Long.class)); this.uuid = uuid; hypervisorType = Q.New(HostVO.class).select(HostVO_.hypervisorType) .eq(HostVO_.uuid, uuid).findValue(); if (hypervisorType == null) { throw new CloudRuntimeException(String.format("host[uuid:%s] is deleted, why you submit a tracker for it???", uuid)); } __name__ = String.format("host-tracker-%s-hypervisor-%s", uuid, hypervisorType); }
private List<String> getNeedRefreshSizeVolumeUuids(){ Set<String> volUuids = new HashSet<>(); for (RefreshVolumeSizeExtensionPoint ext : pluginRgty.getExtensionList(RefreshVolumeSizeExtensionPoint.class)) { volUuids.addAll(ext.getNeedRefreshVolumeSizeVolume()); } return volUuids.isEmpty() ? new ArrayList<>() : Q.New(VolumeVO.class).in(VolumeVO_.uuid, volUuids) .eq(VolumeVO_.state, VolumeState.Enabled) .eq(VolumeVO_.status, VolumeStatus.Ready) .select(VolumeVO_.uuid) .listValues(); } }
@Override public String getSyncSignature() { String vipUuid = Q.New(PortForwardingRuleVO.class).eq(PortForwardingRuleVO_.uuid, msg.getUuid()).select(PortForwardingRuleVO_.vipUuid).findValue(); return String.format("api-delete-portforwardingrule-vip-%s", vipUuid); }
@Transactional protected List<String> getAvoidHost(VmInstanceSpec spec){ return Q.New(PrimaryStorageHostRefVO.class).select(PrimaryStorageHostRefVO_.hostUuid) .eq(PrimaryStorageHostRefVO_.primaryStorageUuid, spec.getRequiredPrimaryStorageUuidForRootVolume()) .eq(PrimaryStorageHostRefVO_.status, PrimaryStorageHostStatus.Disconnected) .listValues(); }
@Transactional private List<String> getAvoidHost(VmInstanceSpec spec){ return Q.New(PrimaryStorageHostRefVO.class).select(PrimaryStorageHostRefVO_.hostUuid) .eq(PrimaryStorageHostRefVO_.primaryStorageUuid, spec.getRequiredPrimaryStorageUuidForRootVolume()) .eq(PrimaryStorageHostRefVO_.status, PrimaryStorageHostStatus.Disconnected) .listValues(); } }
public static String getLdapUseAsLoginName(){ String ldapServerUuid = Q.New(LdapServerVO.class).select(LdapServerVO_.uuid).findValue(); PatternedSystemTag tag = LdapSystemTags.LDAP_USE_AS_LOGIN_NAME; if(!tag.hasTag(ldapServerUuid)){ return LdapConstant.LDAP_UID_KEY; } return tag.getTokenByResourceUuid(ldapServerUuid, LdapSystemTags.LDAP_USE_AS_LOGIN_NAME_TOKEN); }
public static List<String> getIsoUuidByVmUuid(String vmUuid) { List<String> isoUuids = Q.New(VmCdRomVO.class) .select(VmCdRomVO_.isoUuid) .eq(VmCdRomVO_.vmInstanceUuid, vmUuid) .notNull(VmCdRomVO_.isoUuid) .listValues(); return isoUuids; }
public SystemTagInventory updateUnique(String resourceUuid, String oldTag, String newTag) { String tagUuid = Q.New(SystemTagVO.class).eq(SystemTagVO_.resourceUuid, resourceUuid). eq(SystemTagVO_.resourceType, resourceClass.getSimpleName()).like(SystemTagVO_.tag, oldTag). select(SystemTagVO_.uuid).findValue(); if (tagUuid == null) { return null; } return tagMgr.updateSystemTag(tagUuid, newTag); }
private void validate(APIDeleteCephPrimaryStoragePoolMsg msg) { msg.setPrimaryStorageUuid( Q.New(CephPrimaryStoragePoolVO.class).select(CephPrimaryStoragePoolVO_.primaryStorageUuid) .eq(CephPrimaryStoragePoolVO_.uuid, msg.getUuid()).findValue() ); }
private String getVipPeerL3NetworkAttachedVirtualRouter(VipInventory vip) { for (String l3Uuid : vip.getPeerL3NetworkUuids()) { String vrUuid = Q.New(VmNicVO.class).select(VmNicVO_.vmInstanceUuid).eq(VmNicVO_.l3NetworkUuid, l3Uuid).eq(VmNicVO_.metaData, GUEST_NIC_MASK).findValue(); if (vrUuid != null) { return vrUuid; } } return null; }
private void validate(APIDeleteLongJobMsg msg) { LongJobState state = Q.New(LongJobVO.class) .select(LongJobVO_.state) .eq(LongJobVO_.uuid, msg.getUuid()) .findValue(); if (state != LongJobState.Succeeded && state != LongJobState.Canceled && state != LongJobState.Failed) { throw new ApiMessageInterceptionException(argerr("delete longjob only when it's succeeded, canceled, or failed")); } }
private void validate(APIUpdateLoadBalancerListenerMsg msg) { String loadBalancerUuid = Q.New(LoadBalancerListenerVO.class). select(LoadBalancerListenerVO_.loadBalancerUuid). eq(LoadBalancerListenerVO_.uuid,msg. getLoadBalancerListenerUuid()).findValue(); msg.setLoadBalancerUuid(loadBalancerUuid); bus.makeTargetServiceIdByResourceUuid(msg, LoadBalancerConstants.SERVICE_ID, loadBalancerUuid); }
private void validate(final APIGetCandidatePrimaryStoragesForCreatingVmMsg msg) { ImageMediaType mediaType = Q.New(ImageVO.class).eq(ImageVO_.uuid, msg.getImageUuid()).select(ImageVO_.mediaType).findValue(); if (ImageMediaType.ISO == mediaType && msg.getRootDiskOfferingUuid() == null) { throw new ApiMessageInterceptionException(argerr("rootVolumeOffering is needed when image media type is ISO")); } }
@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();
@Override public Result getMessageParams(APIMessage message) { APILogInByAccountMsg msg = (APILogInByAccountMsg) message; String resourceIdentity = Q.New(AccountVO.class).select(AccountVO_.uuid).eq(AccountVO_.name, msg.getAccountName()).findValue(); Result r = new Result(); r.setCaptchaUuid(msg.getCaptchaUuid()); r.setTargetResourceIdentity(resourceIdentity); r.setVerifyCode(msg.getVerifyCode()); return r; } }
@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();
private void validate(APIGetEipAttachableVmNicsMsg msg) { if (msg.getVipUuid() == null && msg.getEipUuid() == null) { throw new ApiMessageInterceptionException(argerr("either eipUuid or vipUuid must be set")); } if (msg.getEipUuid() != null) { EipState state = Q.New(EipVO.class).select(EipVO_.state).eq(EipVO_.uuid,msg.getEipUuid()).findValue(); if (state != EipState.Enabled) { throw new ApiMessageInterceptionException(operr("eip[uuid:%s] is not in state of Enabled, cannot get attachable vm nic", msg.getEipUuid())); } } }