You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2026/10/22 09:39:32 UTC

(cloudstack) branch ghi10752-config-account created (now f3c9b5158dc)

This is an automated email from the ASF dual-hosted git repository.

DaanHoogland pushed a change to branch ghi10752-config-account
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


      at f3c9b5158dc use ConfigKeys for account, domain, project and SSO settings

This branch includes the following new commits:

     new f3c9b5158dc use ConfigKeys for account, domain, project and SSO settings

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(cloudstack) 01/01: use ConfigKeys for account, domain, project and SSO settings

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

DaanHoogland pushed a commit to branch ghi10752-config-account
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit f3c9b5158dcc066fd016ee53de487749189e69ed
Author: Daan Hoogland <da...@apache.org>
AuthorDate: Thu Oct 22 11:35:30 2026 +0200

    use ConfigKeys for account, domain, project and SSO settings
    
    Part of the split of #13884 (phase out the Config enum, #10752).
    
    Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
---
 .../com/cloud/projects/ProjectManagerImpl.java     | 12 +--
 .../resourcelimit/ResourceLimitManagerImpl.java    | 91 +++++++++++-----------
 .../com/cloud/server/ConfigurationServerImpl.java  | 11 ++-
 .../java/com/cloud/user/AccountManagerImpl.java    |  2 +-
 4 files changed, 60 insertions(+), 56 deletions(-)

diff --git a/server/src/main/java/com/cloud/projects/ProjectManagerImpl.java b/server/src/main/java/com/cloud/projects/ProjectManagerImpl.java
index fe9a919acb6..bf36a21a535 100644
--- a/server/src/main/java/com/cloud/projects/ProjectManagerImpl.java
+++ b/server/src/main/java/com/cloud/projects/ProjectManagerImpl.java
@@ -53,7 +53,6 @@ import org.apache.cloudstack.utils.mailing.MailAddress;
 import org.apache.cloudstack.utils.mailing.SMTPMailProperties;
 import org.apache.cloudstack.utils.mailing.SMTPMailSender;
 import org.apache.cloudstack.webhook.WebhookHelper;
-import org.apache.commons.lang3.BooleanUtils;
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
 import org.springframework.stereotype.Component;
 
@@ -61,7 +60,6 @@ import com.cloud.api.ApiDBUtils;
 import com.cloud.api.query.dao.ProjectAccountJoinDao;
 import com.cloud.api.query.dao.ProjectInvitationJoinDao;
 import com.cloud.api.query.dao.ProjectJoinDao;
-import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.domain.DomainVO;
@@ -187,12 +185,10 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager, C
     public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
 
         Map<String, String> configs = _configDao.getConfiguration(params);
-        _invitationRequired = BooleanUtils.toBoolean(configs.get(Config.ProjectInviteRequired.key()));
-
-        String value = configs.get(Config.ProjectInvitationExpirationTime.key());
-        _invitationTimeOut = Long.parseLong(value != null ? value : "86400") * 1000;
-        _allowUserToCreateProject = BooleanUtils.toBoolean(configs.get(Config.AllowUserToCreateProject.key()));
-        senderAddress = configs.get("project.email.sender");
+        _invitationRequired = ProjectInviteRequired.value();
+        _invitationTimeOut = ProjectInvitationExpirationTime.value() * 1000;
+        _allowUserToCreateProject = AllowUserToCreateProject.value();
+        senderAddress = ProjectEmailSender.value();
 
         String namespace = "project.smtp";
 
diff --git a/server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java b/server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
index 385d2b30a50..4321e634d03 100644
--- a/server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
+++ b/server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
@@ -72,7 +72,6 @@ import com.cloud.api.query.dao.UserVmJoinDao;
 import com.cloud.api.query.vo.UserVmJoinVO;
 import com.cloud.cluster.ManagementServerHostVO;
 import com.cloud.cluster.dao.ManagementServerHostDao;
-import com.cloud.configuration.Config;
 import com.cloud.configuration.Resource;
 import com.cloud.configuration.Resource.ResourceOwnerType;
 import com.cloud.configuration.Resource.ResourceType;
