Skip to content

Commit 7a96d5e

Browse files
authored
Merge branch 'main' into refactor-isrootadmin
2 parents d2951e6 + a38205e commit 7a96d5e

File tree

35 files changed

+1250
-168
lines changed

35 files changed

+1250
-168
lines changed

api/src/main/java/org/apache/cloudstack/alert/AlertService.java

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,24 @@
2424

2525
public interface AlertService {
2626
public static class AlertType {
27-
private static Set<AlertType> defaultAlertTypes = new HashSet<AlertType>();
27+
private static final Set<AlertType> defaultAlertTypes = new HashSet<>();
2828
private final String name;
2929
private final short type;
30+
private final boolean repetitionAllowed;
3031

31-
private AlertType(short type, String name, boolean isDefault) {
32+
private AlertType(short type, String name, boolean isDefault, boolean repetitionAllowed) {
3233
this.name = name;
3334
this.type = type;
35+
this.repetitionAllowed = repetitionAllowed;
3436
if (isDefault) {
3537
defaultAlertTypes.add(this);
3638
}
3739
}
3840

41+
private AlertType(short type, String name, boolean isDefault) {
42+
this(type, name, isDefault, false);
43+
}
44+
3945
public static final AlertType ALERT_TYPE_MEMORY = new AlertType(Capacity.CAPACITY_TYPE_MEMORY, "ALERT.MEMORY", true);
4046
public static final AlertType ALERT_TYPE_CPU = new AlertType(Capacity.CAPACITY_TYPE_CPU, "ALERT.CPU", true);
4147
public static final AlertType ALERT_TYPE_STORAGE = new AlertType(Capacity.CAPACITY_TYPE_STORAGE, "ALERT.STORAGE", true);
@@ -45,36 +51,36 @@ private AlertType(short type, String name, boolean isDefault) {
4551
public static final AlertType ALERT_TYPE_VIRTUAL_NETWORK_IPV6_SUBNET = new AlertType(Capacity.CAPACITY_TYPE_VIRTUAL_NETWORK_IPV6_SUBNET, "ALERT.NETWORK.IPV6SUBNET", true);
4652
public static final AlertType ALERT_TYPE_PRIVATE_IP = new AlertType(Capacity.CAPACITY_TYPE_PRIVATE_IP, "ALERT.NETWORK.PRIVATEIP", true);
4753
public static final AlertType ALERT_TYPE_SECONDARY_STORAGE = new AlertType(Capacity.CAPACITY_TYPE_SECONDARY_STORAGE, "ALERT.STORAGE.SECONDARY", true);
48-
public static final AlertType ALERT_TYPE_HOST = new AlertType((short)7, "ALERT.COMPUTE.HOST", true);
49-
public static final AlertType ALERT_TYPE_USERVM = new AlertType((short)8, "ALERT.USERVM", true);
50-
public static final AlertType ALERT_TYPE_DOMAIN_ROUTER = new AlertType((short)9, "ALERT.SERVICE.DOMAINROUTER", true);
51-
public static final AlertType ALERT_TYPE_CONSOLE_PROXY = new AlertType((short)10, "ALERT.SERVICE.CONSOLEPROXY", true);
54+
public static final AlertType ALERT_TYPE_HOST = new AlertType((short)7, "ALERT.COMPUTE.HOST", true, true);
55+
public static final AlertType ALERT_TYPE_USERVM = new AlertType((short)8, "ALERT.USERVM", true, true);
56+
public static final AlertType ALERT_TYPE_DOMAIN_ROUTER = new AlertType((short)9, "ALERT.SERVICE.DOMAINROUTER", true, true);
57+
public static final AlertType ALERT_TYPE_CONSOLE_PROXY = new AlertType((short)10, "ALERT.SERVICE.CONSOLEPROXY", true, true);
5258
public static final AlertType ALERT_TYPE_ROUTING = new AlertType((short)11, "ALERT.NETWORK.ROUTING", true);
53-
public static final AlertType ALERT_TYPE_STORAGE_MISC = new AlertType((short)12, "ALERT.STORAGE.MISC", true);
59+
public static final AlertType ALERT_TYPE_STORAGE_MISC = new AlertType((short)12, "ALERT.STORAGE.MISC", true, true);
5460
public static final AlertType ALERT_TYPE_USAGE_SERVER = new AlertType((short)13, "ALERT.USAGE", true);
55-
public static final AlertType ALERT_TYPE_MANAGEMENT_NODE = new AlertType((short)14, "ALERT.MANAGEMENT", true);
61+
public static final AlertType ALERT_TYPE_MANAGEMENT_NODE = new AlertType((short)14, "ALERT.MANAGEMENT", true, true);
5662
public static final AlertType ALERT_TYPE_DOMAIN_ROUTER_MIGRATE = new AlertType((short)15, "ALERT.NETWORK.DOMAINROUTERMIGRATE", true);
5763
public static final AlertType ALERT_TYPE_CONSOLE_PROXY_MIGRATE = new AlertType((short)16, "ALERT.SERVICE.CONSOLEPROXYMIGRATE", true);
5864
public static final AlertType ALERT_TYPE_USERVM_MIGRATE = new AlertType((short)17, "ALERT.USERVM.MIGRATE", true);
5965
public static final AlertType ALERT_TYPE_VLAN = new AlertType((short)18, "ALERT.NETWORK.VLAN", true);
60-
public static final AlertType ALERT_TYPE_SSVM = new AlertType((short)19, "ALERT.SERVICE.SSVM", true);
66+
public static final AlertType ALERT_TYPE_SSVM = new AlertType((short)19, "ALERT.SERVICE.SSVM", true, true);
6167
public static final AlertType ALERT_TYPE_USAGE_SERVER_RESULT = new AlertType((short)20, "ALERT.USAGE.RESULT", true);
6268
public static final AlertType ALERT_TYPE_STORAGE_DELETE = new AlertType((short)21, "ALERT.STORAGE.DELETE", true);
6369
public static final AlertType ALERT_TYPE_UPDATE_RESOURCE_COUNT = new AlertType((short)22, "ALERT.RESOURCE.COUNT", true);
6470
public static final AlertType ALERT_TYPE_USAGE_SANITY_RESULT = new AlertType((short)23, "ALERT.USAGE.SANITY", true);
6571
public static final AlertType ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP = new AlertType((short)24, "ALERT.NETWORK.DIRECTPUBLICIP", true);
6672
public static final AlertType ALERT_TYPE_LOCAL_STORAGE = new AlertType((short)25, "ALERT.STORAGE.LOCAL", true);
67-
public static final AlertType ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED = new AlertType((short)26, "ALERT.RESOURCE.EXCEED", true);
73+
public static final AlertType ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED = new AlertType((short)26, "ALERT.RESOURCE.EXCEED", true, true);
6874
public static final AlertType ALERT_TYPE_SYNC = new AlertType((short)27, "ALERT.TYPE.SYNC", true);
69-
public static final AlertType ALERT_TYPE_UPLOAD_FAILED = new AlertType((short)28, "ALERT.UPLOAD.FAILED", true);
70-
public static final AlertType ALERT_TYPE_OOBM_AUTH_ERROR = new AlertType((short)29, "ALERT.OOBM.AUTHERROR", true);
71-
public static final AlertType ALERT_TYPE_HA_ACTION = new AlertType((short)30, "ALERT.HA.ACTION", true);
72-
public static final AlertType ALERT_TYPE_CA_CERT = new AlertType((short)31, "ALERT.CA.CERT", true);
75+
public static final AlertType ALERT_TYPE_UPLOAD_FAILED = new AlertType((short)28, "ALERT.UPLOAD.FAILED", true, true);
76+
public static final AlertType ALERT_TYPE_OOBM_AUTH_ERROR = new AlertType((short)29, "ALERT.OOBM.AUTHERROR", true, true);
77+
public static final AlertType ALERT_TYPE_HA_ACTION = new AlertType((short)30, "ALERT.HA.ACTION", true, true);
78+
public static final AlertType ALERT_TYPE_CA_CERT = new AlertType((short)31, "ALERT.CA.CERT", true, true);
7379
public static final AlertType ALERT_TYPE_VM_SNAPSHOT = new AlertType((short)32, "ALERT.VM.SNAPSHOT", true);
7480
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)33, "ALERT.VR.PUBLIC.IFACE.MTU", true);
7581
public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)34, "ALERT.VR.PRIVATE.IFACE.MTU", true);
76-
public static final AlertType ALERT_TYPE_EXTENSION_PATH_NOT_READY = new AlertType((short)33, "ALERT.TYPE.EXTENSION.PATH.NOT.READY", true);
77-
public static final AlertType ALERT_TYPE_VPN_GATEWAY_OBSOLETE_PARAMETERS = new AlertType((short)34, "ALERT.S2S.VPN.GATEWAY.OBSOLETE.PARAMETERS", true);
82+
public static final AlertType ALERT_TYPE_EXTENSION_PATH_NOT_READY = new AlertType((short)33, "ALERT.TYPE.EXTENSION.PATH.NOT.READY", true, true);
83+
public static final AlertType ALERT_TYPE_VPN_GATEWAY_OBSOLETE_PARAMETERS = new AlertType((short)34, "ALERT.S2S.VPN.GATEWAY.OBSOLETE.PARAMETERS", true, true);
7884
public static final AlertType ALERT_TYPE_BACKUP_STORAGE = new AlertType(Capacity.CAPACITY_TYPE_BACKUP_STORAGE, "ALERT.STORAGE.BACKUP", true);
7985
public static final AlertType ALERT_TYPE_OBJECT_STORAGE = new AlertType(Capacity.CAPACITY_TYPE_OBJECT_STORAGE, "ALERT.STORAGE.OBJECT", true);
8086

