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); } }
@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); }
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 void validate(APICreateL3NetworkMsg msg) { String type = Q.New(L2NetworkVO.class).select(L2NetworkVO_.type).eq(L2NetworkVO_.uuid, msg.getL2NetworkUuid()).findValue(); if (type.equals(VxlanNetworkPoolConstant.VXLAN_NETWORK_POOL_TYPE)) { throw new ApiMessageInterceptionException(Platform.err(SysErrors.INVALID_ARGUMENT_ERROR, String.format("vxlan network pool doesn't support create l3 network") )); } } }
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 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; }
protected String getDestMigrationAddress(String srcHostUuid, String dstHostUuid){ MigrateNetworkExtensionPoint.MigrateInfo migrateIpInfo = null; for (MigrateNetworkExtensionPoint ext: pluginRgty.getExtensionList(MigrateNetworkExtensionPoint.class)) { MigrateNetworkExtensionPoint.MigrateInfo r = ext.getMigrationAddressForVM(srcHostUuid, dstHostUuid); if (r == null) { continue; } migrateIpInfo = r; } return migrateIpInfo != null ? migrateIpInfo.dstMigrationAddress : Q.New(HostVO.class).eq(HostVO_.uuid, dstHostUuid).select(HostVO_.managementIp).findValue(); }
private void validate(APIUpdateCephPrimaryStoragePoolMsg msg) { String psUuid = Q.New(CephPrimaryStoragePoolVO.class) .select(CephPrimaryStoragePoolVO_.primaryStorageUuid) .eq(CephPrimaryStoragePoolVO_.uuid, msg.getUuid()) .findValue(); msg.setPrimaryStorageUuid(psUuid); }
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(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 setServiceId(GarbageCollectorMessage msg) { String mgmtUuid = Q.New(GarbageCollectorVO.class).select(GarbageCollectorVO_.managementNodeUuid) .eq(GarbageCollectorVO_.uuid, msg.getGCJobUuid()).findValue(); if (mgmtUuid != null) { bus.makeTargetServiceIdByResourceUuid((Message) msg, GCConstants.SERVICE_ID, mgmtUuid); } else { bus.makeLocalServiceId((Message) msg, GCConstants.SERVICE_ID); } } }
private void validate(APIChangeHostStateMsg msg){ HostStatus hostStatus = Q.New(HostVO.class) .select(HostVO_.status) .eq(HostVO_.uuid,msg.getHostUuid()) .findValue(); if (hostStatus != HostStatus.Connected && msg.getStateEvent().equals(HostStateEvent.maintain.toString())){ throw new ApiMessageInterceptionException(operr("can not maintain host[uuid:%s, status:%s]which is not Connected", msg.getHostUuid(), hostStatus)); } } }
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")); } }
private void validate(APICreateLoadBalancerListenerMsg msg){ String vipUuid = Q.New(LoadBalancerVO.class).eq(LoadBalancerVO_.uuid, msg.getLoadBalancerUuid()).select(LoadBalancerVO_.vipUuid).findValue(); RangeSet.Range cur = new RangeSet.Range(msg.getLoadBalancerPort(), msg.getLoadBalancerPort()); checkVipPortConfliction(vipUuid, msg.getProtocol(), cur); }
@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; } }
private void validate(APICreateEipMsg msg) { String useFor = Q.New(VipVO.class).select(VipVO_.useFor).eq(VipVO_.uuid, msg.getVipUuid()).findValue(); VipUseForList vipUseForList; if (useFor != null){ vipUseForList = new VipUseForList(useFor); } else { vipUseForList = new VipUseForList(); } if(!vipUseForList.validateNewAdded(EipConstant.EIP_NETWORK_SERVICE_TYPE)){ throw new ApiMessageInterceptionException(operr("the vip[uuid:%s] already has bound to other service[%s]", msg.getVipUuid(), vipUseForList.toString())); } }
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())); } } }