Skip to content

Commit 2b84ddb

Browse files
author
Daan Hoogland
committed
Merge branch '22.0.1' into 4.22
2 parents 7c7b2ae + d6f4fc3 commit 2b84ddb

File tree

90 files changed

+3055
-1657
lines changed

Some content is hidden

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

90 files changed

+3055
-1657
lines changed

api/src/main/java/com/cloud/agent/api/to/BucketTO.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ public final class BucketTO {
2626

2727
private String secretKey;
2828

29+
private long accountId;
30+
2931
public BucketTO(Bucket bucket) {
3032
this.name = bucket.getName();
3133
this.accessKey = bucket.getAccessKey();
3234
this.secretKey = bucket.getSecretKey();
35+
this.accountId = bucket.getAccountId();
3336
}
3437

3538
public BucketTO(String name) {
@@ -47,4 +50,8 @@ public String getAccessKey() {
4750
public String getSecretKey() {
4851
return this.secretKey;
4952
}
53+
54+
public long getAccountId() {
55+
return this.accountId;
56+
}
5057
}

api/src/main/java/com/cloud/projects/ProjectService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public interface ProjectService {
8282

8383
Project updateProject(long id, String name, String displayText, String newOwnerName, Long userId, Role newRole) throws ResourceAllocationException;
8484

85-
boolean addAccountToProject(long projectId, String accountName, String email, Long projectRoleId, Role projectRoleType);
85+
boolean addAccountToProject(long projectId, String accountName, String email, Long projectRoleId, Role projectRoleType) throws ResourceAllocationException;
8686

8787
boolean deleteAccountFromProject(long projectId, String accountName);
8888

@@ -100,6 +100,6 @@ public interface ProjectService {
100100

101101
Project findByProjectAccountIdIncludingRemoved(long projectAccountId);
102102

103-
boolean addUserToProject(Long projectId, String username, String email, Long projectRoleId, Role projectRole);
103+
boolean addUserToProject(Long projectId, String username, String email, Long projectRoleId, Role projectRole) throws ResourceAllocationException;
104104

105105
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323

2424
public interface VMTemplateStorageResourceAssoc extends InternalIdentity {
2525
public static enum Status {
26-
UNKNOWN, DOWNLOAD_ERROR, NOT_DOWNLOADED, DOWNLOAD_IN_PROGRESS, DOWNLOADED, ABANDONED, UPLOADED, NOT_UPLOADED, UPLOAD_ERROR, UPLOAD_IN_PROGRESS, CREATING, CREATED, BYPASSED
26+
UNKNOWN, DOWNLOAD_ERROR, NOT_DOWNLOADED, DOWNLOAD_IN_PROGRESS, DOWNLOADED, ABANDONED, LIMIT_REACHED, UPLOADED, NOT_UPLOADED, UPLOAD_ERROR, UPLOAD_IN_PROGRESS, CREATING, CREATED, BYPASSED
2727
}
2828

29+
List<Status> ERROR_DOWNLOAD_STATES = List.of(Status.DOWNLOAD_ERROR, Status.ABANDONED, Status.LIMIT_REACHED, Status.UNKNOWN);
2930
List<Status> PENDING_DOWNLOAD_STATES = List.of(Status.NOT_DOWNLOADED, Status.DOWNLOAD_IN_PROGRESS);
3031

3132
String getInstallPath();

api/src/main/java/com/cloud/user/ResourceLimitService.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.cloud.offering.DiskOffering;
3131
import com.cloud.offering.ServiceOffering;
3232
import com.cloud.template.VirtualMachineTemplate;
33+
import org.apache.cloudstack.resourcelimit.Reserver;
3334

3435
public interface ResourceLimitService {
3536

@@ -191,6 +192,7 @@ public interface ResourceLimitService {
191192
*/
192193
public void checkResourceLimit(Account account, ResourceCount.ResourceType type, long... count) throws ResourceAllocationException;
193194
public void checkResourceLimitWithTag(Account account, ResourceCount.ResourceType type, String tag, long... count) throws ResourceAllocationException;
195+
public void checkResourceLimitWithTag(Account account, Long domainId, boolean considerSystemAccount, ResourceCount.ResourceType type, String tag, long... count) throws ResourceAllocationException;
194196

195197
/**
196198
* Gets the count of resources for a resource type and account
@@ -251,12 +253,12 @@ public interface ResourceLimitService {
251253
List<String> getResourceLimitStorageTags(DiskOffering diskOffering);
252254
void updateTaggedResourceLimitsAndCountsForAccounts(List<AccountResponse> responses, String tag);
253255
void updateTaggedResourceLimitsAndCountsForDomains(List<DomainResponse> responses, String tag);
254-
void checkVolumeResourceLimit(Account owner, Boolean display, Long size, DiskOffering diskOffering) throws ResourceAllocationException;
255-
256+
void checkVolumeResourceLimit(Account owner, Boolean display, Long size, DiskOffering diskOffering, List<Reserver> reservations) throws ResourceAllocationException;
257+
List<String> getResourceLimitStorageTagsForResourceCountOperation(Boolean display, DiskOffering diskOffering);
256258
void checkVolumeResourceLimitForDiskOfferingChange(Account owner, Boolean display, Long currentSize, Long newSize,
257-
DiskOffering currentOffering, DiskOffering newOffering) throws ResourceAllocationException;
259+
DiskOffering currentOffering, DiskOffering newOffering, List<Reserver> reservations) throws ResourceAllocationException;
258260

259-
void checkPrimaryStorageResourceLimit(Account owner, Boolean display, Long size, DiskOffering diskOffering) throws ResourceAllocationException;
261+
void checkPrimaryStorageResourceLimit(Account owner, Boolean display, Long size, DiskOffering diskOffering, List<Reserver> reservations) throws ResourceAllocationException;
260262

261263
void incrementVolumeResourceCount(long accountId, Boolean display, Long size, DiskOffering diskOffering);
262264
void decrementVolumeResourceCount(long accountId, Boolean display, Long size, DiskOffering diskOffering);
@@ -273,25 +275,23 @@ void updateVolumeResourceCountForDiskOfferingChange(long accountId, Boolean disp
273275

274276
void incrementVolumePrimaryStorageResourceCount(long accountId, Boolean display, Long size, DiskOffering diskOffering);
275277
void decrementVolumePrimaryStorageResourceCount(long accountId, Boolean display, Long size, DiskOffering diskOffering);
276-
void checkVmResourceLimit(Account owner, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template) throws ResourceAllocationException;
278+
void checkVmResourceLimit(Account owner, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Reserver> reservations) throws ResourceAllocationException;
277279
void incrementVmResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template);
278280
void decrementVmResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template);
279281

280282
void checkVmResourceLimitsForServiceOfferingChange(Account owner, Boolean display, Long currentCpu, Long newCpu,
281-
Long currentMemory, Long newMemory, ServiceOffering currentOffering, ServiceOffering newOffering, VirtualMachineTemplate template) throws ResourceAllocationException;
283+
Long currentMemory, Long newMemory, ServiceOffering currentOffering, ServiceOffering newOffering, VirtualMachineTemplate template, List<Reserver> reservations) throws ResourceAllocationException;
282284

283285
void checkVmResourceLimitsForTemplateChange(Account owner, Boolean display, ServiceOffering offering,
284-
VirtualMachineTemplate currentTemplate, VirtualMachineTemplate newTemplate) throws ResourceAllocationException;
286+
VirtualMachineTemplate currentTemplate, VirtualMachineTemplate newTemplate, List<Reserver> reservations) throws ResourceAllocationException;
285287

286-
void checkVmCpuResourceLimit(Account owner, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long cpu) throws ResourceAllocationException;
287288
void incrementVmCpuResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long cpu);
288289
void decrementVmCpuResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long cpu);
289-
void checkVmMemoryResourceLimit(Account owner, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long memory) throws ResourceAllocationException;
290290
void incrementVmMemoryResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long memory);
291291
void decrementVmMemoryResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long memory);
292292

293-
void checkVmGpuResourceLimit(Account owner, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long gpu) throws ResourceAllocationException;
294293
void incrementVmGpuResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long gpu);
295294
void decrementVmGpuResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long gpu);
296295

296+
long recalculateDomainResourceCount(final long domainId, final ResourceType type, String tag);
297297
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ public class ApiConstants {
502502
public static final String RECOVER = "recover";
503503
public static final String REPAIR = "repair";
504504
public static final String REQUIRES_HVM = "requireshvm";
505+
public static final String RESERVED_RESOURCE_DETAILS = "reservedresourcedetails";
505506
public static final String RESOURCES = "resources";
506507
public static final String RESOURCE_COUNT = "resourcecount";
507508
public static final String RESOURCE_NAME = "resourcename";

api/src/main/java/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.util.List;
2020

21+
import com.cloud.exception.ResourceAllocationException;
2122
import org.apache.cloudstack.api.ApiArgValidator;
2223
import org.apache.cloudstack.api.ApiCommandResourceType;
2324
import org.apache.cloudstack.api.BaseCmd;
@@ -106,7 +107,7 @@ public ProjectAccount.Role getRoleType() {
106107
/////////////////////////////////////////////////////
107108

108109
@Override
109-
public void execute() {
110+
public void execute() throws ResourceAllocationException {
110111
if (accountName == null && email == null) {
111112
throw new InvalidParameterValueException("Either accountName or email is required");
112113
}

api/src/main/java/org/apache/cloudstack/api/command/user/account/AddUserToProjectCmd.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.cloudstack.api.command.user.account;
1919

20+
import com.cloud.exception.ResourceAllocationException;
2021
import org.apache.cloudstack.acl.RoleType;
2122
import org.apache.cloudstack.api.APICommand;
2223
import org.apache.cloudstack.api.ApiArgValidator;
@@ -111,7 +112,7 @@ public String getEventDescription() {
111112
/////////////////////////////////////////////////////
112113

113114
@Override
114-
public void execute() {
115+
public void execute() throws ResourceAllocationException {
115116
validateInput();
116117
boolean result = _projectService.addUserToProject(getProjectId(), getUsername(), getEmail(), getProjectRoleId(), getRoleType());
117118
if (result) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import javax.inject.Inject;
2121

2222
import org.apache.cloudstack.acl.RoleType;
23+
import org.apache.cloudstack.api.ACL;
2324
import org.apache.cloudstack.api.APICommand;
2425
import org.apache.cloudstack.api.ApiConstants;
2526
import org.apache.cloudstack.api.ApiErrorCode;
@@ -53,19 +54,22 @@ public class RestoreVolumeFromBackupAndAttachToVMCmd extends BaseAsyncCmd {
5354
//////////////// API parameters /////////////////////
5455
/////////////////////////////////////////////////////
5556

57+
@ACL
5658
@Parameter(name = ApiConstants.BACKUP_ID,
5759
type = CommandType.UUID,
5860
entityType = BackupResponse.class,
5961
required = true,
6062
description = "ID of the Instance backup")
6163
private Long backupId;
6264

65+
@ACL
6366
@Parameter(name = ApiConstants.VOLUME_ID,
6467
type = CommandType.STRING,
6568
required = true,
6669
description = "ID of the volume backed up")
6770
private String volumeUuid;
6871

72+
@ACL
6973
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID,
7074
type = CommandType.UUID,
7175
entityType = UserVmResponse.class,

api/src/main/java/org/apache/cloudstack/api/command/user/vm/CreateVMFromBackupCmd.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class CreateVMFromBackupCmd extends BaseDeployVMCmd {
5151
//////////////// API parameters /////////////////////
5252
/////////////////////////////////////////////////////
5353

54+
@ACL
5455
@Parameter(name = ApiConstants.BACKUP_ID,
5556
type = CommandType.UUID,
5657
entityType = BackupResponse.class,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ public class ExtensionResponse extends BaseResponse {
8585
@Param(description = "Removal timestamp of the extension, if applicable")
8686
private Date removed;
8787

88+
@SerializedName(ApiConstants.RESERVED_RESOURCE_DETAILS)
89+
@Param(description = "Resource detail names as comma separated string that should be reserved and not visible " +
90+
"to end users",
91+
since = "4.22.1")
92+
protected String reservedResourceDetails;
93+
8894
public ExtensionResponse(String id, String name, String description, String type) {
8995
this.id = id;
9096
this.name = name;
@@ -179,4 +185,8 @@ public Date getRemoved() {
179185
public void setRemoved(Date removed) {
180186
this.removed = removed;
181187
}
188+
189+
public void setReservedResourceDetails(String reservedResourceDetails) {
190+
this.reservedResourceDetails = reservedResourceDetails;
191+
}
182192
}

0 commit comments

Comments
 (0)