@@ -295,58 +294,58 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
         }
 
         try {
-            projectResourceLimitMap.put(Resource.ResourceType.public_ip.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectPublicIPs.key())));
-            projectResourceLimitMap.put(Resource.ResourceType.snapshot.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectSnapshots.key())));
-            projectResourceLimitMap.put(Resource.ResourceType.template.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectTemplates.key())));
-            projectResourceLimitMap.put(Resource.ResourceType.user_vm.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectUserVms.key())));
-            projectResourceLimitMap.put(Resource.ResourceType.volume.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectVolumes.key())));
-            projectResourceLimitMap.put(Resource.ResourceType.network.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectNetworks.key())));
-            projectResourceLimitMap.put(Resource.ResourceType.vpc.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectVpcs.key())));
-            projectResourceLimitMap.put(Resource.ResourceType.cpu.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectCpus.key())));
-            projectResourceLimitMap.put(Resource.ResourceType.memory.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectMemory.key())));
+            projectResourceLimitMap.put(Resource.ResourceType.public_ip.name(), DefaultMaxProjectPublicIPs.value());
+            projectResourceLimitMap.put(Resource.ResourceType.snapshot.name(), DefaultMaxProjectSnapshots.value());
+            projectResourceLimitMap.put(Resource.ResourceType.template.name(), DefaultMaxProjectTemplates.value());
+            projectResourceLimitMap.put(Resource.ResourceType.user_vm.name(), DefaultMaxProjectUserVms.value());
+            projectResourceLimitMap.put(Resource.ResourceType.volume.name(), DefaultMaxProjectVolumes.value());
+            projectResourceLimitMap.put(Resource.ResourceType.network.name(), DefaultMaxProjectNetworks.value());
+            projectResourceLimitMap.put(Resource.ResourceType.vpc.name(), DefaultMaxProjectVpcs.value());
+            projectResourceLimitMap.put(Resource.ResourceType.cpu.name(), DefaultMaxProjectCpus.value());
+            projectResourceLimitMap.put(Resource.ResourceType.memory.name(), DefaultMaxProjectMemory.value());
             projectResourceLimitMap.put(Resource.ResourceType.gpu.name(), DefaultMaxProjectGpus.value());
-            projectResourceLimitMap.put(Resource.ResourceType.primary_storage.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectPrimaryStorage.key())));
+            projectResourceLimitMap.put(Resource.ResourceType.primary_storage.name(), DefaultMaxProjectPrimaryStorage.value());
             projectResourceLimitMap.put(Resource.ResourceType.secondary_storage.name(), MaxProjectSecondaryStorage.value());
-            projectResourceLimitMap.put(Resource.ResourceType.backup.name(), Long.parseLong(_configDao.getValue(BackupManager.DefaultMaxProjectBackups.key())));
-            projectResourceLimitMap.put(Resource.ResourceType.backup_storage.name(), Long.parseLong(_configDao.getValue(BackupManager.DefaultMaxProjectBackupStorage.key())));
-            projectResourceLimitMap.put(Resource.ResourceType.bucket.name(), Long.parseLong(_configDao.getValue(BucketApiService.DefaultMaxProjectBuckets.key())));
-            projectResourceLimitMap.put(Resource.ResourceType.object_storage.name(), Long.parseLong(_configDao.getValue(BucketApiService.DefaultMaxProjectObjectStorage.key())));
-
-            accountResourceLimitMap.put(Resource.ResourceType.public_ip.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountPublicIPs.key())));
-            accountResourceLimitMap.put(Resource.ResourceType.snapshot.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountSnapshots.key())));
-            accountResourceLimitMap.put(Resource.ResourceType.template.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountTemplates.key())));
-            accountResourceLimitMap.put(Resource.ResourceType.user_vm.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountUserVms.key())));
-            accountResourceLimitMap.put(Resource.ResourceType.volume.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountVolumes.key())));
-            accountResourceLimitMap.put(Resource.ResourceType.network.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountNetworks.key())));
-            accountResourceLimitMap.put(Resource.ResourceType.vpc.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountVpcs.key())));
-            accountResourceLimitMap.put(Resource.ResourceType.cpu.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountCpus.key())));
-            accountResourceLimitMap.put(Resource.ResourceType.memory.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountMemory.key())));
+            projectResourceLimitMap.put(Resource.ResourceType.backup.name(), BackupManager.DefaultMaxProjectBackups.value());
+            projectResourceLimitMap.put(Resource.ResourceType.backup_storage.name(), BackupManager.DefaultMaxProjectBackupStorage.value());
+            projectResourceLimitMap.put(Resource.ResourceType.bucket.name(), BucketApiService.DefaultMaxProjectBuckets.value());
+            projectResourceLimitMap.put(Resource.ResourceType.object_storage.name(), BucketApiService.DefaultMaxProjectObjectStorage.value());
+
+            accountResourceLimitMap.put(Resource.ResourceType.public_ip.name(), DefaultMaxAccountPublicIPs.value());
+            accountResourceLimitMap.put(Resource.ResourceType.snapshot.name(), DefaultMaxAccountSnapshots.value());
+            accountResourceLimitMap.put(Resource.ResourceType.template.name(), DefaultMaxAccountTemplates.value());
+            accountResourceLimitMap.put(Resource.ResourceType.user_vm.name(), DefaultMaxAccountUserVms.value());
+            accountResourceLimitMap.put(Resource.ResourceType.volume.name(), DefaultMaxAccountVolumes.value());
+            accountResourceLimitMap.put(Resource.ResourceType.network.name(), DefaultMaxAccountNetworks.value());
+            accountResourceLimitMap.put(Resource.ResourceType.vpc.name(), DefaultMaxAccountVpcs.value());
+            accountResourceLimitMap.put(Resource.ResourceType.cpu.name(), DefaultMaxAccountCpus.value());
+            accountResourceLimitMap.put(Resource.ResourceType.memory.name(), DefaultMaxAccountMemory.value());
             accountResourceLimitMap.put(Resource.ResourceType.gpu.name(), DefaultMaxAccountGpus.value());
