Skip to content

Commit 0d6e8bf

Browse files
author
toni.zamparetti
committed
Add info of VM snapshots limits in the resource tab
1 parent 08b1d38 commit 0d6e8bf

17 files changed

Lines changed: 168 additions & 6 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ enum ResourceType { // Primary and Secondary storage are allocated_storage and n
3030
project("project", 5),
3131
network("network", 6),
3232
vpc("vpc", 7),
33+
vm_snapshot("vm_snapshot", 12),
3334
cpu("cpu", 8),
3435
memory("memory", 9),
3536
primary_storage("primary_storage", 10),

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,9 @@ public class ApiConstants {
763763
public static final String AUTO_MIGRATE = "automigrate";
764764
public static final String GUID = "guid";
765765
public static final String VM_SNAPSHOT_ENABELD = "vmsnapshotenabled";
766+
public static final String VM_SNAPSHOT_LIMIT = "vmsnapshotlimit";
767+
public static final String VM_SNAPSHOT_TOTAL = "vmsnapshottotal";
768+
public static final String VM_SNAPSHOT_AVAILABLE = "vmsnapshotavailable";
766769
public static final String VSWITCH_TYPE_GUEST_TRAFFIC = "guestvswitchtype";
767770
public static final String VSWITCH_TYPE_PUBLIC_TRAFFIC = "publicvswitchtype";
768771
public static final String VSWITCH_NAME_GUEST_TRAFFIC = "guestvswitchname";

api/src/main/java/org/apache/cloudstack/api/command/user/resource/ListResourceLimitsCmd.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class ListResourceLimitsCmd extends BaseListProjectAndAccountResourcesCmd
4242
@Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "Lists resource limits by ID.")
4343
private Long id;
4444

45-
@Parameter(name = ApiConstants.RESOURCE_TYPE, type = CommandType.INTEGER, description = "Type of resource. Values are 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 and 11. "
45+
@Parameter(name = ApiConstants.RESOURCE_TYPE, type = CommandType.INTEGER, description = "Type of resource. Values are 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11 and 12. "
4646
+ "0 - Instance. Number of Instances a user can create. "
4747
+ "1 - IP. Number of public IP addresses an account can own. "
4848
+ "2 - Volume. Number of disk volumes an account can own. "
@@ -54,7 +54,8 @@ public class ListResourceLimitsCmd extends BaseListProjectAndAccountResourcesCmd
5454
+ "8 - CPU. Number of CPU an account can allocate for their resources. "
5555
+ "9 - Memory. Amount of RAM an account can allocate for their resources. "
5656
+ "10 - PrimaryStorage. Total primary storage space (in GiB) a user can use. "
57-
+ "11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use. ")
57+
+ "11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use. "
58+
+ "12 - VmSnapshot. Number of VM snapshots an account can own.")
5859
private Integer resourceType;
5960

6061
@Parameter(name = ApiConstants.RESOURCE_TYPE_NAME, type = CommandType.STRING, description = "Type of resource (wins over resourceType if both are provided). Values are: "
@@ -69,7 +70,8 @@ public class ListResourceLimitsCmd extends BaseListProjectAndAccountResourcesCmd
6970
+ "cpu - CPU. Number of CPU an account can allocate for their resources. "
7071
+ "memory - Memory. Amount of RAM an account can allocate for their resources. "
7172
+ "primary_storage - PrimaryStorage. Total primary storage space (in GiB) a user can use. "
72-
+ "secondary_storage - SecondaryStorage. Total secondary storage space (in GiB) a user can use. ")
73+
+ "secondary_storage - SecondaryStorage. Total secondary storage space (in GiB) a user can use. "
74+
+ "vm_snapshot - VmSnapshot. Number of VM snapshots an account can own.")
7375
private String resourceTypeName;
7476

7577
@Parameter(name = ApiConstants.TAG, type = CommandType.STRING, description = "Tag for the resource type", since = "4.20.0")

api/src/main/java/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class UpdateResourceCountCmd extends BaseCmd {
6060

6161
@Parameter(name = ApiConstants.RESOURCE_TYPE,
6262
type = CommandType.INTEGER,
63-
description = "Type of resource to update. If specifies valid values are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and 11. If not specified will update all resource counts"
63+
description = "Type of resource to update. If specifies valid values are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12. If not specified will update all resource counts"
6464
+ "0 - Instance. Number of Instances a user can create. "
6565
+ "1 - IP. Number of public IP addresses a user can own. "
6666
+ "2 - Volume. Number of disk volumes a user can create. "
@@ -72,7 +72,8 @@ public class UpdateResourceCountCmd extends BaseCmd {
7272
+ "8 - CPU. Total number of CPU cores a user can use. "
7373
+ "9 - Memory. Total Memory (in MB) a user can use. "
7474
+ "10 - PrimaryStorage. Total primary storage space (in GiB) a user can use. "
75-
+ "11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use. ")
75+
+ "11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use."
76+
+ "12 - VmSnapshot. Number of VM snapshots a user can create.")
7677
private Integer resourceType;
7778

7879
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "Update resource limits for project")

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou
127127
@Param(description = "The total number of Snapshots available for this Account")
128128
private String snapshotAvailable;
129129

