Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/src/main/java/com/cloud/configuration/Resource.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum ResourceType { // Primary and Secondary storage are allocated_storage and n
project("project", 5),
network("network", 6),
vpc("vpc", 7),
vm_snapshot("vm_snapshot", 12),
cpu("cpu", 8),
memory("memory", 9),
primary_storage("primary_storage", 10),
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,9 @@ public class ApiConstants {
public static final String AUTO_MIGRATE = "automigrate";
public static final String GUID = "guid";
public static final String VM_SNAPSHOT_ENABELD = "vmsnapshotenabled";
public static final String VM_SNAPSHOT_LIMIT = "vmsnapshotlimit";
public static final String VM_SNAPSHOT_TOTAL = "vmsnapshottotal";
public static final String VM_SNAPSHOT_AVAILABLE = "vmsnapshotavailable";
public static final String VSWITCH_TYPE_GUEST_TRAFFIC = "guestvswitchtype";
public static final String VSWITCH_TYPE_PUBLIC_TRAFFIC = "publicvswitchtype";
public static final String VSWITCH_NAME_GUEST_TRAFFIC = "guestvswitchname";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ListResourceLimitsCmd extends BaseListProjectAndAccountResourcesCmd
@Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "Lists resource limits by ID.")
private Long id;

@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. "
@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. "
+ "0 - Instance. Number of Instances a user can create. "
+ "1 - IP. Number of public IP addresses an account can own. "
+ "2 - Volume. Number of disk volumes an account can own. "
Expand All @@ -54,7 +54,8 @@ public class ListResourceLimitsCmd extends BaseListProjectAndAccountResourcesCmd
+ "8 - CPU. Number of CPU an account can allocate for their resources. "
+ "9 - Memory. Amount of RAM an account can allocate for their resources. "
+ "10 - PrimaryStorage. Total primary storage space (in GiB) a user can use. "
+ "11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use. ")
+ "11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use. "
+ "12 - VmSnapshot. Number of VM snapshots an account can own.")
private Integer resourceType;

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

@Parameter(name = ApiConstants.TAG, type = CommandType.STRING, description = "Tag for the resource type", since = "4.20.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class UpdateResourceCountCmd extends BaseCmd {

@Parameter(name = ApiConstants.RESOURCE_TYPE,
type = CommandType.INTEGER,
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"
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"
+ "0 - Instance. Number of Instances a user can create. "
+ "1 - IP. Number of public IP addresses a user can own. "
+ "2 - Volume. Number of disk volumes a user can create. "
Expand All @@ -72,7 +72,8 @@ public class UpdateResourceCountCmd extends BaseCmd {
+ "8 - CPU. Total number of CPU cores a user can use. "
+ "9 - Memory. Total Memory (in MB) a user can use. "
+ "10 - PrimaryStorage. Total primary storage space (in GiB) a user can use. "
+ "11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use. ")
+ "11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use."
+ "12 - VmSnapshot. Number of VM snapshots a user can create.")
private Integer resourceType;

@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "Update resource limits for project")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou
@Param(description = "The total number of Snapshots available for this Account")
private String snapshotAvailable;

@SerializedName(ApiConstants.VM_SNAPSHOT_LIMIT)
@Param(description = "the number of VM snapshots that can be stored by this account")
private String vmSnapshotLimit;

@SerializedName(ApiConstants.VM_SNAPSHOT_TOTAL)
@Param(description = "the number of VM snapshots stored by this account")
private Long vmSnapshotTotal;

@SerializedName(ApiConstants.VM_SNAPSHOT_AVAILABLE)
@Param(description = "the number of VM snapshots available for this account")
private String vmSnapshotAvailable;

@SerializedName("templatelimit")
@Param(description = "The total number of Templates which can be created by this Account")
private String templateLimit;
Expand Down Expand Up @@ -386,6 +398,21 @@ public void setSnapshotAvailable(String snapshotAvailable) {
this.snapshotAvailable = snapshotAvailable;
}

@Override
public void setVmSnapshotLimit(String vmSnapshotLimit) {
this.vmSnapshotLimit = vmSnapshotLimit;
}

@Override
public void setVmSnapshotTotal(Long vmSnapshotTotal) {
this.vmSnapshotTotal = vmSnapshotTotal;
}

@Override
public void setVmSnapshotAvailable(String vmSnapshotAvailable) {
this.vmSnapshotAvailable = vmSnapshotAvailable;
}

