Skip to content

Commit 1fb17fc

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

4 files changed

Lines changed: 48 additions & 44 deletions

File tree

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: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import com.cloud.exception.InvalidParameterValueException;
2424

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

@@ -36,15 +36,13 @@ private AlertType(short type, String name, boolean isDefault) {
3636
}
3737
}
3838

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);
39+
public static final AlertType ALERT_TYPE_MEMORY = new AlertType((short)0, "ALERT.MEMORY", true);
40+
public static final AlertType ALERT_TYPE_CPU = new AlertType((short)1, "ALERT.CPU", true);
41+
public static final AlertType ALERT_TYPE_STORAGE = new AlertType((short)2, "ALERT.STORAGE", true);
42+
public static final AlertType ALERT_TYPE_STORAGE_ALLOCATED = new AlertType((short)3, "ALERT.STORAGE.ALLOCATED", true);
43+
public static final AlertType ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = new AlertType((short)4, "ALERT.NETWORK.PUBLICIP", true);
44+
public static final AlertType ALERT_TYPE_PRIVATE_IP = new AlertType((short)5, "ALERT.NETWORK.PRIVATEIP", true);
45+
public static final AlertType ALERT_TYPE_SECONDARY_STORAGE = new AlertType((short)6, "ALERT.STORAGE.SECONDARY", true);
4846
public static final AlertType ALERT_TYPE_HOST = new AlertType((short)7, "ALERT.COMPUTE.HOST", true);
4947
public static final AlertType ALERT_TYPE_USERVM = new AlertType((short)8, "ALERT.USERVM", true);
5048
public static final AlertType ALERT_TYPE_DOMAIN_ROUTER = new AlertType((short)9, "ALERT.SERVICE.DOMAINROUTER", true);
@@ -73,9 +71,11 @@ private AlertType(short type, String name, boolean isDefault) {
7371
public static final AlertType ALERT_TYPE_VM_SNAPSHOT = new AlertType((short)32, "ALERT.VM.SNAPSHOT", true);
7472
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)33, "ALERT.VR.PUBLIC.IFACE.MTU", true);
7573
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);
74+
public static final AlertType ALERT_TYPE_VIRTUAL_NETWORK_IPV6_SUBNET = new AlertType((short)35, "ALERT.NETWORK.IPV6SUBNET", true);
75+
public static final AlertType ALERT_TYPE_EXTENSION_PATH_NOT_READY = new AlertType((short)36, "ALERT.TYPE.EXTENSION.PATH.NOT.READY", true);
76+
public static final AlertType ALERT_TYPE_BACKUP_STORAGE = new AlertType((short)37, "ALERT.STORAGE.BACKUP", true);
77+
public static final AlertType ALERT_TYPE_OBJECT_STORAGE = new AlertType((short)38, "ALERT.STORAGE.OBJECT", true);
78+
// Note: Do not use Capacity Type to define the Alert Type. Always check the 'main' branch and keep the next number for the Alert Type to avoid conflicts.
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)