Skip to content

Commit 830ee2d

Browse files
authored
Merge branch 'main' into Remove-Domain/IP-from-Password-Reset-Link-to-custom-Global-Setting
2 parents 5f54515 + d7b7bd5 commit 830ee2d

File tree

88 files changed

+2400
-685
lines changed

Some content is hidden

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

88 files changed

+2400
-685
lines changed

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/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;

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

Lines changed: 32 additions & 11 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.Collection;
20-
import java.util.HashMap;
21-
import java.util.List;
22-
import java.util.Map;
23-
19+
import com.cloud.exception.InvalidParameterValueException;
20+
import com.cloud.exception.PermissionDeniedException;
21+
import com.cloud.projects.Project;
22+
import com.cloud.storage.Volume;
23+
import com.cloud.storage.snapshot.SnapshotPolicy;
24+
import com.cloud.user.Account;
25+
import java.util.ArrayList;
2426
import org.apache.cloudstack.acl.RoleType;
2527
import org.apache.cloudstack.api.APICommand;
2628
import org.apache.cloudstack.api.ApiCommandResourceType;
@@ -30,16 +32,16 @@
3032
import org.apache.cloudstack.api.Parameter;
3133
import org.apache.cloudstack.api.ServerApiException;
3234
import org.apache.cloudstack.api.response.SnapshotPolicyResponse;
35+
import org.apache.cloudstack.api.response.StoragePoolResponse;
3336
import org.apache.cloudstack.api.response.VolumeResponse;
3437
import org.apache.cloudstack.api.response.ZoneResponse;
3538
import org.apache.commons.collections.MapUtils;
3639

37-
import com.cloud.exception.InvalidParameterValueException;
38-
import com.cloud.exception.PermissionDeniedException;
39-
import com.cloud.projects.Project;
40-
import com.cloud.storage.Volume;
41-
import com.cloud.storage.snapshot.SnapshotPolicy;
42-
import com.cloud.user.Account;
40+
import java.util.Collection;
41+
import java.util.HashMap;
42+
import java.util.List;
43+
import java.util.Map;
44+
import org.apache.commons.lang3.BooleanUtils;
4345

4446
@APICommand(name = "createSnapshotPolicy", description = "Creates a snapshot policy for the account.", responseObject = SnapshotPolicyResponse.class,
4547
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
@@ -83,6 +85,17 @@ public class CreateSnapshotPolicyCmd extends BaseCmd {
8385
"The snapshots will always be made available in the zone in which the volume is present.")
8486
protected List<Long> zoneIds;
8587

88+
@Parameter(name = ApiConstants.STORAGE_ID_LIST,
89+
type=CommandType.LIST,
90+
collectionType = CommandType.UUID,
91+
entityType = StoragePoolResponse.class,
92+
description = "A comma-separated list of IDs of the storage pools in other zones in which the snapshot will be made available. " +
93+
"The snapshot will always be made available in the zone in which the volume is present.",
94+
since = "4.21.0")
95+
protected List<Long> storagePoolIds;
96+
97+
@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")
98+
protected Boolean useStorageReplication;
8699
/////////////////////////////////////////////////////
87100
/////////////////// Accessors ///////////////////////
88101
/////////////////////////////////////////////////////
@@ -119,6 +132,14 @@ public List<Long> getZoneIds() {
119132
return zoneIds;
120133
}
121134

135+
public List<Long> getStoragePoolIds() {
136+
return storagePoolIds == null ? new ArrayList<>() : storagePoolIds;
137+
}
138+
139+
public Boolean useStorageReplication() {
140+
return BooleanUtils.toBoolean(useStorageReplication);
141+
}
142+
122143
/////////////////////////////////////////////////////
123144
/////////////// API Implementation///////////////////
124145
/////////////////////////////////////////////////////

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.response;
1818

19-
import java.util.LinkedHashSet;
20-
import java.util.Set;
21-
19+
import com.cloud.serializer.Param;
20+
import com.cloud.storage.snapshot.SnapshotPolicy;
21+
import com.google.gson.annotations.SerializedName;
2222
import org.apache.cloudstack.acl.RoleType;
2323
import org.apache.cloudstack.api.ApiConstants;
2424
import org.apache.cloudstack.api.BaseResponseWithTagInformation;
2525
import org.apache.cloudstack.api.EntityReference;
2626

27-
import com.cloud.serializer.Param;
28-
import com.cloud.storage.snapshot.SnapshotPolicy;
29-
import com.google.gson.annotations.SerializedName;
27+
import java.util.LinkedHashSet;
28+
import java.util.Set;
3029

3130
@EntityReference(value = SnapshotPolicy.class)
3231
public class SnapshotPolicyResponse extends BaseResponseWithTagInformation {
@@ -62,9 +61,14 @@ public class SnapshotPolicyResponse extends BaseResponseWithTagInformation {
6261
@Param(description = "The list of zones in which snapshot backup is scheduled", responseObject = ZoneResponse.class, since = "4.19.0")
6362
protected Set<ZoneResponse> zones;
6463

64+
@SerializedName(ApiConstants.STORAGE)
65+
@Param(description = "The list of pools in which snapshot backup is scheduled", responseObject = StoragePoolResponse.class, since = "4.21.0")
66+
protected Set<StoragePoolResponse> storagePools;
67+
6568
public SnapshotPolicyResponse() {
6669
tags = new LinkedHashSet<ResourceTagResponse>();
6770
zones = new LinkedHashSet<>();
71+
storagePools = new LinkedHashSet<>();
6872
}
6973

7074
public String getId() {
@@ -130,4 +134,6 @@ public void setTags(Set<ResourceTagResponse> tags) {
130134
public void setZones(Set<ZoneResponse> zones) {
131135
this.zones = zones;
132136
}
137+
138+
public void setStoragePools(Set<StoragePoolResponse> pools) { this.storagePools = pools; }
133139
}

api/src/main/java/org/apache/cloudstack/network/RoutedIpv4Manager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public interface RoutedIpv4Manager extends PluggableService, Configurable {
158158

159159
boolean isRoutedVpc(Vpc vpc);
160160

161-
boolean isVpcVirtualRouterGateway(VpcOffering vpcOffering);
161+
boolean isValidGateway(VpcOffering vpcOffering);
162162

163163
BgpPeer createBgpPeer(CreateBgpPeerCmd createBgpPeerCmd);
164164

0 commit comments

Comments
 (0)