Skip to content

Commit 09eea10

Browse files
committed
Merge branch 'main' into polish_server
2 parents 027552d + f2d6356 commit 09eea10

File tree

139 files changed

+2960
-1440
lines changed

Some content is hidden

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

139 files changed

+2960
-1440
lines changed

agent/conf/agent.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ hypervisor.type=kvm
213213
# If null (default), defaults to the VM's OS architecture
214214
#guest.cpu.arch=
215215

216-
# This param will require CPU features on the CPU section.
217-
# The features listed in this property must be separated by a blank space (e.g.: vmx vme)
216+
# Specifies required CPU features for end-user and system VMs.
217+
# These features must be present on the host CPU for VM deployment.
218+
# Multiple features should be separated by whitespace (e.g.: vmx vme).
218219
#guest.cpu.features=
219220

220221
# Disables memory ballooning on VM guests for overcommit.

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ private void scheduleHostLBCheckerTask(final String lbAlgorithm, final long chec
475475
return;
476476
}
477477

478-
logger.info("Scheduling a recurring preferred host checker task with lb algorithm '{}' and host.lb.interval={} ms", lbAlgorithm, checkInterval);
478+
logger.info("Scheduling a recurring preferred host checker task with host.lb.interval={} ms", checkInterval);
479479
hostLbCheckExecutor = Executors.newSingleThreadScheduledExecutor((new NamedThreadFactory(name)));
480480
hostLbCheckExecutor.scheduleAtFixedRate(new PreferredHostCheckerTask(), checkInterval, checkInterval,
481481
TimeUnit.MILLISECONDS);