130+
@SerializedName(ApiConstants.VM_SNAPSHOT_LIMIT)
131+
@Param(description = "the number of VM snapshots that can be stored by this account")
132+
private String vmSnapshotLimit;
133+
134+
@SerializedName(ApiConstants.VM_SNAPSHOT_TOTAL)
135+
@Param(description = "the number of VM snapshots stored by this account")
136+
private Long vmSnapshotTotal;
137+
138+
@SerializedName(ApiConstants.VM_SNAPSHOT_AVAILABLE)
139+
@Param(description = "the number of VM snapshots available for this account")
140+
private String vmSnapshotAvailable;
141+
130142
@SerializedName("templatelimit")
131143
@Param(description = "The total number of Templates which can be created by this Account")
132144
private String templateLimit;
@@ -386,6 +398,21 @@ public void setSnapshotAvailable(String snapshotAvailable) {
386398
this.snapshotAvailable = snapshotAvailable;
387399
}
388400

401+
@Override
402+
public void setVmSnapshotLimit(String vmSnapshotLimit) {
403+
this.vmSnapshotLimit = vmSnapshotLimit;
404+
}
405+
406+
@Override
407+
public void setVmSnapshotTotal(Long vmSnapshotTotal) {
408+
this.vmSnapshotTotal = vmSnapshotTotal;
409+
}
410+
411+
@Override
412+
public void setVmSnapshotAvailable(String vmSnapshotAvailable) {
413+
this.vmSnapshotAvailable = vmSnapshotAvailable;
414+
}
415+
389416
@Override
390417
public void setTemplateLimit(String templateLimit) {
391418
this.templateLimit = templateLimit;

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ public class DomainResponse extends BaseResponseWithAnnotations implements Resou
105105
@SerializedName("snapshotavailable") @Param(description = "The total number of Snapshots available for this domain")
106106
private String snapshotAvailable;
107107

108+
@SerializedName(ApiConstants.VM_SNAPSHOT_LIMIT)
109+
@Param(description = "the number of VM snapshots that can be stored by this account")
110+
private String vmSnapshotLimit;
111+
112+
@SerializedName(ApiConstants.VM_SNAPSHOT_TOTAL)
113+
@Param(description = "the number of VM snapshots stored by this account")
114+
private Long vmSnapshotTotal;
115+
116+
@SerializedName(ApiConstants.VM_SNAPSHOT_AVAILABLE)
117+
@Param(description = "the number of VM snapshots available for this account")
118+
private String vmSnapshotAvailable;
119+
108120
@SerializedName("templatelimit") @Param(description = "The total number of Templates which can be created by this domain")
109121
private String templateLimit;
110122

@@ -313,6 +325,21 @@ public void setSnapshotAvailable(String snapshotAvailable) {
313325
this.snapshotAvailable = snapshotAvailable;
314326
}
315327

328+
@Override
329+
public void setVmSnapshotLimit(String vmSnapshotLimit) {
330+
this.vmSnapshotLimit = vmSnapshotLimit;
331+
}
332+
333+
@Override
334+
public void setVmSnapshotTotal(Long vmSnapshotTotal) {
335+
this.vmSnapshotTotal = vmSnapshotTotal;
336+
}
337+
338+
@Override
339+
public void setVmSnapshotAvailable(String vmSnapshotAvailable) {
340+
this.vmSnapshotAvailable = vmSnapshotAvailable;
341+
}
342+
316343
@Override
317344
public void setTemplateLimit(String templateLimit) {
318345
this.templateLimit = templateLimit;

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,18 @@ public class ProjectResponse extends BaseResponse implements ResourceLimitAndCou
188188
@Param(description = "The total number of Snapshots available for this project", since = "4.2.0")
189189
private String snapshotAvailable;
190190

191+
@SerializedName(ApiConstants.VM_SNAPSHOT_LIMIT)
192+
@Param(description = "the number of VM snapshots that can be stored by this account")
193+
private String vmSnapshotLimit;
194+
195+
@SerializedName(ApiConstants.VM_SNAPSHOT_TOTAL)
196+
@Param(description = "the number of VM snapshots stored by this account")
197+
private Long vmSnapshotTotal;
198+
199+
@SerializedName(ApiConstants.VM_SNAPSHOT_AVAILABLE)
200+
@Param(description = "the number of VM snapshots available for this account")
201+
private String vmSnapshotAvailable;
202+
191203
@SerializedName("templatelimit")
192204
@Param(description = "The total number of Templates which can be created by this project", since = "4.2.0")
193205
private String templateLimit;
@@ -320,6 +332,21 @@ public void setSnapshotAvailable(String snapshotAvailable) {
320332
this.snapshotAvailable = snapshotAvailable;
321333
}
322334

335+
@Override
336+
public void setVmSnapshotLimit(String vmSnapshotLimit) {
337+
this.vmSnapshotLimit = vmSnapshotLimit;
338+
}
339+
340+
@Override
341+
public void setVmSnapshotTotal(Long vmSnapshotTotal) {
342+
this.vmSnapshotTotal = vmSnapshotTotal;
343+
}
344+
345+
@Override
346+
public void setVmSnapshotAvailable(String vmSnapshotAvailable) {
347+
this.vmSnapshotAvailable = vmSnapshotAvailable;
348+
}
349+
323350
@Override
324351
public void setTemplateLimit(String templateLimit) {
325352
this.templateLimit = templateLimit;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ public interface ResourceLimitAndCountResponse {
8484

8585
public void setSnapshotAvailable(String snapshotAvailable);
8686

87+
public void setVmSnapshotLimit(String vmSnapshotLimit);
88+
89+
public void setVmSnapshotTotal(Long vmSnapshotTotal);
90+
91+
public void setVmSnapshotAvailable(String vmSnapshotAvailable);
92+
8793
public void setTemplateLimit(String templateLimit);
8894

8995
public void setTemplateTotal(Long templateTotal);

engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ select
5252
`volumecount`.`count` AS `volumeTotal`,
5353
`snapshotlimit`.`max` AS `snapshotLimit`,
5454
`snapshotcount`.`count` AS `snapshotTotal`,
55+
`vmsnapshotlimit`.`max` AS `vmSnapshotLimit`,
56+
`vmsnapshotcount`.`count` AS `vmSnapshotTotal`,
5557
`templatelimit`.`max` AS `templateLimit`,
5658
`templatecount`.`count` AS `templateTotal`,
5759
`vpclimit`.`max` AS `vpcLimit`,
@@ -112,6 +114,12 @@ from
112114
`cloud`.`resource_count` snapshotcount ON account.id = snapshotcount.account_id
113115
and snapshotcount.type = 'snapshot'
114116
left join
117+
`cloud`.`resource_limit` vmsnapshotlimit ON account.id = vmsnapshotlimit.account_id
118+
and vmsnapshotlimit.type = 'vm_snapshot'
119+
left join
120+
`cloud`.`resource_count` vmsnapshotcount ON account.id = vmsnapshotcount.account_id
121+
and vmsnapshotcount.type = 'vm_snapshot'
122+
left join
115123
`cloud`.`resource_limit` templatelimit ON account.id = templatelimit.account_id
116124
and templatelimit.type = 'template'
117125
left join

engine/schema/src/main/resources/META-INF/db/views/cloud.domain_view.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ select
4343
`volumecount`.`count` AS `volumeTotal`,
4444
`snapshotlimit`.`max` AS `snapshotLimit`,
4545
`snapshotcount`.`count` AS `snapshotTotal`,
46+
`vmsnapshotlimit`.`max` AS `vmSnapshotLimit`,
47+
`vmsnapshotcount`.`count` AS `vmSnapshotTotal`,
4648
`templatelimit`.`max` AS `templateLimit`,
4749
`templatecount`.`count` AS `templateTotal`,
4850
`vpclimit`.`max` AS `vpcLimit`,
@@ -86,6 +88,12 @@ from
8688
`cloud`.`resource_count` snapshotcount ON domain.id = snapshotcount.domain_id
8789
and snapshotcount.type = 'snapshot'
8890
left join
91+
`cloud`.`resource_limit` vmsnapshotlimit ON domain.id = vmsnapshotlimit.domain_id
92+
and vmsnapshotlimit.type = 'vm_snapshot'
93+
left join
94+
`cloud`.`resource_count` vmsnapshotcount ON domain.id = vmsnapshotcount.domain_id
95+
and vmsnapshotcount.type = 'vm_snapshot'
96+
left join
8997
`cloud`.`resource_limit` templatelimit ON domain.id = templatelimit.domain_id
9098
and templatelimit.type = 'template'
9199
left join

0 commit comments

Comments
 (0)