@@ -86,6 +92,10 @@ public String getName() {
8692
return name;
8793
}
8894

95+
public boolean isRepetitionAllowed() {
96+
return repetitionAllowed;
97+
}
98+
8999
private static AlertType getAlertType(short type) {
90100
for (AlertType alertType : defaultAlertTypes) {
91101
if (alertType.getType() == type) {
@@ -109,7 +119,7 @@ public static AlertType generateAlert(short type, String name) {
109119
if (defaultAlert != null && !defaultAlert.getName().equalsIgnoreCase(name)) {
110120
throw new InvalidParameterValueException("There is a default alert having type " + type + " and name " + defaultAlert.getName());
111121
} else {
112-
return new AlertType(type, name, false);
122+
return new AlertType(type, name, false, false);
113123
}
114124
}
115125
}

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ public class ApiConstants {
503503
public static final String RECONNECT = "reconnect";
504504
public static final String RECOVER = "recover";
505505
public static final String REPAIR = "repair";
506+
public static final String REPETITION_ALLOWED = "repetitionallowed";
506507
public static final String REQUIRES_HVM = "requireshvm";
507508
public static final String RESOURCES = "resources";
508509
public static final String RESOURCE_COUNT = "resourcecount";
@@ -1167,6 +1168,7 @@ public class ApiConstants {
11671168
public static final String OVM3_VIP = "ovm3vip";
11681169
public static final String CLEAN_UP_DETAILS = "cleanupdetails";
11691170
public static final String CLEAN_UP_EXTERNAL_DETAILS = "cleanupexternaldetails";
1171+
public static final String CLEAN_UP_EXTRA_CONFIG = "cleanupextraconfig";
11701172
public static final String CLEAN_UP_PARAMETERS = "cleanupparameters";
11711173
public static final String VIRTUAL_SIZE = "virtualsize";
11721174
public static final String NETSCALER_CONTROLCENTER_ID = "netscalercontrolcenterid";

api/src/main/java/org/apache/cloudstack/api/command/admin/resource/ListAlertTypesCmd.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.admin.resource;
1818

19-
import com.cloud.user.Account;
19+
import java.util.ArrayList;
20+
import java.util.List;
21+
import java.util.Set;
22+
2023
import org.apache.cloudstack.alert.AlertService;
2124
import org.apache.cloudstack.api.APICommand;
2225
import org.apache.cloudstack.api.BaseCmd;
2326
import org.apache.cloudstack.api.response.AlertResponse;
2427
import org.apache.cloudstack.api.response.AlertTypeResponse;
2528
import org.apache.cloudstack.api.response.ListResponse;
2629

27-
import java.util.ArrayList;
28-
import java.util.List;
29-
import java.util.Set;
30+
import com.cloud.user.Account;
3031

3132
@APICommand(name = "listAlertTypes", description = "Lists all alerts types", responseObject = AlertResponse.class,
3233
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
@@ -43,7 +44,8 @@ public void execute() {
4344
ListResponse<AlertTypeResponse> response = new ListResponse<>();
4445
List<AlertTypeResponse> typeResponseList = new ArrayList<>();
4546
for (AlertService.AlertType alertType : result) {
46-
AlertTypeResponse alertResponse = new AlertTypeResponse(alertType.getType(), alertType.getName());
47+
AlertTypeResponse alertResponse = new AlertTypeResponse(alertType.getType(), alertType.getName(),
48+
alertType.isRepetitionAllowed());
4749
alertResponse.setObjectName("alerttype");
4850
typeResponseList.add(alertResponse);
4951
}

api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ public class UpdateVMCmd extends BaseCustomIdCmd implements SecurityGroupAction,
163163
description = "Lease expiry action, valid values are STOP and DESTROY")
164164
private String leaseExpiryAction;
165165

166+
@Parameter(name = ApiConstants.CLEAN_UP_EXTRA_CONFIG, type = CommandType.BOOLEAN, since = "4.23.0",
167+
description = "Optional boolean field, which indicates if extraconfig for the instance should be " +
168+
"cleaned up or not (If set to true, extraconfig removed for this instance, extraconfig field " +
169+
"ignored; if false or not set, no action)")
170+
private Boolean cleanupExtraConfig;
171+
166172
/////////////////////////////////////////////////////
167173
/////////////////// Accessors ///////////////////////
168174
/////////////////////////////////////////////////////
@@ -271,14 +277,18 @@ public String getExtraConfig() {
271277
return extraConfig;
272278
}
273279

274-
/////////////////////////////////////////////////////
275-
/////////////// API Implementation///////////////////
276-
/////////////////////////////////////////////////////
277-
278280
public Long getOsTypeId() {
279281
return osTypeId;
280282
}
281283

284+
public boolean isCleanupExtraConfig() {
285+
return Boolean.TRUE.equals(cleanupExtraConfig);
286+
}
287+
288+
/////////////////////////////////////////////////////
289+
/////////////// API Implementation///////////////////
290+
/////////////////////////////////////////////////////
291+
282292
@Override
283293
public String getCommandName() {
284294
return s_name;

api/src/main/java/org/apache/cloudstack/api/response/AlertTypeResponse.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.response;
1818

19-
import com.cloud.serializer.Param;
20-
import com.google.gson.annotations.SerializedName;
2119
import org.apache.cloudstack.api.ApiConstants;
2220
import org.apache.cloudstack.api.BaseResponse;
2321

22+
import com.cloud.serializer.Param;
23+
import com.google.gson.annotations.SerializedName;
24+
2425
public class AlertTypeResponse extends BaseResponse {
2526

2627
@SerializedName("alerttypeid")
@@ -31,6 +32,10 @@ public class AlertTypeResponse extends BaseResponse {
3132
@Param(description = "description of alert type")
3233
private String name;
3334

35+
@SerializedName(ApiConstants.REPETITION_ALLOWED)
36+
@Param(description = "Whether repetitive alerts allowed for the alert type", since = "4.22.0")
37+
private boolean repetitionAllowed = true;
38+
3439
public String getName() {
3540
return name;
3641
}
@@ -47,9 +52,10 @@ public void setUsageType(short alertType) {
4752
this.alertType = alertType;
4853
}
4954

50-
public AlertTypeResponse(short alertType, String name) {
55+
public AlertTypeResponse(short alertType, String name, boolean repetitionAllowed) {
5156
this.alertType = alertType;
5257
this.name = name;
58+
this.repetitionAllowed = repetitionAllowed;
5359
setObjectName("alerttype");
5460
}
5561
}

client/pom.xml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -666,16 +666,22 @@
666666
<build>
667667
<plugins>
668668
<plugin>
669-
<groupId>ru.concerteza.buildnumber</groupId>
670-
<artifactId>maven-jgit-buildnumber-plugin</artifactId>
671-
<version>1.2.6</version>
669+
<groupId>org.codehaus.mojo</groupId>
670+
<artifactId>buildnumber-maven-plugin</artifactId>
671+
<version>3.2.0</version>
672672
<executions>
673673
<execution>
674674
<id>git-buildnumber</id>
675675
<goals>
676-
<goal>extract-buildnumber</goal>
676+
<goal>create</goal>
677677
</goals>
678678
<phase>prepare-package</phase>
679+
<configuration>
680+
<doCheck>false</doCheck>
681+
<doUpdate>false</doUpdate>
682+
<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
683+
<revisionOnScmFailure>unknown</revisionOnScmFailure>
684+
</configuration>
679685
</execution>
680686
</executions>
681687
</plugin>
@@ -688,11 +694,11 @@
688694
<mainClass>org.apache.cloudstack.ServerDaemon</mainClass>
689695
</manifest>
690696
<manifestEntries>
691-
<X-Git-Branch>${git.branch}</X-Git-Branch>
692-
<X-Git-Tag>${git.tag}</X-Git-Tag>
693-
<X-Git-Revision>${git.revision}</X-Git-Revision>
694-
<Implementation-Revision>${git.revision}</Implementation-Revision>
695-
<Implementation-Branch>${git.branch}</Implementation-Branch>
697+
<X-Git-Branch>${scmBranch}</X-Git-Branch>
698+
<X-Git-Tag>${project.version}</X-Git-Tag>
699+
<X-Git-Revision>${buildNumber}</X-Git-Revision>
700+
<Implementation-Revision>${buildNumber}</Implementation-Revision>
701+
<Implementation-Branch>${scmBranch}</Implementation-Branch>
696702
</manifestEntries>
697703
</archive>
698704
</configuration>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public interface AlertManager extends Manager, AlertService {
4949
"Percentage (as a value between 0 and 1) of guest network IPv6 subnet utilization above which alerts will be sent.",
5050
true);
5151

52+
ConfigKey<String> AllowedRepetitiveAlertTypes = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, String.class,
53+
"alert.allowed.repetitive.types", "",
54+
"Comma-separated list of alert types (by name) that can be sent multiple times", true);
55+
5256
void clearAlert(AlertType alertType, long dataCenterId, long podId);
5357

5458
void recalculateCapacity();

engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDetailsDao.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
import com.cloud.vm.VMInstanceDetailVO;
2323

2424
public interface VMInstanceDetailsDao extends GenericDao<VMInstanceDetailVO, Long>, ResourceDetailsDao<VMInstanceDetailVO> {
25+
int removeDetailsWithPrefix(long vmId, String prefix);
2526
}

engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDetailsDaoImpl.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
package com.cloud.vm.dao;
1818

1919

20+
import org.apache.commons.lang3.StringUtils;
2021
import org.springframework.stereotype.Component;
2122

2223
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
2324

25+
import com.cloud.utils.db.SearchBuilder;
26+
import com.cloud.utils.db.SearchCriteria;
2427
import com.cloud.vm.VMInstanceDetailVO;
2528

2629
@Component
@@ -31,4 +34,18 @@ public void addDetail(long resourceId, String key, String value, boolean display
3134
super.addDetail(new VMInstanceDetailVO(resourceId, key, value, display));
3235
}
3336

37+
@Override
38+
public int removeDetailsWithPrefix(long vmId, String prefix) {
39+
if (StringUtils.isBlank(prefix)) {
40+
return 0;
41+
}
42+
SearchBuilder<VMInstanceDetailVO> sb = createSearchBuilder();
43+
sb.and("vmId", sb.entity().getResourceId(), SearchCriteria.Op.EQ);
44+
sb.and("prefix", sb.entity().getName(), SearchCriteria.Op.LIKE);
45+
sb.done();
46+
SearchCriteria<VMInstanceDetailVO> sc = sb.create();
47+
sc.setParameters("vmId", vmId);
48+
sc.setParameters("prefix", prefix + "%");
49+
return super.remove(sc);
50+
}
3451
}

0 commit comments

Comments
 (0)