Skip to content

Commit a359c2a

Browse files
authored
Merge branch 'apache:main' into LB-source-cidr-edit-UI
2 parents cbfa810 + 973819d commit a359c2a

File tree

180 files changed

+5555
-667
lines changed

Some content is hidden

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

180 files changed

+5555
-667
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/com/cloud/vm/UserVmService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import com.cloud.template.VirtualMachineTemplate;
6565
import com.cloud.user.Account;
6666
import com.cloud.uservm.UserVm;
67+
import com.cloud.utils.Pair;
6768
import com.cloud.utils.exception.ExecutionException;
6869

6970
public interface UserVmService {
@@ -538,9 +539,10 @@ UserVm importVM(final DataCenter zone, final Host host, final VirtualMachineTemp
538539

539540
/**
540541
* Unmanage a guest VM from CloudStack
541-
* @return true if the VM is successfully unmanaged, false if not.
542+
*
543+
* @return (true if successful, false if not, hostUuid) if the VM is successfully unmanaged.
542544
*/
543-
boolean unmanageUserVM(Long vmId);
545+
Pair<Boolean, String> unmanageUserVM(Long vmId, Long targetHostId);
544546

545547
UserVm allocateVMFromBackup(CreateVMFromBackupCmd cmd) throws InsufficientCapacityException, ResourceAllocationException, ResourceUnavailableException;
546548

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class ApiConstants {
2727
public static final String ACTIVATION_RULE = "activationrule";
2828
public static final String ACTIVITY = "activity";
2929
public static final String ADAPTER_TYPE = "adaptertype";
30+
public static final String ADDITONAL_CONFIG_ENABLED = "additionalconfigenabled";
3031
public static final String ADDRESS = "address";
3132
public static final String ALGORITHM = "algorithm";
3233
public static final String ALIAS = "alias";

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/admin/vm/UnmanageVMInstanceCmd.java

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.cloud.exception.ResourceUnavailableException;
2828
import com.cloud.user.Account;
2929
import com.cloud.uservm.UserVm;
30+
import com.cloud.utils.Pair;
3031
import com.cloud.vm.VirtualMachine;
3132
import org.apache.cloudstack.acl.RoleType;
3233
import org.apache.cloudstack.api.APICommand;
@@ -36,10 +37,12 @@
3637
import org.apache.cloudstack.api.BaseAsyncCmd;
3738
import org.apache.cloudstack.api.Parameter;
3839
import org.apache.cloudstack.api.ServerApiException;
40+
import org.apache.cloudstack.api.response.HostResponse;
3941
import org.apache.cloudstack.api.response.UnmanageVMInstanceResponse;
4042
import org.apache.cloudstack.api.response.UserVmResponse;
4143
import org.apache.cloudstack.context.CallContext;
4244
import org.apache.cloudstack.vm.UnmanagedVMsManager;
45+
import org.apache.commons.lang3.BooleanUtils;
4346

4447
import javax.inject.Inject;
4548

@@ -65,6 +68,20 @@ public class UnmanageVMInstanceCmd extends BaseAsyncCmd {
6568
description = "The ID of the virtual machine to unmanage")
6669
private Long vmId;
6770

71+
@Parameter(name = ApiConstants.HOST_ID, type = CommandType.UUID,
72+
entityType = HostResponse.class, required = false,
73+
description = "ID of the host which will be used for unmanaging the Instance. " +
74+
"Applicable only for KVM hypervisor and stopped Instances. Domain XML will be stored on this host.",
75+
since = "4.22.0")
76+
private Long hostId;
77+
78+
@Parameter(name = ApiConstants.FORCED,
79+
type = CommandType.BOOLEAN,
80+
required = false,
81+
description = "Force unmanaging Instance with config drive. Applicable only for KVM Hypervisor.",
82+
since = "4.22.0")
83+
private Boolean forced;
84+
6885
/////////////////////////////////////////////////////
6986
/////////////////// Accessors ///////////////////////
7087
/////////////////////////////////////////////////////
@@ -83,6 +100,18 @@ public String getEventDescription() {
83100
return "unmanaging VM. VM ID = " + vmId;
84101
}
85102

103+
public Long getHostId() {
104+
return hostId;
105+
}
106+
107+
public void setHostId(Long hostId) {
108+
this.hostId = hostId;
109+
}
110+
111+
public Boolean isForced() {
112+
return BooleanUtils.isTrue(forced);
113+
}
114+
86115
/////////////////////////////////////////////////////
87116
/////////////// API Implementation///////////////////
88117
/////////////////////////////////////////////////////
@@ -93,9 +122,10 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
93122
UnmanageVMInstanceResponse response = new UnmanageVMInstanceResponse();
94123
try {
95124
CallContext.current().setEventDetails("VM ID = " + vmId);
96-
boolean result = unmanagedVMsManager.unmanageVMInstance(vmId);
97-
response.setSuccess(result);
98-
if (result) {
125+
Pair<Boolean, String> result = unmanagedVMsManager.unmanageVMInstance(vmId, hostId, isForced());
126+
if (result.first()) {
127+
response.setSuccess(true);
128+
response.setHostId(result.second());
99129
response.setDetails("VM unmanaged successfully");
100130
}
101131
} catch (Exception e) {
@@ -124,5 +154,4 @@ public ApiCommandResourceType getApiResourceType() {
124154
public Long getApiResourceId() {
125155
return vmId;
126156
}
127-
128157
}

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
}

0 commit comments

Comments
 (0)