Skip to content

Commit e6d9205

Browse files
Alert type fixes and some code improvements
1 parent 3626c51 commit e6d9205

File tree

4 files changed

+49
-45
lines changed

4 files changed

+49
-45
lines changed

api/src/main/java/com/cloud/capacity/Capacity.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,49 +22,49 @@
2222
import org.apache.cloudstack.api.InternalIdentity;
2323

2424
public interface Capacity extends InternalIdentity, Identity {
25-
public static final short CAPACITY_TYPE_MEMORY = 0;
26-
public static final short CAPACITY_TYPE_CPU = 1;
27-
public static final short CAPACITY_TYPE_STORAGE = 2;
28-
public static final short CAPACITY_TYPE_STORAGE_ALLOCATED = 3;
29-
public static final short CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = 4;
30-
public static final short CAPACITY_TYPE_PRIVATE_IP = 5;
31-
public static final short CAPACITY_TYPE_SECONDARY_STORAGE = 6;
32-
public static final short CAPACITY_TYPE_VLAN = 7;
33-
public static final short CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8;
34-
public static final short CAPACITY_TYPE_LOCAL_STORAGE = 9;
35-
public static final short CAPACITY_TYPE_VIRTUAL_NETWORK_IPV6_SUBNET = 10;
36-
public static final short CAPACITY_TYPE_GPU = 19;
37-
public static final short CAPACITY_TYPE_OBJECT_STORAGE = 20;
38-
public static final short CAPACITY_TYPE_BACKUP_STORAGE = 21;
39-
40-
public static final short CAPACITY_TYPE_CPU_CORE = 90;
41-
42-
public static final List<Short> STORAGE_CAPACITY_TYPES = List.of(CAPACITY_TYPE_STORAGE,
25+
short CAPACITY_TYPE_MEMORY = 0;
26+
short CAPACITY_TYPE_CPU = 1;
27+
short CAPACITY_TYPE_STORAGE = 2;
28+
short CAPACITY_TYPE_STORAGE_ALLOCATED = 3;
29+
short CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = 4;
30+
short CAPACITY_TYPE_PRIVATE_IP = 5;
31+
short CAPACITY_TYPE_SECONDARY_STORAGE = 6;
32+
short CAPACITY_TYPE_VLAN = 7;
33+
short CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8;
34+
short CAPACITY_TYPE_LOCAL_STORAGE = 9;
35+
short CAPACITY_TYPE_VIRTUAL_NETWORK_IPV6_SUBNET = 10;
36+
short CAPACITY_TYPE_GPU = 19;
37+
short CAPACITY_TYPE_OBJECT_STORAGE = 20;
38+
short CAPACITY_TYPE_BACKUP_STORAGE = 21;
39+
40+
short CAPACITY_TYPE_CPU_CORE = 90;
41+
42+
List<Short> STORAGE_CAPACITY_TYPES = List.of(CAPACITY_TYPE_STORAGE,
4343
CAPACITY_TYPE_STORAGE_ALLOCATED,
4444
CAPACITY_TYPE_SECONDARY_STORAGE,
4545
CAPACITY_TYPE_LOCAL_STORAGE,
4646
CAPACITY_TYPE_BACKUP_STORAGE,
4747
CAPACITY_TYPE_OBJECT_STORAGE);
4848

49-
public Long getHostOrPoolId();
49+
Long getHostOrPoolId();
5050

51-
public Long getDataCenterId();
51+
Long getDataCenterId();
5252

53-
public Long getPodId();
53+
Long getPodId();
5454

55-
public Long getClusterId();
55+
Long getClusterId();
5656

57-
public long getUsedCapacity();
57+
long getUsedCapacity();
5858

59-
public long getTotalCapacity();
59+
long getTotalCapacity();
6060

61-
public short getCapacityType();
61+
short getCapacityType();
6262

63-
public long getReservedCapacity();
63+
long getReservedCapacity();
6464

65-
public Float getUsedPercentage();
65+
Float getUsedPercentage();
6666

67-
public Long getAllocatedCapacity();
67+
Long getAllocatedCapacity();
6868

69-
public String getTag();
69+
String getTag();
7070
}

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
import java.util.HashSet;
2020
import java.util.Set;
2121

22-
import com.cloud.capacity.Capacity;
2322
import com.cloud.exception.InvalidParameterValueException;
2423

2524
public interface AlertService {
26-
public static class AlertType {
27-
private static Set<AlertType> defaultAlertTypes = new HashSet<AlertType>();
25+
class AlertType {
26+
private static Set<AlertType> defaultAlertTypes = new HashSet<>();
2827
private final String name;
2928
private final short type;
3029

@@ -36,15 +35,13 @@ private AlertType(short type, String name, boolean isDefault) {
3635
}
3736
}
3837

39-
public static final AlertType ALERT_TYPE_MEMORY = new AlertType(Capacity.CAPACITY_TYPE_MEMORY, "ALERT.MEMORY", true);
40-
public static final AlertType ALERT_TYPE_CPU = new AlertType(Capacity.CAPACITY_TYPE_CPU, "ALERT.CPU", true);
41-
public static final AlertType ALERT_TYPE_STORAGE = new AlertType(Capacity.CAPACITY_TYPE_STORAGE, "ALERT.STORAGE", true);
42-
public static final AlertType ALERT_TYPE_STORAGE_ALLOCATED = new AlertType(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, "ALERT.STORAGE.ALLOCATED", true);
43-
public static final AlertType ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = new AlertType(Capacity.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP, "ALERT.NETWORK.PUBLICIP",
44-
true);
45-
public static final AlertType ALERT_TYPE_VIRTUAL_NETWORK_IPV6_SUBNET = new AlertType(Capacity.CAPACITY_TYPE_VIRTUAL_NETWORK_IPV6_SUBNET, "ALERT.NETWORK.IPV6SUBNET", true);
46-
public static final AlertType ALERT_TYPE_PRIVATE_IP = new AlertType(Capacity.CAPACITY_TYPE_PRIVATE_IP, "ALERT.NETWORK.PRIVATEIP", true);
47-
public static final AlertType ALERT_TYPE_SECONDARY_STORAGE = new AlertType(Capacity.CAPACITY_TYPE_SECONDARY_STORAGE, "ALERT.STORAGE.SECONDARY", true);
38+
public static final AlertType ALERT_TYPE_MEMORY = new AlertType((short)0, "ALERT.MEMORY", true);
39+
public static final AlertType ALERT_TYPE_CPU = new AlertType((short)1, "ALERT.CPU", true);
40+
public static final AlertType ALERT_TYPE_STORAGE = new AlertType((short)2, "ALERT.STORAGE", true);
41+
public static final AlertType ALERT_TYPE_STORAGE_ALLOCATED = new AlertType((short)3, "ALERT.STORAGE.ALLOCATED", true);
42+
public static final AlertType ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = new AlertType((short)4, "ALERT.NETWORK.PUBLICIP", true);
43+
public static final AlertType ALERT_TYPE_PRIVATE_IP = new AlertType((short)5, "ALERT.NETWORK.PRIVATEIP", true);
44+
public static final AlertType ALERT_TYPE_SECONDARY_STORAGE = new AlertType((short)6, "ALERT.STORAGE.SECONDARY", true);
4845
public static final AlertType ALERT_TYPE_HOST = new AlertType((short)7, "ALERT.COMPUTE.HOST", true);
4946
public static final AlertType ALERT_TYPE_USERVM = new AlertType((short)8, "ALERT.USERVM", true);
5047
public static final AlertType ALERT_TYPE_DOMAIN_ROUTER = new AlertType((short)9, "ALERT.SERVICE.DOMAINROUTER", true);
@@ -73,9 +70,12 @@ private AlertType(short type, String name, boolean isDefault) {
7370
public static final AlertType ALERT_TYPE_VM_SNAPSHOT = new AlertType((short)32, "ALERT.VM.SNAPSHOT", true);
7471
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)33, "ALERT.VR.PUBLIC.IFACE.MTU", true);
7572
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_BACKUP_STORAGE = new AlertType(Capacity.CAPACITY_TYPE_BACKUP_STORAGE, "ALERT.STORAGE.BACKUP", true);
78-
public static final AlertType ALERT_TYPE_OBJECT_STORAGE = new AlertType(Capacity.CAPACITY_TYPE_OBJECT_STORAGE, "ALERT.STORAGE.OBJECT", true);
73+
public static final AlertType ALERT_TYPE_VIRTUAL_NETWORK_IPV6_SUBNET = new AlertType((short)35, "ALERT.NETWORK.IPV6SUBNET", true);
74+
public static final AlertType ALERT_TYPE_EXTENSION_PATH_NOT_READY = new AlertType((short)36, "ALERT.TYPE.EXTENSION.PATH.NOT.READY", true);
75+
public static final AlertType ALERT_TYPE_BACKUP_STORAGE = new AlertType((short)37, "ALERT.STORAGE.BACKUP", true);
76+
public static final AlertType ALERT_TYPE_OBJECT_STORAGE = new AlertType((short)38, "ALERT.STORAGE.OBJECT", true);
77+
// Note: Add next Alert Type before this. Always check the 'main' branch and keep the next number for the Alert Type to avoid conflicts.
78+
// Do not use Capacity Type to define the Alert Type.
7979

8080
public short getType() {
8181
return type;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class ListCapacityCmd extends BaseListCmd {
6565
@Parameter(name = ApiConstants.TYPE, type = CommandType.INTEGER, description = "Lists capacity by type" + "* CAPACITY_TYPE_MEMORY = 0" + "* CAPACITY_TYPE_CPU = 1"
6666
+ "* CAPACITY_TYPE_STORAGE = 2" + "* CAPACITY_TYPE_STORAGE_ALLOCATED = 3" + "* CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = 4" + "* CAPACITY_TYPE_PRIVATE_IP = 5"
6767
+ "* CAPACITY_TYPE_SECONDARY_STORAGE = 6" + "* CAPACITY_TYPE_VLAN = 7" + "* CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8" + "* CAPACITY_TYPE_LOCAL_STORAGE = 9"
68-
+ "* CAPACITY_TYPE_GPU = 19" + "* CAPACITY_TYPE_CPU_CORE = 90.")
68+
+ "* CAPACITY_TYPE_GPU = 19" + "* CAPACITY_TYPE_OBJECT_STORAGE = 20" + "* CAPACITY_TYPE_BACKUP_STORAGE = 21" + "* CAPACITY_TYPE_CPU_CORE = 90.")
6969
private Integer type;
7070

7171
@Parameter(name = ApiConstants.SORT_BY, type = CommandType.STRING, since = "3.0.0", description = "Sort the results. Available values: Usage")

engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ ALTER TABLE `cloud`.`template_store_ref` MODIFY COLUMN `download_url` varchar(20
3030

3131
UPDATE `cloud`.`alert` SET type = 33 WHERE name = 'ALERT.VR.PUBLIC.IFACE.MTU';
3232
UPDATE `cloud`.`alert` SET type = 34 WHERE name = 'ALERT.VR.PRIVATE.IFACE.MTU';
33+
UPDATE `cloud`.`alert` SET type = 35 WHERE name = 'ALERT.NETWORK.IPV6SUBNET';
34+
UPDATE `cloud`.`alert` SET type = 36 WHERE name = 'ALERT.TYPE.EXTENSION.PATH.NOT.READY';
35+
UPDATE `cloud`.`alert` SET type = 37 WHERE name = 'ALERT.STORAGE.BACKUP';
36+
UPDATE `cloud`.`alert` SET type = 38 WHERE name = 'ALERT.STORAGE.OBJECT';
3337

3438
-- Update configuration 'kvm.ssh.to.agent' description and is_dynamic fields
3539
UPDATE `cloud`.`configuration` SET description = 'True if the management server will restart the agent service via SSH into the KVM hosts after or during maintenance operations', is_dynamic = 1 WHERE name = 'kvm.ssh.to.agent';

0 commit comments

Comments
 (0)