Skip to content

Commit c506ee8

Browse files
committed
Merge branch 'main' into 422-vmware-to-kvm-improvements
2 parents 977f6b6 + 973819d commit c506ee8

File tree

106 files changed

+2178
-337
lines changed

Some content is hidden

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

106 files changed

+2178
-337
lines changed

api/src/main/java/com/cloud/offering/DiskOffering.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ enum State {
3737
State getState();
3838

3939
enum DiskCacheMode {
40-
NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough");
40+
NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough"), HYPERVISOR_DEFAULT("hypervisor_default");
4141

4242
private final String _diskCacheMode;
4343

@@ -69,6 +69,8 @@ public String toString() {
6969

7070
boolean isCustomized();
7171

72+
boolean isShared();
73+
7274
void setDiskSize(long diskSize);
7375

7476
long getDiskSize();
@@ -99,7 +101,6 @@ public String toString() {
99101

100102
Long getBytesReadRateMaxLength();
101103

102-
103104
void setBytesWriteRate(Long bytesWriteRate);
104105

105106
Long getBytesWriteRate();
@@ -112,7 +113,6 @@ public String toString() {
112113

113114
Long getBytesWriteRateMaxLength();
114115

115-
116116
void setIopsReadRate(Long iopsReadRate);
117117

118118
Long getIopsReadRate();
@@ -133,7 +133,6 @@ public String toString() {
133133

134134
Long getIopsWriteRateMax();
135135

136-
137136
void setIopsWriteRateMaxLength(Long iopsWriteRateMaxLength);
138137

139138
Long getIopsWriteRateMaxLength();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ Volume updateVolume(long volumeId, String path, String state, Long storageId,
180180
*/
181181
boolean doesStoragePoolSupportDiskOfferingTags(StoragePool destPool, String diskOfferingTags);
182182

183+
boolean validateConditionsToReplaceDiskOfferingOfVolume(Volume volume, DiskOffering newDiskOffering, StoragePool destPool);
184+
183185
Volume destroyVolume(long volumeId, Account caller, boolean expunge, boolean forceExpunge);
184186

185187
void destroyVolume(long volumeId);

api/src/main/java/com/cloud/storage/snapshot/SnapshotApiService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public interface SnapshotApiService {
8585
* the command that specifies the volume criteria
8686
* @return list of snapshot policies
8787
*/
88-
Pair<List<? extends SnapshotPolicy>, Integer> listPoliciesforVolume(ListSnapshotPoliciesCmd cmd);
88+
Pair<List<? extends SnapshotPolicy>, Integer> listSnapshotPolicies(ListSnapshotPoliciesCmd cmd);
8989

9090
boolean deleteSnapshotPolicies(DeleteSnapshotPoliciesCmd cmd);
9191

api/src/main/java/com/cloud/storage/snapshot/SnapshotPolicy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
// under the License.
1717
package com.cloud.storage.snapshot;
1818

19+
import org.apache.cloudstack.acl.ControlledEntity;
1920
import org.apache.cloudstack.api.Displayable;
2021
import org.apache.cloudstack.api.Identity;
2122
import org.apache.cloudstack.api.InternalIdentity;
2223

23-
public interface SnapshotPolicy extends Identity, InternalIdentity, Displayable {
24+
public interface SnapshotPolicy extends ControlledEntity, Identity, InternalIdentity, Displayable {
2425

2526
long getVolumeId();
2627

api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public class CreateDiskOfferingCmd extends BaseCmd {
151151
@Parameter(name = ApiConstants.CACHE_MODE,
152152
type = CommandType.STRING,
153153
required = false,
154-
description = "the cache mode to use for this disk offering. none, writeback or writethrough",
154+
description = "the cache mode to use for this disk offering. none, writeback, writethrough or hypervisor default. If the hypervisor default cache mode is used on other hypervisors than KVM, it will fall back to none cache mode",
155155
since = "4.14")
156156
private String cacheMode;
157157

api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public class CreateServiceOfferingCmd extends BaseCmd {
190190
@Parameter(name = ApiConstants.CACHE_MODE,
191191
type = CommandType.STRING,
192192
required = false,
193-
description = "the cache mode to use for this disk offering. none, writeback or writethrough",
193+
description = "the cache mode to use for this disk offering. none, writeback, writethrough or hypervisor default. If the hypervisor default cache mode is used on other hypervisors than KVM, it will fall back to none cache mode",
194194
since = "4.14")
195195
private String cacheMode;
196196

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.apache.cloudstack.api.APICommand;
2525
import org.apache.cloudstack.api.ApiConstants;
2626
import org.apache.cloudstack.api.ApiErrorCode;
27-
import org.apache.cloudstack.api.BaseCmd;
27+
import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
2828
import org.apache.cloudstack.api.Parameter;
2929
import org.apache.cloudstack.api.ServerApiException;
3030
import org.apache.cloudstack.api.response.BackupScheduleResponse;
@@ -39,7 +39,6 @@
3939
import com.cloud.exception.NetworkRuleConflictException;
4040
import com.cloud.exception.ResourceAllocationException;
4141
import com.cloud.exception.ResourceUnavailableException;
42-
import com.cloud.utils.exception.CloudRuntimeException;
4342

4443
import java.util.ArrayList;
4544
import java.util.List;
@@ -48,10 +47,10 @@
4847
description = "List backup schedule of a VM",
4948
responseObject = BackupScheduleResponse.class, since = "4.14.0",
5049
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
51-
public class ListBackupScheduleCmd extends BaseCmd {
50+
public class ListBackupScheduleCmd extends BaseListProjectAndAccountResourcesCmd {
5251

5352
@Inject
54-
private BackupManager backupManager;
53+
BackupManager backupManager;
5554

5655
/////////////////////////////////////////////////////
5756
//////////////// API parameters /////////////////////
@@ -60,10 +59,16 @@ public class ListBackupScheduleCmd extends BaseCmd {
6059
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID,
6160
type = CommandType.UUID,
6261
entityType = UserVmResponse.class,
63-
required = true,
6462
description = "ID of the VM")
6563
private Long vmId;
6664

65+
@Parameter(name = ApiConstants.ID,
66+
type = CommandType.UUID,
67+
entityType = BackupScheduleResponse.class,
68+
description = "the ID of the backup schedule",
69+
since = "4.22.0")
70+
private Long id;
71+
6772
/////////////////////////////////////////////////////
6873
/////////////////// Accessors ///////////////////////
6974
/////////////////////////////////////////////////////
@@ -72,26 +77,29 @@ public Long getVmId() {
7277
return vmId;
7378
}
7479

80+
public Long getId() {
81+
return id;
82+
}
83+
7584
/////////////////////////////////////////////////////
7685
/////////////// API Implementation///////////////////
7786
/////////////////////////////////////////////////////
7887

7988
@Override
8089
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
8190
try{
82-
List<BackupSchedule> schedules = backupManager.listBackupSchedule(getVmId());
91+
List<BackupSchedule> schedules = backupManager.listBackupSchedules(this);
8392
ListResponse<BackupScheduleResponse> response = new ListResponse<>();
8493
List<BackupScheduleResponse> scheduleResponses = new ArrayList<>();
94+
8595
if (!CollectionUtils.isNullOrEmpty(schedules)) {
8696
for (BackupSchedule schedule : schedules) {
8797
scheduleResponses.add(_responseGenerator.createBackupScheduleResponse(schedule));
8898
}
89-
response.setResponses(scheduleResponses, schedules.size());
90-
response.setResponseName(getCommandName());
91-
setResponseObject(response);
92-
} else {
93-
throw new CloudRuntimeException("No backup schedule exists for the VM");
9499
}
100+
response.setResponses(scheduleResponses, schedules.size());
101+
response.setResponseName(getCommandName());
102+
setResponseObject(response);
95103
} catch (Exception e) {
96104
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
97105
}

api/src/main/java/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmd.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import org.apache.cloudstack.api.APICommand;
2525
import org.apache.cloudstack.api.ApiConstants;
26-
import org.apache.cloudstack.api.BaseListCmd;
26+
import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
2727
import org.apache.cloudstack.api.Parameter;
2828
import org.apache.cloudstack.api.response.ListResponse;
2929
import org.apache.cloudstack.api.response.SnapshotPolicyResponse;
@@ -34,7 +34,7 @@
3434

3535
@APICommand(name = "listSnapshotPolicies", description = "Lists snapshot policies.", responseObject = SnapshotPolicyResponse.class,
3636
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
37-
public class ListSnapshotPoliciesCmd extends BaseListCmd {
37+
public class ListSnapshotPoliciesCmd extends BaseListProjectAndAccountResourcesCmd {
3838

3939

4040
/////////////////////////////////////////////////////
@@ -69,13 +69,14 @@ public boolean isDisplay() {
6969
public Long getId() {
7070
return id;
7171
}
72+
7273
/////////////////////////////////////////////////////
7374
/////////////// API Implementation///////////////////
7475
/////////////////////////////////////////////////////
7576

7677
@Override
7778
public void execute() {
78-
Pair<List<? extends SnapshotPolicy>, Integer> result = _snapshotService.listPoliciesforVolume(this);
79+
Pair<List<? extends SnapshotPolicy>, Integer> result = _snapshotService.listSnapshotPolicies(this);
7980
ListResponse<SnapshotPolicyResponse> response = new ListResponse<SnapshotPolicyResponse>();
8081
List<SnapshotPolicyResponse> policyResponses = new ArrayList<SnapshotPolicyResponse>();
8182
for (SnapshotPolicy policy : result.first()) {

api/src/main/java/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.cloudstack.api.response.VpnUsersResponse;
2929
import org.apache.cloudstack.context.CallContext;
3030

31-
import com.cloud.domain.Domain;
3231
import com.cloud.event.EventTypes;
3332
import com.cloud.network.VpnUser;
3433
import com.cloud.user.Account;
@@ -110,32 +109,17 @@ public String getEventType() {
110109
@Override
111110
public void execute() {
112111
VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
113-
Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
114112
try {
115113
if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
116114
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user");
117115
}
118116
} catch (Exception ex) {
119117
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
120118
}
121-
122-
VpnUsersResponse vpnResponse = new VpnUsersResponse();
123-
vpnResponse.setId(vpnUser.getUuid());
124-
vpnResponse.setUserName(vpnUser.getUsername());
125-
vpnResponse.setAccountName(account.getAccountName());
126119
// re-retrieve the vpnuser, as the call to `applyVpnUsers` might have changed the state
127120
vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
128-
vpnResponse.setState(vpnUser.getState().toString());
129-
130-
Domain domain = _entityMgr.findById(Domain.class, account.getDomainId());
131-
if (domain != null) {
132-
vpnResponse.setDomainId(domain.getUuid());
133-
vpnResponse.setDomainName(domain.getName());
134-
vpnResponse.setDomainPath(domain.getPath());
135-
}
136-
121+
VpnUsersResponse vpnResponse = _responseGenerator.createVpnUserResponse(vpnUser);
137122
vpnResponse.setResponseName(getCommandName());
138-
vpnResponse.setObjectName("vpnuser");
139123
setResponseObject(vpnResponse);
140124
}
141125

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public class ServiceOfferingResponse extends BaseResponseWithAnnotations {
197197
private Boolean isCustomized;
198198

199199
@SerializedName("cacheMode")
200-
@Param(description = "the cache mode to use for this disk offering. none, writeback or writethrough", since = "4.14")
200+
@Param(description = "the cache mode to use for this disk offering. none, writeback, writethrough or hypervisor default", since = "4.14")
201201
private String cacheMode;
202202

203203
@SerializedName("vspherestoragepolicy")

0 commit comments

Comments
 (0)