agent/src/main/java/com/cloud/agent/properties/AgentProperties.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,9 @@ public class AgentProperties{
425425
public static final Property<String> GUEST_CPU_ARCH = new Property<>("guest.cpu.arch", null, String.class);
426426

427427
/**
428-
* This param will require CPU features on the CPU section.<br>
429-
* The features listed in this property must be separated by a blank space (see example below).<br>
428+
* Specifies required CPU features for end-user and system VMs.<br>
429+
* These features must be present on the host CPU for VM deployment.<br>
430+
* Multiple features should be separated by whitespace (see example below).<br>
430431
* Possible values: vmx vme <br>
431432
* Data type: String.<br>
432433
* Default value: <code>null</code>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ public interface VolumeApiService {
113113

114114
Volume detachVolumeFromVM(DetachVolumeCmd cmd);
115115

116-
Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account, boolean quiescevm, Snapshot.LocationType locationType, boolean asyncBackup, Map<String, String> tags, List<Long> zoneIds)
116+
Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account, boolean quiescevm, Snapshot.LocationType locationType, boolean asyncBackup, Map<String, String> tags, List<Long> zoneIds, List<Long> poolIds, Boolean useStorageReplication)
117117
throws ResourceAllocationException;
118118

119-
Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName, Snapshot.LocationType locationType, List<Long> zoneIds) throws ResourceAllocationException;
119+
Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName, Snapshot.LocationType locationType, List<Long> zoneIds, List<Long> storagePoolIds, Boolean useStorageReplication) throws ResourceAllocationException;
120120

121121
Volume updateVolume(long volumeId, String path, String state, Long storageId,
122122
Boolean displayVolume, Boolean deleteProtection,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,9 @@ public class ApiConstants {
539539
public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
540540
public static final String SNAPSHOT_TYPE = "snapshottype";
541541
public static final String SNAPSHOT_QUIESCEVM = "quiescevm";
542+
543+
public static final String USE_STORAGE_REPLICATION = "usestoragereplication";
544+
542545
public static final String SOURCE_CIDR_LIST = "sourcecidrlist";
543546
public static final String SOURCE_ZONE_ID = "sourcezoneid";
544547
public static final String SSL_VERIFICATION = "sslverification";
@@ -1159,6 +1162,7 @@ public class ApiConstants {
11591162

11601163
public static final String ZONE_ID_LIST = "zoneids";
11611164
public static final String DESTINATION_ZONE_ID_LIST = "destzoneids";
1165+
public static final String STORAGE_ID_LIST = "storageids";
11621166
public static final String ADMIN = "admin";
11631167
public static final String CHECKSUM_PARAMETER_PREFIX_DESCRIPTION = "The parameter containing the checksum will be considered a MD5sum if it is not prefixed\n"
11641168
+ " and just a plain ascii/utf8 representation of a hexadecimal string. If it is required to\n"
@@ -1272,6 +1276,7 @@ public class ApiConstants {
12721276
public static final String NETRIS_DETAIL_KEY = "forNetris";
12731277
public static final String NETRIS_TAG = "netristag";
12741278
public static final String NETRIS_VXLAN_ID = "netrisvxlanid";
1279+
public static final String NETRIS_URL = "netrisurl";
12751280
public static final String DISK_PATH = "diskpath";
12761281
public static final String IMPORT_SOURCE = "importsource";
12771282
public static final String TEMP_PATH = "temppath";

api/src/main/java/org/apache/cloudstack/api/command/admin/acl/project/ListProjectRolesCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public String getRoleName() {
7272

7373
@Override
7474
public void execute() {
75-
List<ProjectRole> projectRoles;
75+
List<ProjectRole> projectRoles = new ArrayList<>();
7676
if (getProjectId() != null && getProjectRoleId() != null) {
7777
projectRoles = Collections.singletonList(projRoleService.findProjectRole(getProjectRoleId(), getProjectId()));
7878
} else if (StringUtils.isNotBlank(getRoleName())) {

api/src/main/java/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public Long getServiceOfferingId() {
7474
}
7575

7676
public Map<String, String> getDetails() {
77-
return details;
77+
return convertDetailsToMap(details);
7878
}
7979

8080
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public Long getServiceOfferingId() {
6868
}
6969

7070
public Map<String, String> getDetails() {
71-
return details;
71+
return convertDetailsToMap(details);
7272
}
7373

7474
/////////////////////////////////////////////////////

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

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717

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

20-
import java.util.ArrayList;
21-
import java.util.List;
22-
20+
import com.cloud.dc.DataCenter;
21+
import com.cloud.event.EventTypes;
22+
import com.cloud.exception.ResourceAllocationException;
23+
import com.cloud.exception.ResourceUnavailableException;
24+
import com.cloud.exception.StorageUnavailableException;
25+
import com.cloud.storage.Snapshot;
26+
import com.cloud.user.Account;
2327
import org.apache.cloudstack.acl.RoleType;
2428
import org.apache.cloudstack.api.APICommand;
2529
import org.apache.cloudstack.api.ApiCommandResourceType;
@@ -31,26 +35,24 @@
3135
import org.apache.cloudstack.api.ServerApiException;
3236
import org.apache.cloudstack.api.command.user.UserCmd;
3337
import org.apache.cloudstack.api.response.SnapshotResponse;
38+
import org.apache.cloudstack.api.response.StoragePoolResponse;
3439
import org.apache.cloudstack.api.response.ZoneResponse;
3540
import org.apache.cloudstack.context.CallContext;
3641
import org.apache.commons.collections.CollectionUtils;
37-
38-
import com.cloud.dc.DataCenter;
39-
import com.cloud.event.EventTypes;
40-
import com.cloud.exception.ResourceAllocationException;
41-
import com.cloud.exception.ResourceUnavailableException;
42-
import com.cloud.exception.StorageUnavailableException;
43-
import com.cloud.storage.Snapshot;
44-
import com.cloud.user.Account;
42+
import org.apache.commons.lang3.BooleanUtils;
4543
import org.apache.logging.log4j.LogManager;
4644
import org.apache.logging.log4j.Logger;
4745

46+
import java.util.ArrayList;
47+
import java.util.List;
48+
4849
@APICommand(name = "copySnapshot", description = "Copies a snapshot from one zone to another.",
4950
responseObject = SnapshotResponse.class, responseView = ResponseObject.ResponseView.Restricted,
5051
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, since = "4.19.0",
5152
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
5253
public class CopySnapshotCmd extends BaseAsyncCmd implements UserCmd {
5354
public static final Logger logger = LogManager.getLogger(CopySnapshotCmd.class.getName());
55+
private Snapshot snapshot;
5456

5557
/////////////////////////////////////////////////////
5658
//////////////// API parameters /////////////////////
@@ -84,6 +86,20 @@ public class CopySnapshotCmd extends BaseAsyncCmd implements UserCmd {
8486
"Do not specify destzoneid and destzoneids together, however one of them is required.")
8587
protected List<Long> destZoneIds;
8688

89+
@Parameter(name = ApiConstants.STORAGE_ID_LIST,
90+
type=CommandType.LIST,
91+
collectionType = CommandType.UUID,
92+
entityType = StoragePoolResponse.class,
93+
required = false,
94+
authorized = RoleType.Admin,
95+
since = "4.21.0",
96+
description = "A comma-separated list of IDs of the storage pools in other zones in which the snapshot will be made available. " +
97+
"The snapshot will always be made available in the zone in which the volume is present. Currently supported for StorPool only")
98+
protected List<Long> storagePoolIds;
99+
100+
@Parameter (name = ApiConstants.USE_STORAGE_REPLICATION, type=CommandType.BOOLEAN, required = false, since = "4.21.0", description = "This parameter enables the option the snapshot to be copied to supported primary storage")
101+
protected Boolean useStorageReplication;
102+
87103
/////////////////////////////////////////////////////
88104
/////////////////// Accessors ///////////////////////
89105
/////////////////////////////////////////////////////
@@ -106,7 +122,15 @@ public List<Long> getDestinationZoneIds() {
106122
destIds.add(destZoneId);
107123
return destIds;
108124
}
109-
return null;
125+
return new ArrayList<>();
126+
}
127+
128+
public List<Long> getStoragePoolIds() {
129+
return storagePoolIds;
130+
}
131+
132+
public Boolean useStorageReplication() {
133+
return BooleanUtils.toBoolean(useStorageReplication);
110134
}
111135

112136
@Override
@@ -152,7 +176,7 @@ public long getEntityOwnerId() {
152176
@Override
153177
public void execute() throws ResourceUnavailableException {
154178
try {
155-
if (destZoneId == null && CollectionUtils.isEmpty(destZoneIds))
179+
if (destZoneId == null && CollectionUtils.isEmpty(destZoneIds) && useStorageReplication())
156180
throw new ServerApiException(ApiErrorCode.PARAM_ERROR,
157181
"Either destzoneid or destzoneids parameters have to be specified.");
158182

@@ -161,7 +185,7 @@ public void execute() throws ResourceUnavailableException {
161185
"Both destzoneid and destzoneids cannot be specified at the same time.");
162186

163187
CallContext.current().setEventDetails(getEventDescription());
164-
Snapshot snapshot = _snapshotService.copySnapshot(this);
188+
snapshot = _snapshotService.copySnapshot(this);
165189

166190
if (snapshot != null) {
167191
SnapshotResponse response = _queryService.listSnapshot(this);
@@ -177,6 +201,13 @@ public void execute() throws ResourceUnavailableException {
177201
logger.warn("Exception: ", ex);
178202
throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, ex.getMessage());
179203
}
204+
}
205+
206+
public Snapshot getSnapshot() {
207+
return snapshot;
208+
}
180209

210+
public void setSnapshot(Snapshot snapshot) {
211+
this.snapshot = snapshot;
181212
}
182213
}

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.snapshot;
1818

19+
import java.util.ArrayList;
1920
import java.util.Collection;
2021
import java.util.HashMap;
2122
import java.util.List;
2223
import java.util.Map;
2324

25+
import org.apache.cloudstack.acl.RoleType;
2426
import org.apache.cloudstack.api.APICommand;
2527
import org.apache.cloudstack.api.ApiCommandResourceType;
2628
import org.apache.cloudstack.api.ApiConstants;
@@ -32,6 +34,7 @@
3234
import org.apache.cloudstack.api.response.DomainResponse;
3335
import org.apache.cloudstack.api.response.SnapshotPolicyResponse;
3436
import org.apache.cloudstack.api.response.SnapshotResponse;
37+
import org.apache.cloudstack.api.response.StoragePoolResponse;
3538
import org.apache.cloudstack.api.response.VolumeResponse;
3639
import org.apache.cloudstack.api.response.ZoneResponse;
3740
import org.apache.commons.collections.MapUtils;
@@ -99,6 +102,19 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
99102
since = "4.19.0")
100103
protected List<Long> zoneIds;
101104

105+
@Parameter(name = ApiConstants.STORAGE_ID_LIST,
106+
type=CommandType.LIST,
107+
collectionType = CommandType.UUID,
108+
entityType = StoragePoolResponse.class,
109+
authorized = RoleType.Admin,
110+
description = "A comma-separated list of IDs of the storage pools in other zones in which the snapshot will be made available. " +
111+
"The snapshot will always be made available in the zone in which the volume is present.",
112+
since = "4.21.0")
113+
protected List<Long> storagePoolIds;
114+
115+
@Parameter (name = ApiConstants.USE_STORAGE_REPLICATION, type=CommandType.BOOLEAN, required = false, description = "This parameter enables the option the snapshot to be copied to supported primary storage")
116+
protected Boolean useStorageReplication;
117+
102118
private String syncObjectType = BaseAsyncCmd.snapshotHostSyncObject;
103119

104120
// ///////////////////////////////////////////////////
@@ -161,6 +177,17 @@ public List<Long> getZoneIds() {
161177
return zoneIds;
162178
}
163179

180+
public List<Long> getStoragePoolIds() {
181+
return storagePoolIds == null ? new ArrayList<>() : storagePoolIds;
182+
}
183+
184+
public Boolean useStorageReplication() {
185+
if (useStorageReplication == null) {
186+
return false;
187+
}
188+
return useStorageReplication;
189+
}
190+
164191
// ///////////////////////////////////////////////////
165192
// ///////////// API Implementation///////////////////
166193
// ///////////////////////////////////////////////////
@@ -209,7 +236,7 @@ public ApiCommandResourceType getApiResourceType() {
209236

210237
@Override
211238
public void create() throws ResourceAllocationException {
212-
Snapshot snapshot = _volumeService.allocSnapshot(getVolumeId(), getPolicyId(), getSnapshotName(), getLocationType(), getZoneIds());
239+
Snapshot snapshot = _volumeService.allocSnapshot(getVolumeId(), getPolicyId(), getSnapshotName(), getLocationType(), getZoneIds(), getStoragePoolIds(), useStorageReplication());
213240
if (snapshot != null) {
214241
setEntityId(snapshot.getId());
215242
setEntityUuid(snapshot.getUuid());
@@ -223,7 +250,7 @@ public void execute() {
223250
Snapshot snapshot;
224251
try {
225252
snapshot =
226-
_volumeService.takeSnapshot(getVolumeId(), getPolicyId(), getEntityId(), _accountService.getAccount(getEntityOwnerId()), getQuiescevm(), getLocationType(), getAsyncBackup(), getTags(), getZoneIds());
253+
_volumeService.takeSnapshot(getVolumeId(), getPolicyId(), getEntityId(), _accountService.getAccount(getEntityOwnerId()), getQuiescevm(), getLocationType(), getAsyncBackup(), getTags(), getZoneIds(), getStoragePoolIds(), useStorageReplication());
227254

228255
if (snapshot != null) {
229256
SnapshotResponse response = _responseGenerator.createSnapshotResponse(snapshot);
@@ -243,7 +270,7 @@ public void execute() {
243270
}
244271
}
245272

246-
private Snapshot.LocationType getLocationType() {
273+
public Snapshot.LocationType getLocationType() {
247274

248275
if (Snapshot.LocationType.values() == null || Snapshot.LocationType.values().length == 0 || locationType == null) {
249276
return null;

0 commit comments

Comments
 (0)