-            accountResourceLimitMap.put(Resource.ResourceType.primary_storage.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountPrimaryStorage.key())));
+            accountResourceLimitMap.put(Resource.ResourceType.primary_storage.name(), DefaultMaxAccountPrimaryStorage.value());
             accountResourceLimitMap.put(Resource.ResourceType.secondary_storage.name(), MaxAccountSecondaryStorage.value());
             accountResourceLimitMap.put(Resource.ResourceType.project.name(), DefaultMaxAccountProjects.value());
-            accountResourceLimitMap.put(Resource.ResourceType.backup.name(), Long.parseLong(_configDao.getValue(BackupManager.DefaultMaxAccountBackups.key())));
-            accountResourceLimitMap.put(Resource.ResourceType.backup_storage.name(), Long.parseLong(_configDao.getValue(BackupManager.DefaultMaxAccountBackupStorage.key())));
-            accountResourceLimitMap.put(Resource.ResourceType.bucket.name(), Long.parseLong(_configDao.getValue(BucketApiService.DefaultMaxAccountBuckets.key())));
-            accountResourceLimitMap.put(Resource.ResourceType.object_storage.name(), Long.parseLong(_configDao.getValue(BucketApiService.DefaultMaxAccountObjectStorage.key())));
-
-            domainResourceLimitMap.put(Resource.ResourceType.public_ip.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainPublicIPs.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.snapshot.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainSnapshots.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.template.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainTemplates.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.user_vm.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainUserVms.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.volume.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainVolumes.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.network.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainNetworks.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.vpc.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainVpcs.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.cpu.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainCpus.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.memory.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainMemory.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.primary_storage.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainPrimaryStorage.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.secondary_storage.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainSecondaryStorage.key())));
+            accountResourceLimitMap.put(Resource.ResourceType.backup.name(), BackupManager.DefaultMaxAccountBackups.value());
+            accountResourceLimitMap.put(Resource.ResourceType.backup_storage.name(), BackupManager.DefaultMaxAccountBackupStorage.value());
+            accountResourceLimitMap.put(Resource.ResourceType.bucket.name(), BucketApiService.DefaultMaxAccountBuckets.value());
+            accountResourceLimitMap.put(Resource.ResourceType.object_storage.name(), BucketApiService.DefaultMaxAccountObjectStorage.value());
+
+            domainResourceLimitMap.put(Resource.ResourceType.public_ip.name(), DefaultMaxDomainPublicIPs.value());
+            domainResourceLimitMap.put(Resource.ResourceType.snapshot.name(), DefaultMaxDomainSnapshots.value());
+            domainResourceLimitMap.put(Resource.ResourceType.template.name(), DefaultMaxDomainTemplates.value());
+            domainResourceLimitMap.put(Resource.ResourceType.user_vm.name(), DefaultMaxDomainUserVms.value());
+            domainResourceLimitMap.put(Resource.ResourceType.volume.name(), DefaultMaxDomainVolumes.value());
+            domainResourceLimitMap.put(Resource.ResourceType.network.name(), DefaultMaxDomainNetworks.value());
+            domainResourceLimitMap.put(Resource.ResourceType.vpc.name(), DefaultMaxDomainVpcs.value());
+            domainResourceLimitMap.put(Resource.ResourceType.cpu.name(), DefaultMaxDomainCpus.value());
+            domainResourceLimitMap.put(Resource.ResourceType.memory.name(), DefaultMaxDomainMemory.value());
+            domainResourceLimitMap.put(Resource.ResourceType.primary_storage.name(), DefaultMaxDomainPrimaryStorage.value());
+            domainResourceLimitMap.put(Resource.ResourceType.secondary_storage.name(), DefaultMaxDomainSecondaryStorage.value());
             domainResourceLimitMap.put(Resource.ResourceType.project.name(), DefaultMaxDomainProjects.value());
             domainResourceLimitMap.put(Resource.ResourceType.gpu.name(), DefaultMaxDomainGpus.value());
