Skip to content

Commit 9a723c3

Browse files
author
Fabrício Duarte
committed
Merge branch 'port-10017' into '4.20.0.0-scclouds'
Configurar limites de _backups_ Closes #2936 See merge request scclouds/scclouds!1299
2 parents c3816ad + 33615da commit 9a723c3

56 files changed

Lines changed: 1944 additions & 313 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/src/main/java/com/cloud/configuration/Resource.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public interface Resource {
2121
short RESOURCE_UNLIMITED = -1;
2222
String UNLIMITED = "Unlimited";
2323

24-
enum ResourceType { // Primary and Secondary storage are allocated_storage and not the physical storage.
24+
enum ResourceType { // All storage type resources are allocated_storage and not the physical storage.
2525
user_vm("user_vm", 0),
2626
public_ip("public_ip", 1),
2727
volume("volume", 2),
@@ -34,7 +34,12 @@ enum ResourceType { // Primary and Secondary storage are allocated_storage and n
3434
memory("memory", 9),
3535
primary_storage("primary_storage", 10),
3636
secondary_storage("secondary_storage", 11),
37-
vm_snapshot("vm_snapshot", 12);
37+
vm_snapshot("vm_snapshot", 12),
38+
backup("backup", 13),
39+
backup_storage("backup_storage", 14),
40+
bucket("bucket", 15),
41+
object_storage("object_storage", 16);
42+
3843

3944
private String name;
4045
private int ordinal;
@@ -63,6 +68,10 @@ public static ResourceType fromOrdinal(int ordinal) {
6368
}
6469
return null;
6570
}
71+
72+
public static Boolean isStorageType(ResourceType type) {
73+
return (type == primary_storage || type == secondary_storage || type == backup_storage || type == object_storage);
74+
}
6675
}
6776

6877
public static class ResourceOwnerType {

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,9 @@ public class EventTypes {
795795
// Management Server
796796
public static final String EVENT_MANAGEMENT_SERVER_REMOVE = "MANAGEMENT.SERVER.REMOVE";
797797

798+
// Resource Limit
799+
public static final String EVENT_RESOURCE_LIMIT_UPDATE = "RESOURCE.LIMIT.UPDATE";
800+
798801
static {
799802

800803
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking

api/src/main/java/com/cloud/storage/VolumeApiService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,6 @@ Volume updateVolume(long volumeId, String path, String state, Long storageId,
190190
boolean stateTransitTo(Volume vol, Volume.Event event) throws NoTransitionException;
191191

192192
Pair<String, String> checkAndRepairVolume(CheckAndRepairVolumeCmd cmd) throws ResourceAllocationException;
193+
194+
Long getVolumePhysicalSize(Storage.ImageFormat format, String path, String chainInfo);
193195
}

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,18 @@ public class ApiConstants {
5555
public static final String AVAILABLE = "available";
5656
public static final String AVAILABLE_SUBNETS = "availablesubnets";
5757
public static final String AVAILABLE_VIRTUAL_MACHINE_COUNT = "availablevirtualmachinecount";
58+
public static final String BACKUP_AVAILABLE = "backupavailable";
5859
public static final String BACKUP_ID = "backupid";
5960
public static final String BACKUP_SCHEDULE_ID = "backupscheduleid";
6061
public static final String BACKUP_OFFERING_NAME = "backupofferingname";
6162
public static final String BACKUP_OFFERING_ID = "backupofferingid";
6263
public static final String BALANCE = "balance";
6364
public static final String BALANCES = "balances";
65+
public static final String BACKUP_LIMIT = "backuplimit";
66+
public static final String BACKUP_STORAGE_AVAILABLE = "backupstorageavailable";
67+
public static final String BACKUP_STORAGE_LIMIT = "backupstoragelimit";
68+
public static final String BACKUP_STORAGE_TOTAL = "backupstoragetotal";
69+
public static final String BACKUP_TOTAL = "backuptotal";
6470
public static final String BASE64_IMAGE = "base64image";
6571
public static final String BGP_PEERS = "bgppeers";
6672
public static final String BGP_PEER_IDS = "bgppeerids";
@@ -451,6 +457,7 @@ public class ApiConstants {
451457

452458
public static final String QUICK_RESTORE = "quickrestore";
453459
public static final String SCHEDULE = "schedule";
460+
public static final String SCHEDULE_ID = "scheduleid";
454461
public static final String SCOPE = "scope";
455462
public static final String USER_SECRET_KEY = "usersecretkey";
456463
public static final String SEARCH_BASE = "searchbase";
@@ -1177,7 +1184,6 @@ public class ApiConstants {
11771184
public static final String MTU = "mtu";
11781185
public static final String AUTO_ENABLE_KVM_HOST = "autoenablekvmhost";
11791186
public static final String LIST_APIS = "listApis";
1180-
public static final String OBJECT_STORAGE_ID = "objectstorageid";
11811187
public static final String VERSIONING = "versioning";
11821188
public static final String OBJECT_LOCKING = "objectlocking";
11831189
public static final String ENCRYPTION = "encryption";
@@ -1192,7 +1198,6 @@ public class ApiConstants {
11921198
public static final String DISK_PATH = "diskpath";
11931199
public static final String IMPORT_SOURCE = "importsource";
11941200
public static final String TEMP_PATH = "temppath";
1195-
public static final String OBJECT_STORAGE = "objectstore";
11961201
public static final String HEURISTIC_RULE = "heuristicrule";
11971202
public static final String HEURISTIC_TYPE_VALID_OPTIONS = "Valid options are: ISO, SNAPSHOT, TEMPLATE and VOLUME.";
11981203
public static final String MANAGEMENT = "management";
@@ -1226,11 +1231,20 @@ public class ApiConstants {
12261231
public static final String UNIT = "unit";
12271232
public static final String QUOTA_USED = "quotaused";
12281233

1234+
// Object Storage related
1235+
public static final String BUCKET_AVAILABLE = "bucketavailable";
1236+
public static final String BUCKET_LIMIT = "bucketlimit";
1237+
public static final String BUCKET_TOTAL = "buckettotal";
1238+
public static final String OBJECT_STORAGE_ID = "objectstorageid";
1239+
public static final String OBJECT_STORAGE = "objectstore";
1240+
public static final String OBJECT_STORAGE_AVAILABLE = "objectstorageavailable";
1241+
public static final String OBJECT_STORAGE_LIMIT = "objectstoragelimit";
1242+
public static final String OBJECT_STORAGE_TOTAL = "objectstoragetotal";
1243+
12291244
public static final String PARAMETER_DESCRIPTION_ACTIVATION_RULE = "Quota tariff's activation rule. It can receive a JS script that results in either " +
12301245
"a boolean or a numeric value: if it results in a boolean value, the tariff value will be applied according to the result; if it results in a numeric value, the " +
12311246
"numeric value will be applied; if the result is neither a boolean nor a numeric value, the tariff will not be applied. If the rule is not informed, the tariff " +
12321247
"value will be applied.";
1233-
12341248
public static final String PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
12351249
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
12361250
"added, it will be interpreted as \"00:00:00\"). If the recommended format is not used, the date will be considered in the server timezone.";

api/src/main/java/org/apache/cloudstack/api/command/user/backup/CreateBackupCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public boolean isIsolated() {
114114
@Override
115115
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
116116
try {
117-
boolean result = backupManager.createBackup(this, getJob());
117+
boolean result = backupManager.createBackup(this);
118118
if (result) {
119119
SuccessResponse response = new SuccessResponse(getCommandName());
120120
response.setResponseName(getCommandName());

api/src/main/java/org/apache/cloudstack/api/command/user/bucket/CreateBucketCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class CreateBucketCmd extends BaseAsyncCreateCmd implements UserCmd {
7272
description = "Id of the Object Storage Pool where bucket is created")
7373
private long objectStoragePoolId;
7474

75-
@Parameter(name = ApiConstants.QUOTA, type = CommandType.INTEGER,description = "Bucket Quota in GB")
75+
@Parameter(name = ApiConstants.QUOTA, type = CommandType.INTEGER, required = true, description = "Bucket Quota in GiB")
7676
private Integer quota;
7777

7878
@Parameter(name = ApiConstants.ENCRYPTION, type = CommandType.BOOLEAN, description = "Enable bucket encryption")

api/src/main/java/org/apache/cloudstack/api/command/user/bucket/UpdateBucketCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class UpdateBucketCmd extends BaseCmd {
5656
@Parameter(name = ApiConstants.POLICY, type = CommandType.STRING, description = "Bucket Access Policy")
5757
private String policy;
5858

59-
@Parameter(name = ApiConstants.QUOTA, type = CommandType.INTEGER,description = "Bucket Quota in GB")
59+
@Parameter(name = ApiConstants.QUOTA, type = CommandType.INTEGER, description = "Bucket Quota in GiB")
6060
private Integer quota;
6161

6262
/////////////////////////////////////////////////////

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

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,30 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou
139139
@Param(description = "the number of VM snapshots available for this account")
140140
private String vmSnapshotAvailable;
141141

142+
@SerializedName(ApiConstants.BACKUP_LIMIT)
143+
@Param(description = "the total number of backups which can be stored by this account", since = "4.20.0.6-scclouds")
144+
private String backupLimit;
145+
146+
@SerializedName(ApiConstants.BACKUP_TOTAL)
147+
@Param(description = "the total number of backups stored by this account", since = "4.20.0.6-scclouds")
148+
private Long backupTotal;
149+
150+
@SerializedName(ApiConstants.BACKUP_AVAILABLE)
151+
@Param(description = "the total number of backups available to this account", since = "4.20.0.6-scclouds")
152+
private String backupAvailable;
153+
154+
@SerializedName(ApiConstants.BACKUP_STORAGE_LIMIT)
155+
@Param(description = "the total backup storage space (in GiB) the account can own", since = "4.20.0.6-scclouds")
156+
private String backupStorageLimit;
157+
158+
@SerializedName(ApiConstants.BACKUP_STORAGE_TOTAL)
159+
@Param(description = "the total backup storage space (in GiB) owned by the account", since = "4.20.0.6-scclouds")
160+
private Long backupStorageTotal;
161+
162+
@SerializedName(ApiConstants.BACKUP_STORAGE_AVAILABLE)
163+
@Param(description = "the total backup storage space (in GiB) available to the account", since = "4.20.0.6-scclouds")
164+
private String backupStorageAvailable;
165+
142166
@SerializedName("templatelimit")
143167
@Param(description = "the total number of templates which can be created by this account")
144168
private String templateLimit;
@@ -251,6 +275,30 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou
251275
@Param(description = "the total secondary storage space (in GiB) available to be used for this account", since = "4.2.0")
252276
private String secondaryStorageAvailable;
253277

278+
@SerializedName(ApiConstants.BUCKET_LIMIT)
279+
@Param(description = "the total number of buckets which can be stored by this account", since = "4.20.0.6-scclouds")
280+
private String bucketLimit;
281+
282+
@SerializedName(ApiConstants.BUCKET_TOTAL)
283+
@Param(description = "the total number of buckets stored by this account", since = "4.20.0.6-scclouds")
284+
private Long bucketTotal;
285+
286+
@SerializedName(ApiConstants.BUCKET_AVAILABLE)
287+
@Param(description = "the total number of buckets available to this account", since = "4.20.0.6-scclouds")
288+
private String bucketAvailable;
289+
290+
@SerializedName(ApiConstants.OBJECT_STORAGE_LIMIT)
291+
@Param(description = "the total object storage space (in GiB) the account can own", since = "4.20.0.6-scclouds")
292+
private String objectStorageLimit;
293+
294+
@SerializedName(ApiConstants.OBJECT_STORAGE_TOTAL)
295+
@Param(description = "the total object storage space (in GiB) owned by the account", since = "4.20.0.6-scclouds")
296+
private Long objectStorageTotal;
297+
298+
@SerializedName(ApiConstants.OBJECT_STORAGE_AVAILABLE)
299+
@Param(description = "the total object storage space (in GiB) available to the account", since = "4.20.0.6-scclouds")
300+
private String objectStorageAvailable;
301+
254302
@SerializedName(ApiConstants.STATE)
255303
@Param(description = "the state of the account")
256304
private String state;
@@ -421,6 +469,36 @@ public void setVmSnapshotAvailable(String vmSnapshotAvailable) {
421469
this.vmSnapshotAvailable = vmSnapshotAvailable;
422470
}
423471

472+
@Override
473+
public void setBackupLimit(String backupLimit) {
474+
this.backupLimit = backupLimit;
475+
}
476+
477+
@Override
478+
public void setBackupTotal(Long backupTotal) {
479+
this.backupTotal = backupTotal;
480+
}
481+
482+
@Override
483+
public void setBackupAvailable(String backupAvailable) {
484+
this.backupAvailable = backupAvailable;
485+
}
486+
487+
@Override
488+
public void setBackupStorageLimit(String backupStorageLimit) {
489+
this.backupStorageLimit = backupStorageLimit;
490+
}
491+
492+
@Override
493+
public void setBackupStorageTotal(Long backupStorageTotal) {
494+
this.backupStorageTotal = backupStorageTotal;
495+
}
496+
497+
@Override
498+
public void setBackupStorageAvailable(String backupStorageAvailable) {
499+
this.backupStorageAvailable = backupStorageAvailable;
500+
}
501+
424502
@Override
425503
public void setTemplateLimit(String templateLimit) {
426504
this.templateLimit = templateLimit;
@@ -580,6 +658,36 @@ public void setSecondaryStorageAvailable(String secondaryStorageAvailable) {
580658
this.secondaryStorageAvailable = secondaryStorageAvailable;
581659
}
582660

661+
@Override
662+
public void setBucketLimit(String bucketLimit) {
663+
this.bucketLimit = bucketLimit;
664+
}
665+
666+
@Override
667+
public void setBucketTotal(Long bucketTotal) {
668+
this.bucketTotal = bucketTotal;
669+
}
670+
671+
@Override
672+
public void setBucketAvailable(String bucketAvailable) {
673+
this.bucketAvailable = bucketAvailable;
674+
}
675+
676+
@Override
677+
public void setObjectStorageLimit(String objectStorageLimit) {
678+
this.objectStorageLimit = objectStorageLimit;
679+
}
680+
681+
@Override
682+
public void setObjectStorageTotal(Long objectStorageTotal) {
683+
this.objectStorageTotal = objectStorageTotal;
684+
}
685+
686+
@Override
687+
public void setObjectStorageAvailable(String objectStorageAvailable) {
688+
this.objectStorageAvailable = objectStorageAvailable;
689+
}
690+
583691
public void setDefaultZone(String defaultZoneId) {
584692
this.defaultZoneId = defaultZoneId;
585693
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ public class BackupScheduleResponse extends BaseResponse {
4040
@Param(description = "ID of the VM")
4141
private String vmId;
4242

43-
@SerializedName("schedule")
43+
@SerializedName(ApiConstants.SCHEDULE)
4444
@Param(description = "time the backup is scheduled to be taken.")
4545
private String schedule;
4646

47-
@SerializedName("intervaltype")
47+
@SerializedName(ApiConstants.INTERVAL_TYPE)
4848
@Param(description = "the interval type of the backup schedule")
4949
private DateUtil.IntervalType intervalType;
5050

51-
@SerializedName("timezone")
51+
@SerializedName(ApiConstants.TIMEZONE)
5252
@Param(description = "the time zone of the backup schedule")
5353
private String timezone;
5454

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class BucketResponse extends BaseResponseWithTagInformation implements Co
7575
private String state;
7676

7777
@SerializedName(ApiConstants.QUOTA)
78-
@Param(description = "Bucket Quota in GB")
78+
@Param(description = "Bucket Quota in GiB")
7979
private Integer quota;
8080

8181
@SerializedName(ApiConstants.ENCRYPTION)

0 commit comments

Comments
 (0)