diff --git a/api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java b/api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java index 9471c3d5c84c..efbc1804e9fa 100644 --- a/api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java +++ b/api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java @@ -68,6 +68,18 @@ public interface DeploymentClusterPlanner extends DeploymentPlanner { ConfigKey.Kind.Select, "random,firstfit,userdispersing,firstfitleastconsumed"); + ConfigKey ApplyAllocationAlgorithmToPods = new ConfigKey<>("Advanced", Boolean.class, "apply.allocation.algorithm.to.pods", "false", + "If true, deployment planner applies the allocation heuristics at pods first in the given datacenter during VM resource allocation", true); + + ConfigKey HostCapacityTypeToOrderClusters = new ConfigKey<>("Advanced", String.class, "host.capacityType.to.order.clusters", "CPU", + "The host capacity type (CPU, RAM, COMBINED) is used by deployment planner to order clusters during VM resource allocation", true); + + ConfigKey VmUserDispersionWeight = new ConfigKey<>("Advanced", Float.class, "vm.user.dispersion.weight", "1", + "Weight for user dispersion heuristic (as a value between 0 and 1) applied to resource allocation during vm deployment. Weight for capacity heuristic will be (1 - weight of user dispersion)", true); + + ConfigKey ImplicitHostTags = new ConfigKey<>("Advanced", String.class, "implicit.host.tags", "GPU", + "Tag hosts at the time of host discovery based on the host properties/capabilities", true); + /** * This is called to determine list of possible clusters where a virtual * machine can be deployed. diff --git a/api/src/main/java/com/cloud/network/NetworkModel.java b/api/src/main/java/com/cloud/network/NetworkModel.java index 7e1a07ebeb69..50d98582e0fe 100644 --- a/api/src/main/java/com/cloud/network/NetworkModel.java +++ b/api/src/main/java/com/cloud/network/NetworkModel.java @@ -97,6 +97,25 @@ public interface NetworkModel { static final ConfigKey AdminIsAllowedToDeployAnywhere = new ConfigKey<>("Advanced",Boolean.class, "admin.is.allowed.to.deploy.anywhere", "false", "This will determine if the root admin is allowed to deploy in networks in subdomains.", true, ConfigKey.Scope.Global); + ConfigKey SecurityGroupDefaultAdding = new ConfigKey<>("Network", Boolean.class, "network.securitygroups.defaultadding", "true", + "If true, the user VM would be added to the default security group by default", true); + + ConfigKey CloudIdentifier = new ConfigKey<>("Hidden", String.class, "cloud.identifier", null, + "A unique identifier for the cloud.", true); + + ConfigKey SubDomainNetworkAccess = new ConfigKey<>("Advanced", Boolean.class, "allow.subdomain.network.access", "true", + "Allow subdomains to use networks dedicated to their parent domain(s)", true); + + ConfigKey ExecuteInSequenceNetworkElementCommands = new ConfigKey<>("Advanced", Boolean.class, "execute.in.sequence.network.element.commands", "false", + "If set to true, DhcpEntryCommand, SavePasswordCommand, VmDataCommand will be synchronized on the agent side." + + " If set to false, these commands become asynchronous. Default value is false.", true); + + ConfigKey ExternalNetworkStatsInterval = new ConfigKey<>("Advanced", Integer.class, "external.network.stats.interval", "300", + "Interval (in seconds) to report external network statistics.", true); + + ConfigKey NetworkIPv6SearchRetryMax = new ConfigKey<>("Network", Integer.class, "network.ipv6.search.retry.max", "10000", + "The maximum number of retrying times to search for an available IPv6 address in the table", true); + /** * Lists IP addresses that belong to VirtualNetwork VLANs * diff --git a/api/src/main/java/com/cloud/network/NetworkService.java b/api/src/main/java/com/cloud/network/NetworkService.java index c32bb711c0f2..8f2026fb7e04 100644 --- a/api/src/main/java/com/cloud/network/NetworkService.java +++ b/api/src/main/java/com/cloud/network/NetworkService.java @@ -84,6 +84,36 @@ public interface NetworkService { "allow.end.users.to.specify.vr.mtu", "false", "Allow end Users to specify VR MTU", true, ConfigKey.Scope.Zone); + ConfigKey GuestVlanBits = new ConfigKey<>("Network", Integer.class, "guest.vlan.bits", "12", + "The number of bits to reserve for the VLAN identifier in the guest subnet.", true); + + ConfigKey MaxNumberOfSecondaryIPsPerNIC = new ConfigKey<>("Network", Integer.class, + "vm.network.nic.max.secondary.ipaddresses", "10", + "Specify the number of secondary ip addresses per nic per vm. Default value 10 is used, if not specified.", true); + + ConfigKey NetworkGuestCidrLimit = new ConfigKey<>("Network", Integer.class, "network.guest.cidr.limit", "22", + "size limit for guest cidr; can't be less than this value", true); + + ConfigKey XenServerPublicNetwork = new ConfigKey<>("Hidden", String.class, + "xenserver.public.network.device", null, + "[ONLY IF THE PUBLIC NETWORK IS ON A DEDICATED NIC]:The network name label of the physical device dedicated to the public network on a XenServer host", true); + + ConfigKey XenServerGuestNetwork = new ConfigKey<>("Hidden", String.class, + "xenserver.guest.network.device", null, + "Specify for guest network name label", true); + + ConfigKey XenServerStorageNetwork1 = new ConfigKey<>("Hidden", String.class, + "xenserver.storage.network.device1", null, + "Specify when there are storage networks", true); + + ConfigKey XenServerStorageNetwork2 = new ConfigKey<>("Hidden", String.class, + "xenserver.storage.network.device2", null, + "Specify when there are storage networks", true); + + ConfigKey XenServerPrivateNetwork = new ConfigKey<>("Hidden", String.class, + "xenserver.private.network.device", null, + "Specify when the private network name is different", true); + List getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner); IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp, String ipaddress) throws ResourceAllocationException, InsufficientAddressCapacityException, diff --git a/api/src/main/java/com/cloud/network/NetworkUsageService.java b/api/src/main/java/com/cloud/network/NetworkUsageService.java index 71a2f49b75f2..dbb5ae410536 100644 --- a/api/src/main/java/com/cloud/network/NetworkUsageService.java +++ b/api/src/main/java/com/cloud/network/NetworkUsageService.java @@ -21,12 +21,22 @@ import org.apache.cloudstack.api.command.admin.usage.AddTrafficMonitorCmd; import org.apache.cloudstack.api.command.admin.usage.DeleteTrafficMonitorCmd; import org.apache.cloudstack.api.command.admin.usage.ListTrafficMonitorsCmd; +import org.apache.cloudstack.framework.config.ConfigKey; import com.cloud.host.Host; import com.cloud.utils.component.Manager; public interface NetworkUsageService extends Manager { + ConfigKey DirectNetworkStatsInterval = new ConfigKey<>("Usage", Integer.class, "direct.network.stats.interval", "86400", + "Interval (in seconds) to collect stats from Traffic Monitor", true); + + ConfigKey TrafficSentinelIncludeZones = new ConfigKey<>("Usage", String.class, "traffic.sentinel.include.zones", "EXTERNAL", + "Traffic going into specified list of zones is metered. For metering all traffic leave this parameter empty", true); + + ConfigKey TrafficSentinelExcludeZones = new ConfigKey<>("Usage", String.class, "traffic.sentinel.exclude.zones", "", + "Traffic going into specified list of zones is not metered.", true); + Host addTrafficMonitor(AddTrafficMonitorCmd cmd); boolean deleteTrafficMonitor(DeleteTrafficMonitorCmd cmd); diff --git a/api/src/main/java/com/cloud/network/vpn/RemoteAccessVpnService.java b/api/src/main/java/com/cloud/network/vpn/RemoteAccessVpnService.java index ffa8af4576d7..00bd4b3a512e 100644 --- a/api/src/main/java/com/cloud/network/vpn/RemoteAccessVpnService.java +++ b/api/src/main/java/com/cloud/network/vpn/RemoteAccessVpnService.java @@ -20,6 +20,7 @@ import org.apache.cloudstack.api.command.user.vpn.ListRemoteAccessVpnsCmd; import org.apache.cloudstack.api.command.user.vpn.ListVpnUsersCmd; +import org.apache.cloudstack.framework.config.ConfigKey; import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceUnavailableException; @@ -31,6 +32,12 @@ public interface RemoteAccessVpnService { static final String RemoteAccessVpnClientIpRangeCK = "remote.access.vpn.client.iprange"; + ConfigKey RemoteAccessVpnPskLength = new ConfigKey<>("Network", Integer.class, "remote.access.vpn.psk.length", "24", + "The length of the ipsec preshared key (minimum 8, maximum 256)", true); + + ConfigKey RemoteAccessVpnUserLimit = new ConfigKey<>("Network", Integer.class, "remote.access.vpn.user.limit", "8", + "The maximum number of VPN users that can be created per account", true); + RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean openFirewall, Boolean forDisplay) throws NetworkRuleConflictException; boolean destroyRemoteAccessVpnForIp(long ipId, Account caller, boolean forceCleanup) throws ResourceUnavailableException; diff --git a/api/src/main/java/com/cloud/storage/VolumeApiService.java b/api/src/main/java/com/cloud/storage/VolumeApiService.java index 372eb0385618..904ab5b9bc9c 100644 --- a/api/src/main/java/com/cloud/storage/VolumeApiService.java +++ b/api/src/main/java/com/cloud/storage/VolumeApiService.java @@ -61,6 +61,18 @@ public interface VolumeApiService { true, ConfigKey.Scope.Zone); + ConfigKey CopyVolumeWait = new ConfigKey<>("Storage", Integer.class, "copy.volume.wait", "10800", + "In second, timeout for copy volume command", true); + + ConfigKey CreateVolumeFromSnapshotWait = new ConfigKey<>("Storage", Integer.class, "create.volume.from.snapshot.wait", "10800", + "In second, timeout for creating volume from snapshot", true); + + ConfigKey MaxUploadVolumeSize = new ConfigKey<>("Storage", Long.class, "storage.max.volume.upload.size", "500", + "The maximum size for a uploaded volume(in GB).", true); + + ConfigKey StoragePoolMaxWaitSeconds = new ConfigKey<>("Storage", Integer.class, "storage.pool.max.waitseconds", "3600", + "Timeout (in seconds) to synchronize storage pool operations.", true); + /** * Creates the database object for a volume based on the given criteria * diff --git a/api/src/main/java/com/cloud/user/ResourceLimitService.java b/api/src/main/java/com/cloud/user/ResourceLimitService.java index 89128f87829e..e46e198f877d 100644 --- a/api/src/main/java/com/cloud/user/ResourceLimitService.java +++ b/api/src/main/java/com/cloud/user/ResourceLimitService.java @@ -58,6 +58,71 @@ public interface ResourceLimitService { static final ConfigKey DefaultMaxProjectGpus = new ConfigKey<>("Project Defaults",Long.class,"max.project.gpus","20", "The default maximum number of GPU devices that can be used for a project", false); + static final ConfigKey DefaultMaxAccountUserVms = new ConfigKey<>("Account Defaults", Long.class, "max.account.user.vms", "20", + "The default maximum number of user VMs that can be deployed for an account", false); + static final ConfigKey DefaultMaxAccountPublicIPs = new ConfigKey<>("Account Defaults", Long.class, "max.account.public.ips", "20", + "The default maximum number of public IPs that can be consumed by an account", false); + static final ConfigKey DefaultMaxAccountTemplates = new ConfigKey<>("Account Defaults", Long.class, "max.account.templates", "20", + "The default maximum number of Templates that can be deployed for an account", false); + static final ConfigKey DefaultMaxAccountSnapshots = new ConfigKey<>("Account Defaults", Long.class, "max.account.snapshots", "20", + "The default maximum number of snapshots that can be created for an account", false); + static final ConfigKey DefaultMaxAccountVolumes = new ConfigKey<>("Account Defaults", Long.class, "max.account.volumes", "20", + "The default maximum number of volumes that can be created for an account", false); + static final ConfigKey DefaultMaxAccountNetworks = new ConfigKey<>("Account Defaults", Long.class, "max.account.networks", "20", + "The default maximum number of networks that can be created for an account", false); + static final ConfigKey DefaultMaxAccountVpcs = new ConfigKey<>("Account Defaults", Long.class, "max.account.vpcs", "20", + "The default maximum number of vpcs that can be created for an account", false); + static final ConfigKey DefaultMaxAccountCpus = new ConfigKey<>("Account Defaults", Long.class, "max.account.cpus", "40", + "The default maximum number of cpu cores that can be used for an account", false); + static final ConfigKey DefaultMaxAccountMemory = new ConfigKey<>("Account Defaults", Long.class, "max.account.memory", "40960", + "The default maximum memory (in MB) that can be used for an account", false); + static final ConfigKey DefaultMaxAccountPrimaryStorage = new ConfigKey<>("Account Defaults", Long.class, "max.account.primary.storage", "200", + "The default maximum primary storage space (in GiB) that can be used for an account", false); + + static final ConfigKey DefaultMaxDomainUserVms = new ConfigKey<>("Domain Defaults", Long.class, "max.domain.user.vms", "40", + "The default maximum number of user Instances that can be deployed for a domain", false); + static final ConfigKey DefaultMaxDomainPublicIPs = new ConfigKey<>("Domain Defaults", Long.class, "max.domain.public.ips", "40", + "The default maximum number of public IPs that can be consumed by a domain", false); + static final ConfigKey DefaultMaxDomainTemplates = new ConfigKey<>("Domain Defaults", Long.class, "max.domain.templates", "40", + "The default maximum number of Templates that can be deployed for a domain", false); + static final ConfigKey DefaultMaxDomainSnapshots = new ConfigKey<>("Domain Defaults", Long.class, "max.domain.snapshots", "40", + "The default maximum number of Snapshots that can be created for a domain", false); + static final ConfigKey DefaultMaxDomainVolumes = new ConfigKey<>("Domain Defaults", Long.class, "max.domain.volumes", "40", + "The default maximum number of Volumes that can be created for a domain", false); + static final ConfigKey DefaultMaxDomainNetworks = new ConfigKey<>("Domain Defaults", Long.class, "max.domain.networks", "40", + "The default maximum number of Networks that can be created for a domain", false); + static final ConfigKey DefaultMaxDomainVpcs = new ConfigKey<>("Domain Defaults", Long.class, "max.domain.vpcs", "40", + "The default maximum number of VPCs that can be created for a domain", false); + static final ConfigKey DefaultMaxDomainCpus = new ConfigKey<>("Domain Defaults", Long.class, "max.domain.cpus", "80", + "The default maximum number of CPU cores that can be used for a domain", false); + static final ConfigKey DefaultMaxDomainMemory = new ConfigKey<>("Domain Defaults", Long.class, "max.domain.memory", "81920", + "The default maximum memory (in MB) that can be used for a domain", false); + static final ConfigKey DefaultMaxDomainPrimaryStorage = new ConfigKey<>("Domain Defaults", Long.class, "max.domain.primary.storage", "400", + "The default maximum primary storage space (in GiB) that can be used for a domain", false); + static final ConfigKey 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 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 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 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 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 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 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 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 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 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 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 HostTagsSupportingTypes = List.of(ResourceType.user_vm, ResourceType.cpu, ResourceType.memory, ResourceType.gpu); static final List StorageTagsSupportingTypes = List.of(ResourceType.volume, ResourceType.primary_storage); diff --git a/api/src/main/java/org/apache/cloudstack/usage/UsageService.java b/api/src/main/java/org/apache/cloudstack/usage/UsageService.java index 00e8b431f8fe..d4c8ed756312 100644 --- a/api/src/main/java/org/apache/cloudstack/usage/UsageService.java +++ b/api/src/main/java/org/apache/cloudstack/usage/UsageService.java @@ -20,11 +20,31 @@ import org.apache.cloudstack.api.command.admin.usage.GenerateUsageRecordsCmd; import org.apache.cloudstack.api.command.admin.usage.ListUsageRecordsCmd; import org.apache.cloudstack.api.command.admin.usage.RemoveRawUsageRecordsCmd; +import org.apache.cloudstack.framework.config.ConfigKey; import java.util.List; import java.util.TimeZone; public interface UsageService { + + ConfigKey UsageAggregationTimezone = new ConfigKey<>("Usage", String.class, "usage.aggregation.timezone", "GMT", + "The timezone to use for usage stats aggregation", true); + + ConfigKey UsageExecutionTimezone = new ConfigKey<>("Usage", String.class, "usage.execution.timezone", null, + "The timezone to use for usage job execution time", true); + + ConfigKey UsageSanityCheckInterval = new ConfigKey<>("Usage", Integer.class, "usage.sanity.check.interval", null, + "Interval (in days) to check sanity of usage data. To disable set it to 0 or negative.", true); + + ConfigKey UsageStatsJobAggregationRange = new ConfigKey<>("Usage", Integer.class, "usage.stats.job.aggregation.range", "1440", + "The range of time for aggregating the user statistics specified in minutes (e.g. 1440 for daily, 60 for hourly.", true); + + ConfigKey UsageStatsJobExecTime = new ConfigKey<>("Usage", String.class, "usage.stats.job.exec.time", "00:15", + "The time at which the usage statistics aggregation job will run as an HH24:MM time, e.g. 00:30 to run at 12:30am.", true); + + ConfigKey EnableUsageServer = new ConfigKey<>("Usage", Boolean.class, "enable.usage.server", "true", + "Flag for enabling usage", true); + /** * Generate Billing Records from the last time it was generated to the * time specified. diff --git a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java index 109a44488ec4..992f4adea831 100644 --- a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java +++ b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java @@ -138,6 +138,23 @@ public interface NetworkOrchestrationService { ConfigKey VmNetworkThrottlingRate = new ConfigKey("Network", Integer.class, "vm.network.throttling.rate", "200", "Default data transfer rate in megabits per second allowed in User vm's default network.", true, ConfigKey.Scope.Zone); + ConfigKey NetworkLBHaproxyStatsVisbility = new ConfigKey<>("Network", String.class, + "network.loadbalancer.haproxy.stats.visibility", "global", + "Load Balancer(haproxy) stats visibility, the value can be one of the following six parameters : global,guest-network,link-local,disabled,all,default", + true, ConfigKey.Kind.Select, "global,guest-network,link-local,disabled,all,default"); + + ConfigKey NetworkLBHaproxyStatsUri = new ConfigKey<>("Network", String.class, + "network.loadbalancer.haproxy.stats.uri", "/admin?stats", + "Load Balancer(haproxy) uri.", true); + + ConfigKey NetworkLBHaproxyStatsAuth = new ConfigKey<>("Secure", String.class, + "network.loadbalancer.haproxy.stats.auth", "admin1:AdMiN123", + "Load Balancer(haproxy) authentication string in the format username:password", true); + + ConfigKey NetworkLBHaproxyStatsPort = new ConfigKey<>("Network", String.class, + "network.loadbalancer.haproxy.stats.port", "8081", + "Load Balancer(haproxy) stats port number.", true); + List setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault) throws ConcurrentOperationException; diff --git a/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java b/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java index b8aeb5cf7510..d17adf16cc64 100644 --- a/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java +++ b/engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java @@ -18,7 +18,22 @@ */ package org.apache.cloudstack.engine.subsystem.api.storage; +import org.apache.cloudstack.framework.config.ConfigKey; + public interface StorageCacheManager { + + ConfigKey StorageCacheReplacementEnabled = new ConfigKey<>("Storage", Boolean.class, + "storage.cache.replacement.enabled", "true", + "enable or disable cache storage replacement algorithm.", true); + + ConfigKey StorageCacheReplacementInterval = new ConfigKey<>("Storage", Integer.class, + "storage.cache.replacement.interval", "86400", + "time interval between cache replacement threads (in seconds).", true); + + ConfigKey StorageCacheReplacementLRUTimeInterval = new ConfigKey<>("Storage", Integer.class, + "storage.cache.replacement.lru.interval", "30", + "time interval for unused data on cache storage (in days).", true); + DataStore getCacheStorage(Scope scope); DataStore getCacheStorage(DataObject data, Scope scope); diff --git a/engine/components-api/src/main/java/com/cloud/agent/AgentManager.java b/engine/components-api/src/main/java/com/cloud/agent/AgentManager.java index 4d63fae33560..183c7626cbf5 100644 --- a/engine/components-api/src/main/java/com/cloud/agent/AgentManager.java +++ b/engine/components-api/src/main/java/com/cloud/agent/AgentManager.java @@ -58,6 +58,33 @@ public interface AgentManager { "kvm.host.discovery.ssh.port", String.valueOf(Host.DEFAULT_SSH_PORT), "SSH port used for KVM host discovery and any other operations on host (using SSH)." + " Please note that this is applicable when port is not defined through host url while adding the KVM host.", true, ConfigKey.Scope.Cluster); + ConfigKey InstanceName = new ConfigKey<>("Advanced", String.class, "instance.name", "VM", + "Name of the deployment instance.", false); + + ConfigKey XapiWait = new ConfigKey<>("Advanced", Integer.class, "xapiwait", "60", + "Time (in seconds) to wait for XAPI to return", true); + + ConfigKey MigrateWait = new ConfigKey<>("Advanced", Integer.class, "migratewait", "3600", + "Time (in seconds) to wait for VM migrate finish", true); + + ConfigKey SecStorageVmMTUSize = new ConfigKey<>("Advanced", Integer.class, "secstorage.vm.mtu.size", "1500", + "MTU size (in Byte) of storage network in secondary storage vms", true); + + ConfigKey SecStorageCapacityStandby = new ConfigKey<>("Advanced", Integer.class, "secstorage.capacity.standby", "10", + "The minimal number of command execution sessions that system is able to serve immediately(standby capacity)", true); + + ConfigKey SecStorageSessionMax = new ConfigKey<>("Advanced", Integer.class, "secstorage.session.max", "50", + "The max number of command execution sessions that a SSVM can handle", true); + + ConfigKey SecStorageCmdExecutionTimeMax = new ConfigKey<>("Advanced", Integer.class, "secstorage.cmd.execution.time.max", "30", + "The max command execution time in minute", true); + + ConfigKey SecStorageProxy = new ConfigKey<>("Advanced", String.class, "secstorage.proxy", null, + "http proxy used by ssvm, in http://username:password@proxyserver:port format", true); + + ConfigKey XenServerMaxNics = new ConfigKey<>("Advanced", Integer.class, "xenserver.nics.max", "7", + "Maximum allowed nics for Vms created on XenServer", true); + enum TapAgentsAction { Add, Del, Contains, } diff --git a/engine/components-api/src/main/java/com/cloud/alert/AlertManager.java b/engine/components-api/src/main/java/com/cloud/alert/AlertManager.java index 46993b066a49..aece878d93fd 100644 --- a/engine/components-api/src/main/java/com/cloud/alert/AlertManager.java +++ b/engine/components-api/src/main/java/com/cloud/alert/AlertManager.java @@ -53,6 +53,59 @@ public interface AlertManager extends Manager, AlertService { "alert.allowed.repetitive.types", "", "Comma-separated list of alert types (by name) that can be sent multiple times", true); + ConfigKey AlertEmailAddresses = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, String.class, + "alert.email.addresses", null, + "Comma separated list of email addresses which are going to receive alert emails.", true, + ConfigKey.Kind.CSV, null); + + ConfigKey AlertEmailSender = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, String.class, + "alert.email.sender", null, + "Sender of alert email (will be in the From header of the email).", true); + + ConfigKey AlertSMTPHost = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, String.class, + "alert.smtp.host", null, + "SMTP hostname used for sending out email alerts.", true); + + ConfigKey AlertSMTPPort = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, Integer.class, + "alert.smtp.port", "465", + "Port the SMTP server is listening on.", true); + + ConfigKey AlertSMTPUsername = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, String.class, + "alert.smtp.username", null, + "Username for SMTP authentication (applies only if alert.smtp.useAuth is true).", true); + + ConfigKey AlertSMTPPassword = new ConfigKey<>("Secure", String.class, + "alert.smtp.password", null, + "Password for SMTP authentication (applies only if alert.smtp.useAuth is true).", true); + + ConfigKey CapacityCheckPeriod = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, Integer.class, + "capacity.check.period", "300000", + "The interval in milliseconds between capacity checks", true); + + ConfigKey PublicIpCapacityThreshold = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, Double.class, + "zone.virtualnetwork.publicip.capacity.notificationthreshold", "0.75", + "Percentage (as a value between 0 and 1) of public IP address space utilization above which alerts will be sent.", true); + + ConfigKey PrivateIpCapacityThreshold = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, Double.class, + "pod.privateip.capacity.notificationthreshold", "0.75", + "Percentage (as a value between 0 and 1) of private IP address space utilization above which alerts will be sent.", true); + + ConfigKey SecondaryStorageCapacityThreshold = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, Double.class, + "zone.secstorage.capacity.notificationthreshold", "0.75", + "Percentage (as a value between 0 and 1) of secondary storage utilization above which alerts will be sent about low storage available.", true); + + ConfigKey VlanCapacityThreshold = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, Double.class, + "zone.vlan.capacity.notificationthreshold", "0.75", + "Percentage (as a value between 0 and 1) of Zone Vlan utilization above which alerts will be sent about low number of Zone Vlans.", true); + + ConfigKey DirectNetworkPublicIpCapacityThreshold = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, Double.class, + "zone.directnetwork.publicip.capacity.notificationthreshold", "0.75", + "Percentage (as a value between 0 and 1) of Direct Network Public Ip Utilization above which alerts will be sent about low number of direct network public ips.", true); + + ConfigKey LocalStorageCapacityThreshold = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, Double.class, + "cluster.localStorage.capacity.notificationthreshold", "0.75", + "Percentage (as a value between 0 and 1) of local storage utilization above which alerts will be sent about low local storage available.", true); + void clearAlert(AlertType alertType, long dataCenterId, long podId); void recalculateCapacity(); diff --git a/engine/components-api/src/main/java/com/cloud/deploy/DeploymentPlanningManager.java b/engine/components-api/src/main/java/com/cloud/deploy/DeploymentPlanningManager.java index ce40287bf033..1a7e17019542 100644 --- a/engine/components-api/src/main/java/com/cloud/deploy/DeploymentPlanningManager.java +++ b/engine/components-api/src/main/java/com/cloud/deploy/DeploymentPlanningManager.java @@ -37,6 +37,13 @@ public interface DeploymentPlanningManager extends Manager { static final ConfigKey allowAdminVmOnDisabledResource = new ConfigKey("Advanced", Boolean.class, "allow.admin.vm.on.disabled.resources", "false", "Allow deploying VMs owned by the admin account in disabled Clusters, Pods, and Zones", true); + ConfigKey HostReservationReleasePeriod = new ConfigKey<>("Advanced", Integer.class, "host.reservation.release.period", "300000", + "The interval in milliseconds between host reservation release checks", true); + + ConfigKey VmDeploymentPlanner = new ConfigKey<>("Advanced", String.class, "vm.deployment.planner", "FirstFitPlanner", + "'FirstFitPlanner', 'UserDispersingPlanner', 'UserConcentratedPodPlanner': DeploymentPlanner heuristic that will be used for VM deployment.", + true, ConfigKey.Kind.Select, "FirstFitPlanner,UserDispersingPlanner,UserConcentratedPodPlanner"); + /** * Manages vm deployment stages: First Process Affinity/Anti-affinity - Call * the chain of AffinityGroupProcessor adapters to set deploymentplan scope diff --git a/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java b/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java index 53bfcce27038..a946b0db417b 100644 --- a/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java +++ b/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java @@ -78,6 +78,9 @@ public interface HighAvailabilityManager extends Manager { ConfigKey KvmHAFenceHostIfHeartbeatFailsOnStorage = new ConfigKey<>("Advanced", Boolean.class, "kvm.ha.fence.on.storage.heartbeat.failure", "false", "Proceed fencing the host even the heartbeat failed for only one storage pool", false, ConfigKey.Scope.Zone); + ConfigKey HaTag = new ConfigKey<>("Advanced", String.class, "ha.tag", null, + "HA tag defining that the host marked with this tag can be used for HA purposes only", true); + enum WorkType { Migration, // Migrating VMs off of a host. Stop, // Stops a VM for storage pool migration purposes. This should be obsolete now. diff --git a/engine/components-api/src/main/java/com/cloud/network/security/SecurityGroupManager.java b/engine/components-api/src/main/java/com/cloud/network/security/SecurityGroupManager.java index 6e2270ffb108..5167a396e2e0 100644 --- a/engine/components-api/src/main/java/com/cloud/network/security/SecurityGroupManager.java +++ b/engine/components-api/src/main/java/com/cloud/network/security/SecurityGroupManager.java @@ -19,6 +19,8 @@ import java.util.HashMap; import java.util.List; +import org.apache.cloudstack.framework.config.ConfigKey; + import com.cloud.uservm.UserVm; import com.cloud.utils.Pair; @@ -33,6 +35,23 @@ public interface SecurityGroupManager { public static final int TIME_BETWEEN_CLEANUPS = 60; public static final int WORKER_THREAD_COUNT = 10; + ConfigKey SecurityGroupWorkCleanupInterval = new ConfigKey<>("Network", Integer.class, + "network.securitygroups.work.cleanup.interval", "120", + "Time interval (seconds) in which finished work is cleaned up from the work table", true); + + ConfigKey SecurityGroupWorkerThreads = new ConfigKey<>("Network", Integer.class, + "network.securitygroups.workers.pool.size", "50", + "Number of worker threads processing the security group update work queue", true); + + ConfigKey SecurityGroupWorkGlobalLockTimeout = new ConfigKey<>("Network", Integer.class, + "network.securitygroups.work.lock.timeout", "300", + "Lock wait timeout (seconds) while updating the security group work queue", true); + + ConfigKey SecurityGroupWorkPerAgentMaxQueueSize = new ConfigKey<>("Network", Integer.class, + "network.securitygroups.work.per.agent.queue.size", "100", + "The number of outstanding security group work items that can be queued to a host. If exceeded, work items will get dropped to conserve memory. " + + "Security Group Sync will take care of ensuring that the host gets updated eventually", true); + public SecurityGroupVO createSecurityGroup(String name, String description, Long domainId, Long accountId, String accountName); public SecurityGroupVO createDefaultSecurityGroup(Long accountId); diff --git a/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java b/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java index 792a3a6b397f..5668fa24cd6c 100644 --- a/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java +++ b/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java @@ -58,6 +58,12 @@ public interface VpcManager { ConfigKey.Scope.Global, null); + ConfigKey VpcCleanupInterval = new ConfigKey<>("Advanced", Integer.class, "vpc.cleanup.interval", "3600", + "The interval (in seconds) between cleanup for Inactive VPCs", true); + + ConfigKey VpcMaxNetworks = new ConfigKey<>("Advanced", Integer.class, "vpc.max.networks", "3", + "Maximum number of networks per vpc", true); + /** * Returns all the Guest networks that are part of VPC * diff --git a/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java b/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java index 032fcbe76dce..aae9ec878a51 100644 --- a/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java +++ b/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java @@ -172,6 +172,24 @@ public interface StorageManager extends StorageService { ConfigKey MaxDataMigrationWaitTime = new ConfigKey<>("Advanced", Integer.class, "max.data.migration.wait.time", "15", "Maximum wait time (in minutes) for a data migration task before spawning a new SSVM", false, ConfigKey.Scope.Global); + + ConfigKey VmDiskThrottlingIopsReadRate = new ConfigKey<>("Advanced", Integer.class, "vm.disk.throttling.iops_read_rate", "0", + "Default disk I/O read rate in requests per second allowed in User vm's disk.", true); + + ConfigKey VmDiskThrottlingIopsWriteRate = new ConfigKey<>("Advanced", Integer.class, "vm.disk.throttling.iops_write_rate", "0", + "Default disk I/O writerate in requests per second allowed in User vm's disk.", true); + + ConfigKey VmDiskThrottlingBytesReadRate = new ConfigKey<>("Advanced", Integer.class, "vm.disk.throttling.bytes_read_rate", "0", + "Default disk I/O read rate in bytes per second allowed in User vm's disk.", true); + + ConfigKey VmDiskThrottlingBytesWriteRate = new ConfigKey<>("Advanced", Integer.class, "vm.disk.throttling.bytes_write_rate", "0", + "Default disk I/O writerate in bytes per second allowed in User vm's disk.", true); + + ConfigKey ExpungeWorkers = new ConfigKey<>("Advanced", Integer.class, "expunge.workers", "1", + "Number of workers performing expunge ", true); + + ConfigKey HAStorageMigration = new ConfigKey<>("Storage", Boolean.class, "enable.ha.storage.migration", "true", + "Enable/disable storage migration across primary storage during HA", true); ConfigKey DiskProvisioningStrictness = new ConfigKey<>("Storage", Boolean.class, "disk.provisioning.type.strictness", "false", "If set to true, the disk is created only when there is a suitable storage pool that supports the disk provisioning type specified by the service/disk offering. " + "If set to false, the disk is created with a disk provisioning type supported by the pool. Default value is false, and this is currently supported for VMware only.", diff --git a/engine/components-api/src/main/java/com/cloud/template/TemplateManager.java b/engine/components-api/src/main/java/com/cloud/template/TemplateManager.java index 8c11fe6c93ad..e89b97e6a3e9 100644 --- a/engine/components-api/src/main/java/com/cloud/template/TemplateManager.java +++ b/engine/components-api/src/main/java/com/cloud/template/TemplateManager.java @@ -85,6 +85,13 @@ public interface TemplateManager { true, ConfigKey.Scope.Cluster); + ConfigKey SSVMPSK = new ConfigKey<>("Hidden", String.class, "upload.post.secret.key", "", + "PSK with SSVM", true); + + ConfigKey CreatePrivateTemplateFromSnapshotWait = new ConfigKey<>("Storage", Integer.class, + "create.private.template.from.snapshot.wait", "10800", + "In second, timeout for CreatePrivateTemplateFromSnapshotCommand", true); + // KVM/libvirt maps deviceSeq=3 to hdc (hda/hdb are taken by the root volume on i440fx/IDE). // user_vm.iso_id has always pointed at this slot; additional cdroms live in vm_iso_map. int CDROM_PRIMARY_DEVICE_SEQ = 3; diff --git a/engine/components-api/src/main/java/com/cloud/vm/snapshot/VMSnapshotManager.java b/engine/components-api/src/main/java/com/cloud/vm/snapshot/VMSnapshotManager.java index 6831552b83db..24c165db268f 100644 --- a/engine/components-api/src/main/java/com/cloud/vm/snapshot/VMSnapshotManager.java +++ b/engine/components-api/src/main/java/com/cloud/vm/snapshot/VMSnapshotManager.java @@ -33,6 +33,9 @@ public interface VMSnapshotManager extends VMSnapshotService, Manager { ConfigKey VMSnapshotMax = new ConfigKey("Advanced", Integer.class, "vmsnapshot.max", "10", "Maximum VM snapshots for a single VM", true, ConfigKey.Scope.Account); + ConfigKey VMSnapshotCreateWait = new ConfigKey<>("Advanced", Integer.class, "vmsnapshot.create.wait", "1800", + "In second, timeout for create vm snapshot", true); + /** * Delete all VM snapshots belonging to one VM * @param id, VM id diff --git a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java index 1215829d92f8..24b1a4148441 100644 --- a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java @@ -94,7 +94,6 @@ import com.cloud.alert.AlertManager; import com.cloud.cluster.ManagementServerHostVO; import com.cloud.cluster.dao.ManagementServerHostDao; -import com.cloud.configuration.Config; import com.cloud.configuration.ManagementServiceConfiguration; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenterVO; @@ -119,6 +118,7 @@ import com.cloud.resource.ResourceManager; import com.cloud.resource.ResourceState; import com.cloud.resource.ServerResource; +import com.cloud.server.ManagementServer; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.component.ManagerBase; @@ -2134,7 +2134,9 @@ public ConfigKey[] getConfigKeys() { return new ConfigKey[] { CheckTxnBeforeSending, Workers, Port, Wait, AlertWait, DirectAgentLoadSize, DirectAgentPoolSize, DirectAgentThreadCap, EnableKVMAutoEnableDisable, ReadyCommandWait, GranularWaitTimeForCommands, RemoteAgentSslHandshakeTimeout, RemoteAgentMaxConcurrentNewConnections, - RemoteAgentNewConnectionsMonitorInterval, KVMHostDiscoverySshPort }; + RemoteAgentNewConnectionsMonitorInterval, KVMHostDiscoverySshPort, InstanceName, XapiWait, MigrateWait, + SecStorageVmMTUSize, SecStorageCapacityStandby, SecStorageSessionMax, SecStorageCmdExecutionTimeMax, + SecStorageProxy, XenServerMaxNics }; } protected class SetHostParamsListener implements Listener { @@ -2170,8 +2172,8 @@ public void processConnect(final Host host, final StartupCommand cmd, final bool if (((StartupRoutingCommand)cmd).getHypervisorType() == HypervisorType.KVM || ((StartupRoutingCommand)cmd).getHypervisorType() == HypervisorType.LXC) { Map params = new HashMap<>(); - params.put(Config.RouterAggregationCommandEachTimeout.toString(), _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString())); - params.put(Config.MigrateWait.toString(), _configDao.getValue(Config.MigrateWait.toString())); + params.put(ManagementServer.RouterAggregationCommandEachTimeout.key(), _configDao.getValue(ManagementServer.RouterAggregationCommandEachTimeout.key())); + params.put(MigrateWait.toString(), _configDao.getValue(MigrateWait.toString())); params.put(NetworkOrchestrationService.TUNGSTEN_ENABLED.key(), String.valueOf(NetworkOrchestrationService.TUNGSTEN_ENABLED.valueIn(host.getDataCenterId()))); params.put(ReconcileCommandService.ReconcileCommandsEnabled.key(), String.valueOf(_reconcileCommandsEnabled)); diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index 84a397349cec..7295f46b05a8 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@ -5069,6 +5069,7 @@ public ConfigKey[] getConfigKeys() { GuestDomainSuffix, NetworkThrottlingRate, VmNetworkThrottlingRate, MinVRVersion, DhcpLeaseTimeout, PromiscuousMode, MacAddressChanges, ForgedTransmits, MacLearning, RollingRestartEnabled, TUNGSTEN_ENABLED, NSX_ENABLED, NETRIS_ENABLED, NETWORK_LB_HAPROXY_MAX_CONN, - NETWORK_LB_HAPROXY_IDLE_TIMEOUT}; + NETWORK_LB_HAPROXY_IDLE_TIMEOUT, NetworkLBHaproxyStatsVisbility, NetworkLBHaproxyStatsUri, + NetworkLBHaproxyStatsAuth, NetworkLBHaproxyStatsPort}; } } diff --git a/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java b/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java index 21ef851fb2f2..f7a0c57b5ec4 100644 --- a/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java +++ b/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java @@ -47,6 +47,8 @@ import org.apache.cloudstack.engine.subsystem.api.storage.Scope; import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager; import org.apache.cloudstack.framework.async.AsyncCallFuture; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.cloudstack.storage.cache.allocator.StorageCacheAllocator; @@ -54,8 +56,8 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreVO; import com.cloud.agent.api.to.DataObjectType; -import com.cloud.configuration.Config; import com.cloud.storage.DataStoreRole; +import com.cloud.storage.StorageManager; import com.cloud.utils.NumbersUtil; import com.cloud.utils.component.Manager; import com.cloud.utils.concurrency.NamedThreadFactory; @@ -64,8 +66,9 @@ import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.exception.CloudRuntimeException; -public class StorageCacheManagerImpl implements StorageCacheManager, Manager { +public class StorageCacheManagerImpl implements StorageCacheManager, Manager, Configurable { protected Logger logger = LogManager.getLogger(getClass()); + @Inject List storageCacheAllocator; @Inject @@ -159,13 +162,23 @@ public void setRunLevel(int level) { @Override public boolean configure(String name, Map params) throws ConfigurationException { - cacheReplacementEnabled = Boolean.parseBoolean(configDao.getValue(Config.StorageCacheReplacementEnabled.key())); - cacheReplaceMentInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementInterval.key()), 86400); - workers = NumbersUtil.parseInt(configDao.getValue(Config.ExpungeWorkers.key()), 10); + cacheReplacementEnabled = StorageCacheReplacementEnabled.value(); + cacheReplaceMentInterval = StorageCacheReplacementInterval.value(); + workers = NumbersUtil.parseInt(configDao.getValue(StorageManager.ExpungeWorkers.key()), 10); executors = Executors.newScheduledThreadPool(workers, new NamedThreadFactory("StorageCacheManager-cache-replacement")); return true; } + @Override + public String getConfigComponentName() { + return StorageCacheManager.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {StorageCacheReplacementEnabled, StorageCacheReplacementInterval, StorageCacheReplacementLRUTimeInterval}; + } + protected class CacheReplacementRunner extends ManagedContextRunnable { @Override diff --git a/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java b/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java index 7042ee453334..3a4c590fa5fe 100644 --- a/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java +++ b/engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java @@ -28,22 +28,19 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory; +import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager; import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO; -import com.cloud.configuration.Config; import com.cloud.utils.DateUtil; -import com.cloud.utils.NumbersUtil; import com.cloud.utils.db.QueryBuilder; import com.cloud.utils.db.SearchCriteria; public class StorageCacheReplacementAlgorithmLRU implements StorageCacheReplacementAlgorithm { - @Inject - ConfigurationDao configDao; + @Inject TemplateDataFactory templateFactory; @Inject @@ -59,7 +56,7 @@ public StorageCacheReplacementAlgorithmLRU() { @PostConstruct public void initialize() { - /* Avoid using configDao at this time, we can't be sure that the database is already upgraded + /* Avoid resolving the config value at this time, we can't be sure that the database is already upgraded * and there might be fatal errors when using a dao. */ } @@ -71,7 +68,7 @@ public void setUnusedTimeInterval(Integer interval) { @Override public DataObject chooseOneToBeReplaced(DataStore store) { if (unusedTimeInterval == null) { - unusedTimeInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementLRUTimeInterval.key()), 30); + unusedTimeInterval = StorageCacheManager.StorageCacheReplacementLRUTimeInterval.value(); } Calendar cal = Calendar.getInstance(); cal.setTime(DateUtil.now()); diff --git a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java index bbf775de27ad..6180d9507de2 100644 --- a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java +++ b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java @@ -60,6 +60,7 @@ import org.apache.logging.log4j.LogManager; import org.springframework.stereotype.Component; +import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; import com.cloud.agent.api.storage.MigrateVolumeAnswer; import com.cloud.agent.api.storage.MigrateVolumeCommand; @@ -68,7 +69,6 @@ import com.cloud.agent.api.to.DataTO; import com.cloud.agent.api.to.NfsTO; import com.cloud.agent.api.to.VirtualMachineTO; -import com.cloud.configuration.Config; import com.cloud.host.Host; import com.cloud.hypervisor.Hypervisor; import com.cloud.storage.DataStoreRole; @@ -79,9 +79,12 @@ import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StoragePool; +import com.cloud.storage.VolumeApiService; import com.cloud.storage.VolumeVO; import com.cloud.storage.dao.SnapshotDao; import com.cloud.storage.dao.VolumeDao; +import com.cloud.storage.snapshot.SnapshotManager; +import com.cloud.template.TemplateManager; import com.cloud.utils.NumbersUtil; import com.cloud.utils.db.DB; import com.cloud.utils.exception.CloudRuntimeException; @@ -340,8 +343,7 @@ protected Answer copyVolumeFromSnapshot(DataObject snapObj, DataObject volObj) { srcData = cacheSnapshotChain(snapshot, new ZoneScope(pool.getDataCenterId())); } - String value = configDao.getValue(Config.CreateVolumeFromSnapshotWait.toString()); - int _createVolumeFromSnapshotWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CreateVolumeFromSnapshotWait.getDefaultValue())); + int _createVolumeFromSnapshotWait = VolumeApiService.CreateVolumeFromSnapshotWait.value(); EndPoint ep = null; if (srcData.getDataStore().getRole() == DataStoreRole.Primary) { @@ -425,8 +427,7 @@ private void deleteVolumeOnSecondaryStore(DataObject objectInStore) { } protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData) { - String value = configDao.getValue(Config.CopyVolumeWait.key()); - int _copyvolumewait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue())); + int _copyvolumewait = VolumeApiService.CopyVolumeWait.value(); Scope destScope = getZoneScope(destData.getDataStore().getScope()); DataStore cacheStore = cacheMgr.getCacheStorage(destScope); @@ -623,8 +624,8 @@ private boolean canDirectlyCopyBetweenDataStoreScopes(Scope srcDataStoreScope, S } protected Answer migrateVolumeToPool(DataObject srcData, DataObject destData) { - String value = configDao.getValue(Config.MigrateWait.key()); - int waitInterval = NumbersUtil.parseInt(value, Integer.parseInt(Config.MigrateWait.getDefaultValue())); + String value = configDao.getValue(AgentManager.MigrateWait.key()); + int waitInterval = NumbersUtil.parseInt(value, Integer.parseInt(AgentManager.MigrateWait.defaultValue())); VolumeInfo volume = (VolumeInfo)srcData; StoragePool srcPool = (StoragePool)dataStoreMgr.getDataStore(srcData.getDataStore().getId(), DataStoreRole.Primary); @@ -733,8 +734,7 @@ public void copyAsync(DataObject srcData, DataObject destData, Host destHost, As @DB protected Answer createTemplateFromSnapshot(DataObject srcData, DataObject destData) { - String value = configDao.getValue(Config.CreatePrivateTemplateFromSnapshotWait.toString()); - int _createprivatetemplatefromsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CreatePrivateTemplateFromSnapshotWait.getDefaultValue())); + int _createprivatetemplatefromsnapshotwait = TemplateManager.CreatePrivateTemplateFromSnapshotWait.value(); boolean needCache = false; if (needCacheStorage(srcData, destData)) { @@ -767,8 +767,7 @@ protected Answer createTemplateFromSnapshot(DataObject srcData, DataObject destD } protected Answer copySnapshot(DataObject srcData, DataObject destData) { - String value = configDao.getValue(Config.BackupSnapshotWait.toString()); - int _backupsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.BackupSnapshotWait.getDefaultValue())); + int _backupsnapshotwait = SnapshotManager.BackupSnapshotWait.value(); DataObject cacheData = null; SnapshotInfo snapshotInfo = (SnapshotInfo)srcData; diff --git a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java index 7674f1ce25a1..79198f41e995 100644 --- a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java +++ b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java @@ -101,7 +101,6 @@ import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.NfsTO; import com.cloud.agent.api.to.VirtualMachineTO; -import com.cloud.configuration.Config; import com.cloud.dc.dao.ClusterDao; import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.OperationTimedoutException; @@ -753,8 +752,8 @@ private void handleVolumeMigrationForXenServer(VolumeInfo srcVolumeInfo, VolumeI _volumeService.grantAccess(destVolumeInfo, hostVO, destVolumeInfo.getDataStore()); - String value = _configDao.getValue(Config.MigrateWait.key()); - int waitInterval = NumbersUtil.parseInt(value, Integer.parseInt(Config.MigrateWait.getDefaultValue())); + String value = _configDao.getValue(AgentManager.MigrateWait.key()); + int waitInterval = NumbersUtil.parseInt(value, Integer.parseInt(AgentManager.MigrateWait.defaultValue())); StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(destVolumeInfo.getDataStore().getId(), DataStoreRole.Primary); @@ -1608,7 +1607,7 @@ else if (volumeInfo.getFormat() == ImageFormat.OVA) { AsyncCallFuture future = _volumeService.createVolumeAsync(volumeInfo, volumeInfo.getDataStore()); - int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(_configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); + int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value(); VolumeApiResult result = future.get(storagePoolMaxWaitSeconds, TimeUnit.SECONDS); diff --git a/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java b/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java index 6e32df5d5e3c..86dcbb7e65bc 100644 --- a/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java +++ b/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java @@ -81,7 +81,6 @@ import com.cloud.agent.api.storage.ListTemplateCommand; import com.cloud.agent.api.to.DatadiskTO; import com.cloud.alert.AlertManager; -import com.cloud.configuration.Config; import com.cloud.configuration.Resource.ResourceType; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.ClusterDao; @@ -104,6 +103,7 @@ import com.cloud.storage.VMTemplateZoneVO; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateZoneDao; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.template.TemplateConstants; import com.cloud.storage.template.TemplateProp; import com.cloud.template.TemplateManager; @@ -1520,7 +1520,7 @@ private String generateCopyUrl(String ipAddress, String dir, String path) { String hostname = ipAddress; String scheme = "http"; boolean _sslCopy = false; - String sslCfg = _configDao.getValue(Config.SecStorageEncryptCopy.toString()); + String sslCfg = _configDao.getValue(SecondaryStorageVmManager.SecStorageEncryptCopy.toString()); String _ssvmUrlDomain = _configDao.getValue("secstorage.ssl.cert.domain"); if (sslCfg != null) { _sslCopy = Boolean.parseBoolean(sslCfg); diff --git a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java index a94c04ff4aae..b91b50eeb7d9 100644 --- a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java +++ b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java @@ -75,7 +75,6 @@ import org.apache.logging.log4j.LogManager; import com.cloud.agent.api.Answer; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenter; import com.cloud.event.EventTypes; import com.cloud.event.UsageEventUtils; @@ -86,6 +85,7 @@ import com.cloud.storage.SnapshotVO; import com.cloud.storage.dao.SnapshotDao; import com.cloud.storage.dao.SnapshotDetailsDao; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.template.TemplateConstants; import com.cloud.utils.db.Transaction; import com.cloud.utils.db.TransactionCallbackNoReturn; @@ -189,7 +189,7 @@ public RevertSnapshotContext(AsyncCompletionCallback callback, SnapshotInfo s private String generateCopyUrlBase(String hostname, String dir) { String scheme = "http"; boolean _sslCopy = false; - String sslCfg = _configDao.getValue(Config.SecStorageEncryptCopy.toString()); + String sslCfg = _configDao.getValue(SecondaryStorageVmManager.SecStorageEncryptCopy.toString()); String _ssvmUrlDomain = _configDao.getValue("secstorage.ssl.cert.domain"); if (sslCfg != null) { _sslCopy = Boolean.parseBoolean(sslCfg); diff --git a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/ScaleIOVMSnapshotStrategy.java b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/ScaleIOVMSnapshotStrategy.java index aced750bd320..59731e88324c 100644 --- a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/ScaleIOVMSnapshotStrategy.java +++ b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/ScaleIOVMSnapshotStrategy.java @@ -47,7 +47,7 @@ import com.cloud.event.EventTypes; import com.cloud.event.UsageEventUtils; import com.cloud.event.UsageEventVO; -import com.cloud.server.ManagementServerImpl; +import com.cloud.server.ManagementServer; import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.Storage; import com.cloud.storage.Storage.ImageFormat; @@ -170,7 +170,7 @@ public VMSnapshot takeVMSnapshot(VMSnapshot vmSnapshot) { long virtual_size=0; for (VolumeObjectTO volume : volumeTOs) { String volumeSnapshotName = String.format("%s-%s-%s-%s-%s", ScaleIOUtil.VMSNAPSHOT_PREFIX, vmSnapshotVO.getId(), volume.getId(), - storagePool.getUuid().split("-")[0].substring(4), ManagementServerImpl.customCsIdentifier.value()); + storagePool.getUuid().split("-")[0].substring(4), ManagementServer.customCsIdentifier.value()); srcVolumeDestSnapshotMap.put(ScaleIOUtil.getVolumePath(volume.getPath()), volumeSnapshotName); virtual_size += volume.getSize(); diff --git a/engine/storage/src/main/java/org/apache/cloudstack/storage/LocalHostEndpoint.java b/engine/storage/src/main/java/org/apache/cloudstack/storage/LocalHostEndpoint.java index 758bbe0c8c48..28be8fd819ca 100644 --- a/engine/storage/src/main/java/org/apache/cloudstack/storage/LocalHostEndpoint.java +++ b/engine/storage/src/main/java/org/apache/cloudstack/storage/LocalHostEndpoint.java @@ -33,8 +33,8 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; -import com.cloud.configuration.Config; import com.cloud.resource.ServerResource; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.utils.component.ComponentContext; import com.cloud.utils.net.NetUtils; @@ -51,7 +51,7 @@ public LocalHostEndpoint() { private void configure() { // get mount parent folder configured in global setting, if set, this will overwrite _parent in NfsSecondaryStorageResource to work // around permission issue for default /mnt folder - String mountParent = configDao.getValue(Config.MountParent.key()); + String mountParent = configDao.getValue(SecondaryStorageVmManager.MountParent.key()); String path = mountParent + File.separator + "secStorage"; diff --git a/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java b/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java index 26b39e30776f..013e77cc6c0e 100644 --- a/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java +++ b/engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java @@ -67,7 +67,6 @@ import com.cloud.agent.api.to.NfsTO; import com.cloud.agent.api.to.OVFInformationTO; import com.cloud.alert.AlertManager; -import com.cloud.configuration.Config; import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.OperationTimedoutException; import com.cloud.host.Host; @@ -398,7 +397,7 @@ public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCa (srcdata.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.SNAPSHOT) || (srcdata.getType() == DataObjectType.VOLUME && destData.getType() == DataObjectType.VOLUME)) { - int nMaxExecutionMinutes = NumbersUtil.parseInt(configDao.getValue(Config.SecStorageCmdExecutionTimeMax.key()), 30); + int nMaxExecutionMinutes = NumbersUtil.parseInt(configDao.getValue(AgentManager.SecStorageCmdExecutionTimeMax.key()), 30); CopyCommand cmd = new CopyCommand(srcdata.getTO(), destData.getTO(), nMaxExecutionMinutes * 60 * 1000, VirtualMachineManager.ExecuteInSequence.value()); Answer answer = null; diff --git a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java index 6502de70a1ff..d9d23903bdcb 100644 --- a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java +++ b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java @@ -106,7 +106,6 @@ import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.alert.AlertManager; -import com.cloud.configuration.Config; import com.cloud.configuration.Resource.ResourceType; import com.cloud.dc.dao.ClusterDao; import com.cloud.event.EventTypes; @@ -138,6 +137,7 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; import com.cloud.storage.VMTemplateVO; import com.cloud.storage.Volume; +import com.cloud.storage.VolumeApiService; import com.cloud.storage.VolumeApiServiceImpl; import com.cloud.storage.Volume.State; import com.cloud.storage.VolumeDetailVO; @@ -155,7 +155,6 @@ import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.user.ResourceLimitService; -import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.db.DB; import com.cloud.utils.db.GlobalLock; @@ -669,7 +668,7 @@ public long getTemplatePoolId() { } private TemplateInfo waitForTemplateDownloaded(PrimaryDataStore store, TemplateInfo template) { - int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); + int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value(); int sleepTime = 120; int tries = storagePoolMaxWaitSeconds / sleepTime; while (tries > 0) { @@ -705,7 +704,7 @@ protected void createBaseImageAsync(VolumeInfo volume, PrimaryDataStore dataStor AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().copyBaseImageCallback(null, null)).setContext(context); - int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); + int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value(); if (logger.isDebugEnabled()) { logger.debug("Acquire lock on VMTemplateStoragePool " + templatePoolRefId + " with timeout " + storagePoolMaxWaitSeconds + " seconds"); } @@ -980,7 +979,7 @@ private TemplateInfo createManagedTemplateVolume(TemplateInfo srcTemplateInfo, P // At this point, we have an entry in the DB that points to our cached template. // We need to lock it as there may be other VMs that may get started using the same template. // We want to avoid having to create multiple cache copies of the same template. - int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); + int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value(); long templatePoolRefId = templatePoolRef.getId(); templatePoolRef = _tmpltPoolDao.acquireInLockTable(templatePoolRefId, storagePoolMaxWaitSeconds); @@ -1045,7 +1044,7 @@ public void complete(CreateCmdResult result) { private void copyTemplateToManagedTemplateVolume(TemplateInfo srcTemplateInfo, TemplateInfo templateOnPrimary, VMTemplateStoragePoolVO templatePoolRef, PrimaryDataStore destPrimaryDataStore, Host destHost) throws StorageAccessException { AsyncCallFuture copyTemplateFuture = new AsyncCallFuture<>(); - int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); + int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value(); long templatePoolRefId = templatePoolRef.getId(); try { @@ -1432,7 +1431,7 @@ public TemplateInfo createManagedStorageTemplate(long srcTemplateId, long destDa throw new CloudRuntimeException("Unable to create managed storage template, couldn't get global lock on " + templateIdManagedPoolIdLockString); } - int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); + int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value(); if (!lock.lock(storagePoolMaxWaitSeconds)) { logger.debug("Unable to create managed storage template, couldn't lock on " + templateIdManagedPoolIdLockString); throw new CloudRuntimeException("Unable to create managed storage template, couldn't lock on " + templateIdManagedPoolIdLockString); @@ -1539,7 +1538,7 @@ public AsyncCallFuture createManagedStorageVolumeFromTemplateAs throw new CloudRuntimeException("Unable to create managed storage template/volume, couldn't get global lock on " + tmplIdManagedPoolIdLockString); } - int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); + int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value(); if (!lock.lock(storagePoolMaxWaitSeconds)) { logger.debug("Unable to create managed storage template/volume, couldn't lock on " + tmplIdManagedPoolIdLockString); throw new CloudRuntimeException("Unable to create managed storage template/volume, couldn't lock on " + tmplIdManagedPoolIdLockString); @@ -1611,7 +1610,7 @@ private void createManagedVolumeCopyManagedTemplateAsyncWithLock(VolumeInfo volu throw new CloudRuntimeException("Unable to create volume from template, couldn't get global lock on " + tmplIdManagedPoolIdDestinationHostLockString); } - int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); + int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value(); if (!lock.lock(storagePoolMaxWaitSeconds)) { logger.debug("Unable to create volume from template, couldn't lock on " + tmplIdManagedPoolIdDestinationHostLockString); throw new CloudRuntimeException("Unable to create volume from template, couldn't lock on " + tmplIdManagedPoolIdDestinationHostLockString); diff --git a/framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java b/framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java index 5afef8bc95b6..1b8280d805e8 100644 --- a/framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java +++ b/framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java @@ -54,6 +54,7 @@ import org.apache.cloudstack.quota.vo.QuotaTariffUsageVO; import org.apache.cloudstack.quota.vo.QuotaTariffVO; import org.apache.cloudstack.quota.vo.QuotaUsageVO; +import org.apache.cloudstack.usage.UsageService; import org.apache.cloudstack.usage.UsageUnitTypes; import org.apache.cloudstack.utils.bytescale.ByteScaleUtils; import org.apache.cloudstack.utils.jsinterpreter.JsInterpreter; @@ -123,7 +124,7 @@ public boolean configure(String name, Map params) throws Configu mergeConfigs(configs, params); } - String usageAggregationTimeZoneStr = ObjectUtils.defaultIfNull(configs.get("usage.aggregation.timezone"), "GMT"); + String usageAggregationTimeZoneStr = ObjectUtils.defaultIfNull(UsageService.UsageAggregationTimezone.value(), "GMT"); usageAggregationTimeZone = TimeZone.getTimeZone(usageAggregationTimeZoneStr); return true; diff --git a/plugins/affinity-group-processors/host-anti-affinity/src/main/java/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java b/plugins/affinity-group-processors/host-anti-affinity/src/main/java/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java index bd29a48f2588..ccd0e600dd38 100644 --- a/plugins/affinity-group-processors/host-anti-affinity/src/main/java/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java +++ b/plugins/affinity-group-processors/host-anti-affinity/src/main/java/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java @@ -32,7 +32,6 @@ import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; -import com.cloud.configuration.Config; import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeploymentPlan; import com.cloud.deploy.DeploymentPlanner.ExcludeList; @@ -43,6 +42,7 @@ import com.cloud.utils.db.TransactionCallback; import com.cloud.utils.db.TransactionCallbackNoReturn; import com.cloud.utils.db.TransactionStatus; +import com.cloud.vm.UserVmManager; import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineProfile; @@ -125,7 +125,7 @@ protected void processAffinityGroup(AffinityGroupVMMapVO vmGroupMapping, Exclude @Override public boolean configure(final String name, final Map params) throws ConfigurationException { super.configure(name, params); - _vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600); + _vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(UserVmManager.CapacitySkipcountingHours.key()), 3600); return true; } diff --git a/plugins/affinity-group-processors/non-strict-host-affinity/src/main/java/org/apache/cloudstack/affinity/NonStrictHostAffinityProcessor.java b/plugins/affinity-group-processors/non-strict-host-affinity/src/main/java/org/apache/cloudstack/affinity/NonStrictHostAffinityProcessor.java index 49e3f60ed5d0..8b88a6c94350 100644 --- a/plugins/affinity-group-processors/non-strict-host-affinity/src/main/java/org/apache/cloudstack/affinity/NonStrictHostAffinityProcessor.java +++ b/plugins/affinity-group-processors/non-strict-host-affinity/src/main/java/org/apache/cloudstack/affinity/NonStrictHostAffinityProcessor.java @@ -29,13 +29,13 @@ import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; -import com.cloud.configuration.Config; import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeploymentPlan; import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.exception.AffinityConflictException; import com.cloud.utils.DateUtil; import com.cloud.utils.NumbersUtil; +import com.cloud.vm.UserVmManager; import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineProfile; @@ -119,7 +119,7 @@ protected Integer adjustHostPriority(DeploymentPlan plan, Long hostId) { @Override public boolean configure(final String name, final Map params) throws ConfigurationException { super.configure(name, params); - vmCapacityReleaseInterval = NumbersUtil.parseInt(configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600); + vmCapacityReleaseInterval = NumbersUtil.parseInt(configDao.getValue(UserVmManager.CapacitySkipcountingHours.key()), 3600); return true; } diff --git a/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java b/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java index 663b4fa83544..fb78bc0efd7d 100644 --- a/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java +++ b/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java @@ -32,7 +32,7 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.ratelimit.ApiRateLimitService; -import com.cloud.configuration.Config; +import com.cloud.server.ManagementServer; import com.cloud.user.Account; @APICommand(name = "resetApiLimit", responseObject = SuccessResponse.class, description = "Reset api count", @@ -82,7 +82,7 @@ public long getEntityOwnerId() { @Override public void execute() { - boolean apiLimitEnabled = Boolean.parseBoolean(_configDao.getValue(Config.ApiLimitEnabled.key())); + boolean apiLimitEnabled = Boolean.parseBoolean(_configDao.getValue(ManagementServer.ApiLimitEnabled.key())); if (!apiLimitEnabled) { throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "This api is only available when api.throttling.enabled = true."); } diff --git a/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java b/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java index eafe2782d33f..b40993808ed9 100644 --- a/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java +++ b/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java @@ -28,7 +28,7 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.ratelimit.ApiRateLimitService; -import com.cloud.configuration.Config; +import com.cloud.server.ManagementServer; import com.cloud.user.Account; @APICommand(name = "getApiLimit", responseObject = ApiLimitResponse.class, description = "Get API limit count for the caller", @@ -58,7 +58,7 @@ public long getEntityOwnerId() { @Override public void execute() { - boolean apiLimitEnabled = Boolean.parseBoolean(_configDao.getValue(Config.ApiLimitEnabled.key())); + boolean apiLimitEnabled = Boolean.parseBoolean(_configDao.getValue(ManagementServer.ApiLimitEnabled.key())); if (!apiLimitEnabled) { throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "This api is only available when api.throttling.enabled = true."); } diff --git a/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/ratelimit/ApiRateLimitService.java b/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/ratelimit/ApiRateLimitService.java index bb97f5a6ee09..db886994ae3e 100644 --- a/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/ratelimit/ApiRateLimitService.java +++ b/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/ratelimit/ApiRateLimitService.java @@ -17,6 +17,7 @@ package org.apache.cloudstack.ratelimit; import org.apache.cloudstack.api.response.ApiLimitResponse; +import org.apache.cloudstack.framework.config.ConfigKey; import com.cloud.user.Account; import com.cloud.utils.component.PluggableService; @@ -27,6 +28,9 @@ */ public interface ApiRateLimitService extends PluggableService { + ConfigKey ApiLimitCacheSize = new ConfigKey<>("Advanced", Integer.class, "api.throttling.cachesize", "50000", + "Account based API count cache size", true); + public ApiLimitResponse searchApiLimit(Account caller); public boolean resetApiLimit(Long accountId); diff --git a/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java b/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java index afa2b6155de6..eabce64ac3e1 100644 --- a/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java +++ b/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java @@ -37,18 +37,20 @@ import org.apache.cloudstack.api.command.admin.ratelimit.ResetApiLimitCmd; import org.apache.cloudstack.api.command.user.ratelimit.GetApiLimitCmd; import org.apache.cloudstack.api.response.ApiLimitResponse; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; -import com.cloud.configuration.Config; import com.cloud.exception.PermissionDeniedException; import com.cloud.exception.RequestLimitException; +import com.cloud.server.ManagementServer; import com.cloud.user.Account; import com.cloud.user.AccountService; import com.cloud.user.User; import com.cloud.utils.component.AdapterBase; @Component -public class ApiRateLimitServiceImpl extends AdapterBase implements APIChecker, ApiRateLimitService { +public class ApiRateLimitServiceImpl extends AdapterBase implements APIChecker, ApiRateLimitService, Configurable { /** * True if api rate limiting is enabled @@ -79,22 +81,22 @@ public boolean configure(String name, Map params) throws Configu if (_store == null) { // get global configured duration and max values - String isEnabled = _configDao.getValue(Config.ApiLimitEnabled.key()); + String isEnabled = _configDao.getValue(ManagementServer.ApiLimitEnabled.key()); if (isEnabled != null) { enabled = Boolean.parseBoolean(isEnabled); } - String duration = _configDao.getValue(Config.ApiLimitInterval.key()); + String duration = _configDao.getValue(ManagementServer.ApiLimitInterval.key()); if (duration != null) { timeToLive = Integer.parseInt(duration); } - String maxReqs = _configDao.getValue(Config.ApiLimitMax.key()); + String maxReqs = _configDao.getValue(ManagementServer.ApiLimitMax.key()); if (maxReqs != null) { maxAllowed = Integer.parseInt(maxReqs); } // create limit store EhcacheLimitStore cacheStore = new EhcacheLimitStore(); int maxElements = 10000; - String cachesize = _configDao.getValue(Config.ApiLimitCacheSize.key()); + String cachesize = _configDao.getValue(ApiLimitCacheSize.key()); if (cachesize != null) { maxElements = Integer.parseInt(cachesize); } @@ -264,4 +266,14 @@ public void setEnabled(boolean enabled) { this.enabled = enabled; } + + @Override + public String getConfigComponentName() { + return ApiRateLimitService.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {ApiLimitCacheSize}; + } } diff --git a/plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java b/plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java index 6bfd201253ff..e577c4cf90f6 100644 --- a/plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java +++ b/plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java @@ -36,8 +36,8 @@ import org.apache.cloudstack.api.response.ApiLimitResponse; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; -import com.cloud.configuration.Config; import com.cloud.exception.RequestLimitException; +import com.cloud.server.ManagementServer; import com.cloud.user.Account; import com.cloud.user.AccountService; import com.cloud.user.AccountVO; @@ -55,10 +55,10 @@ public class ApiRateLimitTest { @BeforeClass public static void setUp() throws ConfigurationException { - when(s_configDao.getValue(Config.ApiLimitInterval.key())).thenReturn(null); - when(s_configDao.getValue(Config.ApiLimitMax.key())).thenReturn(null); - when(s_configDao.getValue(Config.ApiLimitCacheSize.key())).thenReturn(null); - when(s_configDao.getValue(Config.ApiLimitEnabled.key())).thenReturn("true"); // enable api rate limiting + when(s_configDao.getValue(ManagementServer.ApiLimitInterval.key())).thenReturn(null); + when(s_configDao.getValue(ManagementServer.ApiLimitMax.key())).thenReturn(null); + when(s_configDao.getValue(ApiRateLimitService.ApiLimitCacheSize.key())).thenReturn(null); + when(s_configDao.getValue(ManagementServer.ApiLimitEnabled.key())).thenReturn("true"); // enable api rate limiting s_limitService._configDao = s_configDao; s_limitService.configure("ApiRateLimitTest", Collections. emptyMap()); diff --git a/plugins/ca/root-ca/src/main/java/org/apache/cloudstack/ca/provider/RootCAProvider.java b/plugins/ca/root-ca/src/main/java/org/apache/cloudstack/ca/provider/RootCAProvider.java index afb4f561160e..a256166313f5 100644 --- a/plugins/ca/root-ca/src/main/java/org/apache/cloudstack/ca/provider/RootCAProvider.java +++ b/plugins/ca/root-ca/src/main/java/org/apache/cloudstack/ca/provider/RootCAProvider.java @@ -78,7 +78,7 @@ import org.bouncycastle.util.io.pem.PemReader; import com.cloud.certificate.dao.CrlDao; -import com.cloud.configuration.Config; +import com.cloud.server.ManagementServer; import com.cloud.utils.component.AdapterBase; import com.cloud.utils.db.GlobalLock; import com.cloud.utils.exception.CloudRuntimeException; @@ -439,7 +439,7 @@ private boolean loadManagementKeyStore() { } protected void addConfiguredManagementIp(List ipList) { - String msNetworkCidr = configDao.getValue(Config.ManagementNetwork.key()); + String msNetworkCidr = configDao.getValue(ManagementServer.ManagementNetwork.key()); try { logger.debug(String.format("Trying to find management IP in CIDR range [%s].", msNetworkCidr)); Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); diff --git a/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaServiceImpl.java b/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaServiceImpl.java index a788f0c8b01e..7a0ff05138b1 100644 --- a/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaServiceImpl.java +++ b/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaServiceImpl.java @@ -59,11 +59,11 @@ import org.apache.cloudstack.quota.vo.QuotaAccountVO; import org.apache.cloudstack.quota.vo.QuotaBalanceVO; import org.apache.cloudstack.quota.vo.QuotaUsageJoinVO; +import org.apache.cloudstack.usage.UsageService; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.time.DateUtils; import org.springframework.stereotype.Component; -import com.cloud.configuration.Config; import com.cloud.domain.dao.DomainDao; import com.cloud.exception.InvalidParameterValueException; import com.cloud.user.Account; @@ -103,7 +103,7 @@ public QuotaServiceImpl() { public boolean configure(String name, Map params) throws ConfigurationException { super.configure(name, params); - String timeZoneStr = ObjectUtils.defaultIfNull(_configDao.getValue(Config.UsageAggregationTimezone.toString()), "GMT"); + String timeZoneStr = ObjectUtils.defaultIfNull(UsageService.UsageAggregationTimezone.value(), "GMT"); _usageTimezone = TimeZone.getTimeZone(timeZoneStr); return true; diff --git a/plugins/database/quota/src/test/java/org/apache/cloudstack/quota/QuotaServiceImplTest.java b/plugins/database/quota/src/test/java/org/apache/cloudstack/quota/QuotaServiceImplTest.java index c0ee6c5fc3fe..9126c36a203e 100644 --- a/plugins/database/quota/src/test/java/org/apache/cloudstack/quota/QuotaServiceImplTest.java +++ b/plugins/database/quota/src/test/java/org/apache/cloudstack/quota/QuotaServiceImplTest.java @@ -16,7 +16,6 @@ // under the License. package org.apache.cloudstack.quota; -import com.cloud.configuration.Config; import com.cloud.domain.dao.DomainDao; import com.cloud.exception.InvalidParameterValueException; import com.cloud.user.AccountVO; @@ -109,7 +108,6 @@ public void setup() throws IllegalAccessException, NoSuchFieldException, Configu QuotaResponseBuilderField.setAccessible(true); QuotaResponseBuilderField.set(quotaServiceImplSpy, respBldr); - Mockito.when(configDao.getValue(Mockito.eq(Config.UsageAggregationTimezone.toString()))).thenReturn("IST"); quotaServiceImplSpy.configure("randomName", null); } diff --git a/plugins/dedicated-resources/src/main/java/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java b/plugins/dedicated-resources/src/main/java/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java index 1f0207267932..a16514217100 100644 --- a/plugins/dedicated-resources/src/main/java/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java +++ b/plugins/dedicated-resources/src/main/java/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java @@ -49,7 +49,6 @@ import org.apache.logging.log4j.Logger; import org.springframework.stereotype.Component; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenterVO; import com.cloud.dc.DedicatedResourceVO; @@ -81,6 +80,7 @@ import com.cloud.utils.db.TransactionCallbackNoReturn; import com.cloud.utils.db.TransactionStatus; import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.vm.UserVmManager; import com.cloud.vm.UserVmVO; import com.cloud.vm.dao.UserVmDao; @@ -117,7 +117,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { private int capacityReleaseInterval; public boolean configure(final String name, final Map params) throws ConfigurationException { - capacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600); + capacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(UserVmManager.CapacitySkipcountingHours.key()), 3600); return true; } diff --git a/plugins/deployment-planners/implicit-dedication/src/main/java/com/cloud/deploy/ImplicitDedicationPlanner.java b/plugins/deployment-planners/implicit-dedication/src/main/java/com/cloud/deploy/ImplicitDedicationPlanner.java index f9cde2ae4414..74912aeddcb1 100644 --- a/plugins/deployment-planners/implicit-dedication/src/main/java/com/cloud/deploy/ImplicitDedicationPlanner.java +++ b/plugins/deployment-planners/implicit-dedication/src/main/java/com/cloud/deploy/ImplicitDedicationPlanner.java @@ -28,7 +28,6 @@ import org.apache.commons.collections.CollectionUtils; -import com.cloud.configuration.Config; import com.cloud.exception.InsufficientServerCapacityException; import com.cloud.resource.ResourceManager; import com.cloud.service.ServiceOfferingVO; @@ -37,6 +36,7 @@ import com.cloud.user.Account; import com.cloud.utils.DateUtil; import com.cloud.utils.NumbersUtil; +import com.cloud.vm.UserVmManager; import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachineProfile; @@ -55,7 +55,7 @@ public class ImplicitDedicationPlanner extends FirstFitPlanner implements Deploy @Override public boolean configure(final String name, final Map params) throws ConfigurationException { super.configure(name, params); - capacityReleaseInterval = NumbersUtil.parseInt(configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600); + capacityReleaseInterval = NumbersUtil.parseInt(configDao.getValue(UserVmManager.CapacitySkipcountingHours.key()), 3600); return true; } diff --git a/plugins/deployment-planners/user-dispersing/src/main/java/com/cloud/deploy/UserDispersingPlanner.java b/plugins/deployment-planners/user-dispersing/src/main/java/com/cloud/deploy/UserDispersingPlanner.java index c5d81e9a51b8..0698f9643097 100644 --- a/plugins/deployment-planners/user-dispersing/src/main/java/com/cloud/deploy/UserDispersingPlanner.java +++ b/plugins/deployment-planners/user-dispersing/src/main/java/com/cloud/deploy/UserDispersingPlanner.java @@ -26,7 +26,6 @@ import javax.naming.ConfigurationException; -import com.cloud.configuration.Config; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.vm.VirtualMachineProfile; @@ -188,7 +187,7 @@ private List orderByApplyingWeights(Pair, Map> ca public boolean configure(String name, Map params) throws ConfigurationException { super.configure(name, params); - String weight = configDao.getValue(Config.VmUserDispersionWeight.key()); + String weight = configDao.getValue(VmUserDispersionWeight.key()); _userDispersionWeight = NumbersUtil.parseFloat(weight, 1.0f); return true; diff --git a/plugins/hypervisors/baremetal/src/main/java/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java b/plugins/hypervisors/baremetal/src/main/java/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java index 3a2384a03c85..84195de9d45e 100644 --- a/plugins/hypervisors/baremetal/src/main/java/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java +++ b/plugins/hypervisors/baremetal/src/main/java/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java @@ -201,7 +201,7 @@ public boolean addUserData(NicProfile nic, VirtualMachineProfile profile) { cmd.addVmData("metadata", "instance-id", String.valueOf(vm.getUuid())); cmd.addVmData("metadata", "vm-id", String.valueOf(vm.getInstanceName())); cmd.addVmData("metadata", "public-keys", null); - String cloudIdentifier = _configDao.getValue("cloud.identifier"); + String cloudIdentifier = NetworkModel.CloudIdentifier.value(); if (cloudIdentifier == null) { cloudIdentifier = ""; } else { diff --git a/plugins/hypervisors/hyperv/src/main/java/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java b/plugins/hypervisors/hyperv/src/main/java/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java index a5fe1442e56e..3234df0f10b6 100644 --- a/plugins/hypervisors/hyperv/src/main/java/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java +++ b/plugins/hypervisors/hyperv/src/main/java/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java @@ -41,7 +41,6 @@ import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; import com.cloud.alert.AlertManager; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; @@ -62,6 +61,7 @@ import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; import com.cloud.resource.UnableDeleteHostException; +import com.cloud.server.ManagementServer; import com.cloud.storage.StorageLayer; import com.cloud.utils.UuidUtils; @@ -285,7 +285,7 @@ public final Map> find(final long params.putAll(details); - params.put("router.aggregation.command.each.timeout", _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString())); + params.put("router.aggregation.command.each.timeout", _configDao.getValue(ManagementServer.RouterAggregationCommandEachTimeout.key())); HypervDirectConnectResource resource = new HypervDirectConnectResource(); resource.configure(agentIp, params); diff --git a/plugins/hypervisors/hyperv/src/main/java/com/cloud/hypervisor/hyperv/manager/HypervManagerImpl.java b/plugins/hypervisors/hyperv/src/main/java/com/cloud/hypervisor/hyperv/manager/HypervManagerImpl.java index a31637b60deb..ca4c1cafd02b 100644 --- a/plugins/hypervisors/hyperv/src/main/java/com/cloud/hypervisor/hyperv/manager/HypervManagerImpl.java +++ b/plugins/hypervisors/hyperv/src/main/java/com/cloud/hypervisor/hyperv/manager/HypervManagerImpl.java @@ -36,9 +36,11 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import com.cloud.configuration.Config; +import com.cloud.agent.AgentManager; +import com.cloud.network.router.VirtualNetworkApplianceManager; import com.cloud.storage.JavaStorageLayer; import com.cloud.storage.StorageLayer; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.utils.FileUtil; import com.cloud.utils.NumbersUtil; import com.cloud.utils.db.GlobalLock; @@ -78,7 +80,7 @@ public boolean configure(String name, Map params) throws Configu _storage = new JavaStorageLayer(); _storage.configure("StorageLayer", params); } - _routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2); + _routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(VirtualNetworkApplianceManager.RouterExtraPublicNics.key()), 2); return true; } @@ -313,12 +315,12 @@ private File getSystemVMPatchIsoFile() { } private String getMountParent() { - String mountParent = _configDao.getValue(Config.MountParent.key()); + String mountParent = _configDao.getValue(SecondaryStorageVmManager.MountParent.key()); if (mountParent == null) { mountParent = File.separator + "mnt"; } - String instance = _configDao.getValue(Config.InstanceName.key()); + String instance = _configDao.getValue(AgentManager.InstanceName.key()); if (instance == null) { instance = "DEFAULT"; } diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 4281036d9456..3dbac7d7c041 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -173,7 +173,7 @@ import com.cloud.agent.resource.virtualnetwork.VRScripts; import com.cloud.agent.resource.virtualnetwork.VirtualRouterDeployer; import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; -import com.cloud.configuration.Config; +import com.cloud.agent.AgentManager; import com.cloud.dc.Vlan; import com.cloud.exception.InternalErrorException; import com.cloud.host.Host.Type; @@ -1735,8 +1735,8 @@ public boolean configureHostParams(final Map params) { storage.persist(AgentProperties.ROUTER_AGGREGATION_COMMAND_EACH_TIMEOUT.getName(), String.valueOf(longValue)); } - if (params.get(Config.MigrateWait.toString()) != null) { - String value = (String)params.get(Config.MigrateWait.toString()); + if (params.get(AgentManager.MigrateWait.toString()) != null) { + String value = (String)params.get(AgentManager.MigrateWait.toString()); Integer intValue = NumbersUtil.parseInt(value, -1); storage.persist("vm.migrate.wait", String.valueOf(intValue)); migrateWait = intValue; diff --git a/plugins/hypervisors/ovm/src/main/java/com/cloud/ovm/hypervisor/OvmDiscoverer.java b/plugins/hypervisors/ovm/src/main/java/com/cloud/ovm/hypervisor/OvmDiscoverer.java index 7dfd98301d72..7914b261aec1 100644 --- a/plugins/hypervisors/ovm/src/main/java/com/cloud/ovm/hypervisor/OvmDiscoverer.java +++ b/plugins/hypervisors/ovm/src/main/java/com/cloud/ovm/hypervisor/OvmDiscoverer.java @@ -31,7 +31,6 @@ import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterVO; import com.cloud.dc.dao.ClusterDao; import com.cloud.exception.DiscoveryException; @@ -46,6 +45,7 @@ import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; import com.cloud.resource.UnableDeleteHostException; +import com.cloud.server.ManagementServer; import com.cloud.utils.UuidUtils; import com.cloud.utils.db.QueryBuilder; import com.cloud.utils.db.SearchCriteria; @@ -65,9 +65,9 @@ public class OvmDiscoverer extends DiscovererBase implements Discoverer, Resourc @Override public boolean configure(String name, Map params) throws ConfigurationException { super.configure(name, params); - _publicNetworkDevice = _params.get(Config.OvmPublicNetwork.key()); - _privateNetworkDevice = _params.get(Config.OvmPrivateNetwork.key()); - _guestNetworkDevice = _params.get(Config.OvmGuestNetwork.key()); + _publicNetworkDevice = ManagementServer.OvmPublicNetwork.value(); + _privateNetworkDevice = ManagementServer.OvmPrivateNetwork.value(); + _guestNetworkDevice = ManagementServer.OvmGuestNetwork.value(); _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this); return true; } diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3Discoverer.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3Discoverer.java index 52cc419ad2e4..30a5b98176f4 100755 --- a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3Discoverer.java +++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3Discoverer.java @@ -38,7 +38,6 @@ import com.cloud.agent.api.Command; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterVO; import com.cloud.dc.dao.ClusterDao; @@ -58,6 +57,7 @@ import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; import com.cloud.resource.UnableDeleteHostException; +import com.cloud.server.ManagementServer; import com.cloud.utils.UuidUtils; import com.cloud.utils.db.QueryBuilder; import com.cloud.utils.db.SearchCriteria; @@ -93,11 +93,10 @@ public boolean configure(String name, Map params) return false; } - /* these are in Config.java */ - publicNetworkDevice = _params.get(Config.Ovm3PublicNetwork.key()); - privateNetworkDevice = _params.get(Config.Ovm3PrivateNetwork.key()); - guestNetworkDevice = _params.get(Config.Ovm3GuestNetwork.key()); - storageNetworkDevice = _params.get(Config.Ovm3StorageNetwork.key()); + publicNetworkDevice = ManagementServer.Ovm3PublicNetwork.value(); + privateNetworkDevice = ManagementServer.Ovm3PrivateNetwork.value(); + guestNetworkDevice = ManagementServer.Ovm3GuestNetwork.value(); + storageNetworkDevice = ManagementServer.Ovm3StorageNetwork.value(); resourceMgr.registerResourceStateAdapter(this.getClass() .getSimpleName(), this); return true; diff --git a/plugins/hypervisors/ucs/src/main/java/com/cloud/ucs/manager/UcsManager.java b/plugins/hypervisors/ucs/src/main/java/com/cloud/ucs/manager/UcsManager.java index 24356172a9e3..21661344f783 100644 --- a/plugins/hypervisors/ucs/src/main/java/com/cloud/ucs/manager/UcsManager.java +++ b/plugins/hypervisors/ucs/src/main/java/com/cloud/ucs/manager/UcsManager.java @@ -26,11 +26,16 @@ import org.apache.cloudstack.api.response.UcsBladeResponse; import org.apache.cloudstack.api.response.UcsManagerResponse; import org.apache.cloudstack.api.response.UcsProfileResponse; +import org.apache.cloudstack.framework.config.ConfigKey; import com.cloud.utils.component.Manager; import com.cloud.utils.component.PluggableService; public interface UcsManager extends Manager, PluggableService { + + ConfigKey UCSSyncBladeInterval = new ConfigKey<>("Advanced", Integer.class, "ucs.sync.blade.interval", "3600", + "the interval cloudstack sync with UCS manager for available blades in case user remove blades from chassis without notifying CloudStack", true); + UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd); ListResponse listUcsProfiles(ListUcsProfileCmd cmd); diff --git a/plugins/hypervisors/ucs/src/main/java/com/cloud/ucs/manager/UcsManagerImpl.java b/plugins/hypervisors/ucs/src/main/java/com/cloud/ucs/manager/UcsManagerImpl.java index 6127ed012f35..dd7eeadf895b 100644 --- a/plugins/hypervisors/ucs/src/main/java/com/cloud/ucs/manager/UcsManagerImpl.java +++ b/plugins/hypervisors/ucs/src/main/java/com/cloud/ucs/manager/UcsManagerImpl.java @@ -39,12 +39,13 @@ import org.apache.cloudstack.api.response.UcsBladeResponse; import org.apache.cloudstack.api.response.UcsManagerResponse; import org.apache.cloudstack.api.response.UcsProfileResponse; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.ClusterDao; @@ -67,7 +68,7 @@ import com.cloud.utils.xmlobject.XmlObject; import com.cloud.utils.xmlobject.XmlObjectParser; -public class UcsManagerImpl implements UcsManager { +public class UcsManagerImpl implements UcsManager, Configurable { protected Logger logger = LogManager.getLogger(getClass()); public static final Long COOKIE_TTL = TimeUnit.MILLISECONDS.convert(100L, TimeUnit.MINUTES); public static final Long COOKIE_REFRESH_TTL = TimeUnit.MILLISECONDS.convert(10L, TimeUnit.MINUTES); @@ -173,7 +174,7 @@ public boolean configure(String name, Map params) throws Configu @Override public boolean start() { try { - syncBladeInterval = Integer.parseInt(configDao.getValue(Config.UCSSyncBladeInterval.key())); + syncBladeInterval = Integer.parseInt(configDao.getValue(UCSSyncBladeInterval.key())); } catch (NumberFormatException e) { syncBladeInterval = 600; } @@ -509,4 +510,14 @@ public void deleteUcsManager(Long id) { } ucsDao.remove(id); } + + @Override + public String getConfigComponentName() { + return UcsManager.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {UCSSyncBladeInterval}; + } } diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java index 9391e0956254..aba10e96d033 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java @@ -32,7 +32,6 @@ import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; import com.cloud.alert.AlertManager; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenter.NetworkType; @@ -66,6 +65,7 @@ import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; import com.cloud.resource.UnableDeleteHostException; +import com.cloud.server.ManagementServer; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.TemplateType; import com.cloud.storage.VMTemplateVO; @@ -381,7 +381,7 @@ public VmwareServerDiscoverer() { params.put("guestTrafficInfo", guestTrafficLabelObj); params.put("publicTrafficInfo", publicTrafficLabelObj); - params.put("router.aggregation.command.each.timeout", _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString())); + params.put("router.aggregation.command.each.timeout", _configDao.getValue(ManagementServer.RouterAggregationCommandEachTimeout.key())); VmwareResource resource = new VmwareResource(); try { @@ -694,9 +694,9 @@ private VmwareTrafficLabel getTrafficInfo(TrafficType trafficType, String zoneWi private void _readGlobalConfigParameters() { String value; if (_configDao != null) { - value = _configDao.getValue(Config.VmwareUseDVSwitch.key()); + value = _configDao.getValue(ManagementServer.VmwareUseDVSwitch.key()); useDVS = Boolean.parseBoolean(value); - value = _configDao.getValue(Config.VmwareUseNexusVSwitch.key()); + value = _configDao.getValue(ManagementServer.VmwareUseNexusVSwitch.key()); nexusDVS = Boolean.parseBoolean(value); } } diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManager.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManager.java index 8be881b94940..8bc88281c2d5 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManager.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManager.java @@ -61,6 +61,24 @@ public interface VmwareManager { "Specify the default network device type for user VMs, valid values are E1000, PCNet32, Vmxnet2, Vmxnet3", true, ConfigKey.Scope.Global, null, null, null, null, null, ConfigKey.Kind.Select, "E1000,PCNet32,Vmxnet2,Vmxnet3"); + ConfigKey VmwareServiceConsole = new ConfigKey<>("Advanced", String.class, "vmware.service.console", "Service Console", + "Specify the service console network name(for ESX hosts)", true); + + ConfigKey VmwareManagementPortGroup = new ConfigKey<>("Advanced", String.class, "vmware.management.portgroup", "Management Network", + "Specify the management network name(for ESXi hosts)", true); + + ConfigKey VmwareAdditionalVncPortRangeStart = new ConfigKey<>("Advanced", Integer.class, "vmware.additional.vnc.portrange.start", "50000", + "Start port number of additional VNC port range", true); + + ConfigKey VmwareAdditionalVncPortRangeSize = new ConfigKey<>("Advanced", Integer.class, "vmware.additional.vnc.portrange.size", "1000", + "Start port number of additional VNC port range", true); + + ConfigKey VmwareRecycleHungWorker = new ConfigKey<>("Advanced", Boolean.class, "vmware.recycle.hung.wokervm", "false", + "Specify whether or not to recycle hung worker VMs", true); + + ConfigKey VmwareVcenterSessionTimeout = new ConfigKey<>("Advanced", Long.class, "vmware.vcenter.session.timeout", "1200", + "VMware client timeout in seconds", true); + String composeWorkerName(); String getSystemVMIsoFileNameOnDatastore(); diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java index 8052317817ad..44059d243725 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java @@ -82,7 +82,6 @@ import com.cloud.api.query.dao.TemplateJoinDao; import com.cloud.cluster.ClusterManager; import com.cloud.cluster.dao.ManagementServerHostPeerDao; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterVO; import com.cloud.dc.ClusterVSMMapVO; @@ -143,6 +142,7 @@ import com.cloud.org.Cluster.ClusterType; import com.cloud.secstorage.CommandExecLogDao; import com.cloud.server.ConfigurationServer; +import com.cloud.server.ManagementServer; import com.cloud.storage.ImageStoreDetailsUtil; import com.cloud.storage.JavaStorageLayer; import com.cloud.storage.StorageLayer; @@ -150,6 +150,7 @@ import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePoolStatus; import com.cloud.storage.dao.VMTemplatePoolDao; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.template.TemplateManager; import com.cloud.utils.FileUtil; import com.cloud.utils.NumbersUtil; @@ -167,6 +168,7 @@ import com.cloud.utils.script.Script; import com.cloud.utils.ssh.SshHelper; import com.cloud.vm.DomainRouterVO; +import com.cloud.vm.UserVmManager; import com.cloud.vm.dao.UserVmCloneSettingDao; import com.cloud.vm.dao.VMInstanceDao; import com.vmware.pbm.PbmProfile; @@ -301,7 +303,8 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {s_vmwareNicHotplugWaitTimeout, s_vmwareCleanOldWorderVMs, templateCleanupInterval, s_vmwareSearchExcludeFolder, s_vmwareOVAPackageTimeout, s_vmwareCleanupPortGroups, VMWARE_STATS_TIME_WINDOW, VmwareUserVmNicDeviceType}; + return new ConfigKey[] {s_vmwareNicHotplugWaitTimeout, s_vmwareCleanOldWorderVMs, templateCleanupInterval, s_vmwareSearchExcludeFolder, s_vmwareOVAPackageTimeout, s_vmwareCleanupPortGroups, VMWARE_STATS_TIME_WINDOW, VmwareUserVmNicDeviceType, + VmwareServiceConsole, VmwareManagementPortGroup, VmwareAdditionalVncPortRangeStart, VmwareAdditionalVncPortRangeSize, VmwareRecycleHungWorker, VmwareVcenterSessionTimeout}; } @Override public boolean configure(String name, Map params) throws ConfigurationException { @@ -312,13 +315,13 @@ public boolean configure(String name, Map params) throws Configu throw new ConfigurationException("Vmware component can only run under premium distribution"); } - _instance = _configDao.getValue(Config.InstanceName.key()); + _instance = _configDao.getValue(AgentManager.InstanceName.key()); if (_instance == null) { _instance = "DEFAULT"; } logger.info("VmwareManagerImpl config - instance.name: " + _instance); - _mountParent = _configDao.getValue(Config.MountParent.key()); + _mountParent = _configDao.getValue(SecondaryStorageVmManager.MountParent.key()); if (_mountParent == null) { _mountParent = File.separator + "mnt"; } @@ -339,49 +342,49 @@ public boolean configure(String name, Map params) throws Configu _fullCloneFlag = StorageManager.VmwareCreateCloneFull.value(); - value = _configDao.getValue(Config.SetVmInternalNameUsingDisplayName.key()); + value = _configDao.getValue(UserVmManager.SetVmInternalNameUsingDisplayName.key()); if (value == null) { _instanceNameFlag = false; } else { _instanceNameFlag = Boolean.parseBoolean(value); } - _serviceConsoleName = _configDao.getValue(Config.VmwareServiceConsole.key()); + _serviceConsoleName = _configDao.getValue(VmwareServiceConsole.key()); if (_serviceConsoleName == null) { _serviceConsoleName = "Service Console"; } - _managementPortGroupName = _configDao.getValue(Config.VmwareManagementPortGroup.key()); + _managementPortGroupName = _configDao.getValue(VmwareManagementPortGroup.key()); if (_managementPortGroupName == null) { _managementPortGroupName = "Management Network"; } - _defaultSystemVmNicAdapterType = _configDao.getValue(Config.VmwareSystemVmNicDeviceType.key()); + _defaultSystemVmNicAdapterType = _configDao.getValue(ManagementServer.VmwareSystemVmNicDeviceType.key()); if (_defaultSystemVmNicAdapterType == null) { _defaultSystemVmNicAdapterType = VirtualEthernetCardType.E1000.toString(); } - _additionalPortRangeStart = NumbersUtil.parseInt(_configDao.getValue(Config.VmwareAdditionalVncPortRangeStart.key()), 59000); + _additionalPortRangeStart = NumbersUtil.parseInt(_configDao.getValue(VmwareAdditionalVncPortRangeStart.key()), 59000); if (_additionalPortRangeStart > 65535) { logger.warn("Invalid port range start port (" + _additionalPortRangeStart + ") for additional VNC port allocation, reset it to default start port 59000"); _additionalPortRangeStart = 59000; } - _additionalPortRangeSize = NumbersUtil.parseInt(_configDao.getValue(Config.VmwareAdditionalVncPortRangeSize.key()), 1000); + _additionalPortRangeSize = NumbersUtil.parseInt(_configDao.getValue(VmwareAdditionalVncPortRangeSize.key()), 1000); if (_additionalPortRangeSize < 0 || _additionalPortRangeStart + _additionalPortRangeSize > 65535) { logger.warn("Invalid port range size (" + _additionalPortRangeSize + " for range starts at " + _additionalPortRangeStart); _additionalPortRangeSize = Math.min(1000, 65535 - _additionalPortRangeStart); } - _vCenterSessionTimeout = NumbersUtil.parseInt(_configDao.getValue(Config.VmwareVcenterSessionTimeout.key()), 1200) * 1000; + _vCenterSessionTimeout = NumbersUtil.parseInt(_configDao.getValue(VmwareVcenterSessionTimeout.key()), 1200) * 1000; logger.info("VmwareManagerImpl config - vmware.vcenter.session.timeout: " + _vCenterSessionTimeout); - _recycleHungWorker = _configDao.getValue(Config.VmwareRecycleHungWorker.key()); + _recycleHungWorker = _configDao.getValue(VmwareRecycleHungWorker.key()); if (_recycleHungWorker == null || _recycleHungWorker.isEmpty()) { _recycleHungWorker = "false"; } - _rootDiskController = _configDao.getValue(Config.VmwareRootDiskControllerType.key()); + _rootDiskController = _configDao.getValue(ManagementServer.VmwareRootDiskControllerType.key()); if (_rootDiskController == null || _rootDiskController.isEmpty()) { _rootDiskController = DiskControllerType.ide.toString(); } diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/network/element/CiscoNexusVSMElement.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/network/element/CiscoNexusVSMElement.java index 193270cc1563..d5b1878c57da 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/network/element/CiscoNexusVSMElement.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/network/element/CiscoNexusVSMElement.java @@ -29,7 +29,6 @@ import com.cloud.api.commands.EnableCiscoNexusVSMCmd; import com.cloud.api.commands.ListCiscoNexusVSMsCmd; import com.cloud.api.response.CiscoNexusVSMResponse; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterVO; import com.cloud.dc.ClusterVSMMapVO; import com.cloud.dc.dao.ClusterDao; @@ -52,6 +51,7 @@ import com.cloud.network.dao.CiscoNexusVSMDeviceDao; import com.cloud.offering.NetworkOffering; import com.cloud.org.Cluster; +import com.cloud.server.ManagementServer; import com.cloud.server.ManagementService; import com.cloud.utils.Pair; import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper; @@ -303,7 +303,7 @@ public CiscoNexusVSMDeviceVO doInTransaction(TransactionStatus status) { } else { String msg; - msg = "The global parameter " + Config.VmwareUseNexusVSwitch.toString() + " is set to \"true\". Following mandatory parameters are not specified. "; + msg = "The global parameter " + ManagementServer.VmwareUseNexusVSwitch.key() + " is set to \"true\". Following mandatory parameters are not specified. "; if (vsmIp == null) { msg += "vsmipaddress: Management IP address of Cisco Nexus 1000v dvSwitch. "; } diff --git a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java index 6d298629e7ef..841c26f34c52 100644 --- a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java +++ b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java @@ -49,7 +49,6 @@ import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; import com.cloud.alert.AlertManager; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; @@ -84,6 +83,7 @@ import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; import com.cloud.resource.UnableDeleteHostException; +import com.cloud.server.ManagementServer; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.TemplateType; import com.cloud.storage.VMTemplateVO; @@ -351,15 +351,15 @@ protected boolean poolHasHotFix(Connection conn, String hostIp, String hotFixUui boolean securityGroupEnabled = zone.isSecurityGroupEnabled() || _networkMgr.isSecurityGroupSupportedForZone(zone.getId()); params.put("securitygroupenabled", Boolean.toString(securityGroupEnabled)); - params.put("router.aggregation.command.each.timeout", _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString())); + params.put("router.aggregation.command.each.timeout", _configDao.getValue(ManagementServer.RouterAggregationCommandEachTimeout.key())); params.put("wait", Integer.toString(_wait)); details.put("wait", Integer.toString(_wait)); - params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString())); - params.put(Config.XenServerMaxNics.toString().toLowerCase(), _configDao.getValue(Config.XenServerMaxNics.toString())); - params.put(Config.XenServerHeartBeatTimeout.toString().toLowerCase(), _configDao.getValue(Config.XenServerHeartBeatTimeout.toString())); - params.put(Config.XenServerHeartBeatInterval.toString().toLowerCase(), _configDao.getValue(Config.XenServerHeartBeatInterval.toString())); - params.put(Config.InstanceName.toString().toLowerCase(), _instance); - details.put(Config.InstanceName.toString().toLowerCase(), _instance); + params.put("migratewait", _configDao.getValue(AgentManager.MigrateWait.toString())); + params.put(AgentManager.XenServerMaxNics.toString().toLowerCase(), _configDao.getValue(AgentManager.XenServerMaxNics.toString())); + params.put(ManagementServer.XenServerHeartBeatTimeout.key().toLowerCase(), _configDao.getValue(ManagementServer.XenServerHeartBeatTimeout.key())); + params.put(ManagementServer.XenServerHeartBeatInterval.key().toLowerCase(), _configDao.getValue(ManagementServer.XenServerHeartBeatInterval.key())); + params.put(AgentManager.InstanceName.toString().toLowerCase(), _instance); + details.put(AgentManager.InstanceName.toString().toLowerCase(), _instance); try { resource.configure("XenServer", params); } catch (ConfigurationException e) { @@ -473,7 +473,7 @@ protected CitrixResourceBase createServerResource(long dcId, Long podId, Host.Re } protected void serverConfig() { - String value = _params.get(Config.XenServerSetupMultipath.key()); + String value = _params.get(ManagementServer.XenServerSetupMultipath.key()); _setupMultipath = Boolean.parseBoolean(value); } @@ -482,10 +482,10 @@ public boolean configure(String name, Map params) throws Configu super.configure(name, params); serverConfig(); - String value = _params.get(Config.XapiWait.toString()); - _wait = NumbersUtil.parseInt(value, Integer.parseInt(Config.XapiWait.getDefaultValue())); + String value = _params.get(AgentManager.XapiWait.toString()); + _wait = NumbersUtil.parseInt(value, Integer.parseInt(AgentManager.XapiWait.defaultValue())); - _instance = _params.get(Config.InstanceName.key()); + _instance = _params.get(AgentManager.InstanceName.key()); value = _params.get("xenserver.check.hvm"); _checkHvm = Boolean.parseBoolean(value); diff --git a/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/element/ElasticLoadBalancerElement.java b/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/element/ElasticLoadBalancerElement.java index 06ff497dfd25..d96e36909dc7 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/element/ElasticLoadBalancerElement.java +++ b/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/element/ElasticLoadBalancerElement.java @@ -29,7 +29,6 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import com.cloud.agent.api.to.LoadBalancerTO; -import com.cloud.configuration.Config; import com.cloud.deploy.DeployDestination; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; @@ -48,6 +47,7 @@ import com.cloud.network.rules.LoadBalancerContainer; import com.cloud.offering.NetworkOffering; import com.cloud.offerings.dao.NetworkOfferingDao; +import com.cloud.server.ManagementServer; import com.cloud.utils.component.AdapterBase; import com.cloud.vm.NicProfile; import com.cloud.vm.ReservationContext; @@ -166,10 +166,10 @@ public boolean applyLBRules(Network network, List rules) thro public boolean configure(String name, Map params) throws ConfigurationException { super.configure(name, params); - String enabled = _configDao.getValue(Config.ElasticLoadBalancerEnabled.key()); + String enabled = _configDao.getValue(ManagementServer.ElasticLoadBalancerEnabled.key()); _enabled = (enabled == null) ? false : Boolean.parseBoolean(enabled); if (_enabled) { - String traffType = _configDao.getValue(Config.ElasticLoadBalancerNetwork.key()); + String traffType = _configDao.getValue(ManagementServer.ElasticLoadBalancerNetwork.key()); if ("guest".equalsIgnoreCase(traffType)) { _frontEndTrafficType = TrafficType.Guest; } else if ("public".equalsIgnoreCase(traffType)) { diff --git a/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/lb/ElasticLoadBalancerManager.java b/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/lb/ElasticLoadBalancerManager.java index a687c8113165..fd6c60710fa2 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/lb/ElasticLoadBalancerManager.java +++ b/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/lb/ElasticLoadBalancerManager.java @@ -19,6 +19,7 @@ import java.util.List; import org.apache.cloudstack.api.command.user.loadbalancer.CreateLoadBalancerRuleCmd; +import org.apache.cloudstack.framework.config.ConfigKey; import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.NetworkRuleConflictException; @@ -31,6 +32,18 @@ public interface ElasticLoadBalancerManager { public static final int DEFAULT_ELB_VM_RAMSIZE = 128; // 512 MB public static final int DEFAULT_ELB_VM_CPU_MHZ = 256; // 500 MHz + ConfigKey ElasticLoadBalancerVmMemory = new ConfigKey<>("Advanced", Integer.class, "network.loadbalancer.basiczone.elb.vm.ram.size", "512", + "Memory in MB for the elastic load balancer vm", true); + + ConfigKey ElasticLoadBalancerVmCpuMhz = new ConfigKey<>("Advanced", Integer.class, "network.loadbalancer.basiczone.elb.vm.cpu.mhz", "128", + "CPU speed for the elastic load balancer vm", true); + + ConfigKey ElasticLoadBalancerVmNumVcpu = new ConfigKey<>("Advanced", Integer.class, "network.loadbalancer.basiczone.elb.vm.vcpu.num", "1", + "Number of VCPU for the elastic load balancer vm", true); + + ConfigKey ElasticLoadBalancerVmGcInterval = new ConfigKey<>("Advanced", Integer.class, "network.loadbalancer.basiczone.elb.gc.interval.minutes", "30", + "Garbage collection interval to destroy unused ELB vms in minutes. Minimum of 5", true); + public boolean applyLoadBalancerRules(Network network, List rules) throws ResourceUnavailableException; public LoadBalancer handleCreateLoadBalancerRule(CreateLoadBalancerRuleCmd lb, Account caller, long networkId) throws InsufficientAddressCapacityException, diff --git a/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java index 9dc083015c3b..43f3dd6cc6fa 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java +++ b/plugins/network-elements/elastic-loadbalancer/src/main/java/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java @@ -33,6 +33,8 @@ import org.apache.cloudstack.api.command.user.loadbalancer.CreateLoadBalancerRuleCmd; import org.apache.cloudstack.config.ApiServiceConfiguration; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.cloudstack.userdata.UserDataManager; @@ -48,7 +50,6 @@ import com.cloud.agent.api.routing.NetworkElementCommand; import com.cloud.agent.api.to.LoadBalancerTO; import com.cloud.agent.manager.Commands; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter.NetworkType; import com.cloud.dc.DataCenterVO; @@ -82,6 +83,7 @@ import com.cloud.offering.NetworkOffering; import com.cloud.offering.ServiceOffering; import com.cloud.offerings.dao.NetworkOfferingDao; +import com.cloud.server.ManagementServer; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.Storage; @@ -107,7 +109,7 @@ import static com.cloud.vm.VirtualMachineManager.SystemVmEnableUserData; @Component -public class ElasticLoadBalancerManagerImpl extends ManagerBase implements ElasticLoadBalancerManager, VirtualMachineGuru { +public class ElasticLoadBalancerManagerImpl extends ManagerBase implements ElasticLoadBalancerManager, VirtualMachineGuru, Configurable { @Inject private AgentManager _agentMgr; @@ -220,10 +222,10 @@ private void createApplyLoadBalancingRulesCommands(List rules cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, elbVm.getInstanceName()); //FIXME: why are we setting attributes directly? Ick!! There should be accessors and //the constructor should set defaults. - cmd.lbStatsVisibility = _configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key()); - cmd.lbStatsUri = _configDao.getValue(Config.NetworkLBHaproxyStatsUri.key()); - cmd.lbStatsAuth = _configDao.getValue(Config.NetworkLBHaproxyStatsAuth.key()); - cmd.lbStatsPort = _configDao.getValue(Config.NetworkLBHaproxyStatsPort.key()); + cmd.lbStatsVisibility = NetworkOrchestrationService.NetworkLBHaproxyStatsVisbility.value(); + cmd.lbStatsUri = NetworkOrchestrationService.NetworkLBHaproxyStatsUri.value(); + cmd.lbStatsAuth = NetworkOrchestrationService.NetworkLBHaproxyStatsAuth.value(); + cmd.lbStatsPort = NetworkOrchestrationService.NetworkLBHaproxyStatsPort.value(); cmds.addCommand(cmd); @@ -292,11 +294,11 @@ public boolean configure(String name, Map params) throws Configu if (_instance == null) { _instance = "VM"; } - _mgmtCidr = _configDao.getValue(Config.ManagementNetwork.key()); + _mgmtCidr = _configDao.getValue(ManagementServer.ManagementNetwork.key()); - _elasticLbVmRamSize = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmMemory.key()), DEFAULT_ELB_VM_RAMSIZE); - _elasticLbvmCpuMHz = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmCpuMhz.key()), DEFAULT_ELB_VM_CPU_MHZ); - _elasticLbvmNumCpu = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmNumVcpu.key()), 1); + _elasticLbVmRamSize = NumbersUtil.parseInt(configs.get(ElasticLoadBalancerVmMemory.key()), DEFAULT_ELB_VM_RAMSIZE); + _elasticLbvmCpuMHz = NumbersUtil.parseInt(configs.get(ElasticLoadBalancerVmCpuMhz.key()), DEFAULT_ELB_VM_CPU_MHZ); + _elasticLbvmNumCpu = NumbersUtil.parseInt(configs.get(ElasticLoadBalancerVmNumVcpu.key()), 1); List offerings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Elastic LB VM", ServiceOffering.elbVmDefaultOffUniqueName, _elasticLbvmNumCpu, _elasticLbVmRamSize, _elasticLbvmCpuMHz, 0, 0, true, null, Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.ElasticLoadBalancerVm, true); @@ -307,11 +309,11 @@ public boolean configure(String name, Map params) throws Configu throw new ConfigurationException(msg); } - String enabled = _configDao.getValue(Config.ElasticLoadBalancerEnabled.key()); + String enabled = _configDao.getValue(ManagementServer.ElasticLoadBalancerEnabled.key()); _enabled = (enabled == null) ? false : Boolean.parseBoolean(enabled); logger.info("Elastic Load balancer enabled: " + _enabled); if (_enabled) { - String traffType = _configDao.getValue(Config.ElasticLoadBalancerNetwork.key()); + String traffType = _configDao.getValue(ManagementServer.ElasticLoadBalancerNetwork.key()); if ("guest".equalsIgnoreCase(traffType)) { _frontendTrafficType = TrafficType.Guest; } else if ("public".equalsIgnoreCase(traffType)) { @@ -319,7 +321,7 @@ public boolean configure(String name, Map params) throws Configu } else throw new ConfigurationException("ELB: Traffic type for front end of load balancer has to be guest or public; found : " + traffType); logger.info("ELB: Elastic Load Balancer: will balance on " + traffType); - int gcIntervalMinutes = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmGcInterval.key()), 5); + int gcIntervalMinutes = NumbersUtil.parseInt(configs.get(ElasticLoadBalancerVmGcInterval.key()), 5); if (gcIntervalMinutes < 5) gcIntervalMinutes = 5; logger.info("ELB: Elastic Load Balancer: scheduling GC to run every " + gcIntervalMinutes + " minutes"); @@ -625,4 +627,14 @@ public void finalizeUnmanage(VirtualMachine vm) { public void expungeLbVmRefs(List vmIds, Long batchSize) { _elbVmMapDao.expungeByLbVmList(vmIds, batchSize); } + + @Override + public String getConfigComponentName() { + return ElasticLoadBalancerManager.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {ElasticLoadBalancerVmMemory, ElasticLoadBalancerVmCpuMhz, ElasticLoadBalancerVmNumVcpu, ElasticLoadBalancerVmGcInterval}; + } } diff --git a/plugins/network-elements/internal-loadbalancer/src/main/java/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java b/plugins/network-elements/internal-loadbalancer/src/main/java/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java index cda139b5a62b..f68e895a759d 100644 --- a/plugins/network-elements/internal-loadbalancer/src/main/java/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java +++ b/plugins/network-elements/internal-loadbalancer/src/main/java/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java @@ -55,7 +55,6 @@ import com.cloud.agent.api.routing.NetworkElementCommand; import com.cloud.agent.api.to.LoadBalancerTO; import com.cloud.agent.manager.Commands; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterVO; @@ -99,6 +98,7 @@ import com.cloud.offering.ServiceOffering; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.resource.ResourceManager; +import com.cloud.server.ManagementServer; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.Storage; @@ -397,16 +397,16 @@ public boolean configure(final String name, final Map params) th } _mgmtHost = configs.get("host"); - _mgmtCidr = _configDao.getValue(Config.ManagementNetwork.key()); + _mgmtCidr = _configDao.getValue(ManagementServer.ManagementNetwork.key()); - final String offUUID = configs.get(Config.InternalLbVmServiceOfferingId.key()); + final String offUUID = configs.get(ManagementServer.InternalLbVmServiceOfferingId.key()); if (offUUID != null && !offUUID.isEmpty()) { //get the id by offering UUID final ServiceOfferingVO off = _serviceOfferingDao.findByUuid(offUUID); if (off != null) { _internalLbVmOfferingId = off.getId(); } else { - logger.warn("Invalid offering UUID is passed in " + Config.InternalLbVmServiceOfferingId.key() + "; the default offering will be used instead"); + logger.warn("Invalid offering UUID is passed in " + ManagementServer.InternalLbVmServiceOfferingId.key() + "; the default offering will be used instead"); } } @@ -516,10 +516,10 @@ private void createApplyLoadBalancingRulesCommands(final List internalLbVm.getHypervisorType()), internalLbVm.getVpcId(), maxconn, offering.isKeepAliveEnabled(), NetworkOrchestrationService.NETWORK_LB_HAPROXY_IDLE_TIMEOUT.value()); - cmd.lbStatsVisibility = _configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key()); - cmd.lbStatsUri = _configDao.getValue(Config.NetworkLBHaproxyStatsUri.key()); - cmd.lbStatsAuth = _configDao.getValue(Config.NetworkLBHaproxyStatsAuth.key()); - cmd.lbStatsPort = _configDao.getValue(Config.NetworkLBHaproxyStatsPort.key()); + cmd.lbStatsVisibility = NetworkOrchestrationService.NetworkLBHaproxyStatsVisbility.value(); + cmd.lbStatsUri = NetworkOrchestrationService.NetworkLBHaproxyStatsUri.value(); + cmd.lbStatsAuth = NetworkOrchestrationService.NetworkLBHaproxyStatsAuth.value(); + cmd.lbStatsPort = NetworkOrchestrationService.NetworkLBHaproxyStatsPort.value(); cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getInternalLbControlIp(internalLbVm.getId())); cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, guestNic.getIPv4Address()); diff --git a/plugins/network-elements/netscaler/src/main/java/com/cloud/network/element/NetscalerElement.java b/plugins/network-elements/netscaler/src/main/java/com/cloud/network/element/NetscalerElement.java index 096b400ee938..302b9e6de0a6 100644 --- a/plugins/network-elements/netscaler/src/main/java/com/cloud/network/element/NetscalerElement.java +++ b/plugins/network-elements/netscaler/src/main/java/com/cloud/network/element/NetscalerElement.java @@ -32,6 +32,7 @@ import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; +import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice; import org.apache.cloudstack.region.gslb.GslbServiceProvider; @@ -66,7 +67,6 @@ import com.cloud.api.response.NetScalerServicePackageResponse; import com.cloud.api.response.NetscalerControlCenterResponse; import com.cloud.api.response.NetscalerLoadBalancerResponse; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter.NetworkType; @@ -296,7 +296,7 @@ public HostVO allocateNCCResourceForNetwork(Network guestConfig) throws Configur hostDetails.put("username", nccVO.getUsername()); hostDetails.put("password", DBEncryptionUtil.decrypt(nccVO.getPassword())); hostDetails.put("deviceName", "netscaler control center"); - hostDetails.put("cmdTimeOut", Long.toString(NumbersUtil.parseInt(_configDao.getValue(Config.NCCCmdTimeOut.key()), 600000))); + hostDetails.put("cmdTimeOut", Long.toString(NumbersUtil.parseInt(_configDao.getValue(NCCCmdTimeOut.key()), 600000))); ServerResource resource = new NetScalerControlCenterResource(); resource.configure(hostName, hostDetails); final Host host = _resourceMgr.addHost(guestConfig.getDataCenterId(), resource, Host.Type.NetScalerControlCenter, hostDetails); @@ -947,7 +947,7 @@ public NetscalerLoadBalancerResponse createNetscalerLoadBalancerResponse(Externa response.setDeviceName(lbDeviceVO.getDeviceName()); if (lbDeviceVO.getCapacity() == 0) { long defaultLbCapacity = NumbersUtil - .parseLong(_configDao.getValue(Config.DefaultExternalLoadBalancerCapacity.key()), 50); + .parseLong(_configDao.getValue(DefaultExternalLoadBalancerCapacity.key()), 50); response.setDeviceCapacity(defaultLbCapacity); } else { response.setDeviceCapacity(lbDeviceVO.getCapacity()); @@ -1161,7 +1161,7 @@ public boolean applyStaticNats(Network config, List rules) } boolean multiNetScalerDeployment = Boolean - .valueOf(_configDao.getValue(Config.EIPWithMultipleNetScalersEnabled.key())); + .valueOf(_configDao.getValue(EIPWithMultipleNetScalersEnabled.key())); try { if (!multiNetScalerDeployment) { @@ -1527,4 +1527,9 @@ public VirtualRouter stopNetscalerServiceVm(Long id, boolean forced, Account cal ResourceUnavailableException { return _netScalerVMManager.stopNetScalerVm(id, forced, callingAccount, callingUserId); } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {DefaultExternalLoadBalancerCapacity, EIPWithMultipleNetScalersEnabled, NCCCmdTimeOut}; + } } diff --git a/plugins/network-elements/netscaler/src/main/java/com/cloud/network/element/NetscalerLoadBalancerElementService.java b/plugins/network-elements/netscaler/src/main/java/com/cloud/network/element/NetscalerLoadBalancerElementService.java index 84f1fcecbff1..08103a930998 100644 --- a/plugins/network-elements/netscaler/src/main/java/com/cloud/network/element/NetscalerLoadBalancerElementService.java +++ b/plugins/network-elements/netscaler/src/main/java/com/cloud/network/element/NetscalerLoadBalancerElementService.java @@ -19,6 +19,8 @@ import java.util.List; import java.util.Map; +import org.apache.cloudstack.framework.config.ConfigKey; + import com.cloud.api.commands.AddNetscalerLoadBalancerCmd; import com.cloud.api.commands.ConfigureNetscalerLoadBalancerCmd; import com.cloud.api.commands.DeleteNetscalerControlCenterCmd; @@ -47,6 +49,12 @@ public interface NetscalerLoadBalancerElementService extends PluggableService { + ConfigKey EIPWithMultipleNetScalersEnabled = new ConfigKey<>("Advanced", Boolean.class, "eip.use.multiple.netscalers", "false", + "Should be set to true, if there will be multiple NetScaler devices providing EIP service in a zone", true); + + ConfigKey NCCCmdTimeOut = new ConfigKey<>("Advanced", Long.class, "ncc.command.timeout", "600000", + "Command Timeout Interval (in millisec)", true); + /** * lists all Netscaler Control Center user Details * @param ListNetscalerControlCenterCmd diff --git a/plugins/network-elements/ovs/src/main/java/com/cloud/network/ovs/OvsTunnelManager.java b/plugins/network-elements/ovs/src/main/java/com/cloud/network/ovs/OvsTunnelManager.java index cd881363ec3b..1c3382f187e3 100644 --- a/plugins/network-elements/ovs/src/main/java/com/cloud/network/ovs/OvsTunnelManager.java +++ b/plugins/network-elements/ovs/src/main/java/com/cloud/network/ovs/OvsTunnelManager.java @@ -16,12 +16,18 @@ // under the License. package com.cloud.network.ovs; +import org.apache.cloudstack.framework.config.ConfigKey; + import com.cloud.host.Host; import com.cloud.network.Network; import com.cloud.utils.component.Manager; public interface OvsTunnelManager extends Manager { + ConfigKey OvsTunnelNetworkDefaultLabel = new ConfigKey<>("Network", String.class, + "sdn.ovs.controller.default.label", "cloud-public", + "Default network label to be used when fetching interface for GRE endpoints", true); + boolean isOvsTunnelEnabled(); /** diff --git a/plugins/network-elements/ovs/src/main/java/com/cloud/network/ovs/OvsTunnelManagerImpl.java b/plugins/network-elements/ovs/src/main/java/com/cloud/network/ovs/OvsTunnelManagerImpl.java index 804f29c01b1e..c3e008698b8f 100644 --- a/plugins/network-elements/ovs/src/main/java/com/cloud/network/ovs/OvsTunnelManagerImpl.java +++ b/plugins/network-elements/ovs/src/main/java/com/cloud/network/ovs/OvsTunnelManagerImpl.java @@ -26,6 +26,8 @@ import javax.naming.ConfigurationException; import javax.persistence.EntityExistsException; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.framework.messagebus.MessageSubscriber; @@ -45,7 +47,6 @@ import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; import com.cloud.agent.manager.Commands; -import com.cloud.configuration.Config; import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.OperationTimedoutException; import com.cloud.host.Host; @@ -91,7 +92,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Component -public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManager, StateListener { +public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManager, StateListener, Configurable { // boolean _isEnabled; ScheduledExecutorService _executorPool; @@ -234,7 +235,7 @@ private String getGreEndpointIP(Host host, Network nw) throws AgentUnavailableException, OperationTimedoutException { String endpointIp = null; // Fetch fefault name for network label from configuration - String physNetLabel = _configDao.getValue(Config.OvsTunnelNetworkDefaultLabel.key()); + String physNetLabel = OvsTunnelNetworkDefaultLabel.value(); Long physNetId = nw.getPhysicalNetworkId(); PhysicalNetworkTrafficType physNetTT = _physNetTTDao.findBy(physNetId, TrafficType.Guest); @@ -930,4 +931,14 @@ public Long doInTransaction(TransactionStatus status) { } } + + @Override + public String getConfigComponentName() { + return OvsTunnelManager.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {OvsTunnelNetworkDefaultLabel}; + } } diff --git a/plugins/network-elements/palo-alto/src/main/java/com/cloud/network/element/PaloAltoExternalFirewallElement.java b/plugins/network-elements/palo-alto/src/main/java/com/cloud/network/element/PaloAltoExternalFirewallElement.java index c81ac5f5f0c3..ab8616915dee 100644 --- a/plugins/network-elements/palo-alto/src/main/java/com/cloud/network/element/PaloAltoExternalFirewallElement.java +++ b/plugins/network-elements/palo-alto/src/main/java/com/cloud/network/element/PaloAltoExternalFirewallElement.java @@ -35,7 +35,6 @@ import com.cloud.api.commands.ListPaloAltoFirewallNetworksCmd; import com.cloud.api.commands.ListPaloAltoFirewallsCmd; import com.cloud.api.response.PaloAltoFirewallResponse; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter.NetworkType; @@ -406,7 +405,7 @@ public PaloAltoFirewallResponse createPaloAltoFirewallResponse(ExternalFirewallD } response.setDeviceName(fwDeviceVO.getDeviceName()); if (fwDeviceVO.getCapacity() == 0) { - long defaultFwCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalFirewallCapacity.key()), 50); + long defaultFwCapacity = NumbersUtil.parseLong(DefaultExternalFirewallCapacity.value(), 50); response.setDeviceCapacity(defaultFwCapacity); } else { response.setDeviceCapacity(fwDeviceVO.getCapacity()); diff --git a/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/service/TungstenElement.java b/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/service/TungstenElement.java index 1f4f98194dce..d4178af15404 100644 --- a/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/service/TungstenElement.java +++ b/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/service/TungstenElement.java @@ -25,7 +25,6 @@ import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.to.LoadBalancerTO; import com.cloud.api.ApiDBUtils; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; @@ -105,7 +104,7 @@ import com.cloud.vm.dao.NicDao; import com.cloud.vm.dao.VMInstanceDao; import com.google.gson.Gson; -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.framework.messagebus.PublishScope; import org.apache.cloudstack.network.tungsten.agent.api.ApplyTungstenNetworkPolicyCommand; @@ -180,8 +179,6 @@ public class TungstenElement extends AdapterBase @Inject AgentManager agentMgr; @Inject - ConfigurationDao configDao; - @Inject VlanDao vlanDao; @Inject HostDao hostDao; @@ -436,11 +433,11 @@ private void updateLBPool(Network network, LoadBalancingRule loadBalancingRule, // update haproxy TungstenCommand updateTungstenLoadBalancerPoolCommand; - String lbStatsVisibility = configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key()); + String lbStatsVisibility = NetworkOrchestrationService.NetworkLBHaproxyStatsVisbility.value(); if (!lbStatsVisibility.equals("disabled")) { - String lbStatsUri = configDao.getValue(Config.NetworkLBHaproxyStatsUri.key()); - String lbStatsAuth = configDao.getValue(Config.NetworkLBHaproxyStatsAuth.key()); - String lbStatsPort = configDao.getValue(Config.NetworkLBHaproxyStatsPort.key()); + String lbStatsUri = NetworkOrchestrationService.NetworkLBHaproxyStatsUri.value(); + String lbStatsAuth = NetworkOrchestrationService.NetworkLBHaproxyStatsAuth.value(); + String lbStatsPort = NetworkOrchestrationService.NetworkLBHaproxyStatsPort.value(); updateTungstenLoadBalancerPoolCommand = new UpdateTungstenLoadBalancerPoolCommand( tungstenProjectFqn, TungstenUtils.getLoadBalancerPoolName(loadBalancingRule.getId()), TungstenUtils.getLoadBalancerAlgorithm(loadBalancingRule.getAlgorithm()), diff --git a/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/service/TungstenServiceImpl.java b/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/service/TungstenServiceImpl.java index 2a29b3976b01..6a74b2c68912 100644 --- a/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/service/TungstenServiceImpl.java +++ b/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/service/TungstenServiceImpl.java @@ -20,7 +20,6 @@ import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; import com.cloud.api.ApiDBUtils; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterIpAddressVO; @@ -118,7 +117,7 @@ import org.apache.cloudstack.acl.ApiKeyPairVO; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.context.CallContext; -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.network.tungsten.agent.api.AddTungstenNetworkGatewayToLogicalRouterCommand; import org.apache.cloudstack.network.tungsten.agent.api.AddTungstenNetworkSubnetCommand; @@ -242,8 +241,6 @@ public class TungstenServiceImpl extends ManagerBase implements TungstenService @Inject protected NetworkDao networkDao; @Inject - protected ConfigurationDao configDao; - @Inject protected AccountManager accountMgr; @Inject protected IPAddressDao ipAddressDao; @@ -1126,11 +1123,11 @@ public boolean updateLoadBalancer(Network network, LoadBalancingRule loadBalanci private boolean updateHaproxyStats(List hostList, String lbUuid) { // update haproxy stats - String lbStatsVisibility = configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key()); + String lbStatsVisibility = NetworkOrchestrationService.NetworkLBHaproxyStatsVisbility.value(); if (!lbStatsVisibility.equals("disabled")) { - String lbStatsUri = configDao.getValue(Config.NetworkLBHaproxyStatsUri.key()); - String lbStatsAuth = configDao.getValue(Config.NetworkLBHaproxyStatsAuth.key()); - String lbStatsPort = configDao.getValue(Config.NetworkLBHaproxyStatsPort.key()); + String lbStatsUri = NetworkOrchestrationService.NetworkLBHaproxyStatsUri.value(); + String lbStatsAuth = NetworkOrchestrationService.NetworkLBHaproxyStatsAuth.value(); + String lbStatsPort = NetworkOrchestrationService.NetworkLBHaproxyStatsPort.value(); UpdateTungstenLoadbalancerStatsCommand updateTungstenLoadbalancerStatsCommand = new UpdateTungstenLoadbalancerStatsCommand(lbUuid, lbStatsPort, lbStatsUri, lbStatsAuth); for (HostVO host : hostList) { diff --git a/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenElementTest.java b/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenElementTest.java index bad21464602e..32ef1237be4c 100644 --- a/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenElementTest.java +++ b/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenElementTest.java @@ -32,7 +32,6 @@ import com.cloud.agent.AgentManager; import com.cloud.api.ApiDBUtils; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; import com.cloud.dc.VlanVO; @@ -91,7 +90,9 @@ import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineProfile; import com.cloud.vm.dao.VMInstanceDao; -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.impl.ConfigDepotImpl; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.network.tungsten.agent.api.ApplyTungstenNetworkPolicyCommand; import org.apache.cloudstack.network.tungsten.agent.api.ApplyTungstenPortForwardingCommand; @@ -144,8 +145,6 @@ public class TungstenElementTest { @Mock IpAddressManager ipAddressMgr; @Mock - ConfigurationDao configDao; - @Mock LoadBalancerDao lbDao; @Mock AccountManager accountMgr; @@ -199,7 +198,6 @@ public void setup() { tungstenElement.lbVmMapDao = lbVmMapDao; tungstenElement.tungstenGuestNetworkIpAddressDao = tungstenGuestNetworkIpAddressDao; tungstenElement.ipAddressMgr = ipAddressMgr; - tungstenElement.configDao = configDao; tungstenElement.lbDao = lbDao; tungstenElement.accountMgr = accountMgr; tungstenElement.hostDao = hostDao; @@ -383,7 +381,6 @@ public void applyLBRulesAddRuleSuccessTest() { when(tungstenFabricUtils.sendTungstenCommand(any(CreateTungstenNetworkLoadbalancerCommand.class), anyLong())).thenReturn(createTungstenNetworkLoadbalancerAnswer); when(tungstenFabricUtils.sendTungstenCommand(any(UpdateTungstenLoadBalancerPoolCommand.class), anyLong())).thenReturn(updateTungstenLoadBalancerPoolAnswer); when(tungstenFabricUtils.sendTungstenCommand(any(UpdateTungstenLoadBalancerMemberCommand.class), anyLong())).thenReturn(updateTungstenLoadBalancerMemberAnswer); - when(configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key())).thenReturn("enabled"); when(tungstenService.updateLoadBalancer(any(), any())).thenReturn(true); when(EncryptionUtil.generateSignature(anyString(), anyString())).thenReturn("generatedString"); when(tungstenFabricLBHealthMonitorDao.findByLbId(anyLong())).thenReturn(tungstenFabricLBHealthMonitorVO); @@ -432,11 +429,18 @@ public void applyLBRulesAddRuleFailTest() { when(tungstenFabricUtils.sendTungstenCommand(any(CreateTungstenNetworkLoadbalancerCommand.class), anyLong())).thenReturn(createTungstenNetworkLoadbalancerAnswer); when(tungstenFabricUtils.sendTungstenCommand(any(UpdateTungstenLoadBalancerPoolCommand.class), anyLong())).thenReturn(updateTungstenLoadBalancerPoolAnswer); when(tungstenFabricUtils.sendTungstenCommand(any(UpdateTungstenLoadBalancerMemberCommand.class), anyLong())).thenReturn(updateTungstenLoadBalancerMemberAnswer); - when(configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key())).thenReturn("disabled"); + ConfigDepotImpl configDepotMock = Mockito.mock(ConfigDepotImpl.class); + ConfigKey.init(configDepotMock); + Mockito.when(configDepotMock.getConfigStringValue(Mockito.eq(NetworkOrchestrationService.NetworkLBHaproxyStatsVisbility.key()), Mockito.any(), Mockito.any())) + .thenReturn("disabled"); when(tungstenFabricLBHealthMonitorDao.findByLbId(anyLong())).thenReturn(tungstenFabricLBHealthMonitorVO); when(tungstenFabricUtils.sendTungstenCommand(any(UpdateTungstenLoadBalancerHealthMonitorCommand.class), anyLong())).thenReturn(updateTungstenHealthMonitorAnswer); - assertFalse(tungstenElement.applyLBRules(network, loadBalancingRuleList1)); + try { + assertFalse(tungstenElement.applyLBRules(network, loadBalancingRuleList1)); + } finally { + ConfigKey.init(null); + } } @Test diff --git a/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenServiceImplTest.java b/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenServiceImplTest.java index 38539d8b6c5f..791f95b4415d 100644 --- a/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenServiceImplTest.java +++ b/plugins/network-elements/tungsten/src/test/java/org/apache/cloudstack/network/tungsten/service/TungstenServiceImplTest.java @@ -30,7 +30,6 @@ import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterIpAddressVO; @@ -123,7 +122,6 @@ import net.juniper.tungsten.api.types.VirtualMachine; import net.juniper.tungsten.api.types.VirtualMachineInterface; import net.juniper.tungsten.api.types.VirtualNetwork; -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.framework.messagebus.MessageSubscriber; import org.apache.cloudstack.network.tungsten.agent.api.AddTungstenNetworkGatewayToLogicalRouterCommand; @@ -228,8 +226,6 @@ public class TungstenServiceImplTest { @Mock NetworkDao networkDao; @Mock - ConfigurationDao configDao; - @Mock IPAddressDao ipAddressDao; @Mock EntityManager entityMgr; @@ -293,7 +289,6 @@ public void setup() { tungstenService.networkDetailsDao = networkDetailsDao; tungstenService.agentMgr = agentMgr; tungstenService.hostDao = hostDao; - tungstenService.configDao = configDao; tungstenService.fwRulesDao = fwRulesDao; tungstenService.lbCertMapDao = lbCertMapDao; tungstenService.entityMgr = entityMgr; @@ -665,7 +660,6 @@ public void updateLoadBalancerTest() { when(agentMgr.easySend(anyLong(), any(UpdateTungstenLoadbalancerSslCommand.class))).thenReturn(updateTungstenLoadbalancerSslAnswer); when(updateTungstenLoadbalancerStatsAnswer.getResult()).thenReturn(true); when(updateTungstenLoadbalancerSslAnswer.getResult()).thenReturn(true); - when(configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key())).thenReturn("enabled"); when(fwRulesDao.listByIpAndPurposeAndNotRevoked(anyLong(), eq(FirewallRule.Purpose.LoadBalancing))).thenReturn(List.of(firewallRuleVO)); when(lbCertMapDao.findByLbRuleId(anyLong())).thenReturn(loadBalancerCertMapVO); when(entityMgr.findById(eq(SslCertVO.class), anyLong())).thenReturn(sslCertVO); diff --git a/plugins/storage/image/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java b/plugins/storage/image/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java index f4c310be40f4..7ac4465ceab7 100644 --- a/plugins/storage/image/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java +++ b/plugins/storage/image/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java @@ -42,8 +42,8 @@ import com.cloud.agent.api.storage.CreateEntityDownloadURLCommand; import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.NfsTO; -import com.cloud.configuration.Config; import com.cloud.storage.Storage.ImageFormat; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.utils.exception.CloudRuntimeException; public class CloudStackImageStoreDriverImpl extends NfsImageStoreDriverImpl { @@ -131,7 +131,7 @@ private String generateCopyUrl(String ipAddress, String fileName, String filePat String hostname = ipAddress; String scheme = "http"; boolean _sslCopy = false; - String sslCfg = _configDao.getValue(Config.SecStorageEncryptCopy.toString()); + String sslCfg = _configDao.getValue(SecondaryStorageVmManager.SecStorageEncryptCopy.toString()); String _ssvmUrlDomain = _configDao.getValue("secstorage.ssl.cert.domain"); if (sslCfg != null) { _sslCopy = Boolean.parseBoolean(sslCfg); diff --git a/plugins/storage/image/s3/src/main/java/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java b/plugins/storage/image/s3/src/main/java/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java index 6318c1920a99..eaa3ed66306d 100644 --- a/plugins/storage/image/s3/src/main/java/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java +++ b/plugins/storage/image/s3/src/main/java/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java @@ -35,8 +35,9 @@ import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.S3TO; -import com.cloud.configuration.Config; +import com.cloud.server.ManagementServer; import com.cloud.storage.Storage.ImageFormat; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.utils.NumbersUtil; import com.cloud.utils.storage.S3.S3Utils; @@ -64,7 +65,7 @@ public DataStoreTO getStoreTO(DataStore store) { details.get(ApiConstants.S3_MAX_ERROR_RETRY) == null ? null : Integer.valueOf(details.get(ApiConstants.S3_MAX_ERROR_RETRY)), details.get(ApiConstants.S3_SOCKET_TIMEOUT) == null ? null : Integer.valueOf(details.get(ApiConstants.S3_SOCKET_TIMEOUT)), imgStore.getCreated(), - _configDao.getValue(Config.S3EnableRRS.toString()) == null ? false : Boolean.parseBoolean(_configDao.getValue(Config.S3EnableRRS.toString())), + _configDao.getValue(ManagementServer.S3EnableRRS.key()) == null ? false : Boolean.parseBoolean(_configDao.getValue(ManagementServer.S3EnableRRS.key())), getMaxSingleUploadSizeInBytes(), details.get(ApiConstants.S3_CONNECTION_TTL) == null ? null : Integer.valueOf(details.get(ApiConstants.S3_CONNECTION_TTL)), details.get(ApiConstants.S3_USE_TCP_KEEPALIVE) == null ? null : Boolean.parseBoolean(details.get(ApiConstants.S3_USE_TCP_KEEPALIVE))); @@ -72,7 +73,7 @@ public DataStoreTO getStoreTO(DataStore store) { private long getMaxSingleUploadSizeInBytes() { try { - return Long.parseLong(_configDao.getValue(Config.S3MaxSingleUploadSize.toString())) * 1024L * 1024L * 1024L; + return Long.parseLong(_configDao.getValue(ManagementServer.S3MaxSingleUploadSize.key())) * 1024L * 1024L * 1024L; } catch (NumberFormatException e) { // use default 1TB return 1024L * 1024L * 1024L * 1024L; @@ -93,7 +94,7 @@ public String createEntityExtractUrl(DataStore store, String key, ImageFormat fo long milliSeconds = expiration.getTime(); // Get extract url expiration interval set in global configuration (in seconds) - String urlExpirationInterval = _configDao.getValue(Config.ExtractURLExpirationInterval.toString()); + String urlExpirationInterval = _configDao.getValue(SecondaryStorageVmManager.ExtractURLExpirationInterval.toString()); // Expired after configured interval (in milliseconds), default 14400 seconds milliSeconds += 1000 * NumbersUtil.parseInt(urlExpirationInterval, 14400); diff --git a/plugins/storage/image/swift/src/main/java/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java b/plugins/storage/image/swift/src/main/java/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java index 61ff57fd0587..bcc60d3072b6 100644 --- a/plugins/storage/image/swift/src/main/java/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java +++ b/plugins/storage/image/swift/src/main/java/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java @@ -44,8 +44,8 @@ import com.cloud.agent.api.to.DataObjectType; import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.SwiftTO; -import com.cloud.configuration.Config; import com.cloud.storage.Storage.ImageFormat; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.utils.SwiftUtil; import com.cloud.utils.exception.CloudRuntimeException; @@ -83,7 +83,7 @@ public String createEntityExtractUrl(DataStore store, String installPath, ImageF String containerName = SwiftUtil.getContainerName(dataObject.getType().toString(), dataObject.getId()); String objectName = installPath.split("\\/")[1]; // Get extract url expiration interval set in global configuration (in seconds) - int urlExpirationInterval = Integer.parseInt(_configDao.getValue(Config.ExtractURLExpirationInterval.toString())); + int urlExpirationInterval = Integer.parseInt(_configDao.getValue(SecondaryStorageVmManager.ExtractURLExpirationInterval.toString())); URL swiftUrl = SwiftUtil.generateTempUrl(swiftTO, containerName, objectName, tempKey, urlExpirationInterval); if (swiftUrl != null) { diff --git a/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java b/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java index bc0e0a897065..7d3dda216082 100644 --- a/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java +++ b/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java @@ -44,6 +44,7 @@ import java.util.Optional; import java.util.stream.Collectors; +import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; import com.cloud.agent.api.storage.ResizeVolumeAnswer; import com.cloud.agent.api.storage.ResizeVolumeCommand; @@ -54,7 +55,6 @@ import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.api.storage.LinstorBackupSnapshotCommand; import com.cloud.api.storage.LinstorRevertBackupSnapshotCommand; -import com.cloud.configuration.Config; import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.Status; @@ -71,6 +71,7 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc; import com.cloud.storage.VMTemplateVO; import com.cloud.storage.Volume; +import com.cloud.storage.VolumeApiService; import com.cloud.storage.VolumeDetailVO; import com.cloud.storage.VolumeVO; import com.cloud.storage.dao.SnapshotDao; @@ -80,6 +81,7 @@ import com.cloud.storage.dao.VMTemplatePoolDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeDetailsDao; +import com.cloud.storage.snapshot.SnapshotManager; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.exception.CloudRuntimeException; @@ -666,9 +668,7 @@ private String revertSnapshotFromImageStore( final String rscName) throws ApiException { String resultMsg = null; - String value = _configDao.getValue(Config.BackupSnapshotWait.toString()); - int _backupsnapshotwait = NumbersUtil.parseInt( - value, Integer.parseInt(Config.BackupSnapshotWait.getDefaultValue())); + int _backupsnapshotwait = SnapshotManager.BackupSnapshotWait.value(); LinstorRevertBackupSnapshotCommand cmd = new LinstorRevertBackupSnapshotCommand( snapshot.getTO(), @@ -978,7 +978,7 @@ private Answer copyTemplate(DataObject srcData, DataObject dstData) { Answer answer; if (newCreated) { int nMaxExecutionMinutes = NumbersUtil.parseInt( - _configDao.getValue(Config.SecStorageCmdExecutionTimeMax.key()), 30); + _configDao.getValue(AgentManager.SecStorageCmdExecutionTimeMax.key()), 30); CopyCommand cmd = new CopyCommand( srcData.getTO(), dstData.getTO(), @@ -1018,8 +1018,7 @@ private Answer copyVolume(DataObject srcData, DataObject dstData) { // uses the format of the base volume and we backup snapshots as QCOW2 // https://github.com/apache/cloudstack/pull/8802#issuecomment-2024019927 to.setFormat(Storage.ImageFormat.RAW); - int nMaxExecutionSeconds = NumbersUtil.parseInt( - _configDao.getValue(Config.CopyVolumeWait.key()), 10800); + int nMaxExecutionSeconds = VolumeApiService.CopyVolumeWait.value(); CopyCommand cmd = new CopyCommand( to, dstData.getTO(), @@ -1106,9 +1105,7 @@ private String setCorrectSnapshotPath(DevelopersApi api, String rscName, Snapsho } protected Answer copySnapshot(DataObject srcData, DataObject destData) { - String value = _configDao.getValue(Config.BackupSnapshotWait.toString()); - int _backupsnapshotwait = NumbersUtil.parseInt( - value, Integer.parseInt(Config.BackupSnapshotWait.getDefaultValue())); + int _backupsnapshotwait = SnapshotManager.BackupSnapshotWait.value(); SnapshotObject snapshotObject = (SnapshotObject)srcData; Boolean snapshotFullBackup = snapshotObject.getFullBackup(); diff --git a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java index 14cb82a4c2b3..631c8ec6d896 100644 --- a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java +++ b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java @@ -68,6 +68,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; import com.cloud.agent.api.GetVolumeStatAnswer; import com.cloud.agent.api.GetVolumeStatCommand; @@ -79,12 +80,11 @@ import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.alert.AlertManager; -import com.cloud.configuration.Config; import com.cloud.exception.OperationTimedoutException; import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.dao.HostDao; -import com.cloud.server.ManagementServerImpl; +import com.cloud.server.ManagementServer; import com.cloud.storage.DataStoreRole; import com.cloud.storage.ResizeVolumePayload; import com.cloud.storage.SnapshotVO; @@ -95,6 +95,7 @@ import com.cloud.storage.StoragePoolHostVO; import com.cloud.storage.VMTemplateStoragePoolVO; import com.cloud.storage.Volume; +import com.cloud.storage.VolumeApiService; import com.cloud.storage.VolumeDetailVO; import com.cloud.storage.VolumeVO; import com.cloud.storage.dao.SnapshotDao; @@ -442,7 +443,7 @@ public void takeSnapshot(SnapshotInfo snapshotInfo, AsyncCompletionCallback"); - String value = configDao.getValue(Config.CopyVolumeWait.key()); - int copyVolumeWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue())); + int copyVolumeWait = VolumeApiService.CopyVolumeWait.value(); CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), copyVolumeWait, VirtualMachineManager.ExecuteInSequence.value()); @@ -888,7 +888,7 @@ public Answer liveMigrateVolume(DataObject srcData, DataObject destData) { grantAccess(destData, host, destData.getDataStore()); - int waitInterval = NumbersUtil.parseInt(configDao.getValue(Config.MigrateWait.key()), Integer.parseInt(Config.MigrateWait.getDefaultValue())); + int waitInterval = NumbersUtil.parseInt(configDao.getValue(AgentManager.MigrateWait.key()), Integer.parseInt(AgentManager.MigrateWait.defaultValue())); MigrateVolumeCommand migrateVolumeCommand = new MigrateVolumeCommand(srcData.getTO(), destVolTO, srcDetails, destDetails, waitInterval); answer = ep.sendMessage(migrateVolumeCommand); @@ -1016,7 +1016,7 @@ public void updateSnapshotsAfterCopyVolume(DataObject srcData, DataObject destDa String snapshotVolumeId = ScaleIOUtil.getVolumePath(snapshotStore.getInstallPath()); String newSnapshotName = String.format("%s-%s-%s-%s", ScaleIOUtil.SNAPSHOT_PREFIX, snapshot.getId(), - destStoragePool.getUuid().split("-")[0].substring(4), ManagementServerImpl.customCsIdentifier.value()); + destStoragePool.getUuid().split("-")[0].substring(4), ManagementServer.customCsIdentifier.value()); boolean renamed = client.renameVolume(snapshotVolumeId, newSnapshotName); snapshotStore.setDataStoreId(destPoolId); @@ -1150,7 +1150,7 @@ private Answer migrateVolume(DataObject srcData, DataObject destData) { boolean migrateStatus = client.migrateVolume(srcVolumeId, destStoragePoolId, migrationTimeout); if (migrateStatus) { String newVolumeName = String.format("%s-%s-%s-%s", ScaleIOUtil.VOLUME_PREFIX, destData.getId(), - destStoragePool.getUuid().split("-")[0].substring(4), ManagementServerImpl.customCsIdentifier.value()); + destStoragePool.getUuid().split("-")[0].substring(4), ManagementServer.customCsIdentifier.value()); boolean renamed = client.renameVolume(srcVolumeId, newVolumeName); if (srcData.getId() != destData.getId()) { @@ -1191,7 +1191,7 @@ private Answer migrateVolume(DataObject srcData, DataObject destData) { String snapshotVolumeId = ScaleIOUtil.getVolumePath(snapshotStore.getInstallPath()); String newSnapshotName = String.format("%s-%s-%s-%s", ScaleIOUtil.SNAPSHOT_PREFIX, snapshot.getId(), - destStoragePool.getUuid().split("-")[0].substring(4), ManagementServerImpl.customCsIdentifier.value()); + destStoragePool.getUuid().split("-")[0].substring(4), ManagementServer.customCsIdentifier.value()); renamed = client.renameVolume(snapshotVolumeId, newSnapshotName); snapshotStore.setDataStoreId(destPoolId); diff --git a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java index cb111e9ccac5..41455dc7f271 100644 --- a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java +++ b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java @@ -46,14 +46,13 @@ import com.cloud.agent.api.PrepareStorageClientAnswer; import com.cloud.agent.api.PrepareStorageClientCommand; import com.cloud.agent.api.UnprepareStorageClientCommand; -import com.cloud.configuration.Config; import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.OperationTimedoutException; import com.cloud.host.Host; import com.cloud.storage.StorageManager; import com.cloud.storage.StoragePoolHostVO; +import com.cloud.storage.VolumeApiService; import com.cloud.storage.dao.StoragePoolHostDao; -import com.cloud.utils.NumbersUtil; import com.cloud.utils.db.GlobalLock; import com.cloud.utils.exception.CloudRuntimeException; @@ -134,7 +133,7 @@ public String prepareSDC(Host host, DataStore dataStore) { throw new CloudRuntimeException("Unable to prepare SDC, couldn't get global lock on " + hostIdStorageSystemIdLockString); } - int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); + int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value(); if (!hostIdStorageSystemIdLock.lock(storagePoolMaxWaitSeconds)) { logger.debug("Unable to prepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString); throw new CloudRuntimeException("Unable to prepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString); @@ -280,7 +279,7 @@ public boolean unprepareSDC(Host host, DataStore dataStore) { throw new CloudRuntimeException("Unable to unprepare SDC, couldn't get global lock on " + hostIdStorageSystemIdLockString); } - int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); + int storagePoolMaxWaitSeconds = VolumeApiService.StoragePoolMaxWaitSeconds.value(); if (!lock.lock(storagePoolMaxWaitSeconds)) { logger.debug("Unable to unprepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString); throw new CloudRuntimeException("Unable to unprepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString); diff --git a/plugins/storage/volume/scaleio/src/test/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriverTest.java b/plugins/storage/volume/scaleio/src/test/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriverTest.java index 610b595ee052..e7779840ca38 100644 --- a/plugins/storage/volume/scaleio/src/test/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriverTest.java +++ b/plugins/storage/volume/scaleio/src/test/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriverTest.java @@ -19,6 +19,7 @@ package org.apache.cloudstack.storage.datastore.driver; +import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; import com.cloud.agent.api.GetVolumeStatAnswer; import com.cloud.agent.api.GetVolumeStatCommand; @@ -26,7 +27,6 @@ import com.cloud.agent.api.storage.MigrateVolumeCommand; import com.cloud.agent.api.to.DataTO; import com.cloud.agent.api.to.DiskTO; -import com.cloud.configuration.Config; import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.dao.HostDao; @@ -216,7 +216,7 @@ public void testMigrateVolumeWithinSameScaleIOClusterSuccess() throws Exception doReturn(true).when(scaleIOPrimaryDataStoreDriver) .grantAccess(any(), any(), any()); - when(configDao.getValue(Config.MigrateWait.key())).thenReturn("3600"); + when(configDao.getValue(AgentManager.MigrateWait.key())).thenReturn("3600"); GetVolumeStatAnswer getVolumeStatAnswer = Mockito.mock(GetVolumeStatAnswer.class); when(ep.sendMessage(any(GetVolumeStatCommand.class))).thenReturn(getVolumeStatAnswer); @@ -266,7 +266,7 @@ public void testMigrateVolumeWithinSameScaleIOClusterFailure() throws Exception Mockito.lenient().doReturn(true).when(scaleIOPrimaryDataStoreDriver) .grantAccess(any(), any(), any()); - Mockito.lenient().when(configDao.getValue(Config.MigrateWait.key())).thenReturn("3600"); + Mockito.lenient().when(configDao.getValue(AgentManager.MigrateWait.key())).thenReturn("3600"); GetVolumeStatAnswer getVolumeStatAnswer = Mockito.mock(GetVolumeStatAnswer.class); Mockito.lenient().when(ep.sendMessage(any(GetVolumeStatCommand.class))).thenReturn(getVolumeStatAnswer); @@ -512,8 +512,6 @@ public void deleteSourceVolumeFailureScenarioWhenNoSDCisFound() { @Test public void testCopyOfflineVolume() { - when(configDao.getValue(Config.CopyVolumeWait.key())).thenReturn("3600"); - DataObject srcData = Mockito.mock(DataObject.class); DataTO srcDataTO = Mockito.mock(DataTO.class); when(srcData.getTO()).thenReturn(srcDataTO); @@ -535,8 +533,6 @@ public void testCopyOfflineVolume() { @Test public void testCopyOfflineVolumeFailureWhenNoEndpointFound() { - when(configDao.getValue(Config.CopyVolumeWait.key())).thenReturn("3600"); - DataObject srcData = Mockito.mock(DataObject.class); DataTO srcDataTO = Mockito.mock(DataTO.class); when(srcData.getTO()).thenReturn(srcDataTO); diff --git a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolStatsCollector.java b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolStatsCollector.java index a2c8b274ce95..487dbb304958 100644 --- a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolStatsCollector.java +++ b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolStatsCollector.java @@ -40,6 +40,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import com.cloud.server.StatsCollector; import com.cloud.storage.DataStoreRole; import com.cloud.storage.SnapshotVO; import com.cloud.storage.dao.SnapshotDao; @@ -84,7 +85,7 @@ public boolean start() { List spPools = storagePoolDao.findPoolsByProvider(StorPoolUtil.SP_PROVIDER_NAME); if (CollectionUtils.isNotEmpty(spPools)) { executor = Executors.newScheduledThreadPool(3, new NamedThreadFactory("StorPoolStatsCollector")); - long storageStatsInterval = NumbersUtil.parseLong(configurationDao.getValue("storage.stats.interval"), 60000L); + long storageStatsInterval = StatsCollector.StorageStatsInterval.value(); long volumeStatsInterval = NumbersUtil.parseLong(configurationDao.getValue("volume.stats.interval"), 60000L); if (StorPoolConfigurationManager.VolumesStatsInterval.value() > 0 && volumeStatsInterval > 0) { diff --git a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java index 4bc34d8a5c60..f4ea01bb759d 100644 --- a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java +++ b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java @@ -23,7 +23,6 @@ import com.cloud.capacity.Capacity; import com.cloud.capacity.CapacityVO; import com.cloud.capacity.dao.CapacityDao; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.deploy.DeploymentClusterPlanner; import com.cloud.deploy.DeploymentPlan; @@ -288,7 +287,7 @@ private Pair, Map> getOrderedHostsByCapacity(Long zoneI double cpuToMemoryWeight = ConfigurationManager.HostCapacityTypeCpuMemoryWeight.value(); // Get capacity by which we should reorder short capacityType = FirstFitPlanner.getHostCapacityTypeToOrderCluster( - _configDao.getValue(Config.HostCapacityTypeToOrderClusters.key()), cpuToMemoryWeight); + _configDao.getValue(DeploymentClusterPlanner.HostCapacityTypeToOrderClusters.key()), cpuToMemoryWeight); logger.debug("CapacityType: {} is used for Host ordering", FirstFitPlanner.getCapacityTypeName(capacityType)); if (capacityType >= 0) { // for CPU or RAM return _capacityDao.orderHostsByFreeCapacity(zoneId, clusterId, capacityType); diff --git a/server/src/main/java/com/cloud/alert/AlertManagerImpl.java b/server/src/main/java/com/cloud/alert/AlertManagerImpl.java index 27b445ba3769..ee890cb6398c 100644 --- a/server/src/main/java/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/main/java/com/cloud/alert/AlertManagerImpl.java @@ -64,7 +64,6 @@ import com.cloud.capacity.CapacityVO; import com.cloud.capacity.dao.CapacityDao; import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenter; @@ -174,12 +173,12 @@ public boolean configure(String name, Map params) throws Configu Map configs = _configDao.getConfiguration("management-server", params); // set up the email system for alerts - String emailAddressList = configs.get("alert.email.addresses"); + String emailAddressList = AlertEmailAddresses.value(); if (emailAddressList != null) { recipients = emailAddressList.split(","); } - senderAddress = configs.get("alert.email.sender"); + senderAddress = AlertEmailSender.value(); String namespace = "alert.smtp"; String timeoutConfig = String.format("%s.timeout", namespace); @@ -193,33 +192,15 @@ public boolean configure(String name, Map params) throws Configu mailSender = new SMTPMailSender(configs, namespace); - String publicIPCapacityThreshold = _configDao.getValue(Config.PublicIpCapacityThreshold.key()); - String privateIPCapacityThreshold = _configDao.getValue(Config.PrivateIpCapacityThreshold.key()); - String secondaryStorageCapacityThreshold = _configDao.getValue(Config.SecondaryStorageCapacityThreshold.key()); - String vlanCapacityThreshold = _configDao.getValue(Config.VlanCapacityThreshold.key()); - String directNetworkPublicIpCapacityThreshold = _configDao.getValue(Config.DirectNetworkPublicIpCapacityThreshold.key()); - String localStorageCapacityThreshold = _configDao.getValue(Config.LocalStorageCapacityThreshold.key()); + _publicIPCapacityThreshold = PublicIpCapacityThreshold.value(); + _privateIPCapacityThreshold = PrivateIpCapacityThreshold.value(); + _secondaryStorageCapacityThreshold = SecondaryStorageCapacityThreshold.value(); + _vlanCapacityThreshold = VlanCapacityThreshold.value(); + _directNetworkPublicIpCapacityThreshold = DirectNetworkPublicIpCapacityThreshold.value(); + _localStorageCapacityThreshold = LocalStorageCapacityThreshold.value(); String backupStorageCapacityThreshold = _configDao.getValue(BackupManager.BackupStorageCapacityThreshold.key()); String objectStorageCapacityThreshold = _configDao.getValue(_storageMgr.ObjectStorageCapacityThreshold.key()); - if (publicIPCapacityThreshold != null) { - _publicIPCapacityThreshold = Double.parseDouble(publicIPCapacityThreshold); - } - if (privateIPCapacityThreshold != null) { - _privateIPCapacityThreshold = Double.parseDouble(privateIPCapacityThreshold); - } - if (secondaryStorageCapacityThreshold != null) { - _secondaryStorageCapacityThreshold = Double.parseDouble(secondaryStorageCapacityThreshold); - } - if (vlanCapacityThreshold != null) { - _vlanCapacityThreshold = Double.parseDouble(vlanCapacityThreshold); - } - if (directNetworkPublicIpCapacityThreshold != null) { - _directNetworkPublicIpCapacityThreshold = Double.parseDouble(directNetworkPublicIpCapacityThreshold); - } - if (localStorageCapacityThreshold != null) { - _localStorageCapacityThreshold = Double.parseDouble(localStorageCapacityThreshold); - } if (backupStorageCapacityThreshold != null) { _backupStorageCapacityThreshold = Double.parseDouble(backupStorageCapacityThreshold); } @@ -237,12 +218,9 @@ public boolean configure(String name, Map params) throws Configu _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_BACKUP_STORAGE, _backupStorageCapacityThreshold); _capacityTypeThresholdMap.put(Capacity.CAPACITY_TYPE_OBJECT_STORAGE, _objectStorageCapacityThreshold); - String capacityCheckPeriodStr = configs.get("capacity.check.period"); - if (capacityCheckPeriodStr != null) { - _capacityCheckPeriod = Long.parseLong(capacityCheckPeriodStr); - if (_capacityCheckPeriod <= 0) { - _capacityCheckPeriod = Long.parseLong(Config.CapacityCheckPeriod.getDefaultValue()); - } + _capacityCheckPeriod = CapacityCheckPeriod.value(); + if (_capacityCheckPeriod <= 0) { + _capacityCheckPeriod = Long.parseLong(CapacityCheckPeriod.defaultValue()); } initMessageBusListener(); setupRepetitiveAlertTypes(); @@ -893,7 +871,10 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { return new ConfigKey[] {CPUCapacityThreshold, MemoryCapacityThreshold, StorageAllocatedCapacityThreshold, StorageCapacityThreshold, AlertSmtpEnabledSecurityProtocols, - AlertSmtpUseStartTLS, Ipv6SubnetCapacityThreshold, AlertSmtpUseAuth, AllowedRepetitiveAlertTypes}; + AlertSmtpUseStartTLS, Ipv6SubnetCapacityThreshold, AlertSmtpUseAuth, AllowedRepetitiveAlertTypes, + AlertEmailAddresses, AlertEmailSender, AlertSMTPHost, AlertSMTPPort, AlertSMTPUsername, AlertSMTPPassword, CapacityCheckPeriod, + PublicIpCapacityThreshold, PrivateIpCapacityThreshold, SecondaryStorageCapacityThreshold, VlanCapacityThreshold, + DirectNetworkPublicIpCapacityThreshold, LocalStorageCapacityThreshold}; } @Override diff --git a/server/src/main/java/com/cloud/api/ApiDBUtils.java b/server/src/main/java/com/cloud/api/ApiDBUtils.java index 934600eb2b61..9cff4de5fd49 100644 --- a/server/src/main/java/com/cloud/api/ApiDBUtils.java +++ b/server/src/main/java/com/cloud/api/ApiDBUtils.java @@ -156,7 +156,6 @@ import com.cloud.capacity.CapacityVO; import com.cloud.capacity.dao.CapacityDao; import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.ConfigurationService; import com.cloud.configuration.Resource; @@ -319,6 +318,7 @@ import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateDetailsDao; import com.cloud.storage.dao.VolumeDao; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.snapshot.SnapshotPolicy; import com.cloud.template.TemplateManager; import com.cloud.template.VirtualMachineTemplate; @@ -1506,7 +1506,7 @@ public static float getMemOverprovisioningFactor(long clusterId) { } public static boolean isExtractionDisabled() { - String disableExtractionString = s_configDao.getValue(Config.DisableExtraction.toString()); + String disableExtractionString = s_configDao.getValue(SecondaryStorageVmManager.DisableExtraction.toString()); boolean disableExtraction = (disableExtractionString == null) ? false : Boolean.parseBoolean(disableExtractionString); return disableExtraction; } @@ -2300,7 +2300,7 @@ public static List listSiteLoadBalancers(long gslbRuleId } public static String getDnsNameConfiguredForGslb() { - String providerDnsName = s_configDao.getValue(Config.CloudDnsName.key()); + String providerDnsName = s_configDao.getValue(ManagementServer.CloudDnsName.key()); return providerDnsName; } diff --git a/server/src/main/java/com/cloud/api/response/ApiResponseSerializer.java b/server/src/main/java/com/cloud/api/response/ApiResponseSerializer.java index bee9cbeb53a7..30d0c0b96d88 100644 --- a/server/src/main/java/com/cloud/api/response/ApiResponseSerializer.java +++ b/server/src/main/java/com/cloud/api/response/ApiResponseSerializer.java @@ -20,7 +20,7 @@ import com.cloud.api.ApiResponseGsonHelper; import com.cloud.api.ApiServer; import com.cloud.serializer.Param; -import com.cloud.server.ManagementServerImpl; +import com.cloud.server.ManagementServer; import com.cloud.user.Account; import com.cloud.utils.HttpUtils; import com.cloud.utils.encoding.URLEncoder; @@ -178,7 +178,7 @@ private static String toXMLSerializedString(ResponseObject result, StringBuilder log.append("<").append(result.getResponseName()); boolean authenticated = CallContext.current().getCallingAccount().getId() != Account.ACCOUNT_ID_SYSTEM; - if (ManagementServerImpl.exposeCloudStackVersionInApiXmlResponse.value() && authenticated) { + if (ManagementServer.exposeCloudStackVersionInApiXmlResponse.value() && authenticated) { sb.append(" cloud-stack-version=\"").append(ApiDBUtils.getVersion()).append("\""); log.append(" cloud-stack-version=\"").append(ApiDBUtils.getVersion()).append("\""); } diff --git a/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java b/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java index 3be7384ffb71..45e47e73e1eb 100644 --- a/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java +++ b/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java @@ -51,7 +51,6 @@ import com.cloud.agent.api.Command; import com.cloud.agent.api.StartupCommand; import com.cloud.capacity.dao.CapacityDao; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterDetailsVO; import com.cloud.dc.dao.ClusterDao; @@ -88,6 +87,7 @@ import com.cloud.utils.fsm.StateListener; import com.cloud.utils.fsm.StateMachine2; import com.cloud.vm.VMInstanceDetailVO; +import com.cloud.vm.UserVmManager; import com.cloud.vm.UserVmVO; import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine; @@ -147,7 +147,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, @Override public boolean configure(String name, Map params) throws ConfigurationException { - _vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600); + _vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(UserVmManager.CapacitySkipcountingHours.key()), 3600); VirtualMachine.State.getStateMachine().registerListener(this); _agentManager.registerForHostEvents(new StorageCapacityListener(_capacityDao, _storageMgr), true, false, false); diff --git a/server/src/main/java/com/cloud/configuration/Config.java b/server/src/main/java/com/cloud/configuration/Config.java index 2f4f7fa8ac5d..1d54ef37947d 100644 --- a/server/src/main/java/com/cloud/configuration/Config.java +++ b/server/src/main/java/com/cloud/configuration/Config.java @@ -26,12 +26,9 @@ import com.cloud.agent.AgentManager; import com.cloud.ha.HighAvailabilityManager; -import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.network.router.VpcVirtualNetworkApplianceManager; import com.cloud.network.vpc.VpcManager; import com.cloud.server.ManagementServer; import com.cloud.storage.StorageManager; -import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.snapshot.SnapshotManager; import com.cloud.template.TemplateManager; import com.cloud.vm.UserVmManager; @@ -45,27 +42,6 @@ public enum Config { // Alert - AlertEmailAddresses( - "Alert", - ManagementServer.class, - String.class, - "alert.email.addresses", - null, - "Comma separated list of email addresses which are going to receive alert emails.", - null, - ConfigKey.Kind.CSV, - null), - AlertEmailSender("Alert", ManagementServer.class, String.class, "alert.email.sender", null, "Sender of alert email (will be in the From header of the email).", null), - AlertSMTPHost("Alert", ManagementServer.class, String.class, "alert.smtp.host", null, "SMTP hostname used for sending out email alerts.", null), - AlertSMTPPassword( - "Secure", - ManagementServer.class, - String.class, - "alert.smtp.password", - null, - "Password for SMTP authentication (applies only if alert.smtp.useAuth is true).", - null), - AlertSMTPPort("Alert", ManagementServer.class, Integer.class, "alert.smtp.port", "465", "Port the SMTP server is listening on.", null), AlertSMTPConnectionTimeout("Alert", ManagementServer.class, Integer.class, "alert.smtp.connectiontimeout", "30000", "Socket connection timeout value in milliseconds. -1 for infinite timeout.", null), AlertSMTPTimeout( @@ -76,124 +52,9 @@ public enum Config { "30000", "Socket I/O timeout value in milliseconds. -1 for infinite timeout.", null), - AlertSMTPUsername( - "Alert", - ManagementServer.class, - String.class, - "alert.smtp.username", - null, - "Username for SMTP authentication (applies only if alert.smtp.useAuth is true).", - null), - CapacityCheckPeriod("Alert", ManagementServer.class, Integer.class, "capacity.check.period", "300000", "The interval in milliseconds between capacity checks", null), - PublicIpCapacityThreshold( - "Alert", - ManagementServer.class, - Float.class, - "zone.virtualnetwork.publicip.capacity.notificationthreshold", - "0.75", - "Percentage (as a value between 0 and 1) of public IP address space utilization above which alerts will be sent.", - null), - PrivateIpCapacityThreshold( - "Alert", - ManagementServer.class, - Float.class, - "pod.privateip.capacity.notificationthreshold", - "0.75", - "Percentage (as a value between 0 and 1) of private IP address space utilization above which alerts will be sent.", - null), - SecondaryStorageCapacityThreshold( - "Alert", - ManagementServer.class, - Float.class, - "zone.secstorage.capacity.notificationthreshold", - "0.75", - "Percentage (as a value between 0 and 1) of secondary storage utilization above which alerts will be sent about low storage available.", - null), - VlanCapacityThreshold( - "Alert", - ManagementServer.class, - Float.class, - "zone.vlan.capacity.notificationthreshold", - "0.75", - "Percentage (as a value between 0 and 1) of Zone Vlan utilization above which alerts will be sent about low number of Zone Vlans.", - null), - DirectNetworkPublicIpCapacityThreshold( - "Alert", - ManagementServer.class, - Float.class, - "zone.directnetwork.publicip.capacity.notificationthreshold", - "0.75", - "Percentage (as a value between 0 and 1) of Direct Network Public Ip Utilization above which alerts will be sent about low number of direct network public ips.", - null), - LocalStorageCapacityThreshold( - "Alert", - ManagementServer.class, - Float.class, - "cluster.localStorage.capacity.notificationthreshold", - "0.75", - "Percentage (as a value between 0 and 1) of local storage utilization above which alerts will be sent about low local storage available.", - null), // Storage - StorageStatsInterval( - "Storage", - ManagementServer.class, - String.class, - "storage.stats.interval", - "60000", - "The interval (in milliseconds) when storage stats (per host) are retrieved from agents.", - null), - StorageCacheReplacementLRUTimeInterval( - "Storage", - ManagementServer.class, - Integer.class, - "storage.cache.replacement.lru.interval", - "30", - "time interval for unused data on cache storage (in days).", - null), - StorageCacheReplacementEnabled( - "Storage", - ManagementServer.class, - Boolean.class, - "storage.cache.replacement.enabled", - "true", - "enable or disable cache storage replacement algorithm.", - null), - StorageCacheReplacementInterval( - "Storage", - ManagementServer.class, - Integer.class, - "storage.cache.replacement.interval", - "86400", - "time interval between cache replacement threads (in seconds).", - null), - MaxUploadVolumeSize("Storage", ManagementServer.class, Integer.class, "storage.max.volume.upload.size", "500", "The maximum size for a uploaded volume(in GB).", null), - TotalRetries( - "Storage", - AgentManager.class, - Integer.class, - "total.retries", - "4", - "The number of times each command sent to a host should be retried in case of failure.", - null), - StoragePoolMaxWaitSeconds( - "Storage", - ManagementServer.class, - Integer.class, - "storage.pool.max.waitseconds", - "3600", - "Timeout (in seconds) to synchronize storage pool operations.", - null), - CreateVolumeFromSnapshotWait( - "Storage", - StorageManager.class, - Integer.class, - "create.volume.from.snapshot.wait", - "10800", - "In second, timeout for creating volume from snapshot", - null), - CopyVolumeWait("Storage", StorageManager.class, Integer.class, "copy.volume.wait", "10800", "In second, timeout for copy volume command", null), CreatePrivateTemplateFromVolumeWait( "Storage", UserVmManager.class, @@ -202,76 +63,7 @@ public enum Config { "10800", "In second, timeout for CreatePrivateTemplateFromVolumeCommand", null), - CreatePrivateTemplateFromSnapshotWait( - "Storage", - UserVmManager.class, - Integer.class, - "create.private.template.from.snapshot.wait", - "10800", - "In second, timeout for CreatePrivateTemplateFromSnapshotCommand", - null), - BackupSnapshotWait("Storage", StorageManager.class, Integer.class, "backup.snapshot.wait", "21600", "In second, timeout for BackupSnapshotCommand", null), - HAStorageMigration( - "Storage", - ManagementServer.class, - Boolean.class, - "enable.ha.storage.migration", - "true", - "Enable/disable storage migration across primary storage during HA", - null), - // Network - NetworkLBHaproxyStatsVisbility( - "Network", - ManagementServer.class, - String.class, - "network.loadbalancer.haproxy.stats.visibility", - "global", - "Load Balancer(haproxy) stats visibility, the value can be one of the following six parameters : global,guest-network,link-local,disabled,all,default", - null, - ConfigKey.Kind.Select, - "global,guest-network,link-local,disabled,all,default"), - NetworkLBHaproxyStatsUri( - "Network", - ManagementServer.class, - String.class, - "network.loadbalancer.haproxy.stats.uri", - "/admin?stats", - "Load Balancer(haproxy) uri.", - null), - NetworkLBHaproxyStatsAuth( - "Secure", - ManagementServer.class, - String.class, - "network.loadbalancer.haproxy.stats.auth", - "admin1:AdMiN123", - "Load Balancer(haproxy) authentication string in the format username:password", - null), - NetworkLBHaproxyStatsPort( - "Network", - ManagementServer.class, - String.class, - "network.loadbalancer.haproxy.stats.port", - "8081", - "Load Balancer(haproxy) stats port number.", - null), - NetworkRouterRpFilter( - "Network", - ManagementServer.class, - Boolean.class, - "network.disable.rpfilter", - "true", - "disable rp_filter on Domain Router VM public interfaces.", - null), - - GuestVlanBits( - "Network", - ManagementServer.class, - Integer.class, - "guest.vlan.bits", - "12", - "The number of bits to reserve for the VLAN identifier in the guest subnet.", - null), //MulticastThrottlingRate("Network", ManagementServer.class, Integer.class, "multicast.throttling.rate", "10", "Default multicast rate in megabits per second allowed.", null), DirectNetworkNoDefaultRoute( "Network", @@ -281,55 +73,6 @@ public enum Config { "false", "Direct Network Dhcp Server should not send a default route", "true/false"), - OvsTunnelNetworkDefaultLabel( - "Network", - ManagementServer.class, - String.class, - "sdn.ovs.controller.default.label", - "cloud-public", - "Default network label to be used when fetching interface for GRE endpoints", - null), - SecurityGroupWorkCleanupInterval( - "Network", - ManagementServer.class, - Integer.class, - "network.securitygroups.work.cleanup.interval", - "120", - "Time interval (seconds) in which finished work is cleaned up from the work table", - null), - SecurityGroupWorkerThreads( - "Network", - ManagementServer.class, - Integer.class, - "network.securitygroups.workers.pool.size", - "50", - "Number of worker threads processing the security group update work queue", - null), - SecurityGroupWorkGlobalLockTimeout( - "Network", - ManagementServer.class, - Integer.class, - "network.securitygroups.work.lock.timeout", - "300", - "Lock wait timeout (seconds) while updating the security group work queue", - null), - SecurityGroupWorkPerAgentMaxQueueSize( - "Network", - ManagementServer.class, - Integer.class, - "network.securitygroups.work.per.agent.queue.size", - "100", - "The number of outstanding security group work items that can be queued to a host. If exceeded, work items will get dropped to conserve memory. Security Group Sync will take care of ensuring that the host gets updated eventually", - null), - - SecurityGroupDefaultAdding( - "Network", - ManagementServer.class, - Boolean.class, - "network.securitygroups.defaultadding", - "true", - "If true, the user VM would be added to the default security group by default", - null), GuestOSNeedGatewayOnNonDefaultNetwork( "Network", @@ -342,558 +85,28 @@ public enum Config { ConfigKey.Kind.CSV, null), - //VPN - RemoteAccessVpnPskLength( - "Network", - AgentManager.class, - Integer.class, - "remote.access.vpn.psk.length", - "24", - "The length of the ipsec preshared key (minimum 8, maximum 256)", - null), - RemoteAccessVpnUserLimit( - "Network", - AgentManager.class, - String.class, - "remote.access.vpn.user.limit", - "8", - "The maximum number of VPN users that can be created per account", - null), - Site2SiteVpnConnectionPerVpnGatewayLimit( - "Network", - ManagementServer.class, - Integer.class, - "site2site.vpn.vpngateway.connection.limit", - "4", - "The maximum number of VPN connection per VPN gateway", - null), - Site2SiteVpnSubnetsPerCustomerGatewayLimit( - "Network", - ManagementServer.class, - Integer.class, - "site2site.vpn.customergateway.subnets.limit", - "10", - "The maximum number of subnets per customer gateway", - null), - MaxNumberOfSecondaryIPsPerNIC( - "Network", ManagementServer.class, Integer.class, - "vm.network.nic.max.secondary.ipaddresses", "10", - "Specify the number of secondary ip addresses per nic per vm. Default value 10 is used, if not specified.", null), - - EnableServiceMonitoring( - "Network", ManagementServer.class, Boolean.class, - "network.router.enableserviceMonitoring", "false", - "service monitoring in router enable/disable option, default false", null), - - - // Snapshots - - SnapshotPollInterval( - "Snapshots", - SnapshotManager.class, - Integer.class, - "snapshot.poll.interval", - "300", - "The time interval in seconds when the management server polls for snapshots to be scheduled.", - null), - // Advanced - EventPurgeInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "event.purge.interval", - "86400", - "The interval (in seconds) to wait before running the event purge thread", - null), - AccountCleanupInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "account.cleanup.interval", - "86400", - "The interval (in seconds) between cleanup for removed accounts", - null), - InstanceName("Advanced", AgentManager.class, String.class, "instance.name", "VM", "Name of the deployment instance.", "instanceName"), - ExpungeDelay( - "Advanced", - UserVmManager.class, - Integer.class, - "expunge.delay", - "86400", - "Determines how long (in seconds) to wait before actually expunging destroyed vm. The default value = the default value of expunge.interval", - null), - ExpungeInterval( - "Advanced", - UserVmManager.class, - Integer.class, - "expunge.interval", - "86400", - "The interval (in seconds) to wait before running the expunge thread.", - null), - ExpungeWorkers("Advanced", UserVmManager.class, Integer.class, "expunge.workers", "1", "Number of workers performing expunge ", null), - ExtractURLCleanUpInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "extract.url.cleanup.interval", - "7200", - "The interval (in seconds) to wait before cleaning up the extract URL's ", - null), - DisableExtraction( - "Advanced", - ManagementServer.class, - Boolean.class, - "disable.extraction", - "false", - "Flag for disabling extraction of Templates, ISOs, Snapshots and volumes", - null), - ExtractURLExpirationInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "extract.url.expiration.interval", - "14400", - "The life of an extract URL after which it is deleted ", - null), - HostStatsInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "host.stats.interval", - "60000", - "The interval (in milliseconds) when host stats are retrieved from agents.", - null), HostRetry("Advanced", AgentManager.class, Integer.class, "host.retry", "2", "Number of times to retry hosts for creating a volume", null), - RouterCpuMHz( - "Advanced", - NetworkOrchestrationService.class, - Integer.class, - "router.cpu.mhz", - String.valueOf(VpcVirtualNetworkApplianceManager.DEFAULT_ROUTER_CPU_MHZ), - "Default CPU speed (MHz) for router VM.", - null), - RouterStatsInterval( - "Advanced", - NetworkOrchestrationService.class, - Integer.class, - "router.stats.interval", - "300", - "Interval (in seconds) to report router statistics.", - null), - ExternalNetworkStatsInterval( - "Advanced", - NetworkOrchestrationService.class, - Integer.class, - "external.network.stats.interval", - "300", - "Interval (in seconds) to report external network statistics.", - null), - RouterCheckInterval( - "Advanced", - NetworkOrchestrationService.class, - Integer.class, - "router.check.interval", - "30", - "Interval (in seconds) to report redundant router status.", - null), - RouterCheckPoolSize( - "Advanced", - NetworkOrchestrationService.class, - Integer.class, - "router.check.poolsize", - "10", - "Numbers of threads using to check redundant router status.", - null), - RouterExtraPublicNics( - "Advanced", - NetworkOrchestrationService.class, - Integer.class, - "router.extra.public.nics", - "2", - "specify extra public nics used for virtual router(up to 5)", - "0-5"), - ScaleRetry("Advanced", ManagementServer.class, Integer.class, "scale.retry", "2", "Number of times to retry scaling up the vm", null), UpdateWait("Advanced", AgentManager.class, Integer.class, "update.wait", "600", "Time to wait (in seconds) before alerting on a updating agent", null), - XapiWait("Advanced", AgentManager.class, Integer.class, "xapiwait", "60", "Time (in seconds) to wait for XAPI to return", null), - MigrateWait("Advanced", AgentManager.class, Integer.class, "migratewait", "3600", "Time (in seconds) to wait for VM migrate finish", null), - MountParent( - "Advanced", - ManagementServer.class, - String.class, - "mount.parent", - "/var/cloudstack/mnt", - "The mount point on the Management Server for Secondary Storage.", - null), - SystemVMAutoReserveCapacity( - "Advanced", - ManagementServer.class, - Boolean.class, - "system.vm.auto.reserve.capacity", - "true", - "Indicates whether or not to automatically reserver system VM standby capacity.", - null), - SystemVMRandomPassword( - "Advanced", - ManagementServer.class, - Boolean.class, - "system.vm.random.password", - "false", - "Randomize system vm password the first time management server starts", - null), - LinkLocalIpNums("Advanced", ManagementServer.class, Integer.class, "linkLocalIp.nums", "10", "The number of link local ip that needed by domR(in power of 2)", null), - HypervisorList( - "Advanced", - ManagementServer.class, - String.class, - "hypervisor.list", - HypervisorType.KVM + "," + HypervisorType.VMware + "," + HypervisorType.XenServer + "," + HypervisorType.Hyperv + "," + - HypervisorType.BareMetal + "," + HypervisorType.Ovm + "," + HypervisorType.LXC + "," + HypervisorType.Ovm3 + "," + HypervisorType.External, - "The list of hypervisors that this deployment will use.", - "hypervisorList", - ConfigKey.Kind.CSV, - null), - ManagementNetwork("Advanced", ManagementServer.class, String.class, "management.network.cidr", null, "The cidr of management server network", null), - EventPurgeDelay( - "Advanced", - ManagementServer.class, - Integer.class, - "event.purge.delay", - "15", - "Events older than specified number days will be purged. Set this value to 0 to never delete events", - null), - SecStorageVmMTUSize( - "Advanced", - AgentManager.class, - Integer.class, - "secstorage.vm.mtu.size", - String.valueOf(SecondaryStorageVmManager.DEFAULT_SS_VM_MTUSIZE), - "MTU size (in Byte) of storage network in secondary storage vms", - null), - MaxTemplateAndIsoSize( - "Advanced", - ManagementServer.class, - Long.class, - "max.template.iso.size", - "50", - "The maximum size for a downloaded template or ISO (in GB).", - null), - SecStorageAllowedInternalDownloadSites( - "Advanced", - ManagementServer.class, - String.class, - "secstorage.allowed.internal.sites", - null, - "Comma separated list of cidrs internal to the datacenter that can host template download servers, please note 0.0.0.0 is not a valid site", - null), - SecStorageEncryptCopy( - "Advanced", - ManagementServer.class, - Boolean.class, - "secstorage.encrypt.copy", - "false", - "Use SSL method used to encrypt copy traffic between zones. Also ensures that the certificate assigned to the zone is used when generating links for external access.", - "true,false"), - SecStorageSecureCopyCert( - "Advanced", - ManagementServer.class, - String.class, - "secstorage.ssl.cert.domain", - "", - "SSL certificate used to encrypt copy traffic between zones", - "domainName"), - SecStorageCapacityStandby( - "Advanced", - AgentManager.class, - Integer.class, - "secstorage.capacity.standby", - "10", - "The minimal number of command execution sessions that system is able to serve immediately(standby capacity)", - null), - SecStorageSessionMax( - "Advanced", - AgentManager.class, - Integer.class, - "secstorage.session.max", - "50", - "The max number of command execution sessions that a SSVM can handle", - null), - SecStorageCmdExecutionTimeMax( - "Advanced", - AgentManager.class, - Integer.class, - "secstorage.cmd.execution.time.max", - "30", - "The max command execution time in minute", - null), - SecStorageProxy( - "Advanced", - AgentManager.class, - String.class, - "secstorage.proxy", - null, - "http proxy used by ssvm, in http://username:password@proxyserver:port format", - null), - AlertPurgeInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "alert.purge.interval", - "86400", - "The interval (in seconds) to wait before running the alert purge thread", - null), - AlertPurgeDelay( - "Advanced", - ManagementServer.class, - Integer.class, - "alert.purge.delay", - "0", - "Alerts older than specified number days will be purged. Set this value to 0 to never delete alerts", - null), - HostReservationReleasePeriod( - "Advanced", - ManagementServer.class, - Integer.class, - "host.reservation.release.period", - "300000", - "The interval in milliseconds between host reservation release checks", - null), - // LB HealthCheck Interval. - LBHealthCheck( - "Advanced", - ManagementServer.class, - String.class, - "healthcheck.update.interval", - "600", - "Time Interval to fetch the LB health check states (in sec)", - null), - NCCCmdTimeOut( - "Advanced", - ManagementServer.class, - Long.class, - "ncc.command.timeout", - "600000", // 10 minutes - "Command Timeout Interval (in millisec)", - null), - DirectAttachNetworkEnabled( - "Advanced", - ManagementServer.class, - Boolean.class, - "direct.attach.network.externalIpAllocator.enabled", - "false", - "Direct-attach VMs using external DHCP server", - "true,false"), - DirectAttachNetworkExternalAPIURL( - "Advanced", - ManagementServer.class, - String.class, - "direct.attach.network.externalIpAllocator.url", - null, - "Direct-attach VMs using external DHCP server (API url)", - null), CheckPodCIDRs( "Advanced", ManagementServer.class, String.class, - "check.pod.cidrs", - "true", - "If true, different pods must belong to different CIDR subnets.", - "true,false"), - NetworkGcWait( - "Advanced", - ManagementServer.class, - Integer.class, - "network.gc.wait", - "600", - "Time (in seconds) to wait before shutting down a network that's not in used", - null), - NetworkGcInterval("Advanced", ManagementServer.class, Integer.class, "network.gc.interval", "600", "Seconds to wait before checking for networks to shutdown", null), - CapacitySkipcountingHours( - "Advanced", - ManagementServer.class, - Integer.class, - "capacity.skipcounting.hours", - "3600", - "Time (in seconds) to wait before release VM's cpu and memory when VM in stopped state", - null), - VmStatsInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "vm.stats.interval", - "60000", - "The interval (in milliseconds) when vm stats are retrieved from agents.", - null), - VmDiskStatsInterval("Advanced", ManagementServer.class, Integer.class, "vm.disk.stats.interval", "0", "Interval (in seconds) to report vm disk statistics.", null), - VolumeStatsInterval("Advanced", ManagementServer.class, Integer.class, "volume.stats.interval", "60000", "Interval (in milliseconds) to report volume statistics.", null), - VmTransitionWaitInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "vm.tranisition.wait.interval", - "3600", - "Time (in seconds) to wait before taking over a VM in transition state", - null), - VmDiskThrottlingIopsReadRate( - "Advanced", - ManagementServer.class, - Integer.class, - "vm.disk.throttling.iops_read_rate", - "0", - "Default disk I/O read rate in requests per second allowed in User vm's disk.", - null), - VmDiskThrottlingIopsWriteRate( - "Advanced", - ManagementServer.class, - Integer.class, - "vm.disk.throttling.iops_write_rate", - "0", - "Default disk I/O writerate in requests per second allowed in User vm's disk.", - null), - VmDiskThrottlingBytesReadRate( - "Advanced", - ManagementServer.class, - Integer.class, - "vm.disk.throttling.bytes_read_rate", - "0", - "Default disk I/O read rate in bytes per second allowed in User vm's disk.", - null), - VmDiskThrottlingBytesWriteRate( - "Advanced", - ManagementServer.class, - Integer.class, - "vm.disk.throttling.bytes_write_rate", - "0", - "Default disk I/O writerate in bytes per second allowed in User vm's disk.", - null), - ControlCidr( - "Advanced", - ManagementServer.class, - String.class, - "control.cidr", - "169.254.0.0/16", - "Changes the cidr for the control network traffic. Defaults to using link local. Must be unique within pods", - null), - ControlGateway("Advanced", ManagementServer.class, String.class, "control.gateway", "169.254.0.1", "gateway for the control network traffic", null), - HostCapacityTypeToOrderClusters( - "Advanced", - ManagementServer.class, - String.class, - "host.capacityType.to.order.clusters", - "CPU", - "The host capacity type (CPU, RAM, COMBINED) is used by deployment planner to order clusters during VM resource allocation", - "CPU,RAM,COMBINED"), - - ApplyAllocationAlgorithmToPods( - "Advanced", - ManagementServer.class, - Boolean.class, - "apply.allocation.algorithm.to.pods", - "false", - "If true, deployment planner applies the allocation heuristics at pods first in the given datacenter during VM resource allocation", - "true,false"), - VmUserDispersionWeight( - "Advanced", - ManagementServer.class, - Float.class, - "vm.user.dispersion.weight", - "1", - "Weight for user dispersion heuristic (as a value between 0 and 1) applied to resource allocation during vm deployment. Weight for capacity heuristic will be (1 - weight of user dispersion)", - null), - VmDeploymentPlanner( - "Advanced", - ManagementServer.class, - String.class, - "vm.deployment.planner", - "FirstFitPlanner", - "'FirstFitPlanner', 'UserDispersingPlanner', 'UserConcentratedPodPlanner': DeploymentPlanner heuristic that will be used for VM deployment.", - null, - ConfigKey.Kind.Select, - "FirstFitPlanner,UserDispersingPlanner,UserConcentratedPodPlanner"), - ElasticLoadBalancerEnabled( - "Advanced", - ManagementServer.class, - String.class, - "network.loadbalancer.basiczone.elb.enabled", - "false", - "Whether the load balancing service is enabled for basic zones", - "true,false"), - ElasticLoadBalancerNetwork( - "Advanced", - ManagementServer.class, - String.class, - "network.loadbalancer.basiczone.elb.network", - "guest", - "Whether the elastic load balancing service public ips are taken from the public or guest network", - "guest,public"), - ElasticLoadBalancerVmMemory( - "Advanced", - ManagementServer.class, - Integer.class, - "network.loadbalancer.basiczone.elb.vm.ram.size", - "512", - "Memory in MB for the elastic load balancer vm", - null), - ElasticLoadBalancerVmCpuMhz( - "Advanced", - ManagementServer.class, - Integer.class, - "network.loadbalancer.basiczone.elb.vm.cpu.mhz", - "128", - "CPU speed for the elastic load balancer vm", - null), - ElasticLoadBalancerVmNumVcpu( - "Advanced", - ManagementServer.class, - Integer.class, - "network.loadbalancer.basiczone.elb.vm.vcpu.num", - "1", - "Number of VCPU for the elastic load balancer vm", - null), - ElasticLoadBalancerVmGcInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "network.loadbalancer.basiczone.elb.gc.interval.minutes", - "30", - "Garbage collection interval to destroy unused ELB vms in minutes. Minimum of 5", - null), - EnableEC2API("Advanced", ManagementServer.class, Boolean.class, "enable.ec2.api", "false", "enable EC2 API on CloudStack", null), - EnableS3API("Advanced", ManagementServer.class, Boolean.class, "enable.s3.api", "false", "enable Amazon S3 API on CloudStack", null), - RecreateSystemVmEnabled( - "Advanced", - ManagementServer.class, - Boolean.class, - "recreate.systemvm.enabled", - "false", - "If true, will recreate system vm root disk whenever starting system vm", - "true,false"), - SetVmInternalNameUsingDisplayName( - "Advanced", - ManagementServer.class, - Boolean.class, - "vm.instancename.flag", - "false", - "If set to true, will set guest VM's name as it appears on the hypervisor, to its hostname. The flag is supported for VMware hypervisor only", + "check.pod.cidrs", + "true", + "If true, different pods must belong to different CIDR subnets.", "true,false"), - IncorrectLoginAttemptsAllowed( + VmTransitionWaitInterval( "Advanced", ManagementServer.class, Integer.class, - "incorrect.login.attempts.allowed", - "5", - "Incorrect login attempts allowed before the user is disabled (when value > 0). If value <=0 users are not disabled after failed login attempts", + "vm.tranisition.wait.interval", + "3600", + "Time (in seconds) to wait before taking over a VM in transition state", null), - // Ovm - OvmPublicNetwork("Hidden", ManagementServer.class, String.class, "ovm.public.network.device", null, "Specify the public bridge on host for public network", null), - OvmPrivateNetwork("Hidden", ManagementServer.class, String.class, "ovm.private.network.device", null, "Specify the private bridge on host for private network", null), - OvmGuestNetwork("Hidden", ManagementServer.class, String.class, "ovm.guest.network.device", null, "Specify the private bridge on host for private network", null), - + EnableEC2API("Advanced", ManagementServer.class, Boolean.class, "enable.ec2.api", "false", "enable EC2 API on CloudStack", null), + EnableS3API("Advanced", ManagementServer.class, Boolean.class, "enable.s3.api", "false", "enable Amazon S3 API on CloudStack", null), // Ovm3 - Ovm3PublicNetwork("Hidden", ManagementServer.class, String.class, "ovm3.public.network.device", null, "Specify the public bridge on host for public network", null), - Ovm3PrivateNetwork("Hidden", ManagementServer.class, String.class, "ovm3.private.network.device", null, "Specify the private bridge on host for private network", null), - Ovm3GuestNetwork("Hidden", ManagementServer.class, String.class, "ovm3.guest.network.device", null, "Specify the guest bridge on host for guest network", null), - Ovm3StorageNetwork("Hidden", ManagementServer.class, String.class, "ovm3.storage.network.device", null, "Specify the storage bridge on host for storage network", null), Ovm3HeartBeatTimeout( "Advanced", ManagementServer.class, @@ -913,55 +126,7 @@ public enum Config { // XenServer - XenServerPublicNetwork( - "Hidden", - ManagementServer.class, - String.class, - "xenserver.public.network.device", - null, - "[ONLY IF THE PUBLIC NETWORK IS ON A DEDICATED NIC]:The network name label of the physical device dedicated to the public network on a XenServer host", - null), - XenServerStorageNetwork1("Hidden", ManagementServer.class, String.class, "xenserver.storage.network.device1", null, "Specify when there are storage networks", null), - XenServerStorageNetwork2("Hidden", ManagementServer.class, String.class, "xenserver.storage.network.device2", null, "Specify when there are storage networks", null), - XenServerPrivateNetwork("Hidden", ManagementServer.class, String.class, "xenserver.private.network.device", null, "Specify when the private network name is different", null), - NetworkGuestCidrLimit( - "Network", - NetworkOrchestrationService.class, - Integer.class, - "network.guest.cidr.limit", - "22", - "size limit for guest cidr; can't be less than this value", - null), - XenServerSetupMultipath("Advanced", ManagementServer.class, String.class, "xenserver.setup.multipath", "false", "Setup the host to do multipath", null), XenServerBondStorageNic("Advanced", ManagementServer.class, String.class, "xenserver.bond.storage.nics", null, "Attempt to bond the two networks if found", null), - XenServerHeartBeatTimeout( - "Advanced", - ManagementServer.class, - Integer.class, - "xenserver.heartbeat.timeout", - "120", - "heartbeat timeout to use when implementing XenServer Self Fencing", - null), - XenServerHeartBeatInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "xenserver.heartbeat.interval", - "60", - "heartbeat interval to use when checking before XenServer Self Fencing", - null), - XenServerGuestNetwork("Hidden", ManagementServer.class, String.class, "xenserver.guest.network.device", null, "Specify for guest network name label", null), - XenServerMaxNics("Advanced", AgentManager.class, Integer.class, "xenserver.nics.max", "7", "Maximum allowed nics for Vms created on XenServer", null), - XenServerPVdriverVersion( - "Advanced", - ManagementServer.class, - String.class, - "xenserver.pvdriver.version", - "xenserver61", - "default Xen PV driver version for registered template, valid value:xenserver56,xenserver61 ", - "xenserver56,xenserver61", - ConfigKey.Kind.Select, - "xenserver56,xenserver61"), XenServerHotFix("Advanced", ManagementServer.class, Boolean.class, @@ -971,90 +136,8 @@ public enum Config { null), // VMware - VmwareUseNexusVSwitch( - "Network", - ManagementServer.class, - Boolean.class, - "vmware.use.nexus.vswitch", - "false", - "Enable/Disable Cisco Nexus 1000v vSwitch in VMware environment", - null), - VmwareUseDVSwitch( - "Network", - ManagementServer.class, - Boolean.class, - "vmware.use.dvswitch", - "false", - "Enable/Disable Nexus/Vmware dvSwitch in VMware environment", - null), - VmwareServiceConsole( - "Advanced", - ManagementServer.class, - String.class, - "vmware.service.console", - "Service Console", - "Specify the service console network name(for ESX hosts)", - null), - VmwareManagementPortGroup( - "Advanced", - ManagementServer.class, - String.class, - "vmware.management.portgroup", - "Management Network", - "Specify the management network name(for ESXi hosts)", - null), - VmwareAdditionalVncPortRangeStart( - "Advanced", - ManagementServer.class, - Integer.class, - "vmware.additional.vnc.portrange.start", - "50000", - "Start port number of additional VNC port range", - null), - VmwareAdditionalVncPortRangeSize( - "Advanced", - ManagementServer.class, - Integer.class, - "vmware.additional.vnc.portrange.size", - "1000", - "Start port number of additional VNC port range", - null), //VmwareGuestNicDeviceType("Advanced", ManagementServer.class, String.class, "vmware.guest.nic.device.type", "E1000", "Ethernet card type used in guest VM, valid values are E1000, PCNet32, Vmxnet2, Vmxnet3", null), - VmwareRootDiskControllerType( - "Advanced", - ManagementServer.class, - String.class, - "vmware.root.disk.controller", - "ide", - "Specify the default disk controller for root volumes, valid values are scsi, ide, osdefault. Please check documentation for more details on each of these values.", - null, - ConfigKey.Kind.Select, - "scsi,ide,osdefault"), - VmwareSystemVmNicDeviceType( - "Advanced", - ManagementServer.class, - String.class, - "vmware.systemvm.nic.device.type", - "E1000", - "Specify the default network device type for system VMs, valid values are E1000, PCNet32, Vmxnet2, Vmxnet3", - null, - ConfigKey.Kind.Select, - "E1000,PCNet32,Vmxnet2,Vmxnet3"), - VmwareRecycleHungWorker( - "Advanced", - ManagementServer.class, - Boolean.class, - "vmware.recycle.hung.wokervm", - "false", - "Specify whether or not to recycle hung worker VMs", - null), VmwareHungWorkerTimeout("Advanced", ManagementServer.class, Long.class, "vmware.hung.wokervm.timeout", "7200", "Worker VM timeout in seconds", null), - VmwareVcenterSessionTimeout("Advanced", ManagementServer.class, Long.class, "vmware.vcenter.session.timeout", "1200", "VMware client timeout in seconds", null), - - // KVM - KvmPublicNetwork("Hidden", ManagementServer.class, String.class, "kvm.public.network.device", null, "Specify the public bridge on host for public network", null), - KvmPrivateNetwork("Hidden", ManagementServer.class, String.class, "kvm.private.network.device", null, "Specify the private bridge on host for private network", null), - KvmGuestNetwork("Hidden", ManagementServer.class, String.class, "kvm.guest.network.device", null, "Specify the private bridge on host for private network", null), // Hyperv HypervPublicNetwork( @@ -1082,68 +165,7 @@ public enum Config { "Specify the virtual switch on host for private network", null), - // Usage - UsageExecutionTimezone("Usage", ManagementServer.class, String.class, "usage.execution.timezone", null, "The timezone to use for usage job execution time", null), - UsageStatsJobAggregationRange( - "Usage", - ManagementServer.class, - Integer.class, - "usage.stats.job.aggregation.range", - "1440", - "The range of time for aggregating the user statistics specified in minutes (e.g. 1440 for daily, 60 for hourly.", - null), - UsageStatsJobExecTime( - "Usage", - ManagementServer.class, - String.class, - "usage.stats.job.exec.time", - "00:15", - "The time at which the usage statistics aggregation job will run as an HH24:MM time, e.g. 00:30 to run at 12:30am.", - null), - EnableUsageServer("Usage", ManagementServer.class, Boolean.class, "enable.usage.server", "true", "Flag for enabling usage", null), - DirectNetworkStatsInterval( - "Usage", - ManagementServer.class, - Integer.class, - "direct.network.stats.interval", - "86400", - "Interval (in seconds) to collect stats from Traffic Monitor", - null), - UsageSanityCheckInterval( - "Usage", - ManagementServer.class, - Integer.class, - "usage.sanity.check.interval", - null, - "Interval (in days) to check sanity of usage data. To disable set it to 0 or negative.", - null), - UsageAggregationTimezone("Usage", ManagementServer.class, String.class, "usage.aggregation.timezone", "GMT", "The timezone to use for usage stats aggregation", null), - TrafficSentinelIncludeZones( - "Usage", - ManagementServer.class, - String.class, - "traffic.sentinel.include.zones", - "EXTERNAL", - "Traffic going into specified list of zones is metered. For metering all traffic leave this parameter empty", - null), - TrafficSentinelExcludeZones( - "Usage", - ManagementServer.class, - String.class, - "traffic.sentinel.exclude.zones", - "", - "Traffic going into specified list of zones is not metered.", - null), - // Hidden - UseSecondaryStorageVm( - "Hidden", - ManagementServer.class, - Boolean.class, - "secondary.storage.vm", - "false", - "Deploys a VM per zone to manage secondary storage if true, otherwise secondary storage is mounted on management server", - null), CreatePoolsInPod( "Hidden", ManagementServer.class, @@ -1152,361 +174,10 @@ public enum Config { "false", "Should we automatically add XenServers into pools that are inside a Pod", null), - CloudIdentifier("Hidden", ManagementServer.class, String.class, "cloud.identifier", null, "A unique identifier for the cloud.", null), - SSOKey("Secure", ManagementServer.class, String.class, "security.singlesignon.key", null, "A Single Sign-On key used for logging into the cloud", null), - SSOAuthTolerance( - "Advanced", - ManagementServer.class, - Long.class, - "security.singlesignon.tolerance.millis", - "300000", - "The allowable clock difference in milliseconds between when an SSO login request is made and when it is received.", - null), //NetworkType("Hidden", ManagementServer.class, String.class, "network.type", "vlan", "The type of network that this deployment will use.", "vlan,direct"), - RouterRamSize("Hidden", NetworkOrchestrationService.class, Integer.class, "router.ram.size", "512", "Default RAM for router VM (in MB).", null), DefaultPageSize("Advanced", ManagementServer.class, Long.class, "default.page.size", "500", "Default page size for API list* commands", null), - // Account Default Limits - DefaultMaxAccountUserVms( - "Account Defaults", - ManagementServer.class, - Long.class, - "max.account.user.vms", - "20", - "The default maximum number of user VMs that can be deployed for an account", - null), - DefaultMaxAccountPublicIPs( - "Account Defaults", - ManagementServer.class, - Long.class, - "max.account.public.ips", - "20", - "The default maximum number of public IPs that can be consumed by an account", - null), - DefaultMaxAccountTemplates( - "Account Defaults", - ManagementServer.class, - Long.class, - "max.account.templates", - "20", - "The default maximum number of Templates that can be deployed for an account", - null), - DefaultMaxAccountSnapshots( - "Account Defaults", - ManagementServer.class, - Long.class, - "max.account.snapshots", - "20", - "The default maximum number of snapshots that can be created for an account", - null), - DefaultMaxAccountVolumes( - "Account Defaults", - ManagementServer.class, - Long.class, - "max.account.volumes", - "20", - "The default maximum number of volumes that can be created for an account", - null), - DefaultMaxAccountNetworks( - "Account Defaults", - ManagementServer.class, - Long.class, - "max.account.networks", - "20", - "The default maximum number of networks that can be created for an account", - null), - DefaultMaxAccountVpcs( - "Account Defaults", - ManagementServer.class, - Long.class, - "max.account.vpcs", - "20", - "The default maximum number of vpcs that can be created for an account", - null), - DefaultMaxAccountCpus( - "Account Defaults", - ManagementServer.class, - Long.class, - "max.account.cpus", - "40", - "The default maximum number of cpu cores that can be used for an account", - null), - DefaultMaxAccountMemory( - "Account Defaults", - ManagementServer.class, - Long.class, - "max.account.memory", - "40960", - "The default maximum memory (in MB) that can be used for an account", - null), - DefaultMaxAccountPrimaryStorage( - "Account Defaults", - ManagementServer.class, - Long.class, - "max.account.primary.storage", - "200", - "The default maximum primary storage space (in GiB) that can be used for an account", - null), - DefaultMaxAccountProjects( - "Account Defaults", - ManagementServer.class, - Long.class, - "max.account.projects", - "10", - "The default maximum number of projects that can be created for an account", - null), - - //disabling lb as cluster sync does not work with distributed cluster - SubDomainNetworkAccess( - "Advanced", - NetworkOrchestrationService.class, - Boolean.class, - "allow.subdomain.network.access", - "true", - "Allow subdomains to use networks dedicated to their parent domain(s)", - null), - DnsBasicZoneUpdates( - "Advanced", - NetworkOrchestrationService.class, - String.class, - "network.dns.basiczone.updates", - "all", - "This parameter can take 2 values: all (default) and pod. It defines if DHCP/DNS requests have to be send to all dhcp servers in cloudstack, or only to the one in the same pod", - "all,pod", - ConfigKey.Kind.Select, - "all,pod"), - - ClusterMessageTimeOutSeconds( - "Advanced", - ManagementServer.class, - Integer.class, - "cluster.message.timeout.seconds", - "300", - "Time (in seconds) to wait before a inter-management server message post times out.", - null), - AgentLoadThreshold( - "Advanced", - ManagementServer.class, - Float.class, - "agent.load.threshold", - "0.7", - "Percentage (as a value between 0 and 1) of connected agents after which agent load balancing will start happening", - null), - - DefaultMaxDomainUserVms("Domain Defaults", ManagementServer.class, Long.class, "max.domain.user.vms", "40", "The default maximum number of user Instances that can be deployed for a domain", null), - DefaultMaxDomainPublicIPs("Domain Defaults", ManagementServer.class, Long.class, "max.domain.public.ips", "40", "The default maximum number of public IPs that can be consumed by a domain", null), - DefaultMaxDomainTemplates("Domain Defaults", ManagementServer.class, Long.class, "max.domain.templates", "40", "The default maximum number of Templates that can be deployed for a domain", null), - DefaultMaxDomainSnapshots("Domain Defaults", ManagementServer.class, Long.class, "max.domain.snapshots", "40", "The default maximum number of Snapshots that can be created for a domain", null), - DefaultMaxDomainVolumes("Domain Defaults", ManagementServer.class, Long.class, "max.domain.volumes", "40", "The default maximum number of Volumes that can be created for a domain", null), - DefaultMaxDomainNetworks("Domain Defaults", ManagementServer.class, Long.class, "max.domain.networks", "40", "The default maximum number of Networks that can be created for a domain", null), - DefaultMaxDomainVpcs("Domain Defaults", ManagementServer.class, Long.class, "max.domain.vpcs", "40", "The default maximum number of VPCs that can be created for a domain", null), - DefaultMaxDomainCpus("Domain Defaults", ManagementServer.class, Long.class, "max.domain.cpus", "80", "The default maximum number of CPU cores that can be used for a domain", null), - DefaultMaxDomainMemory("Domain Defaults", ManagementServer.class, Long.class, "max.domain.memory", "81920", "The default maximum memory (in MB) that can be used for a domain", null), - DefaultMaxDomainPrimaryStorage("Domain Defaults", ManagementServer.class, Long.class, "max.domain.primary.storage", "400", "The default maximum primary storage space (in GiB) that can be used for a domain", null), - DefaultMaxDomainSecondaryStorage("Domain Defaults", ManagementServer.class, Long.class, "max.domain.secondary.storage", "800", "The default maximum secondary storage space (in GiB) that can be used for a domain", null), - DefaultMaxDomainProjects("Domain Defaults",ManagementServer.class,Long.class,"max.domain.projects","50","The default maximum number of projects that can be created for a domain",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, - String.class, - "external.lb.default.capacity", - "50", - "default number of networks permitted per external load balancer device", - null), - DefaultExternalFirewallCapacity( - "Advanced", - ManagementServer.class, - String.class, - "external.firewall.default.capacity", - "50", - "default number of networks permitted per external load firewall device", - null), - EIPWithMultipleNetScalersEnabled( - "Advanced", - ManagementServer.class, - Boolean.class, - "eip.use.multiple.netscalers", - "false", - "Should be set to true, if there will be multiple NetScaler devices providing EIP service in a zone", - null), - SecondaryStorageServiceOffering( - "Advanced", - ManagementServer.class, - String.class, - "secstorage.service.offering", - null, - "Uuid of the service offering used by secondary storage; if NULL - system offering will be used", - null), - HaTag("Advanced", ManagementServer.class, String.class, "ha.tag", null, "HA tag defining that the host marked with this tag can be used for HA purposes only", null), - ImplicitHostTags( - "Advanced", - ManagementServer.class, - String.class, - "implicit.host.tags", - "GPU", - "Tag hosts at the time of host discovery based on the host properties/capabilities", - null), - VpcCleanupInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "vpc.cleanup.interval", - "3600", - "The interval (in seconds) between cleanup for Inactive VPCs", - null), - VpcMaxNetworks("Advanced", ManagementServer.class, Integer.class, "vpc.max.networks", "3", "Maximum number of networks per vpc", null), - DetailBatchQuerySize("Advanced", ManagementServer.class, Integer.class, "detail.batch.query.size", "2000", "Default entity detail batch query size for listing", null), - NetworkIPv6SearchRetryMax( - "Network", - ManagementServer.class, - Integer.class, - "network.ipv6.search.retry.max", - "10000", - "The maximum number of retrying times to search for an available IPv6 address in the table", - null), - BaremetalInternalStorageServer( "Advanced", ManagementServer.class, @@ -1597,83 +268,8 @@ public enum Config { "ipmi interface will be temporary out of order after power operations(e.g. cycle, on), it leads following commands fail immediately. The value specifies retry times before accounting it as real failure", null), - ApiLimitEnabled("Advanced", ManagementServer.class, Boolean.class, "api.throttling.enabled", "false", "Enable/disable Api rate limit", null), - ApiLimitInterval("Advanced", ManagementServer.class, Integer.class, "api.throttling.interval", "1", "Time interval (in seconds) to reset API count", null), - ApiLimitMax("Advanced", ManagementServer.class, Integer.class, "api.throttling.max", "25", "Max allowed number of APIs within fixed interval", null), - ApiLimitCacheSize("Advanced", ManagementServer.class, Integer.class, "api.throttling.cachesize", "50000", "Account based API count cache size", null), - - // object store - S3EnableRRS("Advanced", ManagementServer.class, Boolean.class, "s3.rrs.enabled", "false", "enable s3 reduced redundancy storage", null), - S3MaxSingleUploadSize( - "Advanced", - ManagementServer.class, - Integer.class, - "s3.singleupload.max.size", - "5", - "The maximum size limit for S3 single part upload API(in GB). If it is set to 0, then it means always use multi-part upload to upload object to S3. " - + "If it is set to -1, then it means always use single-part upload to upload object to S3. ", - null), - - // VMSnapshots - VMSnapshotCreateWait("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.create.wait", "1800", "In second, timeout for create vm snapshot", null), - - CloudDnsName("Advanced", ManagementServer.class, String.class, "cloud.dns.name", null, "DNS name of the cloud for the GSLB service", null), - InternalLbVmServiceOfferingId( - "Advanced", - ManagementServer.class, - String.class, - "internallbvm.service.offering", - null, - "Uuid of the service offering used by internal lb vm; if NULL - default system internal lb offering will be used", - null), - ExecuteInSequenceNetworkElementCommands( - "Advanced", - NetworkOrchestrationService.class, - Boolean.class, - "execute.in.sequence.network.element.commands", - "false", - "If set to true, DhcpEntryCommand, SavePasswordCommand, VmDataCommand will be synchronized on the agent side." - + " If set to false, these commands become asynchronous. Default value is false.", - null), - - UCSSyncBladeInterval( - "Advanced", - ManagementServer.class, - Integer.class, - "ucs.sync.blade.interval", - "3600", - "the interval cloudstack sync with UCS manager for available blades in case user remove blades from chassis without notifying CloudStack", - null), - - RedundantRouterVrrpInterval( - "Advanced", - NetworkOrchestrationService.class, - Integer.class, - "router.redundant.vrrp.interval", - "1", - "seconds between VRRP broadcast. It would 3 times broadcast fail to trigger fail-over mechanism of redundant router", - null), - - RouterAggregationCommandEachTimeout( - "Advanced", - NetworkOrchestrationService.class, - Integer.class, - "router.aggregation.command.each.timeout", - "600", - "timeout in seconds for each Virtual Router command being aggregated. The final aggregation command timeout would be determined by this timeout * commands counts ", - null), - ManagementServerVendor("Advanced", ManagementServer.class, String.class, "mgt.server.vendor", "ACS", "the vendor of management server", null), - PublishActionEvent("Advanced", ManagementServer.class, Boolean.class, "publish.action.events", "true", "enable or disable publishing of action events on the event bus", null), - PublishAlertEvent("Advanced", ManagementServer.class, Boolean.class, "publish.alert.events", "true", "enable or disable publishing of alert events on the event bus", null), - PublishResourceStateEvent("Advanced", ManagementServer.class, Boolean.class, "publish.resource.state.events", "true", "enable or disable publishing of alert events on the event bus", null), - PublishUsageEvent("Advanced", ManagementServer.class, Boolean.class, "publish.usage.events", "true", "enable or disable publishing of usage events on the event bus", null), - PublishAsynJobEvent("Advanced", ManagementServer.class, Boolean.class, "publish.async.job.events", "true", "enable or disable publishing of usage events on the event bus", null), - - // StatsCollector - StatsOutPutGraphiteHost("Advanced", ManagementServer.class, String.class, "stats.output.uri", "", "URI to additionally send StatsCollector statistics to", null), - - SSVMPSK("Hidden", ManagementServer.class, String.class, "upload.post.secret.key", "", "PSK with SSVM", null); + PublishAsynJobEvent("Advanced", ManagementServer.class, Boolean.class, "publish.async.job.events", "true", "enable or disable publishing of usage events on the event bus", null); private final String _category; diff --git a/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java index 837254ed8b36..0375144c1eda 100644 --- a/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java @@ -16,7 +16,6 @@ // under the License. package com.cloud.configuration; -import static com.cloud.configuration.Config.SecStorageAllowedInternalDownloadSites; import static com.cloud.offering.NetworkOffering.RoutingMode.Dynamic; import static com.cloud.offering.NetworkOffering.RoutingMode.Static; import static org.apache.cloudstack.framework.config.ConfigKey.CATEGORY_SYSTEM; @@ -261,6 +260,7 @@ import com.cloud.network.netris.NetrisService; import com.cloud.network.rules.LoadBalancerContainer.Scheme; import com.cloud.network.vpc.VpcManager; +import com.cloud.network.vpn.RemoteAccessVpnService; import com.cloud.offering.DiskOffering; import com.cloud.offering.NetworkOffering; import com.cloud.offering.NetworkOffering.Availability; @@ -277,6 +277,7 @@ import com.cloud.projects.Project; import com.cloud.projects.ProjectManager; import com.cloud.resourcelimit.CheckedReservation; +import com.cloud.server.ManagementServer; import com.cloud.server.ManagementService; import com.cloud.service.ServiceOfferingDetailsVO; import com.cloud.service.ServiceOfferingVO; @@ -294,6 +295,7 @@ import com.cloud.storage.dao.StoragePoolTagsDao; import com.cloud.storage.dao.VMTemplateZoneDao; import com.cloud.storage.dao.VolumeDao; +import com.cloud.storage.snapshot.SnapshotManager; import com.cloud.test.IPRangeConfig; import com.cloud.user.Account; import com.cloud.user.AccountDetailVO; @@ -606,7 +608,7 @@ protected void populateConfigValuesForValidationSet() { configValuesForValidation.add("host.stats.interval"); configValuesForValidation.add("network.gc.interval"); configValuesForValidation.add("ping.interval"); - configValuesForValidation.add("snapshot.poll.interval"); + configValuesForValidation.add(SnapshotManager.SnapshotPollInterval.key()); configValuesForValidation.add("storage.stats.interval"); configValuesForValidation.add("storage.cleanup.interval"); configValuesForValidation.add("wait"); @@ -619,7 +621,7 @@ protected void populateConfigValuesForValidationSet() { configValuesForValidation.add("externaldhcp.vmip.retrieval.interval"); configValuesForValidation.add("externaldhcp.vmip.max.retry"); configValuesForValidation.add("externaldhcp.vmipFetch.threadPool.max"); - configValuesForValidation.add("remote.access.vpn.psk.length"); + configValuesForValidation.add(RemoteAccessVpnService.RemoteAccessVpnPskLength.key()); configValuesForValidation.add(StorageManager.STORAGE_POOL_DISK_WAIT.key()); configValuesForValidation.add(StorageManager.STORAGE_POOL_CLIENT_TIMEOUT.key()); configValuesForValidation.add(StorageManager.STORAGE_POOL_CLIENT_MAX_CONNECTIONS.key()); @@ -637,19 +639,19 @@ protected void weightBasedParametersForValidation() { weightBasedParametersForValidation.add(AlertManager.StorageAllocatedCapacityThreshold.key()); weightBasedParametersForValidation.add(AlertManager.StorageCapacityThreshold.key()); weightBasedParametersForValidation.add(AlertManager.MemoryCapacityThreshold.key()); - weightBasedParametersForValidation.add(Config.PublicIpCapacityThreshold.key()); - weightBasedParametersForValidation.add(Config.PrivateIpCapacityThreshold.key()); - weightBasedParametersForValidation.add(Config.SecondaryStorageCapacityThreshold.key()); - weightBasedParametersForValidation.add(Config.VlanCapacityThreshold.key()); - weightBasedParametersForValidation.add(Config.DirectNetworkPublicIpCapacityThreshold.key()); - weightBasedParametersForValidation.add(Config.LocalStorageCapacityThreshold.key()); + weightBasedParametersForValidation.add(AlertManager.PublicIpCapacityThreshold.key()); + weightBasedParametersForValidation.add(AlertManager.PrivateIpCapacityThreshold.key()); + weightBasedParametersForValidation.add(AlertManager.SecondaryStorageCapacityThreshold.key()); + weightBasedParametersForValidation.add(AlertManager.VlanCapacityThreshold.key()); + weightBasedParametersForValidation.add(AlertManager.DirectNetworkPublicIpCapacityThreshold.key()); + weightBasedParametersForValidation.add(AlertManager.LocalStorageCapacityThreshold.key()); weightBasedParametersForValidation.add(CapacityManager.StorageAllocatedCapacityDisableThreshold.key()); weightBasedParametersForValidation.add(CapacityManager.StorageCapacityDisableThreshold.key()); weightBasedParametersForValidation.add(CapacityManager.StorageAllocatedCapacityDisableThresholdForVolumeSize.key()); weightBasedParametersForValidation.add(DeploymentClusterPlanner.ClusterCPUCapacityDisableThreshold.key()); weightBasedParametersForValidation.add(DeploymentClusterPlanner.ClusterMemoryCapacityDisableThreshold.key()); - weightBasedParametersForValidation.add(Config.AgentLoadThreshold.key()); - weightBasedParametersForValidation.add(Config.VmUserDispersionWeight.key()); + weightBasedParametersForValidation.add("agent.load.threshold"); + weightBasedParametersForValidation.add(DeploymentClusterPlanner.VmUserDispersionWeight.key()); weightBasedParametersForValidation.add(CapacityManager.SecondaryStorageCapacityThreshold.key()); weightBasedParametersForValidation.add(ClusterDrsService.ClusterDrsImbalanceThreshold.key()); weightBasedParametersForValidation.add(ClusterDrsService.ClusterDrsImbalanceSkipThreshold.key()); @@ -683,11 +685,11 @@ public void onPublishMessage(String senderAddress, String subject, Object args) if (settingNameUpdated.equals(ApiServiceConfiguration.ManagementServerAddresses.key()) || settingNameUpdated.equals(IndirectAgentLBServiceImpl.IndirectAgentLBAlgorithm.key())) { _indirectAgentLB.propagateMSListToAgents(false); - } else if (settingNameUpdated.equals(Config.RouterAggregationCommandEachTimeout.toString()) - || settingNameUpdated.equals(Config.MigrateWait.toString())) { + } else if (settingNameUpdated.equals(ManagementServer.RouterAggregationCommandEachTimeout.key()) + || settingNameUpdated.equals(AgentManager.MigrateWait.toString())) { Map params = new HashMap<>(); - params.put(Config.RouterAggregationCommandEachTimeout.toString(), _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString())); - params.put(Config.MigrateWait.toString(), _configDao.getValue(Config.MigrateWait.toString())); + params.put(ManagementServer.RouterAggregationCommandEachTimeout.key(), _configDao.getValue(ManagementServer.RouterAggregationCommandEachTimeout.key())); + params.put(AgentManager.MigrateWait.toString(), _configDao.getValue(AgentManager.MigrateWait.toString())); _agentManager.propagateChangeToAgents(params); } else if (settingNameUpdated.equals(IndirectAgentLBServiceImpl.IndirectAgentLBCheckInterval.key())) { ConfigKey.Scope scope = settingUpdated.second(); @@ -751,7 +753,7 @@ public boolean start() { // As it is so common for people to forget about configuring // management.network.cidr, - final String mgtCidr = _configDao.getValue(Config.ManagementNetwork.key()); + final String mgtCidr = _configDao.getValue(ManagementServer.ManagementNetwork.key()); if (mgtCidr == null || mgtCidr.trim().isEmpty()) { final String[] localCidrs = NetUtils.getLocalCidrs(); if (localCidrs != null && localCidrs.length > 0) { @@ -759,7 +761,7 @@ public boolean start() { _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGEMENT_NODE, 0, 0L, "Management network CIDR is not configured originally. Set it default to " + localCidrs[0], ""); - _configDao.update(Config.ManagementNetwork.key(), Config.ManagementNetwork.getCategory(), localCidrs[0]); + _configDao.update(ManagementServer.ManagementNetwork.key(), ManagementServer.ManagementNetwork.category(), localCidrs[0]); } else { logger.warn("Management network CIDR is not properly configured and we are not able to find a default setting"); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGEMENT_NODE, 0, 0L, @@ -925,7 +927,7 @@ public String updateConfiguration(final long userId, final String name, final St _configDepot.invalidateConfigCache(name, ConfigKey.Scope.Global, null); PreparedStatement pstmt; - if (Config.XenServerGuestNetwork.key().equalsIgnoreCase(name)) { + if (NetworkService.XenServerGuestNetwork.key().equalsIgnoreCase(name)) { final String sql = "update host_details set value=? where name=?"; try { pstmt = txn.prepareAutoCloseStatement(sql); @@ -936,7 +938,7 @@ public String updateConfiguration(final long userId, final String name, final St } catch (final Throwable e) { throw new CloudRuntimeException("Failed to update guest.network.device in host_details due to exception ", e); } - } else if (Config.XenServerPrivateNetwork.key().equalsIgnoreCase(name)) { + } else if (NetworkService.XenServerPrivateNetwork.key().equalsIgnoreCase(name)) { final String sql = "update host_details set value=? where name=?"; try { pstmt = txn.prepareAutoCloseStatement(sql); @@ -947,7 +949,7 @@ public String updateConfiguration(final long userId, final String name, final St } catch (final Throwable e) { throw new CloudRuntimeException("Failed to update private.network.device in host_details due to exception ", e); } - } else if (Config.XenServerPublicNetwork.key().equalsIgnoreCase(name)) { + } else if (NetworkService.XenServerPublicNetwork.key().equalsIgnoreCase(name)) { final String sql = "update host_details set value=? where name=?"; try { pstmt = txn.prepareAutoCloseStatement(sql); @@ -958,7 +960,7 @@ public String updateConfiguration(final long userId, final String name, final St } catch (final Throwable e) { throw new CloudRuntimeException("Failed to update public.network.device in host_details due to exception ", e); } - } else if (Config.XenServerStorageNetwork1.key().equalsIgnoreCase(name)) { + } else if (NetworkService.XenServerStorageNetwork1.key().equalsIgnoreCase(name)) { final String sql = "update host_details set value=? where name=?"; try { pstmt = txn.prepareAutoCloseStatement(sql); @@ -969,7 +971,7 @@ public String updateConfiguration(final long userId, final String name, final St } catch (final Throwable e) { throw new CloudRuntimeException("Failed to update storage.network.device1 in host_details due to exception ", e); } - } else if (Config.XenServerStorageNetwork2.key().equals(name)) { + } else if (NetworkService.XenServerStorageNetwork2.key().equals(name)) { final String sql = "update host_details set value=? where name=?"; try { pstmt = txn.prepareAutoCloseStatement(sql); @@ -980,7 +982,7 @@ public String updateConfiguration(final long userId, final String name, final St } catch (final Throwable e) { throw new CloudRuntimeException("Failed to update storage.network.device2 in host_details due to exception ", e); } - } else if (Config.SecStorageSecureCopyCert.key().equalsIgnoreCase(name)) { + } else if (SecondaryStorageVmManager.SecStorageSecureCopyCert.key().equalsIgnoreCase(name)) { //FIXME - Ideally there should be a listener model to listen to global config changes and be able to take action gracefully. //Expire the download urls final String sqlTemplate = "update template_store_ref set download_url_created=?"; @@ -1016,7 +1018,7 @@ private boolean shouldEncryptValue(String category) { * Updates the 'hypervisor.list' value to match the new custom hypervisor name set as newValue if the previous value was set */ private void updateCustomDisplayNameOnHypervisorsList(String previousValue, String newValue) { - String hypervisorListConfigName = Config.HypervisorList.key(); + String hypervisorListConfigName = ManagementServer.HypervisorList.key(); String hypervisors = _configDao.getValue(hypervisorListConfigName); if (Arrays.asList(hypervisors.split(",")).contains(previousValue)) { hypervisors = hypervisors.replace(previousValue, newValue); @@ -1540,7 +1542,7 @@ protected String validateValueRange(String name, String value, Class type, Co if ("vm.password.length".equalsIgnoreCase(name) && val < 6) { return String.format("Please enter a value greater than 5 for the configuration parameter: [%s].", name); } - if ("remote.access.vpn.psk.length".equalsIgnoreCase(name) && (val < 8 || val > 256)) { + if (RemoteAccessVpnService.RemoteAccessVpnPskLength.key().equalsIgnoreCase(name) && (val < 8 || val > 256)) { return String.format("Please enter a value greater than 7 and less than 257 for the configuration parameter: [%s].", name); } if (UserDataManager.VM_USERDATA_MAX_LENGTH_STRING.equalsIgnoreCase(name) && val > 1048576) { @@ -1550,7 +1552,7 @@ protected String validateValueRange(String name, String value, Class type, Co } if (type.equals(String.class)) { - if (SecStorageAllowedInternalDownloadSites.key().equalsIgnoreCase(name) && StringUtils.isNotEmpty(value)) { + if (SecondaryStorageVmManager.SecStorageAllowedInternalDownloadSites.key().equalsIgnoreCase(name) && StringUtils.isNotEmpty(value)) { final String[] cidrs = value.split(","); for (final String cidr : cidrs) { if (!NetUtils.isValidIp4(cidr) && !NetUtils.isValidIp6(cidr) && !NetUtils.getCleanIp4Cidr(cidr).equals(cidr)) { @@ -2702,7 +2704,7 @@ public HostPodVO createPod(final long userId, final String podName, final DataCe _zoneDao.addPrivateIpAddress(zone.getId(), pod.getId(), startIpFinal, endIpFinal, false, null); } - final String[] linkLocalIpRanges = NetUtils.getLinkLocalIPRange(_configDao.getValue(Config.ControlCidr.key())); + final String[] linkLocalIpRanges = NetUtils.getLinkLocalIPRange(_configDao.getValue(ManagementServer.ControlCidr.key())); if (linkLocalIpRanges.length > 1) { _zoneDao.addLinkLocalIpAddress(zone.getId(), pod.getId(), linkLocalIpRanges[0], linkLocalIpRanges[1]); } diff --git a/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index d07641eacc8a..fa1e95ba5557 100644 --- a/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -62,7 +62,6 @@ import com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer; import com.cloud.agent.manager.Commands; import com.cloud.cluster.ClusterManager; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.configuration.ZoneConfig; import com.cloud.dc.DataCenter; @@ -108,12 +107,14 @@ import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; import com.cloud.resource.UnableDeleteHostException; +import com.cloud.server.ManagementServer; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.Storage; import com.cloud.storage.StoragePoolStatus; import com.cloud.storage.VMTemplateVO; import com.cloud.storage.dao.VMTemplateDao; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.utils.DateUtil; @@ -1140,10 +1141,7 @@ public boolean configure(String name, Map params) throws Configu consoleProxyPort = NumbersUtil.parseInt(value, ConsoleProxyManager.DEFAULT_PROXY_VNC_PORT); } - value = configs.get("secondary.storage.vm"); - if (value != null && value.equalsIgnoreCase("true")) { - useStorageVm = true; - } + useStorageVm = SecondaryStorageVmManager.UseSecondaryStorageVm.value(); instance = configs.get("instance.name"); if (instance == null) { @@ -1240,7 +1238,7 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, Depl } if (nic.getTrafficType() == TrafficType.Management) { - String mgmt_cidr = configurationDao.getValue(Config.ManagementNetwork.key()); + String mgmt_cidr = configurationDao.getValue(ManagementServer.ManagementNetwork.key()); if (NetUtils.isValidCidrList(mgmt_cidr)) { logger.debug("Management server cidr list is " + mgmt_cidr); buf.append(" mgmtcidr=").append(mgmt_cidr); diff --git a/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java index 32e904c8de38..8213a2f07fee 100644 --- a/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -75,7 +75,6 @@ import com.cloud.agent.manager.allocator.HostAllocator; import com.cloud.capacity.CapacityManager; import com.cloud.capacity.dao.CapacityDao; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.cpu.CPU; import com.cloud.dc.ClusterDetailsDao; @@ -378,7 +377,7 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile, Deploym } else if (vm.getHypervisorType() == HypervisorType.External) { plannerName = "ExternalServerPlanner"; } else { - plannerName = _configDao.getValue(Config.VmDeploymentPlanner.key()); + plannerName = _configDao.getValue(VmDeploymentPlanner.key()); } } planner = getDeploymentPlannerByName(plannerName); @@ -1280,13 +1279,13 @@ public void onPublishMessage(String senderAddress, String subject, Object obj) { } }); - _vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600); + _vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(UserVmManager.CapacitySkipcountingHours.key()), 3600); - String hostReservationReleasePeriod = _configDao.getValue(Config.HostReservationReleasePeriod.key()); + String hostReservationReleasePeriod = _configDao.getValue(HostReservationReleasePeriod.key()); if (hostReservationReleasePeriod != null) { _hostReservationReleasePeriod = Long.parseLong(hostReservationReleasePeriod); if (_hostReservationReleasePeriod <= 0) - _hostReservationReleasePeriod = Long.parseLong(Config.HostReservationReleasePeriod.getDefaultValue()); + _hostReservationReleasePeriod = Long.parseLong(HostReservationReleasePeriod.defaultValue()); } _timer = new Timer("HostReservationReleaseChecker"); @@ -2087,7 +2086,7 @@ public static String logDeploymentWithoutException(VirtualMachine vm, Deployment } @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {allowRouterOnDisabledResource, allowAdminVmOnDisabledResource}; + return new ConfigKey[] {allowRouterOnDisabledResource, allowAdminVmOnDisabledResource, HostReservationReleasePeriod, VmDeploymentPlanner}; } @Override diff --git a/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java b/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java index 3aab852ba7fc..561a9475910b 100644 --- a/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java +++ b/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java @@ -42,7 +42,6 @@ import com.cloud.capacity.Capacity; import com.cloud.capacity.CapacityManager; import com.cloud.capacity.dao.CapacityDao; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenter; @@ -183,7 +182,7 @@ public List orderClusters(VirtualMachineProfile vmProfile, DeploymentPlan } else { logger.debug("Searching all possible resources under this Zone: {}", dcDao.findById(plan.getDataCenterId())); - boolean applyAllocationAtPods = Boolean.parseBoolean(configDao.getValue(Config.ApplyAllocationAlgorithmToPods.key())); + boolean applyAllocationAtPods = Boolean.parseBoolean(configDao.getValue(ApplyAllocationAlgorithmToPods.key())); if (applyAllocationAtPods) { //start scan at all pods under this zone. clusterList = scanPodsForDestination(vmProfile, plan, avoid); @@ -522,7 +521,7 @@ protected Pair, Map> listPodsByCapacity(long zoneId, in private Pair, Map> getOrderedPodsByCapacity(long zoneId) { double cpuToMemoryWeight = ConfigurationManager.HostCapacityTypeCpuMemoryWeight.value(); short capacityType = getHostCapacityTypeToOrderCluster( - configDao.getValue(Config.HostCapacityTypeToOrderClusters.key()), cpuToMemoryWeight); + configDao.getValue(HostCapacityTypeToOrderClusters.key()), cpuToMemoryWeight); logger.debug("CapacityType: {} is used for Pod ordering", getCapacityTypeName(capacityType)); if (capacityType >= 0) { // for capacityType other than COMBINED @@ -557,7 +556,7 @@ public Map getPodByCombinedCapacities(List capacities, private Pair, Map> getOrderedClustersByCapacity(long id, long vmId, boolean isZone) { double cpuToMemoryWeight = ConfigurationManager.HostCapacityTypeCpuMemoryWeight.value(); short capacityType = getHostCapacityTypeToOrderCluster( - configDao.getValue(Config.HostCapacityTypeToOrderClusters.key()), cpuToMemoryWeight); + configDao.getValue(HostCapacityTypeToOrderClusters.key()), cpuToMemoryWeight); logger.debug("CapacityType: {} is used for Cluster ordering", getCapacityTypeName(capacityType)); if (capacityType >= 0) { // for capacityType other than COMBINED @@ -668,9 +667,9 @@ public boolean canHandle(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeL public boolean configure(String name, Map params) throws ConfigurationException { super.configure(name, params); allocationAlgorithm = VmAllocationAlgorithm.value(); - globalDeploymentPlanner = configDao.getValue(Config.VmDeploymentPlanner.key()); + globalDeploymentPlanner = configDao.getValue(DeploymentPlanningManager.VmDeploymentPlanner.key()); String configValue; - if ((configValue = configDao.getValue(Config.ImplicitHostTags.key())) != null) { + if ((configValue = configDao.getValue(ImplicitHostTags.key())) != null) { implicitHostTags = configValue.trim().split("\\s*,\\s*"); } return true; @@ -694,6 +693,7 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {ClusterCPUCapacityDisableThreshold, ClusterMemoryCapacityDisableThreshold, ClusterThresholdEnabled, VmAllocationAlgorithm}; + return new ConfigKey[] {ClusterCPUCapacityDisableThreshold, ClusterMemoryCapacityDisableThreshold, ClusterThresholdEnabled, VmAllocationAlgorithm, + ApplyAllocationAlgorithmToPods, HostCapacityTypeToOrderClusters, VmUserDispersionWeight, ImplicitHostTags}; } } diff --git a/server/src/main/java/com/cloud/event/ActionEventUtils.java b/server/src/main/java/com/cloud/event/ActionEventUtils.java index ae77446a8561..dfa47f7bedf8 100644 --- a/server/src/main/java/com/cloud/event/ActionEventUtils.java +++ b/server/src/main/java/com/cloud/event/ActionEventUtils.java @@ -40,10 +40,10 @@ import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import com.cloud.configuration.Config; import com.cloud.event.dao.EventDao; import com.cloud.projects.Project; import com.cloud.projects.dao.ProjectDao; +import com.cloud.server.ManagementServer; import com.cloud.server.ManagementService; import com.cloud.user.Account; import com.cloud.user.AccountVO; @@ -208,7 +208,7 @@ private static Event persistActionEvent(Long userId, Long accountId, Long domain private static void publishOnEventBus(Event eventRecord, long userId, long accountId, Long domainId, String eventCategory, String eventType, Event.State state, String description, String resourceUuid, String resourceType) { - String configKey = Config.PublishActionEvent.key(); + String configKey = ManagementServer.PublishActionEvent.key(); String value = s_configDao.getValue(configKey); boolean configValue = Boolean.parseBoolean(value); if(!configValue) diff --git a/server/src/main/java/com/cloud/event/AlertGenerator.java b/server/src/main/java/com/cloud/event/AlertGenerator.java index 601bf5e831a4..a64fb72b9751 100644 --- a/server/src/main/java/com/cloud/event/AlertGenerator.java +++ b/server/src/main/java/com/cloud/event/AlertGenerator.java @@ -32,11 +32,11 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.stereotype.Component; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.HostPodDao; +import com.cloud.server.ManagementServer; import com.cloud.server.ManagementService; import com.cloud.utils.component.ComponentContext; @@ -67,7 +67,7 @@ void init() { } public static void publishAlertOnEventBus(String alertType, long dataCenterId, Long podId, String subject, String body) { - String configKey = Config.PublishAlertEvent.key(); + String configKey = ManagementServer.PublishAlertEvent.key(); String value = s_configDao.getValue(configKey); boolean configValue = Boolean.parseBoolean(value); if (!configValue) { diff --git a/server/src/main/java/com/cloud/ha/HighAvailabilityManagerExtImpl.java b/server/src/main/java/com/cloud/ha/HighAvailabilityManagerExtImpl.java index 6765992ec276..56bcdd338706 100644 --- a/server/src/main/java/com/cloud/ha/HighAvailabilityManagerExtImpl.java +++ b/server/src/main/java/com/cloud/ha/HighAvailabilityManagerExtImpl.java @@ -23,8 +23,8 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.managed.context.ManagedContextRunnable; +import org.apache.cloudstack.usage.UsageService; import com.cloud.alert.AlertManager; import com.cloud.usage.dao.UsageJobDao; @@ -35,9 +35,6 @@ public class HighAvailabilityManagerExtImpl extends HighAvailabilityManagerImpl @Inject UsageJobDao _usageJobDao; - @Inject - ConfigurationDao configDao; - @Override public boolean configure(final String name, final Map xmlParams) throws ConfigurationException { super.configure(name, xmlParams); @@ -48,7 +45,7 @@ public boolean configure(final String name, final Map xmlParams) public boolean start() { super.start(); - boolean enableUsage = new Boolean(configDao.getValue("enable.usage.server")); + boolean enableUsage = UsageService.EnableUsageServer.value(); //By default, usage is enabled for production //Devs might override this value to disable usage in their setup diff --git a/server/src/main/java/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/main/java/com/cloud/ha/HighAvailabilityManagerImpl.java index 755de00dec26..18e95fc79a5f 100644 --- a/server/src/main/java/com/cloud/ha/HighAvailabilityManagerImpl.java +++ b/server/src/main/java/com/cloud/ha/HighAvailabilityManagerImpl.java @@ -1341,7 +1341,7 @@ public String getConfigComponentName() { public ConfigKey[] getConfigKeys() { return new ConfigKey[] {TimeBetweenCleanup, MigrationMaxRetries, TimeToSleep, TimeBetweenFailures, StopRetryInterval, RestartRetryInterval, MigrateRetryInterval, InvestigateRetryInterval, - HAWorkers, ForceHA, VmHaEnabled, VmHaAlertsEnabled, KvmHAFenceHostIfHeartbeatFailsOnStorage}; + HAWorkers, ForceHA, VmHaEnabled, VmHaAlertsEnabled, KvmHAFenceHostIfHeartbeatFailsOnStorage, HaTag}; } @Override diff --git a/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java b/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java index b9fa3f0ebae7..147b4b0fb304 100644 --- a/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java +++ b/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java @@ -43,7 +43,6 @@ import com.cloud.agent.api.ShutdownCommand; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterVO; import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.DiscoveredWithErrorException; @@ -62,6 +61,7 @@ import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; import com.cloud.resource.UnableDeleteHostException; +import com.cloud.server.ManagementServer; import com.cloud.utils.StringUtils; import com.cloud.utils.UuidUtils; import com.cloud.utils.exception.CloudRuntimeException; @@ -311,7 +311,7 @@ private void setupAgentSecurity(final Connection sshConnection, final String age KvmDummyResourceBase kvmResource = new KvmDummyResourceBase(); Map params = new HashMap(); - params.put("router.aggregation.command.each.timeout", _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString())); + params.put("router.aggregation.command.each.timeout", _configDao.getValue(ManagementServer.RouterAggregationCommandEachTimeout.key())); params.put("zone", Long.toString(dcId)); params.put("pod", Long.toString(podId)); @@ -380,17 +380,17 @@ private HostVO waitForHostConnect(long dcId, long podId, long clusterId, String public boolean configure(String name, Map params) throws ConfigurationException { // _setupAgentPath = Script.findScript(getPatchPath(), // "setup_agent.sh"); - _kvmPrivateNic = _configDao.getValue(Config.KvmPrivateNetwork.key()); + _kvmPrivateNic = ManagementServer.KvmPrivateNetwork.value(); if (_kvmPrivateNic == null) { _kvmPrivateNic = "cloudbr0"; } - _kvmPublicNic = _configDao.getValue(Config.KvmPublicNetwork.key()); + _kvmPublicNic = ManagementServer.KvmPublicNetwork.value(); if (_kvmPublicNic == null) { _kvmPublicNic = _kvmPrivateNic; } - _kvmGuestNic = _configDao.getValue(Config.KvmGuestNetwork.key()); + _kvmGuestNic = ManagementServer.KvmGuestNetwork.value(); if (_kvmGuestNic == null) { _kvmGuestNic = _kvmPrivateNic; } diff --git a/server/src/main/java/com/cloud/network/ExternalDeviceUsageManagerImpl.java b/server/src/main/java/com/cloud/network/ExternalDeviceUsageManagerImpl.java index bffc35f72dfa..2616e39cd33c 100644 --- a/server/src/main/java/com/cloud/network/ExternalDeviceUsageManagerImpl.java +++ b/server/src/main/java/com/cloud/network/ExternalDeviceUsageManagerImpl.java @@ -35,7 +35,6 @@ import com.cloud.agent.AgentManager; import com.cloud.agent.api.ExternalNetworkResourceUsageAnswer; import com.cloud.agent.api.ExternalNetworkResourceUsageCommand; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.HostPodDao; @@ -157,7 +156,7 @@ public class ExternalDeviceUsageManagerImpl extends ManagerBase implements Exter @Override public boolean configure(String name, Map params) throws ConfigurationException { - _externalNetworkStatsInterval = NumbersUtil.parseInt(_configDao.getValue(Config.ExternalNetworkStatsInterval.key()), 300); + _externalNetworkStatsInterval = NumbersUtil.parseInt(_configDao.getValue(NetworkModel.ExternalNetworkStatsInterval.key()), 300); if (_externalNetworkStatsInterval > 0) { _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("ExternalNetworkMonitor")); } diff --git a/server/src/main/java/com/cloud/network/ExternalFirewallDeviceManager.java b/server/src/main/java/com/cloud/network/ExternalFirewallDeviceManager.java index dcf33e417a63..19646bf973dd 100644 --- a/server/src/main/java/com/cloud/network/ExternalFirewallDeviceManager.java +++ b/server/src/main/java/com/cloud/network/ExternalFirewallDeviceManager.java @@ -18,6 +18,8 @@ import java.util.List; +import org.apache.cloudstack.framework.config.ConfigKey; + import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.host.Host; @@ -34,6 +36,9 @@ public interface ExternalFirewallDeviceManager extends Manager { + ConfigKey DefaultExternalFirewallCapacity = new ConfigKey<>("Advanced", String.class, "external.firewall.default.capacity", "50", + "default number of networks permitted per external load firewall device", true); + /** * adds a firewall device in to a physical network * @param physicalNetworkId physical network id of the network in to which device to be added @@ -41,7 +46,6 @@ public interface ExternalFirewallDeviceManager extends Manager { * @param username username * @param password password * @param deviceName device name - * @param server resource that will handle the commands specific to this device * @return Host object for the device added */ public ExternalFirewallDeviceVO addExternalFirewall(long physicalNetworkId, String url, String username, String password, String deviceName, ServerResource resource); @@ -64,7 +68,6 @@ public interface ExternalFirewallDeviceManager extends Manager { /** * finds a suitable firewall device which can be used by this network * @param network guest network - * @param dedicatedLb true if a dedicated load balancer is needed for this guest network * @return ExternalLoadBalancerDeviceVO corresponding to the suitable device * @throws InsufficientCapacityException */ diff --git a/server/src/main/java/com/cloud/network/ExternalFirewallDeviceManagerImpl.java b/server/src/main/java/com/cloud/network/ExternalFirewallDeviceManagerImpl.java index ca108749f012..b8dbc5ec8234 100644 --- a/server/src/main/java/com/cloud/network/ExternalFirewallDeviceManagerImpl.java +++ b/server/src/main/java/com/cloud/network/ExternalFirewallDeviceManagerImpl.java @@ -28,6 +28,8 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.response.ExternalFirewallResponse; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice; @@ -46,7 +48,6 @@ import com.cloud.agent.api.to.IpAddressTO; import com.cloud.agent.api.to.PortForwardingRuleTO; import com.cloud.agent.api.to.StaticNatRuleTO; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterVO; import com.cloud.dc.Vlan; @@ -116,7 +117,7 @@ import com.cloud.vm.dao.DomainRouterDao; import com.cloud.vm.dao.NicDao; -public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase implements ExternalFirewallDeviceManager, ResourceStateAdapter { +public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase implements ExternalFirewallDeviceManager, ResourceStateAdapter, Configurable { @Inject HostDao _hostDao; @@ -179,7 +180,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl public boolean configure(String name, Map params) throws ConfigurationException { super.configure(name, params); _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this); - _defaultFwCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalFirewallCapacity.key()), 50); + _defaultFwCapacity = NumbersUtil.parseLong(DefaultExternalFirewallCapacity.value(), 50); return true; } @@ -776,8 +777,7 @@ public int getVlanOffset(long physicalNetworkId, int vlanTag) { public int getGloballyConfiguredCidrSize() { try { - String globalVlanBits = _configDao.getValue(Config.GuestVlanBits.key()); - return 8 + Integer.parseInt(globalVlanBits); + return 8 + NetworkService.GuestVlanBits.value(); } catch (Exception e) { throw new CloudRuntimeException("Failed to read the globally configured VLAN bits size."); } @@ -835,4 +835,14 @@ public boolean applyPortForwardingRules(Network network, List[] getConfigKeys() { + return new ConfigKey[] {DefaultExternalFirewallCapacity}; + } } diff --git a/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManager.java b/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManager.java index 850d0d7cb036..aa1e39c58551 100644 --- a/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManager.java +++ b/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManager.java @@ -18,6 +18,8 @@ import java.util.List; +import org.apache.cloudstack.framework.config.ConfigKey; + import com.cloud.agent.api.to.LoadBalancerTO; import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; @@ -36,6 +38,9 @@ public interface ExternalLoadBalancerDeviceManager extends Manager { public static final int DEFAULT_LOAD_BALANCER_CAPACITY = 50; + ConfigKey DefaultExternalLoadBalancerCapacity = new ConfigKey<>("Advanced", String.class, "external.lb.default.capacity", "50", + "default number of networks permitted per external load balancer device", true); + /** * adds a load balancer device in to a physical network * @param physicalNetworkId physical network id of the network in to which device to be added diff --git a/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java b/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java index f5031dc56675..b8a2bec53a26 100644 --- a/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java +++ b/server/src/main/java/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java @@ -31,6 +31,8 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice; @@ -47,7 +49,6 @@ import com.cloud.agent.api.routing.NetworkElementCommand; import com.cloud.agent.api.to.IpAddressTO; import com.cloud.agent.api.to.LoadBalancerTO; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterIpAddressVO; import com.cloud.dc.DataCenterVO; @@ -138,7 +139,7 @@ import com.cloud.vm.dao.NicDao; import com.cloud.vm.dao.VMInstanceDao; -public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase implements ExternalLoadBalancerDeviceManager, ResourceStateAdapter { +public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase implements ExternalLoadBalancerDeviceManager, ResourceStateAdapter, Configurable { @Inject NetworkExternalLoadBalancerDao _networkExternalLBDao; @@ -1141,7 +1142,7 @@ public boolean manageGuestNetworkWithExternalLoadBalancer(boolean add, Network g @Override public boolean configure(String name, Map params) throws ConfigurationException { super.configure(name, params); - _defaultLbCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalLoadBalancerCapacity.key()), 50); + _defaultLbCapacity = NumbersUtil.parseLong(_configDao.getValue(DefaultExternalLoadBalancerCapacity.key()), 50); _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this); return true; } @@ -1303,4 +1304,14 @@ private NicVO getPlaceholderNic(Network network) { return null; } + @Override + public String getConfigComponentName() { + return ExternalLoadBalancerDeviceManager.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {DefaultExternalLoadBalancerCapacity}; + } + } diff --git a/server/src/main/java/com/cloud/network/Ipv6AddressManagerImpl.java b/server/src/main/java/com/cloud/network/Ipv6AddressManagerImpl.java index d096b09ec0d4..f4da58c525ff 100644 --- a/server/src/main/java/com/cloud/network/Ipv6AddressManagerImpl.java +++ b/server/src/main/java/com/cloud/network/Ipv6AddressManagerImpl.java @@ -24,7 +24,6 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenter; import com.cloud.dc.Vlan; import com.cloud.dc.dao.DataCenterDao; @@ -78,7 +77,7 @@ public class Ipv6AddressManagerImpl extends ManagerBase implements Ipv6AddressMa public boolean configure(String name, Map params) throws ConfigurationException { _name = name; Map configs = _configDao.getConfiguration(params); - _ipv6RetryMax = NumbersUtil.parseInt(configs.get(Config.NetworkIPv6SearchRetryMax.key()), 10000); + _ipv6RetryMax = NumbersUtil.parseInt(configs.get(NetworkModel.NetworkIPv6SearchRetryMax.key()), 10000); return true; } diff --git a/server/src/main/java/com/cloud/network/NetworkModelImpl.java b/server/src/main/java/com/cloud/network/NetworkModelImpl.java index f47046cdc434..f14df9bab64c 100644 --- a/server/src/main/java/com/cloud/network/NetworkModelImpl.java +++ b/server/src/main/java/com/cloud/network/NetworkModelImpl.java @@ -48,7 +48,6 @@ import org.apache.commons.lang3.StringUtils; import com.cloud.api.ApiDBUtils; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterVO; @@ -1836,8 +1835,7 @@ public void canProviderSupportServices(Map> providersMap) @Override public boolean canAddDefaultSecurityGroup() { - String defaultAdding = _configDao.getValue(Config.SecurityGroupDefaultAdding.key()); - return (defaultAdding != null && defaultAdding.equalsIgnoreCase("true")); + return SecurityGroupDefaultAdding.value(); } @Override @@ -2538,8 +2536,8 @@ private List getNetworkProviders(long networkId) { @Override public boolean configure(String name, Map params) throws ConfigurationException { _configs = _configDao.getConfiguration("Network", params); - _allowSubdomainNetworkAccess = Boolean.valueOf(_configs.get(Config.SubDomainNetworkAccess.key())); - _executeInSequenceNtwkElmtCmd = Boolean.valueOf(_configs.get(Config.ExecuteInSequenceNetworkElementCommands.key())); + _allowSubdomainNetworkAccess = Boolean.valueOf(_configs.get(SubDomainNetworkAccess.key())); + _executeInSequenceNtwkElmtCmd = Boolean.valueOf(_configs.get(ExecuteInSequenceNetworkElementCommands.key())); NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOffering.SystemPublicNetwork, TrafficType.Public, true); publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering); @@ -2942,7 +2940,7 @@ public List generateVmData(String userData, String userDataDetails, St vmData.add(new String[]{METATDATA_DIR, PUBLIC_KEYS_FILE, publicKey}); - String cloudIdentifier = _configDao.getValue("cloud.identifier"); + String cloudIdentifier = CloudIdentifier.value(); if (cloudIdentifier == null) { cloudIdentifier = ""; } else { @@ -3010,7 +3008,8 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {MACIdentifier, AdminIsAllowedToDeployAnywhere}; + return new ConfigKey[] {MACIdentifier, AdminIsAllowedToDeployAnywhere, SecurityGroupDefaultAdding, CloudIdentifier, + SubDomainNetworkAccess, ExecuteInSequenceNetworkElementCommands, ExternalNetworkStatsInterval, NetworkIPv6SearchRetryMax}; } @Override diff --git a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java index 2853fa96330d..07d9a130e81c 100644 --- a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java @@ -100,7 +100,6 @@ import com.cloud.api.query.dao.DomainRouterJoinDao; import com.cloud.api.query.vo.DomainRouterJoinVO; import com.cloud.bgp.BGPService; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.Resource; import com.cloud.dc.AccountVlanMapVO; @@ -836,9 +835,9 @@ public boolean releasePortableIpAddress(long ipAddressId) { public boolean configure(final String name, final Map params) throws ConfigurationException { _configs = _configDao.getConfiguration("Network", params); - _cidrLimit = NumbersUtil.parseInt(_configs.get(Config.NetworkGuestCidrLimit.key()), 22); + _cidrLimit = NumbersUtil.parseInt(_configs.get(NetworkGuestCidrLimit.key()), 22); - _allowSubdomainNetworkAccess = Boolean.valueOf(_configs.get(Config.SubDomainNetworkAccess.key())); + _allowSubdomainNetworkAccess = Boolean.valueOf(_configs.get(NetworkModel.SubDomainNetworkAccess.key())); logger.info("Network Service is configured."); @@ -923,7 +922,7 @@ public NicSecondaryIp allocateSecondaryGuestIP(final long nicId, IpAddresses req throw new InvalidParameterValueException("Invalid Network id is given"); } - int maxAllowedIpsPerNic = NumbersUtil.parseInt(_configDao.getValue(Config.MaxNumberOfSecondaryIPsPerNIC.key()), Integer.parseInt(Config.MaxNumberOfSecondaryIPsPerNIC.getDefaultValue())); + int maxAllowedIpsPerNic = MaxNumberOfSecondaryIPsPerNIC.value(); Long nicWiseIpCount = _nicSecondaryIpDao.countByNicId(nicId); if (nicWiseIpCount.intValue() >= maxAllowedIpsPerNic) { logger.error("Maximum Number of IPs \"vm.network.nic.max.secondary.ipaddresses = \"{} per NIC has been crossed for the NIC {}.", maxAllowedIpsPerNic, nicVO); @@ -1367,8 +1366,7 @@ private void checkSharedNetworkCidrOverlap(Long zoneId, long physicalNetworkId, Integer highestVlanTag = vlanRange.second(); for (int vlan = lowestVlanTag; vlan <= highestVlanTag; ++vlan) { int offset = vlan - lowestVlanTag; - String globalVlanBits = _configDao.getValue(Config.GuestVlanBits.key()); - int cidrSize = 8 + Integer.parseInt(globalVlanBits); + int cidrSize = 8 + GuestVlanBits.value(); String guestNetworkCidr = zone.getGuestNetworkCidr(); String[] cidrTuple = guestNetworkCidr.split("\\/"); long newCidrAddress = (NetUtils.ip2Long(cidrTuple[0]) & 0xff000000) | (offset << (32 - cidrSize)); @@ -5505,16 +5503,16 @@ private String getDefaultXenNetworkLabel(TrafficType trafficType) { String xenLabel = null; switch (trafficType) { case Public: - xenLabel = _configDao.getValue(Config.XenServerPublicNetwork.key()); + xenLabel = XenServerPublicNetwork.value(); break; case Guest: - xenLabel = _configDao.getValue(Config.XenServerGuestNetwork.key()); + xenLabel = XenServerGuestNetwork.value(); break; case Storage: - xenLabel = _configDao.getValue(Config.XenServerStorageNetwork1.key()); + xenLabel = XenServerStorageNetwork1.value(); break; case Management: - xenLabel = _configDao.getValue(Config.XenServerPrivateNetwork.key()); + xenLabel = XenServerPrivateNetwork.value(); break; case Control: xenLabel = "cloud_link_local_network"; @@ -6313,7 +6311,9 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {AllowDuplicateNetworkName, AllowEmptyStartEndIpAddress, AllowUsersToMakeNetworksRedundant, VRPrivateInterfaceMtu, VRPublicInterfaceMtu, AllowUsersToSpecifyVRMtu}; + return new ConfigKey[] {AllowDuplicateNetworkName, AllowEmptyStartEndIpAddress, AllowUsersToMakeNetworksRedundant, VRPrivateInterfaceMtu, VRPublicInterfaceMtu, AllowUsersToSpecifyVRMtu, + GuestVlanBits, MaxNumberOfSecondaryIPsPerNIC, XenServerPublicNetwork, XenServerGuestNetwork, XenServerStorageNetwork1, XenServerStorageNetwork2, XenServerPrivateNetwork, + NetworkGuestCidrLimit}; } public boolean isDefaultAcl(Long aclId) { diff --git a/server/src/main/java/com/cloud/network/NetworkUsageManagerImpl.java b/server/src/main/java/com/cloud/network/NetworkUsageManagerImpl.java index 0aee5f234969..81da8cf1da4c 100644 --- a/server/src/main/java/com/cloud/network/NetworkUsageManagerImpl.java +++ b/server/src/main/java/com/cloud/network/NetworkUsageManagerImpl.java @@ -33,6 +33,8 @@ import org.apache.cloudstack.api.command.admin.usage.AddTrafficMonitorCmd; import org.apache.cloudstack.api.command.admin.usage.DeleteTrafficMonitorCmd; import org.apache.cloudstack.api.command.admin.usage.ListTrafficMonitorsCmd; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import com.cloud.agent.AgentManager; @@ -47,7 +49,6 @@ import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupTrafficMonitorCommand; import com.cloud.agent.manager.Commands; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.DataCenterDao; import com.cloud.event.EventTypes; @@ -76,7 +77,6 @@ import com.cloud.user.AccountManager; import com.cloud.user.UserStatisticsVO; import com.cloud.user.dao.UserStatisticsDao; -import com.cloud.utils.NumbersUtil; import com.cloud.utils.component.ManagerBase; import com.cloud.utils.db.DB; import com.cloud.utils.db.GlobalLock; @@ -91,7 +91,7 @@ import com.cloud.utils.net.MacAddress; @Component -public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsageService, NetworkUsageManager, ResourceStateAdapter { +public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsageService, NetworkUsageManager, ResourceStateAdapter, Configurable { public enum NetworkUsageResourceName { TrafficSentinel; } @@ -220,9 +220,9 @@ public boolean configure(String name, Map params) throws Configu AllocatedIpSearch.join("network", networkJoin, AllocatedIpSearch.entity().getSourceNetworkId(), networkJoin.entity().getId(), JoinBuilder.JoinType.INNER); AllocatedIpSearch.done(); - _networkStatsInterval = NumbersUtil.parseInt(_configDao.getValue(Config.DirectNetworkStatsInterval.key()), 86400); - _TSinclZones = _configDao.getValue(Config.TrafficSentinelIncludeZones.key()); - _TSexclZones = _configDao.getValue(Config.TrafficSentinelExcludeZones.key()); + _networkStatsInterval = DirectNetworkStatsInterval.value(); + _TSinclZones = TrafficSentinelIncludeZones.value(); + _TSexclZones = TrafficSentinelExcludeZones.value(); _agentMgr.registerForHostEvents(new DirectNetworkStatsListener(_networkStatsInterval), true, false, false); _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this); return true; @@ -562,4 +562,14 @@ public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForc } + @Override + public String getConfigComponentName() { + return NetworkUsageService.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {DirectNetworkStatsInterval, TrafficSentinelIncludeZones, TrafficSentinelExcludeZones}; + } + } diff --git a/server/src/main/java/com/cloud/network/firewall/FirewallManagerImpl.java b/server/src/main/java/com/cloud/network/firewall/FirewallManagerImpl.java index dc6fc12a6110..ab3a35f0eba0 100644 --- a/server/src/main/java/com/cloud/network/firewall/FirewallManagerImpl.java +++ b/server/src/main/java/com/cloud/network/firewall/FirewallManagerImpl.java @@ -46,7 +46,6 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.network.RoutedIpv4Manager; -import com.cloud.configuration.Config; import com.cloud.domain.dao.DomainDao; import com.cloud.event.ActionEvent; import com.cloud.event.EventTypes; @@ -87,6 +86,7 @@ import com.cloud.network.rules.dao.PortForwardingRulesDao; import com.cloud.network.vpc.VpcManager; import com.cloud.projects.Project.ListProjectResourcesCriteria; +import com.cloud.server.ManagementServer; import com.cloud.server.ResourceTag.ResourceObjectType; import com.cloud.tags.ResourceTagVO; import com.cloud.tags.dao.ResourceTagDao; @@ -175,7 +175,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService, @Override public boolean configure(String name, Map params) throws ConfigurationException { _name = name; - String elbEnabledString = _configDao.getValue(Config.ElasticLoadBalancerEnabled.key()); + String elbEnabledString = _configDao.getValue(ManagementServer.ElasticLoadBalancerEnabled.key()); _elbEnabled = Boolean.parseBoolean(elbEnabledString); if (_ipAddrMgr.RulesContinueOnError.value() != null) { rulesContinueOnErrFlag = _ipAddrMgr.RulesContinueOnError.value(); diff --git a/server/src/main/java/com/cloud/network/guru/ControlNetworkGuru.java b/server/src/main/java/com/cloud/network/guru/ControlNetworkGuru.java index 9cec05446ac6..21b67a47fdfb 100644 --- a/server/src/main/java/com/cloud/network/guru/ControlNetworkGuru.java +++ b/server/src/main/java/com/cloud/network/guru/ControlNetworkGuru.java @@ -24,7 +24,6 @@ import com.cloud.network.router.VirtualNetworkApplianceManager; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter.NetworkType; import com.cloud.dc.DataCenterVO; @@ -43,6 +42,7 @@ import com.cloud.network.Networks.TrafficType; import com.cloud.network.dao.NetworkVO; import com.cloud.offering.NetworkOffering; +import com.cloud.server.ManagementServer; import com.cloud.user.Account; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.NetUtils; @@ -225,12 +225,12 @@ public boolean configure(String name, Map params) throws Configu Map dbParams = _configDao.getConfiguration(params); - _cidr = dbParams.get(Config.ControlCidr.toString()); + _cidr = dbParams.get(ManagementServer.ControlCidr.key()); if (_cidr == null) { _cidr = NetUtils.getLinkLocalCIDR(); } - _gateway = dbParams.get(Config.ControlGateway.toString()); + _gateway = dbParams.get(ManagementServer.ControlGateway.key()); if (_gateway == null) { _gateway = NetUtils.getLinkLocalGateway(); } diff --git a/server/src/main/java/com/cloud/network/guru/GuestNetworkGuru.java b/server/src/main/java/com/cloud/network/guru/GuestNetworkGuru.java index 39b9a32e48e3..9c3de03446dc 100644 --- a/server/src/main/java/com/cloud/network/guru/GuestNetworkGuru.java +++ b/server/src/main/java/com/cloud/network/guru/GuestNetworkGuru.java @@ -36,7 +36,6 @@ import org.apache.cloudstack.network.RoutedIpv4Manager; import org.apache.commons.lang3.StringUtils; -import com.cloud.configuration.Config; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter.NetworkType; import com.cloud.dc.dao.DataCenterDao; @@ -58,6 +57,7 @@ import com.cloud.network.Network.State; import com.cloud.network.NetworkModel; import com.cloud.network.NetworkProfile; +import com.cloud.network.NetworkService; import com.cloud.network.Networks; import com.cloud.network.Networks.AddressFormat; import com.cloud.network.Networks.BroadcastDomainType; @@ -353,8 +353,7 @@ public int getVlanOffset(final long physicalNetworkId, final int vlanTag) { public int getGloballyConfiguredCidrSize() { try { - final String globalVlanBits = _configDao.getValue(Config.GuestVlanBits.key()); - return 8 + Integer.parseInt(globalVlanBits); + return 8 + NetworkService.GuestVlanBits.value(); } catch (final Exception e) { throw new CloudRuntimeException("Failed to read the globally configured VLAN bits size."); } diff --git a/server/src/main/java/com/cloud/network/lb/LBHealthCheckManager.java b/server/src/main/java/com/cloud/network/lb/LBHealthCheckManager.java index 315184d580dc..1032701375cc 100644 --- a/server/src/main/java/com/cloud/network/lb/LBHealthCheckManager.java +++ b/server/src/main/java/com/cloud/network/lb/LBHealthCheckManager.java @@ -16,10 +16,15 @@ // under the License. package com.cloud.network.lb; +import org.apache.cloudstack.framework.config.ConfigKey; + import com.cloud.network.rules.LoadBalancerContainer.Scheme; public interface LBHealthCheckManager { + ConfigKey LBHealthCheck = new ConfigKey<>("Advanced", String.class, "healthcheck.update.interval", "600", + "Time Interval to fetch the LB health check states (in sec)", true); + void updateLBHealthCheck(Scheme scheme); } diff --git a/server/src/main/java/com/cloud/network/lb/LBHealthCheckManagerImpl.java b/server/src/main/java/com/cloud/network/lb/LBHealthCheckManagerImpl.java index b9d687e66b41..da03fd5e18d4 100644 --- a/server/src/main/java/com/cloud/network/lb/LBHealthCheckManagerImpl.java +++ b/server/src/main/java/com/cloud/network/lb/LBHealthCheckManagerImpl.java @@ -28,10 +28,11 @@ import org.springframework.stereotype.Component; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.managed.context.ManagedContextRunnable; -import com.cloud.configuration.Config; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.rules.LoadBalancerContainer.Scheme; import com.cloud.utils.NumbersUtil; @@ -40,7 +41,7 @@ import com.cloud.utils.concurrency.NamedThreadFactory; @Component -public class LBHealthCheckManagerImpl extends ManagerBase implements LBHealthCheckManager, Manager { +public class LBHealthCheckManagerImpl extends ManagerBase implements LBHealthCheckManager, Manager, Configurable { @Inject ConfigurationDao _configDao; @@ -60,7 +61,7 @@ public boolean configure(String name, Map params) throws Configu logger.info(format("Configuring LBHealthCheck Manager %1$s", name)); } this.name = name; - _interval = NumbersUtil.parseLong(_configs.get(Config.LBHealthCheck.key()), 600); + _interval = NumbersUtil.parseLong(_configs.get(LBHealthCheck.key()), 600); _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("LBHealthCheck")); return true; } @@ -106,4 +107,14 @@ public void updateLBHealthCheck(Scheme scheme) { logger.debug("LB HealthCheck Manager is running and getting the updates from LB providers and updating service status"); } + @Override + public String getConfigComponentName() { + return LBHealthCheckManager.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {LBHealthCheck}; + } + } diff --git a/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java b/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java index 58b2892e09c3..58bffd83809a 100644 --- a/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java +++ b/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java @@ -75,7 +75,6 @@ import com.cloud.agent.api.to.PortForwardingRuleTO; import com.cloud.agent.api.to.StaticNatRuleTO; import com.cloud.agent.manager.Commands; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.ASNumberVO; import com.cloud.dc.DataCenter; @@ -136,6 +135,7 @@ import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.offerings.dao.NetworkOfferingDetailsDao; +import com.cloud.server.ManagementServer; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.user.Account; import com.cloud.uservm.UserVm; @@ -403,10 +403,10 @@ public void createApplyLoadBalancingRulesCommands(final List router.getPrivateIpAddress(), _itMgr.toNicTO(nicProfile, router.getHypervisorType()), router.getVpcId(), maxconn, offering.isKeepAliveEnabled(), NetworkOrchestrationService.NETWORK_LB_HAPROXY_IDLE_TIMEOUT.value()); - cmd.lbStatsVisibility = _configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key()); - cmd.lbStatsUri = _configDao.getValue(Config.NetworkLBHaproxyStatsUri.key()); - cmd.lbStatsAuth = _configDao.getValue(Config.NetworkLBHaproxyStatsAuth.key()); - cmd.lbStatsPort = _configDao.getValue(Config.NetworkLBHaproxyStatsPort.key()); + cmd.lbStatsVisibility = NetworkOrchestrationService.NetworkLBHaproxyStatsVisbility.value(); + cmd.lbStatsUri = NetworkOrchestrationService.NetworkLBHaproxyStatsUri.value(); + cmd.lbStatsAuth = NetworkOrchestrationService.NetworkLBHaproxyStatsAuth.value(); + cmd.lbStatsPort = NetworkOrchestrationService.NetworkLBHaproxyStatsPort.value(); cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId())); cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(guestNetworkId, router.getId())); @@ -806,7 +806,7 @@ public void createVmDataCommandForVMs(final DomainRouterVO router, final Command public void createDhcpEntryCommandsForVMs(final DomainRouterVO router, final Commands cmds, final long guestNetworkId) { final List vms = _userVmDao.listByNetworkIdAndStates(guestNetworkId, VirtualMachine.State.Running, VirtualMachine.State.Migrating, VirtualMachine.State.Stopping); final DataCenterVO dc = _dcDao.findById(router.getDataCenterId()); - String dnsBasicZoneUpdates = _configDao.getValue(Config.DnsBasicZoneUpdates.key()); + String dnsBasicZoneUpdates = _configDao.getValue(VirtualNetworkApplianceManager.DnsBasicZoneUpdates.key()); for (final UserVmVO vm : vms) { if (dc.getNetworkType() == NetworkType.Basic && router.getPodIdToDeployIn().longValue() != vm.getPodIdToDeployIn().longValue() && dnsBasicZoneUpdates.equalsIgnoreCase("pod")) { @@ -1065,9 +1065,9 @@ public int compare(final PublicIpAddress o1, final PublicIpAddress o2) { setIpAddressNetworkParams(ip, network, router); if (router.getHypervisorType() == Hypervisor.HypervisorType.VMware) { Map details = new HashMap<>(); - String defaultSystemVmNicAdapterType = _configDao.getValue(Config.VmwareSystemVmNicDeviceType.key()); + String defaultSystemVmNicAdapterType = _configDao.getValue(ManagementServer.VmwareSystemVmNicDeviceType.key()); if (defaultSystemVmNicAdapterType == null) { - defaultSystemVmNicAdapterType = Config.VmwareSystemVmNicDeviceType.getDefaultValue(); + defaultSystemVmNicAdapterType = ManagementServer.VmwareSystemVmNicDeviceType.defaultValue(); } details.put(VmDetailConstants.NIC_ADAPTER, defaultSystemVmNicAdapterType); ip.setDetails(details); @@ -1338,7 +1338,7 @@ private VmDataCommand generateVmDataCommand(final VirtualRouter router, final St } cmd.addVmData("metadata", "public-keys", publicKey); - String cloudIdentifier = _configDao.getValue("cloud.identifier"); + String cloudIdentifier = NetworkModel.CloudIdentifier.value(); if (cloudIdentifier == null) { cloudIdentifier = ""; } else { diff --git a/server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java b/server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java index 56534a8ee7df..6f48284d3de7 100644 --- a/server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java +++ b/server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java @@ -48,7 +48,6 @@ import com.cloud.agent.manager.Commands; import com.cloud.alert.AlertManager; import com.cloud.capacity.CapacityManager; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenter; import com.cloud.dc.Pod; @@ -950,7 +949,7 @@ public static void setVMInstanceName(final String vmInstanceName) { @Override public boolean validateHAProxyLBRule(final LoadBalancingRule rule) { final String timeEndChar = "dhms"; - int haproxy_stats_port = Integer.parseInt(_configDao.getValue(Config.NetworkLBHaproxyStatsPort.key())); + int haproxy_stats_port = Integer.parseInt(NetworkOrchestrationService.NetworkLBHaproxyStatsPort.value()); if (rule.getSourcePortStart() == haproxy_stats_port) { if (logger.isDebugEnabled()) { logger.debug("Can't create LB on port "+ haproxy_stats_port +", haproxy is listening for LB stats on this port"); diff --git a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManager.java b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManager.java index 8ef77d3fb32f..ecd924c8347a 100644 --- a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManager.java +++ b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManager.java @@ -64,6 +64,9 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA ConfigKey RouterTemplateOvm3 = new ConfigKey<>(String.class, RouterTemplateOvm3CK, "Advanced", "SystemVM Template (Ovm3)", "Name of the default router template on Ovm3.", true, ConfigKey.Scope.Zone, null); + ConfigKey RouterRamSize = new ConfigKey<>("Hidden", Integer.class, "router.ram.size", "512", + "Default RAM for router VM (in MB).", true); + ConfigKey VirtualRouterUserData = new ConfigKey<>(String.class, "virtual.router.userdata", ConfigKey.CATEGORY_ADVANCED, "", "UUID for user data of VR, VPC VR, internal LB, and elastic LB. This works only when systemvm.userdata.enabled is set to true", @@ -73,6 +76,12 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA ConfigKey SetServiceMonitor = new ConfigKey<>(Boolean.class, SetServiceMonitorCK, "Advanced", "true", "service monitoring in router enable/disable option, default true", true, ConfigKey.Scope.Zone, null); + ConfigKey NetworkRouterRpFilter = new ConfigKey<>("Network", Boolean.class, "network.disable.rpfilter", "true", + "disable rp_filter on Domain Router VM public interfaces.", true); + + ConfigKey EnableServiceMonitoring = new ConfigKey<>("Network", Boolean.class, "network.router.enableserviceMonitoring", "false", + "service monitoring in router enable/disable option, default false", true); + ConfigKey RouterAlertsCheckInterval = new ConfigKey<>(Integer.class, RouterAlertsCheckIntervalCK, "Advanced", "1800", "Interval (in seconds) to check for alerts in Virtual Router.", false, ConfigKey.Scope.Global, null); ConfigKey RouterVersionCheckEnabled = new ConfigKey<>("Advanced", Boolean.class, "router.version.check", "true", @@ -131,12 +140,40 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA ConfigKey RemoveControlIpOnStop = new ConfigKey<>(Boolean.class, RemoveControlIpOnStopCK, "Advanced", "true", "on stopping routers and system VMs the IP will be released to preserve IPv4 space.", true, ConfigKey.Scope.Zone, null); + ConfigKey RouterStatsInterval = new ConfigKey<>("Advanced", Integer.class, "router.stats.interval", "300", + "Interval (in seconds) to report router statistics.", true); + + ConfigKey RouterCheckInterval = new ConfigKey<>("Advanced", Integer.class, "router.check.interval", "30", + "Interval (in seconds) to report redundant router status.", true); + + ConfigKey RouterCheckPoolSize = new ConfigKey<>("Advanced", Integer.class, "router.check.poolsize", "10", + "Numbers of threads using to check redundant router status.", true); + + ConfigKey RouterExtraPublicNics = new ConfigKey<>("Advanced", Integer.class, "router.extra.public.nics", "2", + "specify extra public nics used for virtual router(up to 5)", true); + + ConfigKey DnsBasicZoneUpdates = new ConfigKey<>("Advanced", String.class, "network.dns.basiczone.updates", "all", + "This parameter can take 2 values: all (default) and pod. It defines if DHCP/DNS requests have to be send to all dhcp servers in cloudstack, or only to the one in the same pod", + true, ConfigKey.Kind.Select, "all,pod"); + + ConfigKey RedundantRouterVrrpInterval = new ConfigKey<>("Advanced", Integer.class, "router.redundant.vrrp.interval", "1", + "seconds between VRRP broadcast. It would 3 times broadcast fail to trigger fail-over mechanism of redundant router", true); + + ConfigKey DirectAttachNetworkEnabled = new ConfigKey<>("Advanced", Boolean.class, "direct.attach.network.externalIpAllocator.enabled", "false", + "Direct-attach VMs using external DHCP server", true); + + ConfigKey DirectAttachNetworkExternalAPIURL = new ConfigKey<>("Advanced", String.class, "direct.attach.network.externalIpAllocator.url", null, + "Direct-attach VMs using external DHCP server (API url)", true); + int DEFAULT_ROUTER_VM_RAMSIZE = 256; // 256M int DEFAULT_ROUTER_CPU_MHZ = 500; // 500 MHz boolean USE_POD_VLAN = false; int DEFAULT_PRIORITY = 100; int DEFAULT_DELTA = 2; + ConfigKey RouterCpuMHz = new ConfigKey<>("Advanced", Integer.class, "router.cpu.mhz", String.valueOf(DEFAULT_ROUTER_CPU_MHZ), + "Default CPU speed (MHz) for router VM.", true); + boolean startRemoteAccessVpn(Network network, RemoteAccessVpn vpn, List routers) throws ResourceUnavailableException; diff --git a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index a166e894be1b..1f25d801f9f4 100644 --- a/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -74,6 +74,7 @@ import org.apache.cloudstack.network.RoutedIpv4Manager; import org.apache.cloudstack.network.topology.NetworkTopology; import org.apache.cloudstack.network.topology.NetworkTopologyContext; +import org.apache.cloudstack.usage.UsageService; import org.apache.cloudstack.userdata.UserDataManager; import org.apache.cloudstack.utils.CloudStackVersion; import org.apache.cloudstack.utils.identity.ManagementServerNode; @@ -545,10 +546,10 @@ public boolean configure(final String name, final Map params) th final Map configs = _configDao.getConfiguration("AgentManager", params); - int routerRamSize = NumbersUtil.parseInt(configs.get("router.ram.size"), DEFAULT_ROUTER_VM_RAMSIZE); + int routerRamSize = RouterRamSize.value(); int routerCpuMHz = NumbersUtil.parseInt(configs.get("router.cpu.mhz"), DEFAULT_ROUTER_CPU_MHZ); - _routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2); + _routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(RouterExtraPublicNics.key()), 2); String value = configs.get("router.stats.interval"); _routerStatsInterval = NumbersUtil.parseInt(value, 300); @@ -576,12 +577,9 @@ public boolean configure(final String name, final Map params) th NetworkHelperImpl.setVMInstanceName(instance); - final String rpValue = configs.get("network.disable.rpfilter"); - if (rpValue != null && rpValue.equalsIgnoreCase("true")) { - _disableRpFilter = true; - } + _disableRpFilter = NetworkRouterRpFilter.value(); - _dnsBasicZoneUpdates = String.valueOf(_configDao.getValue(Config.DnsBasicZoneUpdates.key())); + _dnsBasicZoneUpdates = String.valueOf(_configDao.getValue(DnsBasicZoneUpdates.key())); logger.info("Router configurations: " + "ramsize=" + routerRamSize); @@ -599,9 +597,8 @@ public boolean configure(final String name, final Map params) th NetworkHelperImpl.setSystemAccount(_accountMgr.getSystemAccount()); - final String aggregationRange = configs.get("usage.stats.job.aggregation.range"); - _usageAggregationRange = NumbersUtil.parseInt(aggregationRange, 1440); - _usageTimeZone = configs.get("usage.aggregation.timezone"); + _usageAggregationRange = UsageService.UsageStatsJobAggregationRange.value(); + _usageTimeZone = UsageService.UsageAggregationTimezone.value(); if (_usageTimeZone == null) { _usageTimeZone = "GMT"; } @@ -1968,7 +1965,7 @@ public boolean finalizeVirtualMachineProfile(final VirtualMachineProfile profile // always add management explicit route, for basic // networking setup, DomR may have two interfaces while both // are on the same subnet - String _mgmtCidr = _configDao.getValue(Config.ManagementNetwork.key()); + String _mgmtCidr = _configDao.getValue(ManagementServer.ManagementNetwork.key()); if (NetUtils.isValidIp4Cidr(_mgmtCidr)) { buf.append(" mgmtcidr=").append(_mgmtCidr); buf.append(" localgw=").append(dest.getPod().getGateway()); @@ -2002,8 +1999,7 @@ public boolean finalizeVirtualMachineProfile(final VirtualMachineProfile profile throw new CloudRuntimeException("Didn't start a control port"); } - final String rpValue = _configDao.getValue(Config.NetworkRouterRpFilter.key()); - _disableRpFilter = rpValue != null && rpValue.equalsIgnoreCase("true"); + _disableRpFilter = NetworkRouterRpFilter.value(); String rpFilter = " "; String type; @@ -2183,7 +2179,7 @@ protected StringBuilder createGuestBootLoadArgs(final NicProfile guestNic, final buf.append(" guestbrd=").append(brd); buf.append(" guestcidrsize=").append(NetUtils.getCidrSize(guestNic.getIPv4Netmask())); - final int advertInt = NumbersUtil.parseInt(_configDao.getValue(Config.RedundantRouterVrrpInterval.key()), 1); + final int advertInt = NumbersUtil.parseInt(_configDao.getValue(RedundantRouterVrrpInterval.key()), 1); buf.append(" advert_int=").append(advertInt); } @@ -2226,7 +2222,7 @@ protected StringBuilder createRedundantRouterArgs(final NicProfile nic, final Do if (isRedundant) { buf.append(" redundant_router=1"); - final int advertInt = NumbersUtil.parseInt(_configDao.getValue(Config.RedundantRouterVrrpInterval.key()), 1); + final int advertInt = NumbersUtil.parseInt(_configDao.getValue(RedundantRouterVrrpInterval.key()), 1); buf.append(" advert_int=").append(advertInt); final Long vpcId = router.getVpcId(); @@ -2359,8 +2355,7 @@ protected void finalizeMonitorService(final Commands cmds, final VirtualMachineP return; } - final String serviceMonitoringSet = _configDao.getValue(Config.EnableServiceMonitoring.key()); - final boolean isMonitoringServicesEnabled = serviceMonitoringSet != null && serviceMonitoringSet.equalsIgnoreCase("true"); + final boolean isMonitoringServicesEnabled = EnableServiceMonitoring.value(); final NetworkVO network = _networkDao.findById(networkId); logger.debug("Creating monitoring services on " + router + " start..."); @@ -3384,7 +3379,19 @@ public ConfigKey[] getConfigKeys() { ExposeDnsAndBootpServer, RouterLogrotateFrequency, RemoveControlIpOnStop, - VirtualRouterUserData + VirtualRouterUserData, + NetworkRouterRpFilter, + EnableServiceMonitoring, + RouterRamSize, + RouterCpuMHz, + RouterStatsInterval, + RouterCheckInterval, + RouterCheckPoolSize, + RouterExtraPublicNics, + DnsBasicZoneUpdates, + RedundantRouterVrrpInterval, + DirectAttachNetworkEnabled, + DirectAttachNetworkExternalAPIURL }; } diff --git a/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java b/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java index 585b65aa4d94..94d6765a86ad 100644 --- a/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java +++ b/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java @@ -48,6 +48,8 @@ import org.apache.cloudstack.api.command.user.securitygroup.UpdateSecurityGroupCmd; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.framework.messagebus.PublishScope; @@ -63,7 +65,6 @@ import com.cloud.agent.api.SecurityGroupRulesCmd.IpPortAndProto; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.agent.manager.Commands; -import com.cloud.configuration.Config; import com.cloud.domain.dao.DomainDao; import com.cloud.event.ActionEvent; import com.cloud.event.EventTypes; @@ -92,7 +93,6 @@ import com.cloud.user.DomainManager; import com.cloud.user.dao.AccountDao; import com.cloud.uservm.UserVm; -import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.component.ManagerBase; import com.cloud.utils.concurrency.NamedThreadFactory; @@ -124,7 +124,7 @@ import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.VMInstanceDao; -public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGroupManager, SecurityGroupService, StateListener { +public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGroupManager, SecurityGroupService, StateListener, Configurable { @Inject SecurityGroupDao _securityGroupDao; @@ -944,10 +944,9 @@ public SecurityGroupVO createSecurityGroup(String name, String description, Long @Override public boolean configure(String name, Map params) throws ConfigurationException { - Map configs = _configDao.getConfiguration("Network", params); - _numWorkerThreads = NumbersUtil.parseInt(configs.get(Config.SecurityGroupWorkerThreads.key()), WORKER_THREAD_COUNT); - _timeBetweenCleanups = NumbersUtil.parseInt(configs.get(Config.SecurityGroupWorkCleanupInterval.key()), TIME_BETWEEN_CLEANUPS); - _globalWorkLockTimeout = NumbersUtil.parseInt(configs.get(Config.SecurityGroupWorkGlobalLockTimeout.key()), 300); + _numWorkerThreads = SecurityGroupWorkerThreads.value(); + _timeBetweenCleanups = SecurityGroupWorkCleanupInterval.value(); + _globalWorkLockTimeout = SecurityGroupWorkGlobalLockTimeout.value(); /* register state listener, no matter security group is enabled or not */ VirtualMachine.State.getStateMachine().registerListener(this); @@ -1488,4 +1487,14 @@ public boolean securityGroupRulesForVmSecIp(long nicId, String secondaryIp, bool return true; } + + @Override + public String getConfigComponentName() { + return SecurityGroupManager.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {SecurityGroupWorkCleanupInterval, SecurityGroupWorkerThreads, SecurityGroupWorkGlobalLockTimeout, SecurityGroupWorkPerAgentMaxQueueSize}; + } } diff --git a/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl2.java b/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl2.java index bd532f8162ff..e96fa5595bfa 100644 --- a/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl2.java +++ b/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl2.java @@ -31,13 +31,11 @@ import com.cloud.agent.api.SecurityGroupRulesCmd; import com.cloud.agent.manager.Commands; -import com.cloud.configuration.Config; import com.cloud.exception.AgentUnavailableException; import com.cloud.network.Networks; import com.cloud.network.security.SecurityGroupWork.Step; import com.cloud.network.security.SecurityRule.SecurityRuleType; import com.cloud.uservm.UserVm; -import com.cloud.utils.NumbersUtil; import com.cloud.utils.Profiler; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.mgmt.JmxUtil; @@ -282,8 +280,7 @@ public boolean configure(String name, Map params) throws Configu logger.error("Failed to register MBean", e); } boolean result = super.configure(name, params); - Map configs = _configDao.getConfiguration("Network", params); - int bufferLength = NumbersUtil.parseInt(configs.get(Config.SecurityGroupWorkPerAgentMaxQueueSize.key()), 100); + int bufferLength = SecurityGroupWorkPerAgentMaxQueueSize.value(); _workTracker = new SecurityGroupWorkTracker(_agentMgr, _answerListener, bufferLength); _answerListener.setWorkDispatcher(_workTracker); return result; diff --git a/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java index bcf2c6176efe..9711a069309f 100644 --- a/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java @@ -89,7 +89,6 @@ import com.cloud.api.query.dao.VpcOfferingJoinDao; import com.cloud.api.query.vo.VpcOfferingJoinVO; import com.cloud.bgp.BGPService; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.configuration.Resource.ResourceType; @@ -514,10 +513,10 @@ public void doInTransactionWithoutResult(final TransactionStatus status) { }); final Map configs = _configDao.getConfiguration(params); - final String value = configs.get(Config.VpcCleanupInterval.key()); + final String value = configs.get(VpcCleanupInterval.key()); _cleanupInterval = NumbersUtil.parseInt(value, 60 * 60); // 1 hour - final String maxNtwks = configs.get(Config.VpcMaxNetworks.key()); + final String maxNtwks = configs.get(VpcMaxNetworks.key()); _maxNetworks = NumbersUtil.parseInt(maxNtwks, 3); // max=3 is default IpAddressSearch = _ipAddressDao.createSearchBuilder(); @@ -2581,7 +2580,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) { try { // check number of active networks in vpc if (_ntwkDao.countVpcNetworks(vpc.getId()) >= _maxNetworks) { - logger.warn(String.format("Failed to create a new VPC Guest Network because the number of networks per VPC has reached its maximum capacity of [%s]. Increase it by modifying global config [%s].", _maxNetworks, Config.VpcMaxNetworks)); + logger.warn(String.format("Failed to create a new VPC Guest Network because the number of networks per VPC has reached its maximum capacity of [%s]. Increase it by modifying global config [%s].", _maxNetworks, VpcMaxNetworks.key())); throw new CloudRuntimeException(String.format("Number of networks per VPC cannot surpass [%s].", _maxNetworks)); } @@ -3721,7 +3720,9 @@ public String getConfigComponentName() { public ConfigKey[] getConfigKeys() { return new ConfigKey[]{ VpcTierNamePrepend, - VpcTierNamePrependDelimiter + VpcTierNamePrependDelimiter, + VpcCleanupInterval, + VpcMaxNetworks }; } diff --git a/server/src/main/java/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/main/java/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java index 24c2f2221d96..8ecdff5785c3 100644 --- a/server/src/main/java/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java +++ b/server/src/main/java/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java @@ -35,7 +35,6 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.commons.collections.CollectionUtils; -import com.cloud.configuration.Config; import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; import com.cloud.event.ActionEvent; @@ -75,7 +74,6 @@ import com.cloud.user.AccountManager; import com.cloud.user.DomainManager; import com.cloud.user.dao.AccountDao; -import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.PasswordGenerator; import com.cloud.utils.Ternary; @@ -810,11 +808,9 @@ public Pair, Integer> searchForRemoteAccessVpns( @Override public boolean configure(String name, Map params) throws ConfigurationException { - Map configs = _configDao.getConfiguration(params); + _userLimit = RemoteAccessVpnUserLimit.value(); - _userLimit = NumbersUtil.parseInt(configs.get(Config.RemoteAccessVpnUserLimit.key()), 8); - - _pskLength = NumbersUtil.parseInt(configs.get(Config.RemoteAccessVpnPskLength.key()), 24); + _pskLength = RemoteAccessVpnPskLength.value(); validateRemoteAccessVpnConfiguration(); @@ -859,7 +855,7 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {RemoteAccessVpnClientIpRange}; + return new ConfigKey[] {RemoteAccessVpnClientIpRange, RemoteAccessVpnPskLength, RemoteAccessVpnUserLimit}; } public List getVpnServiceProviders() { diff --git a/server/src/main/java/com/cloud/network/vpn/Site2SiteVpnManager.java b/server/src/main/java/com/cloud/network/vpn/Site2SiteVpnManager.java index 9cf604f85070..3dc47d68aa99 100644 --- a/server/src/main/java/com/cloud/network/vpn/Site2SiteVpnManager.java +++ b/server/src/main/java/com/cloud/network/vpn/Site2SiteVpnManager.java @@ -19,11 +19,22 @@ import java.util.List; import java.util.Set; +import org.apache.cloudstack.framework.config.ConfigKey; + import com.cloud.network.Site2SiteCustomerGateway; import com.cloud.network.dao.Site2SiteVpnConnectionVO; import com.cloud.vm.DomainRouterVO; public interface Site2SiteVpnManager extends Site2SiteVpnService { + + ConfigKey Site2SiteVpnConnectionPerVpnGatewayLimit = new ConfigKey<>("Network", Integer.class, + "site2site.vpn.vpngateway.connection.limit", "4", + "The maximum number of VPN connection per VPN gateway", true); + + ConfigKey Site2SiteVpnSubnetsPerCustomerGatewayLimit = new ConfigKey<>("Network", Integer.class, + "site2site.vpn.customergateway.subnets.limit", "10", + "The maximum number of subnets per customer gateway", true); + Set getExcludedVpnGatewayParameters(Site2SiteCustomerGateway customerGw); Set getObsoleteVpnGatewayParameters(Site2SiteCustomerGateway customerGw); diff --git a/server/src/main/java/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java b/server/src/main/java/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java index 47362feb4d15..8d4add175fc4 100644 --- a/server/src/main/java/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java +++ b/server/src/main/java/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java @@ -55,7 +55,6 @@ import com.cloud.utils.concurrency.NamedThreadFactory; import com.cloud.alert.AlertManager; -import com.cloud.configuration.Config; import com.cloud.event.ActionEvent; import com.cloud.event.ActionEventUtils; import com.cloud.event.EventTypes; @@ -88,7 +87,6 @@ import com.cloud.user.AccountManager; import com.cloud.user.User; import com.cloud.user.dao.AccountDao; -import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.StringUtils; import com.cloud.utils.Ternary; @@ -187,9 +185,8 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn @Override public boolean configure(String name, Map params) throws ConfigurationException { - Map configs = _configDao.getConfiguration(params); - _connLimit = NumbersUtil.parseInt(configs.get(Config.Site2SiteVpnConnectionPerVpnGatewayLimit.key()), 4); - _subnetsLimit = NumbersUtil.parseInt(configs.get(Config.Site2SiteVpnSubnetsPerCustomerGatewayLimit.key()), 10); + _connLimit = Site2SiteVpnConnectionPerVpnGatewayLimit.value(); + _subnetsLimit = Site2SiteVpnSubnetsPerCustomerGatewayLimit.value(); assert (_s2sProviders.iterator().hasNext()) : "Did not get injected with a list of S2S providers!"; _vpnCheckExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("VpnCustomerGateway-ExcludedAndObsoleteCheck")); return true; @@ -1184,7 +1181,7 @@ public ConfigKey[] getConfigKeys() { return new ConfigKey[] { VpnCustomerGatewayExcludedEncryptionAlgorithms, VpnCustomerGatewayExcludedHashingAlgorithms, VpnCustomerGatewayExcludedIkeVersions, VpnCustomerGatewayExcludedDhGroup, VpnCustomerGatewayObsoleteEncryptionAlgorithms, VpnCustomerGatewayObsoleteHashingAlgorithms, VpnCustomerGatewayObsoleteIkeVersions, VpnCustomerGatewayObsoleteDhGroup, - VpnCustomerGatewayObsoleteCheckInterval}; + VpnCustomerGatewayObsoleteCheckInterval, Site2SiteVpnConnectionPerVpnGatewayLimit, Site2SiteVpnSubnetsPerCustomerGatewayLimit}; } protected class CheckVpnCustomerGatewayObsoleteParametersTask extends ManagedContextRunnable { diff --git a/server/src/main/java/com/cloud/projects/ProjectManager.java b/server/src/main/java/com/cloud/projects/ProjectManager.java index 5f58205208be..d24746b213fd 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 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 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 ProjectInvitationExpirationTime = new ConfigKey<>("Project Defaults", Long.class, + "project.invite.timeout", "86400", + "Invitation expiration time (in seconds). Default is 1 day - 86400 seconds", true); + + ConfigKey AllowUserToCreateProject = new ConfigKey<>("Project Defaults", Boolean.class, + "allow.user.create.projects", "true", + "If regular user can create a project; true by default", true); + + ConfigKey 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 ProjectSMTPHost = new ConfigKey<>("Project Defaults", String.class, + "project.smtp.host", null, + "SMTP hostname used for sending out email project invitations", true); + + ConfigKey ProjectSMTPPort = new ConfigKey<>("Project Defaults", Integer.class, + "project.smtp.port", "465", + "Port the SMTP server is listening on", true); + + ConfigKey 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 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 92af441d06b9..226abda58195 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.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.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 @@ protected List listWebhooksForProject(Project projec public boolean configure(final String name, final Map params) throws ConfigurationException { Map 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 String getConfigComponentName() { @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/resource/DiscovererBase.java b/server/src/main/java/com/cloud/resource/DiscovererBase.java index 43f31c8745de..135a2de0e67d 100644 --- a/server/src/main/java/com/cloud/resource/DiscovererBase.java +++ b/server/src/main/java/com/cloud/resource/DiscovererBase.java @@ -27,13 +27,15 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao; -import com.cloud.configuration.Config; +import com.cloud.agent.AgentManager; import com.cloud.dc.ClusterVO; import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.DataCenterDao; import com.cloud.host.HostVO; import com.cloud.host.dao.HostDao; import com.cloud.network.NetworkModel; +import com.cloud.server.ManagementServer; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.utils.component.AdapterBase; import com.cloud.utils.net.UrlUtil; @@ -133,12 +135,12 @@ protected HashMap buildConfigParams(HostVO host) { params.put("ipaddress", host.getPrivateIpAddress()); params.put("secondary.storage.vm", "false"); - params.put("max.template.iso.size", _configDao.getValue(Config.MaxTemplateAndIsoSize.toString())); - params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString())); - params.put(Config.XenServerMaxNics.toString().toLowerCase(), _configDao.getValue(Config.XenServerMaxNics.toString())); - params.put(Config.XenServerHeartBeatInterval.toString().toLowerCase(), _configDao.getValue(Config.XenServerHeartBeatInterval.toString())); - params.put(Config.XenServerHeartBeatTimeout.toString().toLowerCase(), _configDao.getValue(Config.XenServerHeartBeatTimeout.toString())); - params.put("router.aggregation.command.each.timeout", _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString())); + params.put("max.template.iso.size", _configDao.getValue(SecondaryStorageVmManager.MaxTemplateAndIsoSize.toString())); + params.put("migratewait", _configDao.getValue(AgentManager.MigrateWait.toString())); + params.put(AgentManager.XenServerMaxNics.toString().toLowerCase(), _configDao.getValue(AgentManager.XenServerMaxNics.toString())); + params.put(ManagementServer.XenServerHeartBeatInterval.key().toLowerCase(), _configDao.getValue(ManagementServer.XenServerHeartBeatInterval.key())); + params.put(ManagementServer.XenServerHeartBeatTimeout.key().toLowerCase(), _configDao.getValue(ManagementServer.XenServerHeartBeatTimeout.key())); + params.put("router.aggregation.command.each.timeout", _configDao.getValue(ManagementServer.RouterAggregationCommandEachTimeout.key())); return params; diff --git a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java index 32a519c79fe9..3cedc8c9f909 100755 --- a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java @@ -115,7 +115,6 @@ import com.cloud.capacity.CapacityVO; import com.cloud.capacity.dao.CapacityDao; import com.cloud.cluster.ClusterManager; -import com.cloud.configuration.Config; import com.cloud.cpu.CPU; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterDetailsVO; @@ -180,6 +179,7 @@ import com.cloud.org.Grouping; import com.cloud.org.Managed; import com.cloud.serializer.GsonHelper; +import com.cloud.server.ManagementServer; import com.cloud.server.ManagementService; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; @@ -1228,7 +1228,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) { // If this cluster is of type vmware, and if the nexus vswitch // global parameter setting is turned // on, remove the row in cluster_vsm_map for this cluster id. - if (hypervisorType == HypervisorType.VMware && Boolean.parseBoolean(_configDao.getValue(Config.VmwareUseNexusVSwitch.toString()))) { + if (hypervisorType == HypervisorType.VMware && Boolean.parseBoolean(_configDao.getValue(ManagementServer.VmwareUseNexusVSwitch.key()))) { _clusterVSMMapDao.removeByClusterId(cmd.getId()); } // remove from dedicated resources diff --git a/server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java b/server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java index bc3abd30d880..b8a1508f2973 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.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,34 +293,34 @@ public boolean configure(final String name, final Map params) th } 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()))); + 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()))); @@ -329,17 +328,17 @@ public boolean configure(final String name, final Map params) th 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()))); + 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()))); @@ -2259,7 +2258,38 @@ public ConfigKey[] getConfigKeys() { DefaultMaxDomainProjects, DefaultMaxAccountGpus, DefaultMaxDomainGpus, - DefaultMaxProjectGpus + DefaultMaxProjectGpus, + DefaultMaxAccountUserVms, + DefaultMaxAccountPublicIPs, + DefaultMaxAccountTemplates, + DefaultMaxAccountSnapshots, + DefaultMaxAccountVolumes, + DefaultMaxAccountNetworks, + DefaultMaxAccountVpcs, + DefaultMaxAccountCpus, + DefaultMaxAccountMemory, + DefaultMaxAccountPrimaryStorage, + DefaultMaxDomainUserVms, + DefaultMaxDomainPublicIPs, + DefaultMaxDomainTemplates, + DefaultMaxDomainSnapshots, + DefaultMaxDomainVolumes, + DefaultMaxDomainNetworks, + DefaultMaxDomainVpcs, + DefaultMaxDomainCpus, + DefaultMaxDomainMemory, + DefaultMaxDomainPrimaryStorage, + DefaultMaxDomainSecondaryStorage, + DefaultMaxProjectUserVms, + DefaultMaxProjectPublicIPs, + DefaultMaxProjectTemplates, + DefaultMaxProjectSnapshots, + DefaultMaxProjectVolumes, + DefaultMaxProjectNetworks, + DefaultMaxProjectVpcs, + DefaultMaxProjectCpus, + DefaultMaxProjectMemory, + DefaultMaxProjectPrimaryStorage }; } diff --git a/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java b/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java index def564dfdc68..af89b4b3ae91 100644 --- a/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/main/java/com/cloud/server/ConfigurationServerImpl.java @@ -71,6 +71,7 @@ import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.network.Network.State; +import com.cloud.network.NetworkModel; import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; @@ -92,8 +93,11 @@ import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.Storage.ProvisioningType; import com.cloud.storage.dao.DiskOfferingDao; +import com.cloud.storage.secondary.SecondaryStorageVmManager; +import com.cloud.template.TemplateManager; 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; @@ -216,10 +220,24 @@ public void persistDefaultValues() throws InternalErrorException { } } - _configDao.update(Config.UseSecondaryStorageVm.key(), Config.UseSecondaryStorageVm.getCategory(), "true"); + ConfigurationVO useSecondaryStorageVmConfig = _configDao.findByName(SecondaryStorageVmManager.UseSecondaryStorageVm.key()); + if (useSecondaryStorageVmConfig == null) { + ConfigurationVO configVO = new ConfigurationVO(SecondaryStorageVmManager.class.getSimpleName(), SecondaryStorageVmManager.UseSecondaryStorageVm); + configVO.setValue("true"); + _configDao.persist(configVO); + } else { + _configDao.update(SecondaryStorageVmManager.UseSecondaryStorageVm.key(), SecondaryStorageVmManager.UseSecondaryStorageVm.category(), "true"); + } logger.debug("ConfigurationServer made secondary storage vm required."); - _configDao.update(Config.SecStorageEncryptCopy.key(), Config.SecStorageEncryptCopy.getCategory(), "false"); + ConfigurationVO secStorageEncryptCopyConfig = _configDao.findByName(SecondaryStorageVmManager.SecStorageEncryptCopy.key()); + if (secStorageEncryptCopyConfig == null) { + ConfigurationVO configVO = new ConfigurationVO(SecondaryStorageVmManager.class.getSimpleName(), SecondaryStorageVmManager.SecStorageEncryptCopy); + configVO.setValue("false"); + _configDao.persist(configVO); + } else { + _configDao.update(SecondaryStorageVmManager.SecStorageEncryptCopy.key(), SecondaryStorageVmManager.SecStorageEncryptCopy.category(), "false"); + } logger.debug("ConfigurationServer made secondary storage copy encrypt set to false."); _configDao.update("user.password.encoders.exclude", "MD5,LDAP,PLAINTEXT"); @@ -241,7 +259,14 @@ public void persistDefaultValues() throws InternalErrorException { // Save the mount parent to the configuration table String mountParent = getMountParent(); if (mountParent != null) { - _configDao.update(Config.MountParent.key(), Config.MountParent.getCategory(), mountParent); + ConfigurationVO mountParentConfig = _configDao.findByName(SecondaryStorageVmManager.MountParent.key()); + if (mountParentConfig == null) { + ConfigurationVO configVO = new ConfigurationVO(SecondaryStorageVmManager.class.getSimpleName(), SecondaryStorageVmManager.MountParent); + configVO.setValue(mountParent); + _configDao.persist(configVO); + } else { + _configDao.update(SecondaryStorageVmManager.MountParent.key(), SecondaryStorageVmManager.MountParent.category(), mountParent); + } logger.debug("ConfigurationServer saved \"" + mountParent + "\" as mount.parent."); } else { logger.debug("ConfigurationServer could not detect mount.parent."); @@ -369,12 +394,12 @@ private void initiateXenServerPVDriverVersion() { @Override public void doInTransactionWithoutResult(TransactionStatus status) { TransactionLegacy txn = TransactionLegacy.currentTxn(); - String pvdriverversion = Config.XenServerPVdriverVersion.getDefaultValue(); + String pvdriverversion = ManagementServer.XenServerPVdriverVersion.defaultValue(); PreparedStatement pstmt = null; ResultSet rs1 = null; ResultSet rs2 = null; try { - String oldValue = _configDao.getValue(Config.XenServerPVdriverVersion.key()); + String oldValue = _configDao.getValue(ManagementServer.XenServerPVdriverVersion.key()); if (oldValue == null) { String sql = "select resource from host where hypervisor_type='XenServer' and removed is null and status not in ('Error', 'Removed') group by resource"; pstmt = txn.prepareAutoCloseStatement(sql); @@ -392,8 +417,8 @@ public void doInTransactionWithoutResult(TransactionStatus status) { break; } } - _configDao.getValueAndInitIfNotExist(Config.XenServerPVdriverVersion.key(), Config.XenServerPVdriverVersion.getCategory(), pvdriverversion, - Config.XenServerPVdriverVersion.getDescription()); + _configDao.getValueAndInitIfNotExist(ManagementServer.XenServerPVdriverVersion.key(), ManagementServer.XenServerPVdriverVersion.category(), pvdriverversion, + ManagementServer.XenServerPVdriverVersion.description()); sql = "select id from vm_template where hypervisor_type='XenServer' and format!='ISO' and removed is null"; pstmt = txn.prepareAutoCloseStatement(sql); rs2 = pstmt.executeQuery(); @@ -532,10 +557,17 @@ public void doInTransactionWithoutResult(TransactionStatus status) { protected void updateCloudIdentifier() { // Creates and saves a UUID as the cloud identifier - String currentCloudIdentifier = _configDao.getValue("cloud.identifier"); + String currentCloudIdentifier = NetworkModel.CloudIdentifier.value(); if (currentCloudIdentifier == null || currentCloudIdentifier.isEmpty()) { String uuid = UUID.randomUUID().toString(); - _configDao.update(Config.CloudIdentifier.key(), Config.CloudIdentifier.getCategory(), uuid); + ConfigurationVO configInDB = _configDao.findByName(NetworkModel.CloudIdentifier.key()); + if (configInDB == null) { + ConfigurationVO configVO = new ConfigurationVO(NetworkModel.class.getSimpleName(), NetworkModel.CloudIdentifier); + configVO.setValue(uuid); + _configDao.persist(configVO); + } else { + _configDao.update(NetworkModel.CloudIdentifier.key(), NetworkModel.CloudIdentifier.category(), uuid); + } } } @@ -820,7 +852,15 @@ public void doInTransactionWithoutResult(TransactionStatus status) { 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); } @@ -831,15 +871,15 @@ private void updateSSOKey() { */ private void updateSecondaryStorageVMSharedKey() { try { - ConfigurationVO configInDB = _configDao.findByName(Config.SSVMPSK.key()); + ConfigurationVO configInDB = _configDao.findByName(TemplateManager.SSVMPSK.key()); if(configInDB == null) { - ConfigurationVO configVO = new ConfigurationVO(Config.SSVMPSK.getCategory(), "DEFAULT", Config.SSVMPSK.getComponent(), Config.SSVMPSK.key(), getPrivateKey(), - Config.SSVMPSK.getDescription()); + ConfigurationVO configVO = new ConfigurationVO(TemplateManager.class.getSimpleName(), TemplateManager.SSVMPSK); + configVO.setValue(getPrivateKey()); logger.info("generating a new SSVM PSK. This goes to SSVM on Start"); _configDao.persist(configVO); } else if (StringUtils.isEmpty(configInDB.getValue())) { logger.info("updating the SSVM PSK with new value. This goes to SSVM on Start"); - _configDao.update(Config.SSVMPSK.key(), Config.SSVMPSK.getCategory(), getPrivateKey()); + _configDao.update(TemplateManager.SSVMPSK.key(), TemplateManager.SSVMPSK.category(), getPrivateKey()); } } catch (NoSuchAlgorithmException ex) { logger.error("error generating ssvm psk", ex); @@ -901,7 +941,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) throws Intern throw new InvalidParameterValueException("The linkLocalIp.nums: " + nums + "is wrong, should be 1~16"); } /* local link ip address starts from 169.254.0.2 - 169.254.(nums) */ - String[] linkLocalIpRanges = NetUtils.getLinkLocalIPRange(_configDao.getValue(Config.ControlCidr.key())); + String[] linkLocalIpRanges = NetUtils.getLinkLocalIPRange(_configDao.getValue(ManagementServer.ControlCidr.key())); _zoneDao.addLinkLocalIpAddress(zoneId, pod.getId(), linkLocalIpRanges[0], linkLocalIpRanges[1]); } }); diff --git a/server/src/main/java/com/cloud/server/ManagementServer.java b/server/src/main/java/com/cloud/server/ManagementServer.java index 3932006c2924..8ae1b7e1dd5c 100644 --- a/server/src/main/java/com/cloud/server/ManagementServer.java +++ b/server/src/main/java/com/cloud/server/ManagementServer.java @@ -16,7 +16,12 @@ // under the License. package com.cloud.server; +import java.util.UUID; + +import org.apache.cloudstack.framework.config.ConfigKey; + import com.cloud.agent.api.Answer; +import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.host.DetailVO; import com.cloud.host.Host; import com.cloud.host.HostVO; @@ -31,6 +36,151 @@ */ public interface ManagementServer extends ManagementService, PluggableService { + ConfigKey customCsIdentifier = new ConfigKey<>("Advanced", String.class, "custom.cs.identifier", + UUID.randomUUID().toString().split("-")[0].substring(4), "Custom identifier for the cloudstack installation", true, ConfigKey.Scope.Global); + + ConfigKey exposeCloudStackVersionInApiXmlResponse = new ConfigKey<>("Advanced", Boolean.class, "expose.cloudstack.version.api.xml.response", "true", + "Indicates whether ACS version should appear in the root element of an API XML response.", true, ConfigKey.Scope.Global); + + ConfigKey ElasticLoadBalancerEnabled = new ConfigKey<>("Advanced", String.class, "network.loadbalancer.basiczone.elb.enabled", "false", + "Whether the load balancing service is enabled for basic zones", true); + + ConfigKey ElasticLoadBalancerNetwork = new ConfigKey<>("Advanced", String.class, "network.loadbalancer.basiczone.elb.network", "guest", + "Whether the elastic load balancing service public ips are taken from the public or guest network", true); + + ConfigKey ApiLimitEnabled = new ConfigKey<>("Advanced", Boolean.class, "api.throttling.enabled", "false", "Enable/disable Api rate limit", true); + + ConfigKey ApiLimitInterval = new ConfigKey<>("Advanced", Integer.class, "api.throttling.interval", "1", "Time interval (in seconds) to reset API count", true); + + ConfigKey ApiLimitMax = new ConfigKey<>("Advanced", Integer.class, "api.throttling.max", "25", "Max allowed number of APIs within fixed interval", true); + + ConfigKey OvmPublicNetwork = new ConfigKey<>("Hidden", String.class, + "ovm.public.network.device", null, + "Specify the public bridge on host for public network", true); + + ConfigKey OvmPrivateNetwork = new ConfigKey<>("Hidden", String.class, + "ovm.private.network.device", null, + "Specify the private bridge on host for private network", true); + + ConfigKey OvmGuestNetwork = new ConfigKey<>("Hidden", String.class, + "ovm.guest.network.device", null, + "Specify the private bridge on host for private network", true); + + ConfigKey Ovm3PublicNetwork = new ConfigKey<>("Hidden", String.class, + "ovm3.public.network.device", null, + "Specify the public bridge on host for public network", true); + + ConfigKey Ovm3PrivateNetwork = new ConfigKey<>("Hidden", String.class, + "ovm3.private.network.device", null, + "Specify the private bridge on host for private network", true); + + ConfigKey Ovm3GuestNetwork = new ConfigKey<>("Hidden", String.class, + "ovm3.guest.network.device", null, + "Specify the guest bridge on host for guest network", true); + + ConfigKey Ovm3StorageNetwork = new ConfigKey<>("Hidden", String.class, + "ovm3.storage.network.device", null, + "Specify the storage bridge on host for storage network", true); + + ConfigKey KvmPublicNetwork = new ConfigKey<>("Hidden", String.class, + "kvm.public.network.device", null, + "Specify the public bridge on host for public network", true); + + ConfigKey KvmPrivateNetwork = new ConfigKey<>("Hidden", String.class, + "kvm.private.network.device", null, + "Specify the private bridge on host for private network", true); + + ConfigKey KvmGuestNetwork = new ConfigKey<>("Hidden", String.class, + "kvm.guest.network.device", null, + "Specify the private bridge on host for private network", true); + + ConfigKey PublishActionEvent = new ConfigKey<>("Advanced", Boolean.class, "publish.action.events", "true", + "enable or disable publishing of action events on the event bus", true); + + ConfigKey PublishAlertEvent = new ConfigKey<>("Advanced", Boolean.class, "publish.alert.events", "true", + "enable or disable publishing of alert events on the event bus", true); + + ConfigKey PublishResourceStateEvent = new ConfigKey<>("Advanced", Boolean.class, "publish.resource.state.events", "true", + "enable or disable publishing of alert events on the event bus", true); + + ConfigKey PublishUsageEvent = new ConfigKey<>("Advanced", Boolean.class, "publish.usage.events", "true", + "enable or disable publishing of usage events on the event bus", true); + + ConfigKey EventPurgeInterval = new ConfigKey<>("Advanced", Integer.class, "event.purge.interval", "86400", + "The interval (in seconds) to wait before running the event purge thread", true); + + ConfigKey LinkLocalIpNums = new ConfigKey<>("Advanced", Integer.class, "linkLocalIp.nums", "10", + "The number of link local ip that needed by domR(in power of 2)", true); + + ConfigKey HypervisorList = new ConfigKey<>("Advanced", String.class, "hypervisor.list", + HypervisorType.KVM + "," + HypervisorType.VMware + "," + HypervisorType.XenServer + "," + HypervisorType.Hyperv + "," + + HypervisorType.BareMetal + "," + HypervisorType.Ovm + "," + HypervisorType.LXC + "," + HypervisorType.Ovm3 + "," + HypervisorType.External, + "The list of hypervisors that this deployment will use.", true, ConfigKey.Kind.CSV, null); + + ConfigKey ManagementNetwork = new ConfigKey<>("Advanced", String.class, "management.network.cidr", null, + "The cidr of management server network", true); + + ConfigKey EventPurgeDelay = new ConfigKey<>("Advanced", Integer.class, "event.purge.delay", "15", + "Events older than specified number days will be purged. Set this value to 0 to never delete events", true); + + ConfigKey AlertPurgeInterval = new ConfigKey<>("Advanced", Integer.class, "alert.purge.interval", "86400", + "The interval (in seconds) to wait before running the alert purge thread", true); + + ConfigKey AlertPurgeDelay = new ConfigKey<>("Advanced", Integer.class, "alert.purge.delay", "0", + "Alerts older than specified number days will be purged. Set this value to 0 to never delete alerts", true); + + ConfigKey ControlCidr = new ConfigKey<>("Advanced", String.class, "control.cidr", "169.254.0.0/16", + "Changes the cidr for the control network traffic. Defaults to using link local. Must be unique within pods", true); + + ConfigKey ControlGateway = new ConfigKey<>("Advanced", String.class, "control.gateway", "169.254.0.1", + "gateway for the control network traffic", true); + + ConfigKey DetailBatchQuerySize = new ConfigKey<>("Advanced", Integer.class, "detail.batch.query.size", "2000", + "Default entity detail batch query size for listing", true); + + ConfigKey S3EnableRRS = new ConfigKey<>("Advanced", Boolean.class, "s3.rrs.enabled", "false", + "enable s3 reduced redundancy storage", true); + + ConfigKey S3MaxSingleUploadSize = new ConfigKey<>("Advanced", Integer.class, "s3.singleupload.max.size", "5", + "The maximum size limit for S3 single part upload API(in GB). If it is set to 0, then it means always use multi-part upload to upload object to S3. " + + "If it is set to -1, then it means always use single-part upload to upload object to S3. ", true); + + ConfigKey CloudDnsName = new ConfigKey<>("Advanced", String.class, "cloud.dns.name", null, + "DNS name of the cloud for the GSLB service", true); + + ConfigKey InternalLbVmServiceOfferingId = new ConfigKey<>("Advanced", String.class, "internallbvm.service.offering", null, + "Uuid of the service offering used by internal lb vm; if NULL - default system internal lb offering will be used", true); + + ConfigKey RouterAggregationCommandEachTimeout = new ConfigKey<>("Advanced", Integer.class, "router.aggregation.command.each.timeout", "600", + "timeout in seconds for each Virtual Router command being aggregated. The final aggregation command timeout would be determined by this timeout * commands counts ", true); + + ConfigKey VmwareRootDiskControllerType = new ConfigKey<>("Advanced", String.class, "vmware.root.disk.controller", "ide", + "Specify the default disk controller for root volumes, valid values are scsi, ide, osdefault. Please check documentation for more details on each of these values.", + true, ConfigKey.Kind.Select, "scsi,ide,osdefault"); + + ConfigKey VmwareSystemVmNicDeviceType = new ConfigKey<>("Advanced", String.class, "vmware.systemvm.nic.device.type", "E1000", + "Specify the default network device type for system VMs, valid values are E1000, PCNet32, Vmxnet2, Vmxnet3", + true, ConfigKey.Kind.Select, "E1000,PCNet32,Vmxnet2,Vmxnet3"); + + ConfigKey VmwareUseNexusVSwitch = new ConfigKey<>("Network", Boolean.class, "vmware.use.nexus.vswitch", "false", + "Enable/Disable Cisco Nexus 1000v vSwitch in VMware environment", true); + + ConfigKey VmwareUseDVSwitch = new ConfigKey<>("Network", Boolean.class, "vmware.use.dvswitch", "false", + "Enable/Disable Nexus/Vmware dvSwitch in VMware environment", true); + + ConfigKey XenServerSetupMultipath = new ConfigKey<>("Advanced", String.class, "xenserver.setup.multipath", "false", + "Setup the host to do multipath", true); + + ConfigKey XenServerHeartBeatTimeout = new ConfigKey<>("Advanced", Integer.class, "xenserver.heartbeat.timeout", "120", + "heartbeat timeout to use when implementing XenServer Self Fencing", true); + + ConfigKey XenServerHeartBeatInterval = new ConfigKey<>("Advanced", Integer.class, "xenserver.heartbeat.interval", "60", + "heartbeat interval to use when checking before XenServer Self Fencing", true); + + ConfigKey XenServerPVdriverVersion = new ConfigKey<>("Advanced", String.class, "xenserver.pvdriver.version", "xenserver61", + "default Xen PV driver version for registered template, valid value:xenserver56,xenserver61 ", + true, ConfigKey.Kind.Select, "xenserver56,xenserver61"); + /** * returns the instance id of this management server. * diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java b/server/src/main/java/com/cloud/server/ManagementServerImpl.java index f32857d7cf04..b79f69d13f32 100644 --- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java +++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java @@ -31,7 +31,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.UUID; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -703,7 +702,6 @@ import com.cloud.cluster.ClusterManager; import com.cloud.cluster.ManagementServerHostVO; import com.cloud.cluster.dao.ManagementServerHostDao; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.consoleproxy.ConsoleProxyManagementState; import com.cloud.consoleproxy.ConsoleProxyManager; @@ -893,8 +891,6 @@ public class ManagementServerImpl extends MutualExclusiveIdsManagerBase implemen static final ConfigKey vmPasswordLength = new ConfigKey<>("Advanced", Integer.class, "vm.password.length", "6", "Specifies the length of a randomly generated password", false); static final ConfigKey sshKeyLength = new ConfigKey<>("Advanced", Integer.class, "ssh.key.length", "2048", "Specifies custom SSH key length (bit)", true, ConfigKey.Scope.Global); static final ConfigKey humanReadableSizes = new ConfigKey<>("Advanced", Boolean.class, "display.human.readable.sizes", "true", "Enables outputting human readable byte sizes to logs and usage records.", false, ConfigKey.Scope.Global); - public static final ConfigKey customCsIdentifier = new ConfigKey<>("Advanced", String.class, "custom.cs.identifier", UUID.randomUUID().toString().split("-")[0].substring(4), "Custom identifier for the cloudstack installation", true, ConfigKey.Scope.Global); - public static final ConfigKey exposeCloudStackVersionInApiXmlResponse = new ConfigKey<>("Advanced", Boolean.class, "expose.cloudstack.version.api.xml.response", "true", "Indicates whether ACS version should appear in the root element of an API XML response.", true, ConfigKey.Scope.Global); public static final ConfigKey exposeCloudStackVersionInApiListCapabilities = new ConfigKey<>("Advanced", Boolean.class, "expose.cloudstack.version.api.list.capabilities", "true", "Indicates whether ACS version should show in the listCapabilities API.", true, ConfigKey.Scope.Global); private static final VirtualMachine.Type []systemVmTypes = { VirtualMachine.Type.SecondaryStorageVm, VirtualMachine.Type.ConsoleProxy}; @@ -1153,8 +1149,8 @@ public boolean configure(final String name, final Map params) th } //Alerts purge configurations - final int alertPurgeInterval = NumbersUtil.parseInt(_configDao.getValue(Config.AlertPurgeInterval.key()), 60 * 60 * 24); // 1 day. - _alertPurgeDelay = NumbersUtil.parseInt(_configDao.getValue(Config.AlertPurgeDelay.key()), 0); + final int alertPurgeInterval = NumbersUtil.parseInt(_configDao.getValue(AlertPurgeInterval.key()), 60 * 60 * 24); // 1 day. + _alertPurgeDelay = NumbersUtil.parseInt(_configDao.getValue(AlertPurgeDelay.key()), 0); if (_alertPurgeDelay != 0) { _alertExecutor.scheduleAtFixedRate(new AlertPurgeTask(), alertPurgeInterval, alertPurgeInterval, TimeUnit.SECONDS); } @@ -4448,7 +4444,16 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {exposeCloudStackVersionInApiXmlResponse, exposeCloudStackVersionInApiListCapabilities, vmPasswordLength, sshKeyLength, humanReadableSizes, customCsIdentifier}; + return new ConfigKey[] {exposeCloudStackVersionInApiXmlResponse, exposeCloudStackVersionInApiListCapabilities, vmPasswordLength, sshKeyLength, humanReadableSizes, customCsIdentifier, + OvmPublicNetwork, OvmPrivateNetwork, OvmGuestNetwork, Ovm3PublicNetwork, Ovm3PrivateNetwork, Ovm3GuestNetwork, Ovm3StorageNetwork, + KvmPublicNetwork, KvmPrivateNetwork, KvmGuestNetwork, ElasticLoadBalancerEnabled, ElasticLoadBalancerNetwork, + ApiLimitEnabled, ApiLimitInterval, ApiLimitMax, + PublishActionEvent, PublishAlertEvent, PublishResourceStateEvent, PublishUsageEvent, + EventPurgeInterval, LinkLocalIpNums, HypervisorList, ManagementNetwork, EventPurgeDelay, + AlertPurgeInterval, AlertPurgeDelay, ControlCidr, ControlGateway, DetailBatchQuerySize, + S3EnableRRS, S3MaxSingleUploadSize, CloudDnsName, InternalLbVmServiceOfferingId, RouterAggregationCommandEachTimeout, + VmwareRootDiskControllerType, VmwareSystemVmNicDeviceType, VmwareUseNexusVSwitch, VmwareUseDVSwitch, + XenServerSetupMultipath, XenServerHeartBeatTimeout, XenServerHeartBeatInterval, XenServerPVdriverVersion}; } protected class EventPurgeTask extends ManagedContextRunnable { @@ -4811,7 +4816,7 @@ public ArrayList getCloudIdentifierResponse(final long userId) { // check permissions _accountMgr.checkAccess(caller, null, true, _accountMgr.getAccount(user.getAccountId())); - String cloudIdentifier = _configDao.getValue("cloud.identifier"); + String cloudIdentifier = NetworkModel.CloudIdentifier.value(); if (cloudIdentifier == null) { cloudIdentifier = ""; } @@ -4860,10 +4865,10 @@ public Map listCapabilities(final ListCapabilitiesCmd cmd) { final List networks = networkDao.listSecurityGroupEnabledNetworks(); if (networks != null && !networks.isEmpty()) { securityGroupsEnabled = true; - final String elbEnabled = _configDao.getValue(Config.ElasticLoadBalancerEnabled.key()); + final String elbEnabled = _configDao.getValue(ElasticLoadBalancerEnabled.key()); elasticLoadBalancerEnabled = elbEnabled == null ? false : Boolean.parseBoolean(elbEnabled); if (elasticLoadBalancerEnabled) { - final String networkType = _configDao.getValue(Config.ElasticLoadBalancerNetwork.key()); + final String networkType = _configDao.getValue(ElasticLoadBalancerNetwork.key()); if (networkType != null) { supportELB = networkType; } @@ -4878,9 +4883,9 @@ public Map listCapabilities(final ListCapabilitiesCmd cmd) { final boolean userPublicTemplateEnabled = TemplateManager.AllowPublicUserTemplates.valueIn(caller.getId()); // add some parameters UI needs to handle API throttling - final boolean apiLimitEnabled = Boolean.parseBoolean(_configDao.getValue(Config.ApiLimitEnabled.key())); - final Integer apiLimitInterval = Integer.valueOf(_configDao.getValue(Config.ApiLimitInterval.key())); - final Integer apiLimitMax = Integer.valueOf(_configDao.getValue(Config.ApiLimitMax.key())); + final boolean apiLimitEnabled = Boolean.parseBoolean(_configDao.getValue(ApiLimitEnabled.key())); + final Integer apiLimitInterval = Integer.valueOf(_configDao.getValue(ApiLimitInterval.key())); + final Integer apiLimitMax = Integer.valueOf(_configDao.getValue(ApiLimitMax.key())); final boolean allowUserViewDestroyedVM = (QueryService.AllowUserViewDestroyedVM.valueIn(caller.getId()) | isCallerAdmin); final boolean allowUserExpungeRecoverVM = (UserVmManager.AllowUserExpungeRecoverVm.valueIn(caller.getId()) | isCallerAdmin); @@ -5101,7 +5106,7 @@ private void validateCertificate(String certificate, String key, String domainSu @Override public List getHypervisors(final Long zoneId) { final List result = new ArrayList<>(); - final String hypers = _configDao.getValue(Config.HypervisorList.key()); + final String hypers = _configDao.getValue(HypervisorList.key()); final String[] hypervisors = hypers.split(","); if (zoneId != null) { diff --git a/server/src/main/java/com/cloud/server/StatsCollector.java b/server/src/main/java/com/cloud/server/StatsCollector.java index 293b28c6cb46..3266128e3812 100644 --- a/server/src/main/java/com/cloud/server/StatsCollector.java +++ b/server/src/main/java/com/cloud/server/StatsCollector.java @@ -59,6 +59,7 @@ import org.apache.cloudstack.management.ManagementServerHost; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; +import org.apache.cloudstack.usage.UsageService; import org.apache.cloudstack.utils.bytescale.ByteScaleUtils; import org.apache.cloudstack.utils.graphite.GraphiteClient; import org.apache.cloudstack.utils.graphite.GraphiteException; @@ -275,6 +276,14 @@ public String toString() { private static final ConfigKey StatsTimeout = new ConfigKey<>("Advanced", Integer.class, "stats.timeout", "60000", "The timeout for stats call in milli seconds.", true, ConfigKey.Scope.Cluster); + public static final ConfigKey StorageStatsInterval = new ConfigKey<>("Storage", Long.class, "storage.stats.interval", "60000", + "The interval (in milliseconds) when storage stats (per host) are retrieved from agents.", true); + public static final ConfigKey HostStatsInterval = new ConfigKey<>("Advanced", Integer.class, "host.stats.interval", "60000", + "The interval (in milliseconds) when host stats are retrieved from agents.", true); + public static final ConfigKey VmStatsInterval = new ConfigKey<>("Advanced", Integer.class, "vm.stats.interval", "60000", + "The interval (in milliseconds) when vm stats are retrieved from agents.", true); + public static final ConfigKey VolumeStatsInterval = new ConfigKey<>("Advanced", Integer.class, "volume.stats.interval", "60000", + "Interval (in milliseconds) to report volume statistics.", true); private static final ConfigKey statsOutputUri = new ConfigKey<>("Advanced", String.class, "stats.output.uri", "", "URI to send StatsCollector statistics to. The collector is defined on the URI scheme. Example: graphite://graphite-hostaddress:port or influxdb://influxdb-hostaddress/dbname. Note that the port is optional, if not added the default port for the respective collector (graphite or influxdb) will be used. Additionally, the database name '/dbname' is also optional; default db name is 'cloudstack'. You must create and configure the database if using influxdb.", true); @@ -445,7 +454,7 @@ protected void init(Map configs) { hostStatsInterval = NumbersUtil.parseLong(configs.get("host.stats.interval"), ONE_MINUTE_IN_MILLISCONDS); vmStatsInterval = NumbersUtil.parseLong(configs.get("vm.stats.interval"), ONE_MINUTE_IN_MILLISCONDS); - storageStatsInterval = NumbersUtil.parseLong(configs.get("storage.stats.interval"), ONE_MINUTE_IN_MILLISCONDS); + storageStatsInterval = StorageStatsInterval.value(); volumeStatsInterval = NumbersUtil.parseLong(configs.get("volume.stats.interval"), ONE_MINUTE_IN_MILLISCONDS); autoScaleStatsInterval = AutoScaleManager.AutoScaleStatsInterval.value(); ManagementServerStatusAdministrator managementServerStatusAdministrator = new ManagementServerStatusAdministrator(); @@ -546,9 +555,8 @@ protected void init(Map configs) { //Schedule disk stats update task _diskStatsUpdateExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("DiskStatsUpdater")); - String aggregationRange = configs.get("usage.stats.job.aggregation.range"); - _usageAggregationRange = NumbersUtil.parseInt(aggregationRange, 1440); - _usageTimeZone = configs.get("usage.aggregation.timezone"); + _usageAggregationRange = UsageService.UsageStatsJobAggregationRange.value(); + _usageTimeZone = UsageService.UsageAggregationTimezone.value(); if (_usageTimeZone == null) { _usageTimeZone = "GMT"; } @@ -2208,7 +2216,8 @@ public ConfigKey[] getConfigKeys() { vmStatsIncrementMetrics, vmStatsMaxRetentionTime, vmStatsCollectUserVMOnly, vmDiskStatsRetentionEnabled, vmDiskStatsMaxRetentionTime, MANAGEMENT_SERVER_STATUS_COLLECTION_INTERVAL, DATABASE_SERVER_STATUS_COLLECTION_INTERVAL, - DATABASE_SERVER_LOAD_HISTORY_RETENTION_NUMBER}; + DATABASE_SERVER_LOAD_HISTORY_RETENTION_NUMBER, + StorageStatsInterval, HostStatsInterval, VmStatsInterval, VolumeStatsInterval}; } public double getImageStoreCapacityThreshold() { diff --git a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java index d9b9bc629a6b..30ff7a93d97f 100644 --- a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java @@ -181,7 +181,6 @@ import com.cloud.capacity.CapacityVO; import com.cloud.capacity.dao.CapacityDao; import com.cloud.cluster.ClusterManagerListener; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.Resource.ResourceType; import com.cloud.cpu.CPU; @@ -4542,7 +4541,7 @@ public Long getDiskBytesReadRate(final ServiceOffering offering, final DiskOffer } else if ((diskOffering != null) && (diskOffering.getBytesReadRate() != null) && (diskOffering.getBytesReadRate() > 0)) { return diskOffering.getBytesReadRate(); } else { - Long bytesReadRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingBytesReadRate.key())); + Long bytesReadRate = Long.parseLong(_configDao.getValue(VmDiskThrottlingBytesReadRate.key())); if ((bytesReadRate > 0) && ((offering == null) || (!offering.isSystemUse()))) { return bytesReadRate; } @@ -4556,7 +4555,7 @@ public Long getDiskBytesWriteRate(final ServiceOffering offering, final DiskOffe if ((diskOffering != null) && (diskOffering.getBytesWriteRate() != null) && (diskOffering.getBytesWriteRate() > 0)) { return diskOffering.getBytesWriteRate(); } else { - Long bytesWriteRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingBytesWriteRate.key())); + Long bytesWriteRate = Long.parseLong(_configDao.getValue(VmDiskThrottlingBytesWriteRate.key())); if ((bytesWriteRate > 0) && ((offering == null) || (!offering.isSystemUse()))) { return bytesWriteRate; } @@ -4570,7 +4569,7 @@ public Long getDiskIopsReadRate(final ServiceOffering offering, final DiskOfferi if ((diskOffering != null) && (diskOffering.getIopsReadRate() != null) && (diskOffering.getIopsReadRate() > 0)) { return diskOffering.getIopsReadRate(); } else { - Long iopsReadRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingIopsReadRate.key())); + Long iopsReadRate = Long.parseLong(_configDao.getValue(VmDiskThrottlingIopsReadRate.key())); if ((iopsReadRate > 0) && ((offering == null) || (!offering.isSystemUse()))) { return iopsReadRate; } @@ -4584,7 +4583,7 @@ public Long getDiskIopsWriteRate(final ServiceOffering offering, final DiskOffer if ((diskOffering != null) && (diskOffering.getIopsWriteRate() != null) && (diskOffering.getIopsWriteRate() > 0)) { return diskOffering.getIopsWriteRate(); } else { - Long iopsWriteRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingIopsWriteRate.key())); + Long iopsWriteRate = Long.parseLong(_configDao.getValue(VmDiskThrottlingIopsWriteRate.key())); if ((iopsWriteRate > 0) && ((offering == null) || (!offering.isSystemUse()))) { return iopsWriteRate; } @@ -4628,7 +4627,13 @@ public ConfigKey[] getConfigKeys() { StoragePoolHostConnectWorkers, ObjectStorageCapacityThreshold, COPY_TEMPLATES_FROM_OTHER_SECONDARY_STORAGES, - AgentMaxDataMigrationWaitTime + AgentMaxDataMigrationWaitTime, + VmDiskThrottlingIopsReadRate, + VmDiskThrottlingIopsWriteRate, + VmDiskThrottlingBytesReadRate, + VmDiskThrottlingBytesWriteRate, + ExpungeWorkers, + HAStorageMigration }; } diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java index 535946ecdbcc..7e2f55427bfc 100644 --- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java @@ -136,7 +136,6 @@ import com.cloud.agent.api.to.DataTO; import com.cloud.agent.api.to.DiskTO; import com.cloud.api.ApiDBUtils; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.Resource.ResourceType; import com.cloud.dc.ClusterDetailsDao; @@ -190,6 +189,7 @@ import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeDetailsDao; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.snapshot.SnapshotApiService; import com.cloud.storage.snapshot.SnapshotManager; import com.cloud.template.TemplateManager; @@ -530,7 +530,7 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws GetUploadParamsResponse response = new GetUploadParamsResponse(); - String ssvmUrlDomain = _configDao.getValue(Config.SecStorageSecureCopyCert.key()); + String ssvmUrlDomain = _configDao.getValue(SecondaryStorageVmManager.SecStorageSecureCopyCert.key()); String protocol = UseHttpsToUpload.value() ? "https" : "http"; String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, ep.getPublicAddr(), vol.getUuid(), protocol); @@ -549,7 +549,7 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws String expires = currentDateTime.plusMinutes(timeout).toString(); response.setTimeout(expires); - String key = _configDao.getValue(Config.SSVMPSK.key()); + String key = TemplateManager.SSVMPSK.value(); /* * encoded metadata using the post upload config key */ @@ -560,7 +560,7 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws command.setLocalPath(volumeStore.getLocalDownloadPath()); //using the existing max upload size configuration command.setProcessTimeout(NumbersUtil.parseLong(_configDao.getValue("vmware.package.ova.timeout"), 3600)); - command.setMaxUploadSize(_configDao.getValue(Config.MaxUploadVolumeSize.key())); + command.setMaxUploadSize(String.valueOf(MaxUploadVolumeSize.value())); long accountId = vol.getAccountId(); Account account = _accountDao.findById(accountId); @@ -4873,9 +4873,6 @@ private String orchestrateExtractVolume(long volumeId, long zoneId) { if (secStore == null) { throw new InvalidParameterValueException(String.format("Secondary storage to satisfy storage needs cannot be found for zone: %d", zoneId)); } - String value = _configDao.getValue(Config.CopyVolumeWait.toString()); - NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue())); - // Copy volume from primary to secondary storage VolumeInfo srcVol = volFactory.getVolume(volumeId); VolumeInfo destVol = volFactory.getVolume(volumeId, DataStoreRole.Image); @@ -5786,7 +5783,11 @@ public ConfigKey[] getConfigKeys() { MatchStoragePoolTagsWithDiskOffering, UseHttpsToUpload, WaitDetachDevice, - AllowCheckAndRepairVolume + AllowCheckAndRepairVolume, + CopyVolumeWait, + CreateVolumeFromSnapshotWait, + MaxUploadVolumeSize, + StoragePoolMaxWaitSeconds }; } } diff --git a/server/src/main/java/com/cloud/storage/download/DownloadMonitorImpl.java b/server/src/main/java/com/cloud/storage/download/DownloadMonitorImpl.java index 5258f4337550..ed2f7188e3e2 100644 --- a/server/src/main/java/com/cloud/storage/download/DownloadMonitorImpl.java +++ b/server/src/main/java/com/cloud/storage/download/DownloadMonitorImpl.java @@ -49,10 +49,10 @@ import com.cloud.agent.AgentManager; import com.cloud.agent.api.storage.DownloadAnswer; -import com.cloud.configuration.Config; import com.cloud.storage.DataStoreRole; import com.cloud.storage.RegisterVolumePayload; import com.cloud.storage.Storage.ImageFormat; +import com.cloud.storage.VolumeApiService; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; import com.cloud.storage.template.TemplateConstants; import com.cloud.storage.upload.UploadListener; @@ -85,7 +85,7 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor @Override public boolean configure(String name, Map params) { final Map configs = _configDao.getConfiguration("management-server", params); - _proxy = configs.get(Config.SecStorageProxy.key()); + _proxy = configs.get(AgentManager.SecStorageProxy.key()); _copyAuthPasswd = configs.get("secstorage.copy.password"); @@ -336,7 +336,7 @@ private Long getMaxTemplateSizeInBytes() { private Long getMaxVolumeSizeInBytes() { try { - return Long.parseLong(_configDao.getValue("storage.max.volume.upload.size")) * 1024L * 1024L * 1024L; + return VolumeApiService.MaxUploadVolumeSize.value() * 1024L * 1024L * 1024L; } catch (NumberFormatException e) { return null; } @@ -344,7 +344,7 @@ private Long getMaxVolumeSizeInBytes() { private Long getMaxSnapshotSizeInBytes() { try { - return Long.parseLong(_configDao.getValue("storage.max.volume.upload.size")) * 1024L * 1024L * 1024L; + return VolumeApiService.MaxUploadVolumeSize.value() * 1024L * 1024L * 1024L; } catch (NumberFormatException e) { return null; } diff --git a/server/src/main/java/com/cloud/storage/listener/SnapshotStateListener.java b/server/src/main/java/com/cloud/storage/listener/SnapshotStateListener.java index 18ab4168c249..9887db55c106 100644 --- a/server/src/main/java/com/cloud/storage/listener/SnapshotStateListener.java +++ b/server/src/main/java/com/cloud/storage/listener/SnapshotStateListener.java @@ -31,8 +31,8 @@ import org.apache.logging.log4j.Logger; import org.springframework.stereotype.Component; -import com.cloud.configuration.Config; import com.cloud.event.EventCategory; +import com.cloud.server.ManagementServer; import com.cloud.server.ManagementService; import com.cloud.storage.Snapshot; import com.cloud.storage.Snapshot.Event; @@ -80,7 +80,7 @@ public boolean postStateTransitionEvent(StateMachine2.Transition t private void pubishOnEventBus(String event, String status, Snapshot vo, State oldState, State newState) { - String configKey = Config.PublishResourceStateEvent.key(); + String configKey = ManagementServer.PublishResourceStateEvent.key(); String value = s_configDao.getValue(configKey); boolean configValue = Boolean.parseBoolean(value); if(!configValue) { diff --git a/server/src/main/java/com/cloud/storage/listener/VolumeStateListener.java b/server/src/main/java/com/cloud/storage/listener/VolumeStateListener.java index 0910c46705af..ac53d7f5666b 100644 --- a/server/src/main/java/com/cloud/storage/listener/VolumeStateListener.java +++ b/server/src/main/java/com/cloud/storage/listener/VolumeStateListener.java @@ -27,10 +27,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import com.cloud.configuration.Config; import com.cloud.event.EventCategory; import com.cloud.event.EventTypes; import com.cloud.event.UsageEventUtils; +import com.cloud.server.ManagementServer; import com.cloud.server.ManagementService; import com.cloud.storage.Volume; import com.cloud.storage.Volume.Event; @@ -96,7 +96,7 @@ public boolean postStateTransitionEvent(StateMachine2.Transition t private void pubishOnEventBus(String event, String status, Volume vo, State oldState, State newState) { - String configKey = Config.PublishResourceStateEvent.key(); + String configKey = ManagementServer.PublishResourceStateEvent.key(); String value = _configDao.getValue(configKey); boolean configValue = Boolean.parseBoolean(value); if(!configValue) diff --git a/server/src/main/java/com/cloud/storage/secondary/SecondaryStorageVmManager.java b/server/src/main/java/com/cloud/storage/secondary/SecondaryStorageVmManager.java index 599e8c171c51..c72e8beb0d10 100644 --- a/server/src/main/java/com/cloud/storage/secondary/SecondaryStorageVmManager.java +++ b/server/src/main/java/com/cloud/storage/secondary/SecondaryStorageVmManager.java @@ -50,6 +50,41 @@ public interface SecondaryStorageVmManager extends Manager { true, ConfigKey.Scope.Zone, null, "User Data for SSVMs", null, ConfigKey.GROUP_SYSTEM_VMS, ConfigKey.SUBGROUP_SEC_STORAGE_VM); + ConfigKey UseSecondaryStorageVm = new ConfigKey<>("Hidden", Boolean.class, "secondary.storage.vm", "false", + "Deploys a VM per zone to manage secondary storage if true, otherwise secondary storage is mounted on management server", true); + + ConfigKey MountParent = new ConfigKey<>("Advanced", String.class, "mount.parent", "/var/cloudstack/mnt", + "The mount point on the Management Server for Secondary Storage.", true); + + ConfigKey SystemVMAutoReserveCapacity = new ConfigKey<>("Advanced", Boolean.class, "system.vm.auto.reserve.capacity", "true", + "Indicates whether or not to automatically reserver system VM standby capacity.", true); + + ConfigKey SystemVMRandomPassword = new ConfigKey<>("Advanced", Boolean.class, "system.vm.random.password", "false", + "Randomize system vm password the first time management server starts", true); + + ConfigKey MaxTemplateAndIsoSize = new ConfigKey<>("Advanced", Long.class, "max.template.iso.size", "50", + "The maximum size for a downloaded template or ISO (in GB).", true); + + ConfigKey SecStorageAllowedInternalDownloadSites = new ConfigKey<>("Advanced", String.class, "secstorage.allowed.internal.sites", null, + "Comma separated list of cidrs internal to the datacenter that can host template download servers, please note 0.0.0.0 is not a valid site", true); + + ConfigKey SecStorageEncryptCopy = new ConfigKey<>("Advanced", Boolean.class, "secstorage.encrypt.copy", "false", + "Use SSL method used to encrypt copy traffic between zones. Also ensures that the certificate assigned to the zone is used when generating links for external access.", true); + + ConfigKey SecStorageSecureCopyCert = new ConfigKey<>("Advanced", String.class, "secstorage.ssl.cert.domain", "", + "SSL certificate used to encrypt copy traffic between zones", true); + + ConfigKey ExtractURLCleanUpInterval = new ConfigKey<>("Advanced", Integer.class, "extract.url.cleanup.interval", "7200", + "The interval (in seconds) to wait before cleaning up the extract URL's ", true); + + ConfigKey DisableExtraction = new ConfigKey<>("Advanced", Boolean.class, "disable.extraction", "false", + "Flag for disabling extraction of Templates, ISOs, Snapshots and volumes", true); + + ConfigKey ExtractURLExpirationInterval = new ConfigKey<>("Advanced", Integer.class, "extract.url.expiration.interval", "14400", + "The life of an extract URL after which it is deleted ", true); + + ConfigKey SecondaryStorageServiceOffering = new ConfigKey<>("Advanced", String.class, "secstorage.service.offering", null, + "Uuid of the service offering used by secondary storage; if NULL - system offering will be used", true); public static final int DEFAULT_SS_VM_RAMSIZE = 512; // 512M public static final int DEFAULT_SS_VM_CPUMHZ = 500; // 500 MHz diff --git a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManager.java b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManager.java index 10dcc2683de8..7eece969403b 100644 --- a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManager.java +++ b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManager.java @@ -72,6 +72,15 @@ public interface SnapshotManager extends Configurable { "For snapshot copy to another primary storage in a different zone. This is supported only for StorPool storage for now.", true, ConfigKey.Scope.StoragePool, null); + ConfigKey BackupSnapshotWait = new ConfigKey<>("Storage", Integer.class, "backup.snapshot.wait", "21600", + "In second, timeout for BackupSnapshotCommand", true); + + ConfigKey TotalRetries = new ConfigKey<>("Storage", Integer.class, "total.retries", "4", + "The number of times each command sent to a host should be retried in case of failure.", true); + + ConfigKey SnapshotPollInterval = new ConfigKey<>("Snapshots", Integer.class, "snapshot.poll.interval", "300", + "The time interval in seconds when the management server polls for snapshots to be scheduled.", true); + void deletePoliciesForVolume(Long volumeId); /** diff --git a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java index dc33a4442a33..aa0e816d8688 100755 --- a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -96,7 +96,6 @@ import com.cloud.api.ApiDBUtils; import com.cloud.api.commands.ListRecurringSnapshotScheduleCmd; import com.cloud.api.query.MutualExclusiveIdsManagerBase; -import com.cloud.configuration.Config; import com.cloud.configuration.Resource.ResourceType; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenter; @@ -151,6 +150,7 @@ import com.cloud.storage.dao.SnapshotZoneDao; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VolumeDao; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.template.TemplateConstants; import com.cloud.tags.ResourceTagVO; import com.cloud.tags.dao.ResourceTagDao; @@ -310,7 +310,8 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { return new ConfigKey[] {BackupRetryAttempts, BackupRetryInterval, SnapshotHourlyMax, SnapshotDailyMax, SnapshotMonthlyMax, SnapshotWeeklyMax, usageSnapshotSelection, - SnapshotInfo.BackupSnapshotAfterTakingSnapshot, VmStorageSnapshotKvm, kvmIncrementalSnapshot, snapshotDeltaMax, snapshotShowChainSize, UseStorageReplication, KVMSnapshotEnabled}; + SnapshotInfo.BackupSnapshotAfterTakingSnapshot, VmStorageSnapshotKvm, kvmIncrementalSnapshot, snapshotDeltaMax, snapshotShowChainSize, UseStorageReplication, KVMSnapshotEnabled, + BackupSnapshotWait, TotalRetries, SnapshotPollInterval}; } @Override @@ -546,7 +547,7 @@ public String extractSnapshot(ExtractSnapshotCmd cmd) { Long zoneId = cmd.getZoneId(); if (!_accountMgr.isRootAdmin(caller.getId()) && ApiDBUtils.isExtractionDisabled()) { - logger.error("Extraction is disabled through [{}].", Config.DisableExtraction); + logger.error("Extraction is disabled through [{}].", SecondaryStorageVmManager.DisableExtraction); throw new PermissionDeniedException("Extraction could not be completed."); } @@ -1882,13 +1883,11 @@ private void updateSnapshotPayload(long storagePoolId, CreateSnapshotPayload pay @Override public boolean configure(String name, Map params) throws ConfigurationException { - String value = _configDao.getValue(Config.BackupSnapshotWait.toString()); - Type.HOURLY.setMax(SnapshotHourlyMax.value()); Type.DAILY.setMax(SnapshotDailyMax.value()); Type.WEEKLY.setMax(SnapshotWeeklyMax.value()); Type.MONTHLY.setMax(SnapshotMonthlyMax.value()); - _totalRetries = NumbersUtil.parseInt(_configDao.getValue("total.retries"), 4); + _totalRetries = TotalRetries.value(); _pauseInterval = 2 * NumbersUtil.parseInt(_configDao.getValue("ping.interval"), 60); snapshotBackupRetries = BackupRetryAttempts.value(); diff --git a/server/src/main/java/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java b/server/src/main/java/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java index ddaa96100bd1..4c0064bc84ed 100644 --- a/server/src/main/java/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java +++ b/server/src/main/java/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java @@ -446,7 +446,7 @@ public boolean removeSchedule(final Long volumeId, final Long policyId) { @Override public boolean configure(final String name, final Map params) throws ConfigurationException { - _snapshotPollInterval = NumbersUtil.parseInt(_configDao.getValue("snapshot.poll.interval"), 300); + _snapshotPollInterval = SnapshotManager.SnapshotPollInterval.value(); final boolean snapshotsRecurringTest = Boolean.parseBoolean(_configDao.getValue("snapshot.recurring.test")); if (snapshotsRecurringTest) { // look for some test values in the configuration table so that snapshots can be taken more frequently (QA test code) diff --git a/server/src/main/java/com/cloud/template/TemplateAdapterBase.java b/server/src/main/java/com/cloud/template/TemplateAdapterBase.java index 1aa3bedbdf0a..6710a76fb004 100644 --- a/server/src/main/java/com/cloud/template/TemplateAdapterBase.java +++ b/server/src/main/java/com/cloud/template/TemplateAdapterBase.java @@ -56,7 +56,6 @@ import org.apache.commons.lang3.StringUtils; import com.cloud.api.ApiDBUtils; -import com.cloud.configuration.Config; import com.cloud.configuration.Resource.ResourceType; import com.cloud.cpu.CPU; import com.cloud.dc.DataCenterVO; @@ -74,6 +73,7 @@ import com.cloud.org.Grouping; import com.cloud.projects.ProjectManager; import com.cloud.server.ConfigurationServer; +import com.cloud.server.ManagementServer; import com.cloud.server.StatsCollector; import com.cloud.storage.GuestOS; import com.cloud.storage.Storage.ImageFormat; @@ -83,6 +83,7 @@ import com.cloud.storage.dao.GuestOSHypervisorDao; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateZoneDao; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.upload.params.IsoUploadParams; import com.cloud.storage.upload.params.TemplateUploadParams; import com.cloud.storage.upload.params.UploadParams; @@ -238,7 +239,7 @@ protected void postUploadAllocation(List imageStores, VMTemplateVO te template.getUniqueName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(), templateOnStore.getDataStore().getRole().toString(), zoneId_is); //using the existing max template size configuration - payload.setMaxUploadSize(_configDao.getValue(Config.MaxTemplateAndIsoSize.key())); + payload.setMaxUploadSize(_configDao.getValue(SecondaryStorageVmManager.MaxTemplateAndIsoSize.key())); Long accountId = template.getAccountId(); Account account = _accountDao.findById(accountId); @@ -387,7 +388,7 @@ public TemplateProfile prepare(boolean isIso, long userId, String name, String d if (hypervisorType.equals(Hypervisor.HypervisorType.XenServer)) { if (details == null || !details.containsKey("hypervisortoolsversion") || details.get("hypervisortoolsversion") == null || ((String)details.get("hypervisortoolsversion")).equalsIgnoreCase("none")) { - String hpvs = _configDao.getValue(Config.XenServerPVdriverVersion.key()); + String hpvs = _configDao.getValue(ManagementServer.XenServerPVdriverVersion.key()); if (hpvs != null) { if (details == null) { details = new HashMap(); diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index 416684707192..78598cc44ee6 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -127,7 +127,6 @@ import com.cloud.api.ApiDBUtils; import com.cloud.api.query.dao.UserVmJoinDao; import com.cloud.api.query.vo.UserVmJoinVO; -import com.cloud.configuration.Config; import com.cloud.configuration.Resource.ResourceType; import com.cloud.cpu.CPU; import com.cloud.dc.DataCenter; @@ -190,6 +189,7 @@ import com.cloud.storage.dao.VMTemplatePoolDao; import com.cloud.storage.dao.VMTemplateZoneDao; import com.cloud.storage.dao.VolumeDao; +import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.snapshot.SnapshotManager; import com.cloud.template.TemplateAdapter.TemplateAdapterType; import com.cloud.template.VirtualMachineTemplate.BootloaderType; @@ -454,7 +454,7 @@ private GetUploadParamsResponse registerPostUploadInternal(TemplateAdapter adapt */ TemplateOrVolumePostUploadCommand firstCommand = payload.get(0); - String ssvmUrlDomain = _configDao.getValue(Config.SecStorageSecureCopyCert.key()); + String ssvmUrlDomain = _configDao.getValue(SecondaryStorageVmManager.SecStorageSecureCopyCert.key()); String protocol = VolumeApiService.UseHttpsToUpload.valueIn(firstCommand.getZoneId()) ? "https" : "http"; String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, firstCommand.getRemoteEndPoint(), firstCommand.getEntityUUID(), protocol); @@ -474,7 +474,7 @@ private GetUploadParamsResponse registerPostUploadInternal(TemplateAdapter adapt String expires = currentDateTime.plusMinutes(timeout).toString(); response.setTimeout(expires); - String key = _configDao.getValue(Config.SSVMPSK.key()); + String key = SSVMPSK.value(); /* * encoded metadata using the post upload config ssh key */ @@ -2753,7 +2753,9 @@ public ConfigKey[] getConfigKeys() { TemplateDeleteFromPrimaryStorage, PublicTemplateSecStorageCopy, PrivateTemplateSecStorageCopy, - VmIsoMaxCount}; + VmIsoMaxCount, + CreatePrivateTemplateFromSnapshotWait, + SSVMPSK}; } public List getTemplateAdapters() { diff --git a/server/src/main/java/com/cloud/usage/UsageServiceImpl.java b/server/src/main/java/com/cloud/usage/UsageServiceImpl.java index de8d4633d224..9bc91f5704f3 100644 --- a/server/src/main/java/com/cloud/usage/UsageServiceImpl.java +++ b/server/src/main/java/com/cloud/usage/UsageServiceImpl.java @@ -30,6 +30,8 @@ import org.apache.cloudstack.api.command.admin.usage.ListUsageRecordsCmd; import org.apache.cloudstack.api.command.admin.usage.RemoveRawUsageRecordsCmd; import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.usage.Usage; import org.apache.cloudstack.usage.UsageService; @@ -40,7 +42,6 @@ import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Component; -import com.cloud.configuration.Config; import com.cloud.domain.Domain; import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; @@ -85,7 +86,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Component -public class UsageServiceImpl extends ManagerBase implements UsageService, Manager { +public class UsageServiceImpl extends ManagerBase implements UsageService, Manager, Configurable { //ToDo: Move implementation to ManagaerImpl @@ -138,10 +139,10 @@ public UsageServiceImpl() { public boolean configure(String name, Map params) throws ConfigurationException { super.configure(name, params); - String timeZoneStr = ObjectUtils.defaultIfNull(_configDao.getValue(Config.UsageAggregationTimezone.toString()), "GMT"); + String timeZoneStr = ObjectUtils.defaultIfNull(UsageAggregationTimezone.value(), "GMT"); _usageTimezone = TimeZone.getTimeZone(timeZoneStr); - String executionTimeZone = _configDao.getValue(Config.UsageExecutionTimezone.toString()); + String executionTimeZone = UsageExecutionTimezone.value(); if (executionTimeZone != null) { usageExecutionTimeZone = TimeZone.getTimeZone(executionTimeZone); } @@ -480,7 +481,7 @@ public boolean removeRawUsageRecords(RemoveRawUsageRecordsCmd cmd) throws Invali throw new InvalidParameterValueException("Interval should be greater than 0."); } - String jobExecTime = _configDao.getValue(Config.UsageStatsJobExecTime.toString()); + String jobExecTime = UsageStatsJobExecTime.value(); Date previousJobExecTime = UsageUtils.getPreviousJobExecutionTime(usageExecutionTimeZone, jobExecTime); Date nextJobExecTime = UsageUtils.getNextJobExecutionTime(usageExecutionTimeZone, jobExecTime); if (ObjectUtils.allNotNull(previousJobExecTime, nextJobExecTime)) { @@ -500,4 +501,15 @@ public boolean removeRawUsageRecords(RemoveRawUsageRecordsCmd cmd) throws Invali _usageDao.expungeAllOlderThan(interval, ConfigurationManagerImpl.DELETE_QUERY_BATCH_SIZE.value()); return true; } + + @Override + public String getConfigComponentName() { + return UsageService.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {UsageAggregationTimezone, UsageExecutionTimezone, UsageSanityCheckInterval, + UsageStatsJobAggregationRange, UsageStatsJobExecTime, EnableUsageServer}; + } } diff --git a/server/src/main/java/com/cloud/user/AccountManager.java b/server/src/main/java/com/cloud/user/AccountManager.java index eca1a571dd88..3edddc34215e 100644 --- a/server/src/main/java/com/cloud/user/AccountManager.java +++ b/server/src/main/java/com/cloud/user/AccountManager.java @@ -190,6 +190,18 @@ void buildACLViewSearchCriteria(SearchCriteria s ConfigKey UseSecretKeyInResponse = new ConfigKey("Advanced", Boolean.class, "use.secret.key.in.response", "false", "This parameter allows the users to enable or disable of showing secret key as a part of response for various APIs. By default it is set to false.", true); + ConfigKey SSOKey = new ConfigKey<>("Secure", String.class, "security.singlesignon.key", null, + "A Single Sign-On key used for logging into the cloud", true); + + ConfigKey AccountCleanupInterval = new ConfigKey<>("Advanced", Integer.class, "account.cleanup.interval", "86400", + "The interval (in seconds) between cleanup for removed accounts", true); + + ConfigKey IncorrectLoginAttemptsAllowed = new ConfigKey<>("Advanced", Integer.class, "incorrect.login.attempts.allowed", "5", + "Incorrect login attempts allowed before the user is disabled (when value > 0). If value <=0 users are not disabled after failed login attempts", true); + + ConfigKey SSOAuthTolerance = new ConfigKey<>("Advanced", Long.class, "security.singlesignon.tolerance.millis", "300000", + "The allowable clock difference in milliseconds between when an SSO login request is made and when it is received.", true); + boolean moveUser(long id, Long domainId, Account newAccount); UserTwoFactorAuthenticator getUserTwoFactorAuthenticator(final Long domainId, final Long userAccountId); diff --git a/server/src/main/java/com/cloud/user/AccountManagerImpl.java b/server/src/main/java/com/cloud/user/AccountManagerImpl.java index db9c1d1dafde..1d34573536dd 100644 --- a/server/src/main/java/com/cloud/user/AccountManagerImpl.java +++ b/server/src/main/java/com/cloud/user/AccountManagerImpl.java @@ -554,10 +554,10 @@ public boolean configure(final String name, final Map params) th Map configs = _configDao.getConfiguration(params); - String loginAttempts = configs.get(Config.IncorrectLoginAttemptsAllowed.key()); + String loginAttempts = configs.get(IncorrectLoginAttemptsAllowed.key()); _allowedLoginAttempts = NumbersUtil.parseInt(loginAttempts, 5); - String value = configs.get(Config.AccountCleanupInterval.key()); + String value = configs.get(AccountCleanupInterval.key()); _cleanupInterval = NumbersUtil.parseInt(value, 60 * 60 * 24); // 1 day. return true; @@ -3109,7 +3109,7 @@ private UserAccount getUserAccount(String username, String password, Long domain } private UserAccount getUserAccountForSSO(String username, Long domainId, Map 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; @@ -4101,7 +4101,8 @@ public String getConfigComponentName() { public ConfigKey[] getConfigKeys() { return new ConfigKey[] {UseSecretKeyInResponse, enableUserTwoFactorAuthentication, userTwoFactorAuthenticationDefaultProvider, mandateUserTwoFactorAuthentication, userTwoFactorAuthenticationIssuer, apiKeyAccess, - userAllowMultipleAccounts, listOfRoleTypesAllowedForOperationsOfSameRoleType, allowOperationsOnUsersInSameAccount}; + userAllowMultipleAccounts, listOfRoleTypesAllowedForOperationsOfSameRoleType, allowOperationsOnUsersInSameAccount, SSOKey, + AccountCleanupInterval, IncorrectLoginAttemptsAllowed, SSOAuthTolerance}; } public List getUserTwoFactorAuthenticationProviders() { diff --git a/server/src/main/java/com/cloud/vm/UserVmManager.java b/server/src/main/java/com/cloud/vm/UserVmManager.java index f6eb0593be6c..ac68be102793 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManager.java +++ b/server/src/main/java/com/cloud/vm/UserVmManager.java @@ -119,6 +119,21 @@ public interface UserVmManager extends UserVmService { "Advanced", Boolean.class, "enforce.resource.limit.on.backup.validation.vm", "false", "If set to true, validation VMs will be accounted in the resource limit of the " + "account/domain.", true, ConfigKey.Scope.Account); + ConfigKey ExpungeDelay = new ConfigKey<>("Advanced", Integer.class, "expunge.delay", "86400", + "Determines how long (in seconds) to wait before actually expunging destroyed vm. The default value = the default value of expunge.interval", true); + + ConfigKey ExpungeInterval = new ConfigKey<>("Advanced", Integer.class, "expunge.interval", "86400", + "The interval (in seconds) to wait before running the expunge thread.", true); + + ConfigKey ScaleRetry = new ConfigKey<>("Advanced", Integer.class, "scale.retry", "2", + "Number of times to retry scaling up the vm", true); + + ConfigKey SetVmInternalNameUsingDisplayName = new ConfigKey<>("Advanced", Boolean.class, "vm.instancename.flag", "false", + "If set to true, will set guest VM's name as it appears on the hypervisor, to its hostname. The flag is supported for VMware hypervisor only", true); + + ConfigKey CapacitySkipcountingHours = new ConfigKey<>("Advanced", Integer.class, "capacity.skipcounting.hours", "3600", + "Time (in seconds) to wait before release VM's cpu and memory when VM in stopped state", true); + static final int MAX_USER_DATA_LENGTH_BYTES = 2048; public static final String CKS_NODE = "cksnode"; diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index b3bc69835ff5..187407001e5c 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -160,6 +160,7 @@ import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; import org.apache.cloudstack.storage.template.VnfTemplateManager; +import org.apache.cloudstack.usage.UsageService; import org.apache.cloudstack.userdata.UserDataManager; import org.apache.cloudstack.utils.bytescale.ByteScaleUtils; import org.apache.cloudstack.utils.security.ParserUtils; @@ -214,7 +215,6 @@ import com.cloud.api.query.vo.ServiceOfferingJoinVO; import com.cloud.capacity.Capacity; import com.cloud.capacity.CapacityManager; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.configuration.Resource.ResourceType; @@ -329,6 +329,7 @@ import com.cloud.resourcelimit.CheckedReservation; import com.cloud.serializer.GsonHelper; import com.cloud.resourcelimit.ReservationHelper; +import com.cloud.server.ManagementServer; import com.cloud.server.ManagementService; import com.cloud.server.ResourceTag; import com.cloud.service.ServiceOfferingVO; @@ -2590,7 +2591,7 @@ public boolean configure(String name, Map params) throws Configu String workers = configs.get("expunge.workers"); int wrks = NumbersUtil.parseInt(workers, 10); - capacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600); + capacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(CapacitySkipcountingHours.key()), 3600); String time = configs.get("expunge.interval"); _expungeInterval = NumbersUtil.parseInt(time, 86400); @@ -2604,8 +2605,7 @@ public boolean configure(String name, Map params) throws Configu _vmIpFetchExecutor = Executors.newScheduledThreadPool(vmipwrks, new NamedThreadFactory("UserVm-ipfetch")); - String aggregationRange = configs.get("usage.stats.job.aggregation.range"); - int _usageAggregationRange = NumbersUtil.parseInt(aggregationRange, 1440); + int _usageAggregationRange = UsageService.UsageStatsJobAggregationRange.value(); int HOURLY_TIME = 60; final int DAILY_TIME = 60 * 24; if (_usageAggregationRange == DAILY_TIME) { @@ -2620,10 +2620,10 @@ public boolean configure(String name, Map params) throws Configu VirtualMachine.State.getStateMachine().registerListener(new UserVmStateListener(_usageEventDao, _networkDao, _nicDao, serviceOfferingDao, _vmDao, this, _configDao)); - String value = _configDao.getValue(Config.SetVmInternalNameUsingDisplayName.key()); + String value = _configDao.getValue(SetVmInternalNameUsingDisplayName.key()); _instanceNameFlag = (value == null) ? false : Boolean.parseBoolean(value); - _scaleRetry = NumbersUtil.parseInt(configs.get(Config.ScaleRetry.key()), 2); + _scaleRetry = NumbersUtil.parseInt(configs.get(ScaleRetry.key()), 2); _vmIpFetchThreadExecutor = Executors.newFixedThreadPool(VmIpFetchThreadPoolMax.value(), new NamedThreadFactory("vmIpFetchThread")); logger.info("User VM Manager is configured."); @@ -5262,8 +5262,8 @@ private void updateVMDiskController(UserVmVO vm, Map customParam // Don't override if VM already has root/data disk controller detail if (vm.getDetail(VmDetailConstants.ROOT_DISK_CONTROLLER) == null) { - String vmwareRootDiskControllerTypeFromSetting = StringUtils.defaultIfEmpty(_configDao.getValue(Config.VmwareRootDiskControllerType.key()), - Config.VmwareRootDiskControllerType.getDefaultValue()); + String vmwareRootDiskControllerTypeFromSetting = StringUtils.defaultIfEmpty(_configDao.getValue(ManagementServer.VmwareRootDiskControllerType.key()), + ManagementServer.VmwareRootDiskControllerType.defaultValue()); vm.setDetail(VmDetailConstants.ROOT_DISK_CONTROLLER, vmwareRootDiskControllerTypeFromSetting); } @@ -5620,7 +5620,7 @@ private void addUserVMCmdlineArgs(Long vmId, VirtualMachineProfile profile, Depl } if (nic.getTrafficType() == TrafficType.Management) { - String mgmt_cidr = _configDao.getValue(Config.ManagementNetwork.key()); + String mgmt_cidr = _configDao.getValue(ManagementServer.ManagementNetwork.key()); if (NetUtils.isValidIp4Cidr(mgmt_cidr)) { buf.append(" mgmtcidr=").append(mgmt_cidr); } @@ -9716,7 +9716,8 @@ public ConfigKey[] getConfigKeys() { KvmAdditionalConfigAllowList, XenServerAdditionalConfigAllowList, VmwareAdditionalConfigAllowList, DestroyRootVolumeOnVmDestruction, EnforceStrictResourceLimitHostTagCheck, StrictHostTags, AllowUserForceStopVm, VmDistinctHostNameScope, VmwareAdditionalDetailsFromOvaEnabled, VmwareAllowedAdditionalDetailsFromOva, AllowDifferentHostTagsOfferingsForVmScale, - AutoMigrateVmOnLiveScaleInsufficientCapacity, EnforceResourceLimitOnValidationVm}; + AutoMigrateVmOnLiveScaleInsufficientCapacity, EnforceResourceLimitOnValidationVm, ExpungeDelay, ExpungeInterval, ScaleRetry, + SetVmInternalNameUsingDisplayName, CapacitySkipcountingHours}; } @Override @@ -9846,7 +9847,7 @@ private void destroyVolumeInContext(UserVmVO vm, boolean expunge, VolumeVO volum } private String getInternalName(long accountId, long vmId) { - String instanceSuffix = _configDao.getValue(Config.InstanceName.key()); + String instanceSuffix = _configDao.getValue(AgentManager.InstanceName.key()); if (instanceSuffix == null) { instanceSuffix = "DEFAULT"; } diff --git a/server/src/main/java/com/cloud/vm/UserVmStateListener.java b/server/src/main/java/com/cloud/vm/UserVmStateListener.java index aa1805d3366e..f653325d20c5 100644 --- a/server/src/main/java/com/cloud/vm/UserVmStateListener.java +++ b/server/src/main/java/com/cloud/vm/UserVmStateListener.java @@ -30,13 +30,13 @@ import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import com.cloud.configuration.Config; import com.cloud.event.EventCategory; import com.cloud.event.EventTypes; import com.cloud.event.UsageEventUtils; import com.cloud.event.dao.UsageEventDao; import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.NetworkVO; +import com.cloud.server.ManagementServer; import com.cloud.server.ManagementService; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.utils.component.ComponentContext; @@ -122,7 +122,7 @@ private void generateUsageEvent(Long serviceOfferingId, VirtualMachine vm, Stri private void pubishOnEventBus(String event, String status, VirtualMachine vo, VirtualMachine.State oldState, VirtualMachine.State newState) { - String configKey = Config.PublishResourceStateEvent.key(); + String configKey = ManagementServer.PublishResourceStateEvent.key(); String value = _configDao.getValue(configKey); boolean configValue = Boolean.parseBoolean(value); if(!configValue) diff --git a/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java index ea985a0dbb52..774a5d36f8bb 100644 --- a/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java @@ -1467,6 +1467,6 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {VMSnapshotExpireInterval, VMSnapshotMax}; + return new ConfigKey[] {VMSnapshotExpireInterval, VMSnapshotMax, VMSnapshotCreateWait}; } } diff --git a/server/src/main/java/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java b/server/src/main/java/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java index a448c612ece9..33a153ddd88e 100644 --- a/server/src/main/java/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java +++ b/server/src/main/java/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java @@ -42,7 +42,6 @@ import com.cloud.agent.AgentManager; import com.cloud.agent.api.routing.GlobalLoadBalancerConfigCommand; import com.cloud.agent.api.routing.SiteLoadBalancerConfig; -import com.cloud.configuration.Config; import com.cloud.event.ActionEvent; import com.cloud.event.EventTypes; import com.cloud.event.UsageEventUtils; @@ -58,6 +57,7 @@ import com.cloud.network.rules.RulesManager; import com.cloud.region.ha.GlobalLoadBalancerRule; import com.cloud.region.ha.GlobalLoadBalancingRulesService; +import com.cloud.server.ManagementServer; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.utils.Pair; @@ -143,7 +143,7 @@ public GlobalLoadBalancerRule createGlobalLoadBalancerRule(CreateGlobalLoadBalan throw new InvalidParameterValueException("Invalid region ID: " + regionId); } - String providerDnsName = _globalConfigDao.getValue(Config.CloudDnsName.key()); + String providerDnsName = _globalConfigDao.getValue(ManagementServer.CloudDnsName.key()); if (!region.checkIfServiceEnabled(Region.Service.Gslb) || (providerDnsName == null)) { throw new CloudRuntimeException("GSLB service is not enabled in region : " + region.getName()); } @@ -625,7 +625,7 @@ private boolean applyGlobalLoadBalancerRuleConfig(long gslbRuleId, boolean revok // each Gslb rule will have a FQDN, formed from the domain name associated with the gslb rule // and the deployment DNS name configured in global config parameter 'cloud.dns.name' String domainName = gslbRule.getGslbDomain(); - String providerDnsName = _globalConfigDao.getValue(Config.CloudDnsName.key()); + String providerDnsName = _globalConfigDao.getValue(ManagementServer.CloudDnsName.key()); String gslbFqdn = domainName + "." + providerDnsName; GlobalLoadBalancerConfigCommand gslbConfigCmd = new GlobalLoadBalancerConfigCommand(gslbFqdn, lbMethod, persistenceMethod, serviceType, gslbRuleId, revoke); diff --git a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java index 840a1de45962..dae1239f3ca2 100644 --- a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java @@ -39,7 +39,6 @@ import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.RemoteInstanceTO; import com.cloud.agent.api.to.StorageFilerTO; -import com.cloud.configuration.Config; import com.cloud.configuration.Resource; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterVO; @@ -1417,7 +1416,7 @@ protected void basicParametersCheckForImportInstance(String name, Long domainId, private void checkVmwareInstanceNameForImportInstance(Hypervisor.HypervisorType hypervisorType, String instanceName, String hostName, DataCenter zone) { if (hypervisorType.equals(Hypervisor.HypervisorType.VMware) && - Boolean.parseBoolean(configurationDao.getValue(Config.SetVmInternalNameUsingDisplayName.key()))) { + Boolean.parseBoolean(configurationDao.getValue(UserVmManager.SetVmInternalNameUsingDisplayName.key()))) { // If global config vm.instancename.flag is set to true, then CS will set guest VM's name as it appears on the hypervisor, to its hostname. // In case of VMware since VM name must be unique within a DC, check if VM with the same hostname already exists in the zone. VMInstanceVO vmByHostName = vmDao.findVMByHostNameInZone(hostName, zone.getId()); diff --git a/server/src/test/java/com/cloud/configuration/ConfigurationManagerImplTest.java b/server/src/test/java/com/cloud/configuration/ConfigurationManagerImplTest.java index 9a0b150780e4..04cc88a6e47d 100644 --- a/server/src/test/java/com/cloud/configuration/ConfigurationManagerImplTest.java +++ b/server/src/test/java/com/cloud/configuration/ConfigurationManagerImplTest.java @@ -863,7 +863,7 @@ public void validateValueRangeTestReturnsNotNullWhenConfigKeyHasRangeAndValueIsI @Test public void validateValueRangeTestValidatesValueWhenConfigHasRange() { - Config config = Config.SecStorageEncryptCopy; + Config config = Config.CheckPodCIDRs; String name = config.name(); String value = "value"; String expectedResult = "expectedResult"; @@ -877,14 +877,16 @@ public void validateValueRangeTestValidatesValueWhenConfigHasRange() { @Test public void validateValueRangeTestValidatesIntValueWhenConfigHasNumericRange() { - Config config = Config.RouterExtraPublicNics; - String name = config.name(); + Config config = Mockito.mock(Config.class); + String range = "0-5"; + Mockito.doReturn(range).when(config).getRange(); + String name = "some.numeric.range.config"; String value = "1"; String expectedResult = "expectedResult"; - Mockito.doReturn(expectedResult).when(configurationManagerImplSpy).validateIfIntValueIsInRange(name, value, config.getRange()); + Mockito.doReturn(expectedResult).when(configurationManagerImplSpy).validateIfIntValueIsInRange(name, value, range); - String result = configurationManagerImplSpy.validateValueRange(name, value, config.getType(), config); + String result = configurationManagerImplSpy.validateValueRange(name, value, Integer.class, config); Assert.assertEquals(expectedResult, result); } @@ -957,7 +959,7 @@ public void testValidateConfigurationAllowedOnlyForDefaultAdmin_withValidConfigN @Test public void getConfigurationTypeWrapperClassTestReturnsConfigType() { - Config configuration = Config.AlertEmailAddresses; + Config configuration = Config.AlertSMTPConnectionTimeout; Assert.assertEquals(configuration.getType(), configurationManagerImplSpy.getConfigurationTypeWrapperClass(configuration.key())); } diff --git a/server/src/test/java/com/cloud/configuration/ConfigurationManagerTest.java b/server/src/test/java/com/cloud/configuration/ConfigurationManagerTest.java index 8873d58de605..d36d36b0560c 100644 --- a/server/src/test/java/com/cloud/configuration/ConfigurationManagerTest.java +++ b/server/src/test/java/com/cloud/configuration/ConfigurationManagerTest.java @@ -61,6 +61,7 @@ import com.cloud.network.dao.PhysicalNetworkVO; import com.cloud.offering.DiskOffering; import com.cloud.projects.ProjectManager; +import com.cloud.server.ManagementServer; import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.StoragePoolTagVO; import com.cloud.storage.VolumeVO; @@ -1425,7 +1426,7 @@ public void testEdgeZoneCreatePod() { Mockito.when(zone.getType()).thenReturn(DataCenter.Type.Edge); Mockito.when(zone.getId()).thenReturn(1L); Mockito.when(_zoneDao.findById(Mockito.anyLong())).thenReturn(zone); - Mockito.when(_configDao.getValue(Config.ControlCidr.key())).thenReturn(Config.ControlCidr.getDefaultValue()); + Mockito.when(_configDao.getValue(ManagementServer.ControlCidr.key())).thenReturn(ManagementServer.ControlCidr.defaultValue()); Mockito.when(_podDao.persist(Mockito.any(HostPodVO.class))).thenAnswer((Answer) invocation -> { HostPodVO pod = (HostPodVO)invocation.getArguments()[0]; ReflectionTestUtils.setField(pod, "uuid", UUID.randomUUID().toString()); diff --git a/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java b/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java index f655c0d74c0b..21b9446a6b72 100644 --- a/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java +++ b/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java @@ -17,9 +17,9 @@ package com.cloud.event; -import com.cloud.configuration.Config; import com.cloud.event.dao.EventDao; import com.cloud.projects.dao.ProjectDao; +import com.cloud.server.ManagementServer; import com.cloud.user.Account; import com.cloud.user.AccountVO; import com.cloud.user.User; @@ -150,7 +150,7 @@ public void setup() throws Exception { */ public void setupCommonMocks() throws Exception { //Some basic mocks. - Mockito.when(configDao.getValue(Config.PublishActionEvent.key())).thenReturn("true"); + Mockito.when(configDao.getValue(ManagementServer.PublishActionEvent.key())).thenReturn("true"); componentContextMocked = Mockito.mockStatic(ComponentContext.class); Mockito.when(ComponentContext.getComponent(EventBus.class)).thenReturn(eventBus); persistedEvents = new ArrayList<>(); diff --git a/server/src/test/java/com/cloud/event/ActionEventUtilsTest.java b/server/src/test/java/com/cloud/event/ActionEventUtilsTest.java index aba8acf59c26..32788f048f2b 100644 --- a/server/src/test/java/com/cloud/event/ActionEventUtilsTest.java +++ b/server/src/test/java/com/cloud/event/ActionEventUtilsTest.java @@ -43,10 +43,10 @@ import org.mockito.junit.MockitoJUnitRunner; import org.mockito.stubbing.Answer; -import com.cloud.configuration.Config; import com.cloud.event.dao.EventDao; import com.cloud.network.IpAddress; import com.cloud.projects.dao.ProjectDao; +import com.cloud.server.ManagementServer; import com.cloud.storage.Snapshot; import com.cloud.user.Account; import com.cloud.user.AccountVO; @@ -148,7 +148,7 @@ public void setup() throws Exception { */ public void setupCommonMocks() throws Exception { //Some basic mocks. - Mockito.when(configDao.getValue(Config.PublishActionEvent.key())).thenReturn("true"); + Mockito.when(configDao.getValue(ManagementServer.PublishActionEvent.key())).thenReturn("true"); componentContextMocked = Mockito.mockStatic(ComponentContext.class); componentContextMocked.when(() -> ComponentContext.getComponent(EventDistributor.class)).thenReturn(eventDistributor); diff --git a/server/src/test/java/com/cloud/network/element/ConfigDriveNetworkElementTest.java b/server/src/test/java/com/cloud/network/element/ConfigDriveNetworkElementTest.java index 336f9990c12b..d689ec7a62d0 100644 --- a/server/src/test/java/com/cloud/network/element/ConfigDriveNetworkElementTest.java +++ b/server/src/test/java/com/cloud/network/element/ConfigDriveNetworkElementTest.java @@ -104,7 +104,6 @@ @RunWith(MockitoJUnitRunner.class) public class ConfigDriveNetworkElementTest { - public static final String CLOUD_ID = "xx"; public static final String PUBLIC_KEY = "publicKey"; public static final String PASSWORD = "password"; public static final long NETWORK_ID = 1L; @@ -178,7 +177,6 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { when(_serviceOfferingDao.findByIdIncludingRemoved(VMID, SOID)).thenReturn(serviceOfferingVO); when(_guestOSDao.findById(Mockito.anyLong())).thenReturn(guestOSVO); when(_guestOSCategoryDao.findById(Mockito.anyLong())).thenReturn(guestOSCategoryVo); - when(_configDao.getValue("cloud.identifier")).thenReturn(CLOUD_ID); when(guestOSCategoryVo.getName()).thenReturn("Linux"); when(dataCenterVO.getName()).thenReturn(ZONENAME); when(serviceOfferingVO.getDisplayText()).thenReturn(VMOFFERING); diff --git a/server/src/test/java/com/cloud/vm/FirstFitPlannerTest.java b/server/src/test/java/com/cloud/vm/FirstFitPlannerTest.java index 5b877cc66169..8783808bc371 100644 --- a/server/src/test/java/com/cloud/vm/FirstFitPlannerTest.java +++ b/server/src/test/java/com/cloud/vm/FirstFitPlannerTest.java @@ -65,7 +65,6 @@ import com.cloud.capacity.Capacity; import com.cloud.capacity.CapacityManager; import com.cloud.capacity.dao.CapacityDao; -import com.cloud.configuration.Config; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.ClusterDao; @@ -159,7 +158,7 @@ public void setUp() { when(configDepot.global()).thenReturn(configDao); when(configDao.getValue(Mockito.anyString())).thenReturn(null); - when(configDao.getValue(Config.ImplicitHostTags.key())).thenReturn("GPU"); + when(configDao.getValue(DeploymentClusterPlanner.ImplicitHostTags.key())).thenReturn("GPU"); ComponentContext.initComponentsLifeCycle(); acct.setType(Account.Type.ADMIN); diff --git a/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/PremiumSecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/PremiumSecondaryStorageManagerImpl.java index 8c2a6bbd9a39..9e05fe96c427 100644 --- a/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/PremiumSecondaryStorageManagerImpl.java +++ b/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/PremiumSecondaryStorageManagerImpl.java @@ -26,8 +26,8 @@ import javax.naming.ConfigurationException; +import com.cloud.agent.AgentManager; import com.cloud.agent.api.Command; -import com.cloud.configuration.Config; import com.cloud.consoleproxy.ConsoleProxyManager; import com.cloud.host.Host; import com.cloud.host.HostVO; @@ -79,10 +79,10 @@ public class PremiumSecondaryStorageManagerImpl extends SecondaryStorageManagerI public boolean configure(String name, Map params) throws ConfigurationException { super.configure(name, params); - _capacityPerSSVM = NumbersUtil.parseInt(_configDao.getValue(Config.SecStorageSessionMax.key()), DEFAULT_SS_VM_CAPACITY); - _standbyCapacity = NumbersUtil.parseInt(_configDao.getValue(Config.SecStorageCapacityStandby.key()), DEFAULT_STANDBY_CAPACITY); + _capacityPerSSVM = NumbersUtil.parseInt(_configDao.getValue(AgentManager.SecStorageSessionMax.key()), DEFAULT_SS_VM_CAPACITY); + _standbyCapacity = NumbersUtil.parseInt(_configDao.getValue(AgentManager.SecStorageCapacityStandby.key()), DEFAULT_STANDBY_CAPACITY); - int nMaxExecutionMinutes = NumbersUtil.parseInt(_configDao.getValue(Config.SecStorageCmdExecutionTimeMax.key()), 30); + int nMaxExecutionMinutes = NumbersUtil.parseInt(_configDao.getValue(AgentManager.SecStorageCmdExecutionTimeMax.key()), 30); _maxExecutionTimeMs = nMaxExecutionMinutes * 60 * 1000; migrateCapPerSSVM = StorageManager.SecStorageMaxMigrateSessions.value(); @@ -239,7 +239,7 @@ private List findAllActiveCopyCommands(long dcId, Date cutTime } private boolean reserveStandbyCapacity() { - String value = _configDao.getValue(Config.SystemVMAutoReserveCapacity.key()); + String value = _configDao.getValue(SystemVMAutoReserveCapacity.key()); if (value != null && value.equalsIgnoreCase("true")) { return true; } diff --git a/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java index 9d4c73111595..0b240115229f 100644 --- a/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java +++ b/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java @@ -16,7 +16,6 @@ // under the License. package org.apache.cloudstack.secondarystorage; -import static com.cloud.configuration.Config.SecStorageAllowedInternalDownloadSites; import static com.cloud.vm.VirtualMachineManager.SystemVmEnableUserData; import java.net.URI; @@ -74,7 +73,6 @@ import com.cloud.agent.manager.Commands; import com.cloud.capacity.dao.CapacityDao; import com.cloud.cluster.ClusterManager; -import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManagerImpl; import com.cloud.configuration.ZoneConfig; import com.cloud.consoleproxy.ConsoleProxyManager; @@ -116,6 +114,7 @@ import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; import com.cloud.resource.UnableDeleteHostException; +import com.cloud.server.ManagementServer; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.ImageStoreDetailsUtil; @@ -337,7 +336,7 @@ public boolean generateSetupCommand(Long ssHostId) { String nfsVersion = imageStoreDetailsUtil.getNfsVersion(ssStore.getId()); setupCmd.setNfsVersion(nfsVersion); - String postUploadKey = _configDao.getValue(Config.SSVMPSK.key()); + String postUploadKey = TemplateManager.SSVMPSK.value(); setupCmd.setPostUploadKey(postUploadKey); Answer answer = _agentMgr.easySend(ssHostId, setupCmd); @@ -918,7 +917,7 @@ public boolean configure(String name, Map params) throws Configu Map configs = _configDao.getConfiguration("management-server", params); _secStorageVmMtuSize = NumbersUtil.parseInt(configs.get("secstorage.vm.mtu.size"), DEFAULT_SS_VM_MTUSIZE); - boolean _useServiceVM = BooleanUtils.toBoolean(_configDao.getValue("secondary.storage.vm")); + boolean _useServiceVM = UseSecondaryStorageVm.value(); _useSSlCopy = BooleanUtils.toBoolean(_configDao.getValue("secstorage.encrypt.copy")); String ssvmUrlDomain = _configDao.getValue("secstorage.ssl.cert.domain"); @@ -943,7 +942,7 @@ public boolean configure(String name, Map params) throws Configu _itMgr.registerGuru(VirtualMachine.Type.SecondaryStorageVm, this); - String configKey = Config.SecondaryStorageServiceOffering.key(); + String configKey = SecondaryStorageServiceOffering.key(); String ssvmSrvcOffIdStr = configs.get(configKey); if (ssvmSrvcOffIdStr != null) { _serviceOffering = _offeringDao.findByUuid(ssvmSrvcOffIdStr); @@ -980,7 +979,7 @@ public boolean configure(String name, Map params) throws Configu _loadScanner.initScan(STARTUP_DELAY_IN_MILLISECONDS, SecondaryStorageCapacityScanInterval.value()); } - _httpProxy = configs.get(Config.SecStorageProxy.key()); + _httpProxy = configs.get(AgentManager.SecStorageProxy.key()); if (_httpProxy != null) { boolean valid = true; String errMsg = null; @@ -1198,7 +1197,7 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, Depl buf.append(" gateway=").append(nic.getIPv4Gateway()); } if (nic.getTrafficType() == TrafficType.Management) { - String mgmt_cidr = _configDao.getValue(Config.ManagementNetwork.key()); + String mgmt_cidr = _configDao.getValue(ManagementServer.ManagementNetwork.key()); if (NetUtils.isValidCidrList(mgmt_cidr)) { logger.debug("Management server cidr list is " + mgmt_cidr); buf.append(" mgmtcidr=").append(mgmt_cidr); @@ -1550,7 +1549,10 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { return new ConfigKey[] {NTPServerConfig, MaxNumberOfSsvmsForMigration, SecondaryStorageCapacityScanInterval, - SecondaryStorageVmUserData}; + SecondaryStorageVmUserData, UseSecondaryStorageVm, MountParent, SystemVMAutoReserveCapacity, + SystemVMRandomPassword, MaxTemplateAndIsoSize, SecStorageAllowedInternalDownloadSites, + SecStorageEncryptCopy, SecStorageSecureCopyCert, ExtractURLCleanUpInterval, DisableExtraction, + ExtractURLExpirationInterval, SecondaryStorageServiceOffering}; } } diff --git a/usage/src/main/java/com/cloud/usage/UsageAlertManagerImpl.java b/usage/src/main/java/com/cloud/usage/UsageAlertManagerImpl.java index 675118ddfab0..3ddfe66e3d2c 100644 --- a/usage/src/main/java/com/cloud/usage/UsageAlertManagerImpl.java +++ b/usage/src/main/java/com/cloud/usage/UsageAlertManagerImpl.java @@ -55,8 +55,8 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager { public boolean configure(String name, Map params) throws ConfigurationException { Map configs = _configDao.getConfiguration("management-server", params); - senderAddress = configs.get("alert.email.sender"); - String emailAddressList = configs.get("alert.email.addresses"); + senderAddress = AlertEmailSender.value(); + String emailAddressList = AlertEmailAddresses.value(); recipients = null; if (emailAddressList != null) { recipients = emailAddressList.split(","); diff --git a/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java b/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java index eab371ab353f..46b7a554d16d 100644 --- a/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java +++ b/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java @@ -47,6 +47,7 @@ import org.apache.cloudstack.quota.QuotaAlertManager; import org.apache.cloudstack.quota.QuotaManager; import org.apache.cloudstack.quota.QuotaStatement; +import org.apache.cloudstack.usage.UsageService; import org.apache.cloudstack.usage.UsageTypes; import org.apache.cloudstack.utils.usage.UsageUtils; import org.apache.commons.collections.CollectionUtils; @@ -229,16 +230,16 @@ public boolean configure(String name, Map params) throws Configu throw new CloudRuntimeException("Unhandled configuration exception", e); } - String execTime = configs.get("usage.stats.job.exec.time"); - String aggregationRange = configs.get("usage.stats.job.aggregation.range"); - String execTimeZone = configs.get("usage.execution.timezone"); - String aggregationTimeZone = configs.get("usage.aggregation.timezone"); - String sanityCheckInterval = configs.get("usage.sanity.check.interval"); + String execTime = UsageService.UsageStatsJobExecTime.value(); + Integer aggregationRange = UsageService.UsageStatsJobAggregationRange.value(); + String execTimeZone = UsageService.UsageExecutionTimezone.value(); + String aggregationTimeZone = UsageService.UsageAggregationTimezone.value(); + Integer sanityCheckInterval = UsageService.UsageSanityCheckInterval.value(); String quotaEnable = configs.get("quota.enable.service"); _runQuota = Boolean.valueOf(quotaEnable == null ? "false" : quotaEnable ); usageSnapshotSelection = Boolean.valueOf(configs.get("usage.snapshot.virtualsize.select")); if (sanityCheckInterval != null) { - _sanityCheckInterval = Integer.parseInt(sanityCheckInterval); + _sanityCheckInterval = sanityCheckInterval; } if (aggregationTimeZone != null && !aggregationTimeZone.isEmpty()) { @@ -268,7 +269,7 @@ public boolean configure(String name, Map params) throws Configu usageExecutionTimeZone.getID(), execTime, aggregationRange, DateUtil.displayDateInTimezone(usageExecutionTimeZone, new Date()), DateUtil.displayDateInTimezone(usageExecutionTimeZone, _jobExecTime.getTime()), usageAggregationTimeZone.getID()); - _aggregationDuration = Integer.parseInt(aggregationRange); + _aggregationDuration = aggregationRange; if (_aggregationDuration < UsageUtils.USAGE_AGGREGATION_RANGE_MIN) { logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + UsageUtils.USAGE_AGGREGATION_RANGE_MIN); _aggregationDuration = UsageUtils.USAGE_AGGREGATION_RANGE_MIN;