-            domainResourceLimitMap.put(Resource.ResourceType.backup.name(), Long.parseLong(_configDao.getValue(BackupManager.DefaultMaxDomainBackups.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.backup_storage.name(), Long.parseLong(_configDao.getValue(BackupManager.DefaultMaxDomainBackupStorage.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.bucket.name(), Long.parseLong(_configDao.getValue(BucketApiService.DefaultMaxDomainBuckets.key())));
-            domainResourceLimitMap.put(Resource.ResourceType.object_storage.name(), Long.parseLong(_configDao.getValue(BucketApiService.DefaultMaxDomainObjectStorage.key())));
+            domainResourceLimitMap.put(Resource.ResourceType.backup.name(), BackupManager.DefaultMaxDomainBackups.value());
+            domainResourceLimitMap.put(Resource.ResourceType.backup_storage.name(), BackupManager.DefaultMaxDomainBackupStorage.value());
+            domainResourceLimitMap.put(Resource.ResourceType.bucket.name(), BucketApiService.DefaultMaxDomainBuckets.value());
+            domainResourceLimitMap.put(Resource.ResourceType.object_storage.name(), BucketApiService.DefaultMaxDomainObjectStorage.value());
         } catch (NumberFormatException e) {
             logger.error("NumberFormatException during configuration", e);
             throw new ConfigurationException("Configuration failed due to NumberFormatException, see log for the stacktrace");
diff --git a/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java b/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java
index 1f48967b253..bd5a78134a4 100644
--- a/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java
+++ b/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java
@@ -94,6 +94,7 @@ import com.cloud.storage.Storage.ProvisioningType;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.test.IPRangeConfig;
 import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
 import com.cloud.user.AccountVO;
 import com.cloud.user.User;
 import com.cloud.user.dao.AccountDao;
@@ -820,7 +821,15 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
 
     private void updateSSOKey() {
         try {
-            _configDao.update(Config.SSOKey.key(), Config.SSOKey.getCategory(), getPrivateKey());
+            String key = getPrivateKey();
+            ConfigurationVO configInDB = _configDao.findByName(AccountManager.SSOKey.key());
+            if (configInDB == null) {
+                ConfigurationVO configVO = new ConfigurationVO(AccountManager.class.getSimpleName(), AccountManager.SSOKey);
+                configVO.setValue(key);
+                _configDao.persist(configVO);
+            } else {
+                _configDao.update(AccountManager.SSOKey.key(), AccountManager.SSOKey.category(), key);
+            }
         } catch (NoSuchAlgorithmException ex) {
             logger.error("error generating sso key", ex);
         }
diff --git a/server/src/main/java/com/cloud/user/AccountManagerImpl.java b/server/src/main/java/com/cloud/user/AccountManagerImpl.java
index 18994b79677..70e566bb80c 100644
--- a/server/src/main/java/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/main/java/com/cloud/user/AccountManagerImpl.java
@@ -3184,7 +3184,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
     }
 
     private UserAccount getUserAccountForSSO(String username, Long domainId, Map<String, Object[]> requestParameters) {
-        String key = _configDao.getValue("security.singlesignon.key");
+        String key = SSOKey.value();
         if (key == null) {
             // the SSO key is gone, don't authenticate
             return null;