This is an automated email from the ASF dual-hosted git repository. DaanHoogland pushed a commit to branch ghi10752-configCleanup in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 01a89937f74db21cd0e907dded0c81df42cba2b0 Author: Daan Hoogland <[email protected]> AuthorDate: Sat Aug 15 10:10:28 2026 +0200 move project related configuration items from deprecated Config enum to services --- .../java/com/cloud/user/ResourceLimitService.java | 21 ++++ .../main/java/com/cloud/configuration/Config.java | 140 --------------------- .../java/com/cloud/projects/ProjectManager.java | 32 +++++ .../com/cloud/projects/ProjectManagerImpl.java | 16 ++- .../resourcelimit/ResourceLimitManagerImpl.java | 33 +++-- 5 files changed, 81 insertions(+), 161 deletions(-) diff --git a/api/src/main/java/com/cloud/user/ResourceLimitService.java b/api/src/main/java/com/cloud/user/ResourceLimitService.java index ad3d304571c..e46e198f877 100644 --- a/api/src/main/java/com/cloud/user/ResourceLimitService.java +++ b/api/src/main/java/com/cloud/user/ResourceLimitService.java @@ -102,6 +102,27 @@ public interface ResourceLimitService { static final ConfigKey<Long> DefaultMaxDomainSecondaryStorage = new ConfigKey<>("Domain Defaults", Long.class, "max.domain.secondary.storage", "800", "The default maximum secondary storage space (in GiB) that can be used for a domain", false); + static final ConfigKey<Long> DefaultMaxProjectUserVms = new ConfigKey<>("Project Defaults", Long.class, "max.project.user.vms", "20", + "The default maximum number of user VMs that can be deployed for a project", false); + static final ConfigKey<Long> DefaultMaxProjectPublicIPs = new ConfigKey<>("Project Defaults", Long.class, "max.project.public.ips", "20", + "The default maximum number of public IPs that can be consumed by a project", false); + static final ConfigKey<Long> DefaultMaxProjectTemplates = new ConfigKey<>("Project Defaults", Long.class, "max.project.templates", "20", + "The default maximum number of Templates that can be deployed for a project", false); + static final ConfigKey<Long> DefaultMaxProjectSnapshots = new ConfigKey<>("Project Defaults", Long.class, "max.project.snapshots", "20", + "The default maximum number of snapshots that can be created for a project", false); + static final ConfigKey<Long> DefaultMaxProjectVolumes = new ConfigKey<>("Project Defaults", Long.class, "max.project.volumes", "20", + "The default maximum number of volumes that can be created for a project", false); + static final ConfigKey<Long> DefaultMaxProjectNetworks = new ConfigKey<>("Project Defaults", Long.class, "max.project.networks", "20", + "The default maximum number of networks that can be created for a project", false); + static final ConfigKey<Long> DefaultMaxProjectVpcs = new ConfigKey<>("Project Defaults", Long.class, "max.project.vpcs", "20", + "The default maximum number of vpcs that can be created for a project", false); + static final ConfigKey<Long> DefaultMaxProjectCpus = new ConfigKey<>("Project Defaults", Long.class, "max.project.cpus", "40", + "The default maximum number of cpu cores that can be used for a project", false); + static final ConfigKey<Long> DefaultMaxProjectMemory = new ConfigKey<>("Project Defaults", Long.class, "max.project.memory", "40960", + "The default maximum memory (in MB) that can be used for a project", false); + static final ConfigKey<Long> DefaultMaxProjectPrimaryStorage = new ConfigKey<>("Project Defaults", Long.class, "max.project.primary.storage", "200", + "The default maximum primary storage space (in GiB) that can be used for a project", false); + static final List<ResourceType> HostTagsSupportingTypes = List.of(ResourceType.user_vm, ResourceType.cpu, ResourceType.memory, ResourceType.gpu); static final List<ResourceType> StorageTagsSupportingTypes = List.of(ResourceType.volume, ResourceType.primary_storage); diff --git a/server/src/main/java/com/cloud/configuration/Config.java b/server/src/main/java/com/cloud/configuration/Config.java index 0b0d388a11d..455d06858ca 100644 --- a/server/src/main/java/com/cloud/configuration/Config.java +++ b/server/src/main/java/com/cloud/configuration/Config.java @@ -851,146 +851,6 @@ public enum Config { "Percentage (as a value between 0 and 1) of connected agents after which agent load balancing will start happening", null), - DefaultMaxProjectUserVms( - "Project Defaults", - ManagementServer.class, - Long.class, - "max.project.user.vms", - "20", - "The default maximum number of user VMs that can be deployed for a project", - null), - DefaultMaxProjectPublicIPs( - "Project Defaults", - ManagementServer.class, - Long.class, - "max.project.public.ips", - "20", - "The default maximum number of public IPs that can be consumed by a project", - null), - DefaultMaxProjectTemplates( - "Project Defaults", - ManagementServer.class, - Long.class, - "max.project.templates", - "20", - "The default maximum number of Templates that can be deployed for a project", - null), - DefaultMaxProjectSnapshots( - "Project Defaults", - ManagementServer.class, - Long.class, - "max.project.snapshots", - "20", - "The default maximum number of snapshots that can be created for a project", - null), - DefaultMaxProjectVolumes( - "Project Defaults", - ManagementServer.class, - Long.class, - "max.project.volumes", - "20", - "The default maximum number of volumes that can be created for a project", - null), - DefaultMaxProjectNetworks( - "Project Defaults", - ManagementServer.class, - Long.class, - "max.project.networks", - "20", - "The default maximum number of networks that can be created for a project", - null), - DefaultMaxProjectVpcs( - "Project Defaults", - ManagementServer.class, - Long.class, - "max.project.vpcs", - "20", - "The default maximum number of vpcs that can be created for a project", - null), - DefaultMaxProjectCpus( - "Project Defaults", - ManagementServer.class, - Long.class, - "max.project.cpus", - "40", - "The default maximum number of cpu cores that can be used for a project", - null), - DefaultMaxProjectMemory( - "Project Defaults", - ManagementServer.class, - Long.class, - "max.project.memory", - "40960", - "The default maximum memory (in MB) that can be used for a project", - null), - DefaultMaxProjectPrimaryStorage( - "Project Defaults", - ManagementServer.class, - Long.class, - "max.project.primary.storage", - "200", - "The default maximum primary storage space (in GiB) that can be used for an project", - null), - - ProjectInviteRequired( - "Project Defaults", - ManagementServer.class, - Boolean.class, - "project.invite.required", - "false", - "If invitation confirmation is required when add account to project. Default value is false", - null), - ProjectInvitationExpirationTime( - "Project Defaults", - ManagementServer.class, - Long.class, - "project.invite.timeout", - "86400", - "Invitation expiration time (in seconds). Default is 1 day - 86400 seconds", - null), - AllowUserToCreateProject( - "Project Defaults", - ManagementServer.class, - Boolean.class, - "allow.user.create.projects", - "true", - "If regular user can create a project; true by default", - null), - - ProjectEmailSender( - "Project Defaults", - ManagementServer.class, - String.class, - "project.email.sender", - null, - "Sender of project invitation email (will be in the From header of the email)", - null), - ProjectSMTPHost( - "Project Defaults", - ManagementServer.class, - String.class, - "project.smtp.host", - null, - "SMTP hostname used for sending out email project invitations", - null), - ProjectSMTPPassword( - "Secure", - ManagementServer.class, - String.class, - "project.smtp.password", - null, - "Password for SMTP authentication (applies only if project.smtp.useAuth is true)", - null), - ProjectSMTPPort("Project Defaults", ManagementServer.class, Integer.class, "project.smtp.port", "465", "Port the SMTP server is listening on", null), - ProjectSMTPUsername( - "Project Defaults", - ManagementServer.class, - String.class, - "project.smtp.username", - null, - "Username for SMTP authentication (applies only if project.smtp.useAuth is true)", - null), - DefaultExternalLoadBalancerCapacity( "Advanced", ManagementServer.class, diff --git a/server/src/main/java/com/cloud/projects/ProjectManager.java b/server/src/main/java/com/cloud/projects/ProjectManager.java index 5f58205208b..d24746b213f 100644 --- a/server/src/main/java/com/cloud/projects/ProjectManager.java +++ b/server/src/main/java/com/cloud/projects/ProjectManager.java @@ -31,6 +31,38 @@ public interface ProjectManager extends ProjectService { public static final ConfigKey<Boolean> ProjectSmtpUseAuth = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, Boolean.class, "project.smtp.useAuth", "false", "If true, use SMTP authentication when sending emails", false, ConfigKey.Scope.ManagementServer); + ConfigKey<Boolean> ProjectInviteRequired = new ConfigKey<>("Project Defaults", Boolean.class, + "project.invite.required", "false", + "If invitation confirmation is required when add account to project. Default value is false", true); + + ConfigKey<Long> ProjectInvitationExpirationTime = new ConfigKey<>("Project Defaults", Long.class, + "project.invite.timeout", "86400", + "Invitation expiration time (in seconds). Default is 1 day - 86400 seconds", true); + + ConfigKey<Boolean> AllowUserToCreateProject = new ConfigKey<>("Project Defaults", Boolean.class, + "allow.user.create.projects", "true", + "If regular user can create a project; true by default", true); + + ConfigKey<String> ProjectEmailSender = new ConfigKey<>("Project Defaults", String.class, + "project.email.sender", null, + "Sender of project invitation email (will be in the From header of the email)", true); + + ConfigKey<String> ProjectSMTPHost = new ConfigKey<>("Project Defaults", String.class, + "project.smtp.host", null, + "SMTP hostname used for sending out email project invitations", true); + + ConfigKey<Integer> ProjectSMTPPort = new ConfigKey<>("Project Defaults", Integer.class, + "project.smtp.port", "465", + "Port the SMTP server is listening on", true); + + ConfigKey<String> ProjectSMTPUsername = new ConfigKey<>("Project Defaults", String.class, + "project.smtp.username", null, + "Username for SMTP authentication (applies only if project.smtp.useAuth is true)", true); + + ConfigKey<String> ProjectSMTPPassword = new ConfigKey<>("Secure", String.class, + "project.smtp.password", null, + "Password for SMTP authentication (applies only if project.smtp.useAuth is true)", true); + boolean canAccessProjectAccount(Account caller, long accountId); boolean canModifyProjectAccount(Account caller, long accountId); diff --git a/server/src/main/java/com/cloud/projects/ProjectManagerImpl.java b/server/src/main/java/com/cloud/projects/ProjectManagerImpl.java index 92af441d06b..226abda5819 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"; @@ -1475,7 +1471,9 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager, C @Override public ConfigKey<?>[] getConfigKeys() { - return new ConfigKey<?>[] {ProjectSmtpEnabledSecurityProtocols, ProjectSmtpUseStartTLS, ProjectSmtpUseAuth}; + return new ConfigKey<?>[] {ProjectSmtpEnabledSecurityProtocols, ProjectSmtpUseStartTLS, ProjectSmtpUseAuth, + ProjectInviteRequired, ProjectInvitationExpirationTime, AllowUserToCreateProject, ProjectEmailSender, + ProjectSMTPHost, ProjectSMTPPort, ProjectSMTPUsername, ProjectSMTPPassword}; } protected void updateProjectNameAndDisplayText(final ProjectVO project, String name, String displayText) { diff --git a/server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java b/server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java index d92f4fc06d8..b8a1508f297 100644 --- a/server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java +++ b/server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java @@ -71,7 +71,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; @@ -294,17 +293,17 @@ 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()))); @@ -2280,7 +2279,17 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim DefaultMaxDomainCpus, DefaultMaxDomainMemory, DefaultMaxDomainPrimaryStorage, - DefaultMaxDomainSecondaryStorage + DefaultMaxDomainSecondaryStorage, + DefaultMaxProjectUserVms, + DefaultMaxProjectPublicIPs, + DefaultMaxProjectTemplates, + DefaultMaxProjectSnapshots, + DefaultMaxProjectVolumes, + DefaultMaxProjectNetworks, + DefaultMaxProjectVpcs, + DefaultMaxProjectCpus, + DefaultMaxProjectMemory, + DefaultMaxProjectPrimaryStorage }; }