@Override
public void setTemplateLimit(String templateLimit) {
this.templateLimit = templateLimit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ public class DomainResponse extends BaseResponseWithAnnotations implements Resou
@SerializedName("snapshotavailable") @Param(description = "The total number of Snapshots available for this domain")
private String snapshotAvailable;

@SerializedName(ApiConstants.VM_SNAPSHOT_LIMIT)
@Param(description = "the number of VM snapshots that can be stored by this account")
private String vmSnapshotLimit;

@SerializedName(ApiConstants.VM_SNAPSHOT_TOTAL)
@Param(description = "the number of VM snapshots stored by this account")
private Long vmSnapshotTotal;

@SerializedName(ApiConstants.VM_SNAPSHOT_AVAILABLE)
@Param(description = "the number of VM snapshots available for this account")
private String vmSnapshotAvailable;
Comment on lines +109 to +118

@SerializedName("templatelimit") @Param(description = "The total number of Templates which can be created by this domain")
private String templateLimit;

Expand Down Expand Up @@ -313,6 +325,21 @@ public void setSnapshotAvailable(String snapshotAvailable) {
this.snapshotAvailable = snapshotAvailable;
}

@Override
public void setVmSnapshotLimit(String vmSnapshotLimit) {
this.vmSnapshotLimit = vmSnapshotLimit;
}

@Override
public void setVmSnapshotTotal(Long vmSnapshotTotal) {
this.vmSnapshotTotal = vmSnapshotTotal;
}

@Override
public void setVmSnapshotAvailable(String vmSnapshotAvailable) {
this.vmSnapshotAvailable = vmSnapshotAvailable;
}

@Override
public void setTemplateLimit(String templateLimit) {
this.templateLimit = templateLimit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ public class ProjectResponse extends BaseResponse implements ResourceLimitAndCou
@Param(description = "The total number of Snapshots available for this project", since = "4.2.0")
private String snapshotAvailable;

@SerializedName(ApiConstants.VM_SNAPSHOT_LIMIT)
@Param(description = "the number of VM snapshots that can be stored by this account")
private String vmSnapshotLimit;

@SerializedName(ApiConstants.VM_SNAPSHOT_TOTAL)
@Param(description = "the number of VM snapshots stored by this account")
private Long vmSnapshotTotal;

@SerializedName(ApiConstants.VM_SNAPSHOT_AVAILABLE)
@Param(description = "the number of VM snapshots available for this account")
private String vmSnapshotAvailable;
Comment on lines +192 to +201

@SerializedName("templatelimit")
@Param(description = "The total number of Templates which can be created by this project", since = "4.2.0")
private String templateLimit;
Expand Down Expand Up @@ -320,6 +332,21 @@ public void setSnapshotAvailable(String snapshotAvailable) {
this.snapshotAvailable = snapshotAvailable;
}

@Override
public void setVmSnapshotLimit(String vmSnapshotLimit) {
this.vmSnapshotLimit = vmSnapshotLimit;
}

@Override
public void setVmSnapshotTotal(Long vmSnapshotTotal) {
this.vmSnapshotTotal = vmSnapshotTotal;
}

@Override
public void setVmSnapshotAvailable(String vmSnapshotAvailable) {
this.vmSnapshotAvailable = vmSnapshotAvailable;
}

@Override
public void setTemplateLimit(String templateLimit) {
this.templateLimit = templateLimit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ public interface ResourceLimitAndCountResponse {

public void setSnapshotAvailable(String snapshotAvailable);

public void setVmSnapshotLimit(String vmSnapshotLimit);

public void setVmSnapshotTotal(Long vmSnapshotTotal);

public void setVmSnapshotAvailable(String vmSnapshotAvailable);

public void setTemplateLimit(String templateLimit);

public void setTemplateTotal(Long templateTotal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ select
`volumecount`.`count` AS `volumeTotal`,
`snapshotlimit`.`max` AS `snapshotLimit`,
`snapshotcount`.`count` AS `snapshotTotal`,
`vmsnapshotlimit`.`max` AS `vmSnapshotLimit`,
`vmsnapshotcount`.`count` AS `vmSnapshotTotal`,
`templatelimit`.`max` AS `templateLimit`,
`templatecount`.`count` AS `templateTotal`,
`vpclimit`.`max` AS `vpcLimit`,
Expand Down Expand Up @@ -112,6 +114,12 @@ from
`cloud`.`resource_count` snapshotcount ON account.id = snapshotcount.account_id
and snapshotcount.type = 'snapshot'
left join
`cloud`.`resource_limit` vmsnapshotlimit ON account.id = vmsnapshotlimit.account_id
and vmsnapshotlimit.type = 'vm_snapshot'
left join
`cloud`.`resource_count` vmsnapshotcount ON account.id = vmsnapshotcount.account_id
and vmsnapshotcount.type = 'vm_snapshot'
left join
`cloud`.`resource_limit` templatelimit ON account.id = templatelimit.account_id
and templatelimit.type = 'template'
left join
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ select
`volumecount`.`count` AS `volumeTotal`,
`snapshotlimit`.`max` AS `snapshotLimit`,
`snapshotcount`.`count` AS `snapshotTotal`,
`vmsnapshotlimit`.`max` AS `vmSnapshotLimit`,
`vmsnapshotcount`.`count` AS `vmSnapshotTotal`,
`templatelimit`.`max` AS `templateLimit`,
`templatecount`.`count` AS `templateTotal`,
`vpclimit`.`max` AS `vpcLimit`,
Expand Down Expand Up @@ -86,6 +88,12 @@ from
`cloud`.`resource_count` snapshotcount ON domain.id = snapshotcount.domain_id
and snapshotcount.type = 'snapshot'
left join
`cloud`.`resource_limit` vmsnapshotlimit ON domain.id = vmsnapshotlimit.domain_id
and vmsnapshotlimit.type = 'vm_snapshot'
left join
`cloud`.`resource_count` vmsnapshotcount ON domain.id = vmsnapshotcount.domain_id
and vmsnapshotcount.type = 'vm_snapshot'
left join
`cloud`.`resource_limit` templatelimit ON domain.id = templatelimit.domain_id
and templatelimit.type = 'template'
left join
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ public void setResourceLimits(AccountJoinVO account, boolean fullView, ResourceL
response.setSnapshotTotal(snapshotTotal);
response.setSnapshotAvailable(snapshotAvail);

Long vmSnapshotLimit = ApiDBUtils.findCorrectResourceLimit(account.getVmSnapshotLimit(), account.getId(), ResourceType.vm_snapshot);
String vmSnapshotLimitDisplay = (fullView || vmSnapshotLimit == -1) ? Resource.UNLIMITED : String.valueOf(vmSnapshotLimit);
Long vmSnapshotTotal = (account.getVmSnapshotTotal() == null) ? 0 : account.getVmSnapshotTotal();
String snapshotAvailable = (fullView || vmSnapshotLimit == -1) ? Resource.UNLIMITED : String.valueOf(vmSnapshotLimit - vmSnapshotTotal);
response.setVmSnapshotLimit(vmSnapshotLimitDisplay);
response.setVmSnapshotTotal(vmSnapshotTotal);
response.setVmSnapshotAvailable(snapshotAvailable);
Comment on lines +178 to +181

Long templateLimit = ApiDBUtils.findCorrectResourceLimit(account.getTemplateLimit(), account.getId(), ResourceType.template);
String templateLimitDisplay = (fullView || templateLimit == -1) ? Resource.UNLIMITED : String.valueOf(templateLimit);
Long templateTotal = (account.getTemplateTotal() == null) ? 0 : account.getTemplateTotal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ public void setResourceLimits(DomainJoinVO domain, boolean fullView, ResourceLim
response.setSnapshotTotal(snapshotTotal);
response.setSnapshotAvailable(snapshotAvail);

Long vmSnapshotLimit = ApiDBUtils.findCorrectResourceLimitForDomain(domain.getVmSnapshotLimit(), ResourceType.vm_snapshot, domain.getId());
String vmSnapshotLimitDisplay = (fullView || vmSnapshotLimit == -1) ? Resource.UNLIMITED : String.valueOf(vmSnapshotLimit);
Long vmSnapshotTotal = (domain.getVmSnapshotTotal() == null) ? 0 : domain.getVmSnapshotTotal();
String vmSnapshotAvailable = (fullView || vmSnapshotLimit == -1) ? Resource.UNLIMITED : String.valueOf(vmSnapshotLimit - vmSnapshotTotal);
response.setVmSnapshotLimit(vmSnapshotLimitDisplay);
response.setVmSnapshotTotal(vmSnapshotTotal);
response.setVmSnapshotAvailable(vmSnapshotAvailable);

Long templateLimit = ApiDBUtils.findCorrectResourceLimitForDomain(domain.getTemplateLimit(), ResourceType.template, domain.getId());
String templateLimitDisplay = (fullView || templateLimit == -1) ? Resource.UNLIMITED : String.valueOf(templateLimit);
Long templateTotal = (domain.getTemplateTotal() == null) ? 0 : domain.getTemplateTotal();
Expand Down
14 changes: 14 additions & 0 deletions server/src/main/java/com/cloud/api/query/vo/AccountJoinVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ public class AccountJoinVO extends BaseViewVO implements InternalIdentity, Ident
@Column(name = "snapshotTotal")
private Long snapshotTotal;

@Column(name = "vmSnapshotLimit")
private Long vmSnapshotLimit;

@Column(name = "vmSnapshotTotal")
private Long vmSnapshotTotal;

@Column(name = "templateLimit")
private Long templateLimit;

Expand Down Expand Up @@ -293,6 +299,10 @@ public Long getSnapshotTotal() {
return snapshotTotal;
}

public Long getVmSnapshotTotal() {
return vmSnapshotTotal;
}

public Long getTemplateTotal() {
return templateTotal;
}
Expand Down Expand Up @@ -349,6 +359,10 @@ public Long getSnapshotLimit() {
return snapshotLimit;
}

public Long getVmSnapshotLimit() {
return vmSnapshotLimit;
}

public Long getTemplateLimit() {
return templateLimit;
}
Expand Down
20 changes: 20 additions & 0 deletions server/src/main/java/com/cloud/api/query/vo/DomainJoinVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ public class DomainJoinVO extends BaseViewVO implements InternalIdentity, Identi
@Column(name="snapshotTotal")
private Long snapshotTotal;

@Column(name = "vmSnapshotLimit")
private Long vmSnapshotLimit;

@Column(name = "vmSnapshotTotal")
private Long vmSnapshotTotal;

@Column(name="templateLimit")
private Long templateLimit;

Expand Down Expand Up @@ -311,8 +317,14 @@ public void setSnapshotTotal(Long snapshotTotal) {
this.snapshotTotal = snapshotTotal;
}

public Long getVmSnapshotTotal() {
return vmSnapshotTotal;
}


public void setVmSnapshotTotal(Long vmSnapshotTotal) {
this.vmSnapshotTotal = vmSnapshotTotal;
}

public Long getTemplateTotal() {
return templateTotal;
Expand Down Expand Up @@ -433,6 +445,14 @@ public void setSnapshotLimit(Long snapshotLimit) {
this.snapshotLimit = snapshotLimit;
}

public Long getVmSnapshotLimit() {
return vmSnapshotLimit;
}


public void setVmSnapshotLimit(Long vmSnapshotLimit) {
this.vmSnapshotLimit = vmSnapshotLimit;
}

public Long getTemplateLimit() {
return templateLimit;
Expand Down
1 change: 1 addition & 0 deletions ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2505,6 +2505,7 @@
"label.vmlimit": "Instance limits",
"label.vmname": "Instance name",
"label.vms": "Instances",
"label.vmsnapshotlimit": "VM snapshot limits",
"label.vmscheduleactions": "Actions",
"label.vmstate": "Instance state",
"label.vmtotal": "Total of Instances",
Expand Down
1 change: 1 addition & 0 deletions ui/public/locales/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1750,6 +1750,7 @@
"label.vmlimit": "Limites de inst\u00e2ncias",
"label.vmname": "Nome da VM",
"label.vms": "VMs",
"label.vmsnapshotlimit": "Limite de snapshots de VM",
"label.vmstate": "Estado da VM",
"label.vmtotal": "VMs totais",
"label.vmware.storage.policy": "Pol\u00edtica de armazenamento do VMWare",
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/view/ResourceCountUsage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default {
return {
usageList: [
'vm', 'cpu', 'memory', 'primarystorage', 'volume', 'ip', 'network',
'vpc', 'secondarystorage', 'snapshot', 'template', 'project'
'vpc', 'secondarystorage', 'snapshot', 'vmsnapshot', 'template', 'project'
],
taggedUsage: {},
tagData: {},
Expand Down
Loading