Skip to content

Commit 1383625

Browse files
Fix *.smtp.useAuth, quota.usage.smtp.useStartTLS and *.smtp.enabledSecurityProtocols settings definitions (#9031)
* change configs definitions * add normalization query * add ui support * add labels * add end of line to SQL script
1 parent ee39104 commit 1383625

File tree

11 files changed

+56
-22
lines changed

11 files changed

+56
-22
lines changed

engine/components-api/src/main/java/com/cloud/alert/AlertManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ public interface AlertManager extends Manager, AlertService {
3838
public static final ConfigKey<Boolean> AlertSmtpUseStartTLS = new ConfigKey<Boolean>("Advanced", Boolean.class, "alert.smtp.useStartTLS", "false",
3939
"If set to true and if we enable security via alert.smtp.useAuth, this will enable StartTLS to secure the connection.", true);
4040

41-
public static final ConfigKey<String> AlertSmtpEnabledSecurityProtocols = new ConfigKey<String>("Advanced", String.class, "alert.smtp.enabledSecurityProtocols", "",
42-
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2", true);
41+
public static final ConfigKey<Boolean> AlertSmtpUseAuth = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, Boolean.class, "alert.smtp.useAuth", "false", "If true, use SMTP authentication when sending emails.", false, ConfigKey.Scope.ManagementServer);
42+
43+
public static final ConfigKey<String> AlertSmtpEnabledSecurityProtocols = new ConfigKey<String>(ConfigKey.CATEGORY_ADVANCED, String.class, "alert.smtp.enabledSecurityProtocols", "",
44+
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2", true, ConfigKey.Kind.WhitespaceSeparatedListWithOptions, "SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2");
4345

4446
public static final ConfigKey<Double> Ipv6SubnetCapacityThreshold = new ConfigKey<Double>("Advanced", Double.class,
4547
"zone.virtualnetwork.ipv6subnet.capacity.notificationthreshold",

engine/schema/src/main/resources/META-INF/db/schema-41910to42000.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,20 @@ CREATE TABLE `cloud`.`webhook_delivery` (
133133
CONSTRAINT `fk_webhook__event_id` FOREIGN KEY (`event_id`) REFERENCES `event`(`id`) ON DELETE CASCADE,
134134
CONSTRAINT `fk_webhook__webhook_id` FOREIGN KEY (`webhook_id`) REFERENCES `webhook`(`id`) ON DELETE CASCADE
135135
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
136+
137+
-- Normalize quota.usage.smtp.useStartTLS, quota.usage.smtp.useAuth, alert.smtp.useAuth and project.smtp.useAuth values
138+
UPDATE
139+
`cloud`.`configuration`
140+
SET
141+
value = "true"
142+
WHERE
143+
name IN ("quota.usage.smtp.useStartTLS", "quota.usage.smtp.useAuth", "alert.smtp.useAuth", "project.smtp.useAuth")
144+
AND value IN ("true", "y", "t", "1", "on", "yes");
145+
146+
UPDATE
147+
`cloud`.`configuration`
148+
SET
149+
value = "false"
150+
WHERE
151+
name IN ("quota.usage.smtp.useStartTLS", "quota.usage.smtp.useAuth", "alert.smtp.useAuth", "project.smtp.useAuth")
152+
AND value NOT IN ("true", "y", "t", "1", "on", "yes");

framework/config/src/main/java/org/apache/cloudstack/framework/config/ConfigKey.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public enum Scope {
4141
}
4242

4343
public enum Kind {
44-
CSV, Order, Select
44+
CSV, Order, Select, WhitespaceSeparatedListWithOptions
4545
}
4646

4747
private final String _category;
@@ -136,6 +136,10 @@ public ConfigKey(String category, Class<T> type, String name, String defaultValu
136136
this(type, name, category, defaultValue, description, isDynamic, Scope.Global, null);
137137
}
138138

139+
public ConfigKey(String category, Class<T> type, String name, String defaultValue, String description, boolean isDynamic, Kind kind, String options) {
140+
this(type, name, category, defaultValue, description, isDynamic, Scope.Global, null, null, null, null, null, kind, options);
141+
}
142+
139143
public ConfigKey(String category, Class<T> type, String name, String defaultValue, String description, boolean isDynamic, String parent) {
140144
this(type, name, category, defaultValue, description, isDynamic, Scope.Global, null, null, parent, null, null, null, null);
141145
}

framework/quota/src/main/java/org/apache/cloudstack/quota/constant/QuotaConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ public interface QuotaConfig {
4848

4949
public static final ConfigKey<String> QuotaSmtpPort = new ConfigKey<String>("Advanced", String.class, "quota.usage.smtp.port", "", "Quota SMTP port.", true);
5050

51-
public static final ConfigKey<String> QuotaSmtpAuthType = new ConfigKey<String>("Advanced", String.class, "quota.usage.smtp.useAuth", "",
51+
public static final ConfigKey<Boolean> QuotaSmtpAuthType = new ConfigKey<Boolean>("Advanced", Boolean.class, "quota.usage.smtp.useAuth", "false",
5252
"If true, use secure SMTP authentication when sending emails.", true);
5353

5454
public static final ConfigKey<String> QuotaSmtpSender = new ConfigKey<String>("Advanced", String.class, "quota.usage.smtp.sender", "",
5555
"Sender of quota alert email (will be in the From header of the email).", true);
5656

5757
public static final ConfigKey<String> QuotaSmtpEnabledSecurityProtocols = new ConfigKey<String>("Advanced", String.class, "quota.usage.smtp.enabledSecurityProtocols", "",
58-
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2.", true);
58+
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2.", true, ConfigKey.Kind.WhitespaceSeparatedListWithOptions, "SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2");
5959

60-
public static final ConfigKey<String> QuotaSmtpUseStartTLS = new ConfigKey<String>("Advanced", String.class, "quota.usage.smtp.useStartTLS", "false",
60+
public static final ConfigKey<Boolean> QuotaSmtpUseStartTLS = new ConfigKey<Boolean>("Advanced", Boolean.class, "quota.usage.smtp.useStartTLS", "false",
6161
"If set to true and if we enable security via quota.usage.smtp.useAuth, this will enable StartTLS to secure the connection.", true);
6262

6363
public static final ConfigKey<Long> QuotaActivationRuleTimeout = new ConfigKey<>("Advanced", Long.class, "quota.activationrule.timeout", "2000", "The maximum runtime,"

server/src/main/java/com/cloud/alert/AlertManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ public String getConfigComponentName() {
800800
@Override
801801
public ConfigKey<?>[] getConfigKeys() {
802802
return new ConfigKey<?>[] {CPUCapacityThreshold, MemoryCapacityThreshold, StorageAllocatedCapacityThreshold, StorageCapacityThreshold, AlertSmtpEnabledSecurityProtocols,
803-
AlertSmtpUseStartTLS, Ipv6SubnetCapacityThreshold};
803+
AlertSmtpUseStartTLS, Ipv6SubnetCapacityThreshold, AlertSmtpUseAuth};
804804
}
805805

806806
@Override

server/src/main/java/com/cloud/configuration/Config.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public enum Config {
7878
"30000",
7979
"Socket I/O timeout value in milliseconds. -1 for infinite timeout.",
8080
null),
81-
AlertSMTPUseAuth("Alert", ManagementServer.class, String.class, "alert.smtp.useAuth", null, "If true, use SMTP authentication when sending emails.", null),
8281
AlertSMTPUsername(
8382
"Alert",
8483
ManagementServer.class,
@@ -1547,14 +1546,6 @@ public enum Config {
15471546
"Password for SMTP authentication (applies only if project.smtp.useAuth is true)",
15481547
null),
15491548
ProjectSMTPPort("Project Defaults", ManagementServer.class, Integer.class, "project.smtp.port", "465", "Port the SMTP server is listening on", null),
1550-
ProjectSMTPUseAuth(
1551-
"Project Defaults",
1552-
ManagementServer.class,
1553-
String.class,
1554-
"project.smtp.useAuth",
1555-
null,
1556-
"If true, use SMTP authentication when sending emails",
1557-
null),
15581549
ProjectSMTPUsername(
15591550
"Project Defaults",
15601551
ManagementServer.class,

server/src/main/java/com/cloud/projects/ProjectManager.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@
2222
import org.apache.cloudstack.framework.config.ConfigKey;
2323

2424
public interface ProjectManager extends ProjectService {
25-
public static final ConfigKey<Boolean> ProjectSmtpUseStartTLS = new ConfigKey<Boolean>("Advanced", Boolean.class, "project.smtp.useStartTLS", "false",
25+
public static final ConfigKey<Boolean> ProjectSmtpUseStartTLS = new ConfigKey<Boolean>(ConfigKey.CATEGORY_ADVANCED, Boolean.class, "project.smtp.useStartTLS", "false",
2626
"If set to true and if we enable security via project.smtp.useAuth, this will enable StartTLS to secure the connection.", true);
2727

28-
public static final ConfigKey<String> ProjectSmtpEnabledSecurityProtocols = new ConfigKey<String>("Advanced", String.class, "project.smtp.enabledSecurityProtocols", "",
29-
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2", true);
28+
public static final ConfigKey<String> ProjectSmtpEnabledSecurityProtocols = new ConfigKey<String>(ConfigKey.CATEGORY_ADVANCED, String.class, "project.smtp.enabledSecurityProtocols", "",
29+
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2", true, ConfigKey.Kind.WhitespaceSeparatedListWithOptions, "SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2");
30+
31+
public static final ConfigKey<Boolean> ProjectSmtpUseAuth = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, Boolean.class, "project.smtp.useAuth", "false",
32+
"If true, use SMTP authentication when sending emails", false, ConfigKey.Scope.ManagementServer);
3033

3134
boolean canAccessProjectAccount(Account caller, long accountId);
3235

server/src/main/java/com/cloud/projects/ProjectManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ public String getConfigComponentName() {
14511451

14521452
@Override
14531453
public ConfigKey<?>[] getConfigKeys() {
1454-
return new ConfigKey<?>[] {ProjectSmtpEnabledSecurityProtocols, ProjectSmtpUseStartTLS};
1454+
return new ConfigKey<?>[] {ProjectSmtpEnabledSecurityProtocols, ProjectSmtpUseStartTLS, ProjectSmtpUseAuth};
14551455
}
14561456

14571457
protected void updateProjectNameAndDisplayText(final ProjectVO project, String name, String displayText) {

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3185,6 +3185,7 @@
31853185
"message.scaleup.policy.name.continue": "Please input a name to ScaleUp policy to continue",
31863186
"message.select.a.zone": "A zone typically corresponds to a single datacenter. Multiple zones help make the cloud more reliable by providing physical isolation and redundancy.",
31873187
"message.select.affinity.groups": "Please select any affinity groups you want this Instance to belong to:",
3188+
"message.select.deselect.desired.options": "Please select / deselect the desired options",
31883189
"message.select.deselect.to.sort": "Please select / deselect to sort the values",
31893190
"message.select.destination.image.stores": "Please select Image Store(s) to which data is to be migrated to",
31903191
"message.select.disk.offering": "Please select a disk offering for disk",

ui/public/locales/pt_BR.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,6 +2317,7 @@
23172317
"message.scale.processing": "Escalonamento em progresso",
23182318
"message.select.a.zone": "A zona tipicamente corresponde a um \u00fanico datacenter. M\u00faltiplas zonas auxiliam a nuvem a ser mais confi\u00e1vel provendo isolamento f\u00edsico e redund\u00e2ncia.",
23192319
"message.select.affinity.groups": "Por favor, selecione quaisquer grupos de afinidade que voc\u00ea deseja que esta VM perten\u00e7a:",
2320+
"message.select.deselect.desired.options": "Por favor, selecione / desselecione as op\u00e7\u00f5es desejadas",
23202321
"message.select.destination.image.stores": "Por favor, selecione o(s) armazenamento(s) de imagem(ns) para os quais os dados devem ser migrados",
23212322
"message.select.disk.offering": "Por favor, selecione uma oferta de disco para o disco",
23222323
"message.select.end.date.and.time": "Selecione uma data e hor\u00e1rio final.",

0 commit comments

Comments
 (0)