Skip to content

Commit a55f85a

Browse files
Merge branch '4.22'
2 parents c681d0d + d700e2d commit a55f85a

File tree

91 files changed

+2745
-1051
lines changed

Some content is hidden

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

91 files changed

+2745
-1051
lines changed

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ public class EventTypes {
583583

584584
// Network ACL
585585
public static final String EVENT_NETWORK_ACL_CREATE = "NETWORK.ACL.CREATE";
586+
public static final String EVENT_NETWORK_ACL_IMPORT = "NETWORK.ACL.IMPORT";
586587
public static final String EVENT_NETWORK_ACL_DELETE = "NETWORK.ACL.DELETE";
587588
public static final String EVENT_NETWORK_ACL_REPLACE = "NETWORK.ACL.REPLACE";
588589
public static final String EVENT_NETWORK_ACL_UPDATE = "NETWORK.ACL.UPDATE";

api/src/main/java/com/cloud/network/vpc/NetworkACLService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.List;
2020

2121
import org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd;
22+
import org.apache.cloudstack.api.command.user.network.ImportNetworkACLCmd;
2223
import org.apache.cloudstack.api.command.user.network.ListNetworkACLListsCmd;
2324
import org.apache.cloudstack.api.command.user.network.ListNetworkACLsCmd;
2425
import org.apache.cloudstack.api.command.user.network.MoveNetworkAclItemCmd;
@@ -98,4 +99,6 @@ public interface NetworkACLService {
9899
NetworkACLItem moveNetworkAclRuleToNewPosition(MoveNetworkAclItemCmd moveNetworkAclItemCmd);
99100

100101
NetworkACLItem moveRuleToTheTopInACLList(NetworkACLItem ruleBeingMoved);
102+
103+
List<NetworkACLItem> importNetworkACLRules(ImportNetworkACLCmd cmd) throws ResourceUnavailableException;
101104
}

api/src/main/java/org/apache/cloudstack/alert/AlertService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ private AlertType(short type, String name, boolean isDefault) {
7171
public static final AlertType ALERT_TYPE_HA_ACTION = new AlertType((short)30, "ALERT.HA.ACTION", true);
7272
public static final AlertType ALERT_TYPE_CA_CERT = new AlertType((short)31, "ALERT.CA.CERT", true);
7373
public static final AlertType ALERT_TYPE_VM_SNAPSHOT = new AlertType((short)32, "ALERT.VM.SNAPSHOT", true);
74-
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PUBLIC.IFACE.MTU", true);
75-
public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PRIVATE.IFACE.MTU", true);
74+
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)33, "ALERT.VR.PUBLIC.IFACE.MTU", true);
75+
public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)34, "ALERT.VR.PRIVATE.IFACE.MTU", true);
7676
public static final AlertType ALERT_TYPE_EXTENSION_PATH_NOT_READY = new AlertType((short)33, "ALERT.TYPE.EXTENSION.PATH.NOT.READY", true);
7777
public static final AlertType ALERT_TYPE_VPN_GATEWAY_OBSOLETE_PARAMETERS = new AlertType((short)34, "ALERT.S2S.VPN.GATEWAY.OBSOLETE.PARAMETERS", true);
7878
public static final AlertType ALERT_TYPE_BACKUP_STORAGE = new AlertType(Capacity.CAPACITY_TYPE_BACKUP_STORAGE, "ALERT.STORAGE.BACKUP", true);

api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
import com.cloud.exception.DiscoveryException;
3030
import com.cloud.storage.ImageStore;
3131
import com.cloud.user.Account;
32+
import org.apache.commons.collections.MapUtils;
33+
34+
import java.util.Collection;
35+
import java.util.HashMap;
36+
import java.util.Map;
3237

3338
@APICommand(name = "addSecondaryStorage", description = "Adds secondary storage.", responseObject = ImageStoreResponse.class,
3439
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
@@ -44,6 +49,9 @@ public class AddSecondaryStorageCmd extends BaseCmd {
4449
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "The Zone ID for the secondary storage")
4550
protected Long zoneId;
4651

52+
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "Details in key/value pairs using format details[i].keyname=keyvalue. Example: details[0].copytemplatesfromothersecondarystorages=true")
53+
protected Map details;
54+
4755
/////////////////////////////////////////////////////
4856
/////////////////// Accessors ///////////////////////
4957
/////////////////////////////////////////////////////
@@ -56,6 +64,20 @@ public Long getZoneId() {
5664
return zoneId;
5765
}
5866

67+
public Map<String, String> getDetails() {
68+
Map<String, String> detailsMap = new HashMap<>();
69+
if (MapUtils.isNotEmpty(details)) {
70+
Collection<?> props = details.values();
71+
for (Object prop : props) {
72+
HashMap<String, String> detail = (HashMap<String, String>) prop;
73+
for (Map.Entry<String, String> entry: detail.entrySet()) {
74+
detailsMap.put(entry.getKey(),entry.getValue());
75+
}
76+
}
77+
}
78+
return detailsMap;
79+
}
80+
5981
/////////////////////////////////////////////////////
6082
/////////////// API Implementation///////////////////
6183
/////////////////////////////////////////////////////
@@ -68,7 +90,7 @@ public long getEntityOwnerId() {
6890
@Override
6991
public void execute(){
7092
try{
71-
ImageStore result = _storageService.discoverImageStore(null, getUrl(), "NFS", getZoneId(), null);
93+
ImageStore result = _storageService.discoverImageStore(null, getUrl(), "NFS", getZoneId(), getDetails());
7294
ImageStoreResponse storeResponse = null;
7395
if (result != null ) {
7496
storeResponse = _responseGenerator.createImageStoreResponse(result);

api/src/main/java/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public void execute() {
6363
response.setDiskOffMaxSize((Long)capabilities.get("customDiskOffMaxSize"));
6464
response.setRegionSecondaryEnabled((Boolean)capabilities.get("regionSecondaryEnabled"));
6565
response.setKVMSnapshotEnabled((Boolean)capabilities.get("KVMSnapshotEnabled"));
66+
response.setSnapshotShowChainSize((Boolean)capabilities.get("SnapshotShowChainSize"));
6667
response.setAllowUserViewDestroyedVM((Boolean)capabilities.get("allowUserViewDestroyedVM"));
6768
response.setAllowUserExpungeRecoverVM((Boolean)capabilities.get("allowUserExpungeRecoverVM"));
6869
response.setAllowUserExpungeRecoverVolume((Boolean)capabilities.get("allowUserExpungeRecoverVolume"));

api/src/main/java/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd {
5858
private Integer publicEndPort;
5959

6060
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "The CIDR list to allow traffic from/to. Multiple entries must be separated by a single comma character (,).")
61-
private List<String> cidrlist;
61+
private List<String> cidrList;
6262

6363
@Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "Type of the ICMP message being sent")
6464
private Integer icmpType;
@@ -118,8 +118,8 @@ public void setProtocol(String protocol) {
118118
}
119119

120120
public List<String> getSourceCidrList() {
121-
if (cidrlist != null) {
122-
return cidrlist;
121+
if (cidrList != null) {
122+
return cidrList;
123123
} else {
124124
List<String> oneCidrList = new ArrayList<String>();
125125
oneCidrList.add(NetUtils.ALL_IP4_CIDRS);
@@ -238,6 +238,30 @@ public String getReason() {
238238
return reason;
239239
}
240240

241+
public void setCidrList(List<String> cidrList) {
242+
this.cidrList = cidrList;
243+
}
244+
245+
public void setIcmpType(Integer icmpType) {
246+
this.icmpType = icmpType;
247+
}
248+
249+
public void setIcmpCode(Integer icmpCode) {
250+
this.icmpCode = icmpCode;
251+
}
252+
253+
public void setNumber(Integer number) {
254+
this.number = number;
255+
}
256+
257+
public void setDisplay(Boolean display) {
258+
this.display = display;
259+
}
260+
261+
public void setReason(String reason) {
262+
this.reason = reason;
263+
}
264+
241265
@Override
242266
public void create() {
243267
NetworkACLItem result = _networkACLService.createNetworkACLItem(this);
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.api.command.user.network;
18+
19+
import java.util.ArrayList;
20+
import java.util.List;
21+
import java.util.Map;
22+
23+
import org.apache.cloudstack.api.APICommand;
24+
import org.apache.cloudstack.api.ApiConstants;
25+
import org.apache.cloudstack.api.ApiErrorCode;
26+
import org.apache.cloudstack.api.BaseAsyncCmd;
27+
import org.apache.cloudstack.api.Parameter;
28+
import org.apache.cloudstack.api.ServerApiException;
29+
import org.apache.cloudstack.api.response.ListResponse;
30+
import org.apache.cloudstack.api.response.NetworkACLItemResponse;
31+
import org.apache.cloudstack.api.response.NetworkACLResponse;
32+
import org.apache.cloudstack.context.CallContext;
33+
import org.apache.commons.collections.MapUtils;
34+
35+
import com.cloud.event.EventTypes;
36+
import com.cloud.exception.ResourceUnavailableException;
37+
import com.cloud.network.vpc.NetworkACLItem;
38+
import com.cloud.user.Account;
39+
40+
@APICommand(name = "importNetworkACL", description = "Imports Network ACL rules.",
41+
responseObject = NetworkACLItemResponse.class,
42+
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
43+
since = "4.22.1")
44+
public class ImportNetworkACLCmd extends BaseAsyncCmd {
45+
46+
// ///////////////////////////////////////////////////
47+
// ////////////// API parameters /////////////////////
48+
// ///////////////////////////////////////////////////
49+
50+
@Parameter(
51+
name = ApiConstants.ACL_ID,
52+
type = CommandType.UUID,
53+
entityType = NetworkACLResponse.class,
54+
required = true,
55+
description = "The ID of the Network ACL to which the rules will be imported"
56+
)
57+
private Long aclId;
58+
59+
@Parameter(name = ApiConstants.RULES, type = CommandType.MAP, required = true,
60+
description = "Rules param list, id and protocol are must. Invalid rules will be discarded. Example: " +
61+
"rules[0].id=101&rules[0].protocol=tcp&rules[0].traffictype=ingress&rules[0].state=active&rules[0].cidrlist=192.168.1.0/24" +
62+
"&rules[0].tags=web&rules[0].aclid=acl-001&rules[0].aclname=web-acl&rules[0].number=1&rules[0].action=allow&rules[0].fordisplay=true" +
63+
"&rules[0].description=allow%20web%20traffic&rules[1].id=102&rules[1].protocol=udp&rules[1].traffictype=egress&rules[1].state=enabled" +
64+
"&rules[1].cidrlist=10.0.0.0/8&rules[1].tags=db&rules[1].aclid=acl-002&rules[1].aclname=db-acl&rules[1].number=2&rules[1].action=deny" +
65+
"&rules[1].fordisplay=false&rules[1].description=deny%20database%20traffic")
66+
private Map rules;
67+
68+
69+
// ///////////////////////////////////////////////////
70+
// ///////////////// Accessors ///////////////////////
71+
// ///////////////////////////////////////////////////
72+
73+
// Returns map, corresponds to a rule with the details in the keys:
74+
// id, protocol, startport, endport, traffictype, state, cidrlist, tags, aclid, aclname, number, action, fordisplay, description
75+
public Map getRules() {
76+
return rules;
77+
}
78+
79+
public Long getAclId() {
80+
return aclId;
81+
}
82+
83+
// ///////////////////////////////////////////////////
84+
// ///////////// API Implementation///////////////////
85+
// ///////////////////////////////////////////////////
86+
87+
88+
@Override
89+
public void execute() throws ResourceUnavailableException {
90+
validateParams();
91+
List<NetworkACLItem> importedRules = _networkACLService.importNetworkACLRules(this);
92+
ListResponse<NetworkACLItemResponse> response = new ListResponse<>();
93+
List<NetworkACLItemResponse> aclResponse = new ArrayList<>();
94+
for (NetworkACLItem acl : importedRules) {
95+
NetworkACLItemResponse ruleData = _responseGenerator.createNetworkACLItemResponse(acl);
96+
aclResponse.add(ruleData);
97+
}
98+
response.setResponses(aclResponse, importedRules.size());
99+
response.setResponseName(getCommandName());
100+
setResponseObject(response);
101+
}
102+
103+
@Override
104+
public long getEntityOwnerId() {
105+
Account account = CallContext.current().getCallingAccount();
106+
if (account != null) {
107+
return account.getId();
108+
}
109+
return Account.ACCOUNT_ID_SYSTEM;
110+
}
111+
112+
@Override
113+
public String getEventType() {
114+
return EventTypes.EVENT_NETWORK_ACL_IMPORT;
115+
}
116+
117+
@Override
118+
public String getEventDescription() {
119+
return "Importing ACL rules for ACL ID: " + getAclId();
120+
}
121+
122+
123+
private void validateParams() {
124+
if(MapUtils.isEmpty(rules)) {
125+
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Rules parameter is empty or null");
126+
}
127+
128+
if (getAclId() == null || _networkACLService.getNetworkACL(getAclId()) == null) {
129+
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find Network ACL with provided ACL ID");
130+
}
131+
}
132+
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ public void execute() {
274274
}
275275

276276
public Snapshot.LocationType getLocationType() {
277-
278-
if (Snapshot.LocationType.values() == null || Snapshot.LocationType.values().length == 0 || locationType == null) {
277+
if (locationType == null) {
279278
return null;
280279
}
281280

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ public class CapabilitiesResponse extends BaseResponse {
7575
@Param(description = "True if Snapshot is supported for KVM host, false otherwise")
7676
private boolean kvmSnapshotEnabled;
7777

78+
@SerializedName("snapshotshowchainsize")
79+
@Param(description = "True to show the parent and chain size (sum of physical size of snapshot and all its parents) for incremental snapshots", since = "4.22.1")
80+
private boolean snapshotShowChainSize;
81+
7882
@SerializedName("apilimitmax")
7983
@Param(description = "Max allowed number of api requests within the specified interval")
8084
private Integer apiLimitMax;
@@ -203,6 +207,10 @@ public void setKVMSnapshotEnabled(boolean kvmSnapshotEnabled) {
203207
this.kvmSnapshotEnabled = kvmSnapshotEnabled;
204208
}
205209

210+
public void setSnapshotShowChainSize(boolean snapshotShowChainSize) {
211+
this.snapshotShowChainSize = snapshotShowChainSize;
212+
}
213+
206214
public void setApiLimitInterval(Integer apiLimitInterval) {
207215
this.apiLimitInterval = apiLimitInterval;
208216
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ public class SnapshotResponse extends BaseResponseWithTagInformation implements
155155
@Param(description = "download progress of a snapshot", since = "4.19.0")
156156
private Map<String, String> downloadDetails;
157157

158+
@SerializedName("parent")
159+
@Param(description = "The parent ID of the Snapshot", since = "4.22.1")
160+
private String parent;
161+
162+
@SerializedName("parentname")
163+
@Param(description = "The parent name of the Snapshot", since = "4.22.1")
164+
private String parentName;
165+
158166
public SnapshotResponse() {
159167
tags = new LinkedHashSet<ResourceTagResponse>();
160168
}
@@ -313,4 +321,12 @@ public void setDatastoreType(String datastoreType) {
313321
public void setDownloadDetails(Map<String, String> downloadDetails) {
314322
this.downloadDetails = downloadDetails;
315323
}
324+
325+
public void setParent(String parent) {
326+
this.parent = parent;
327+
}
328+
329+
public void setParentName(String parentName) {
330+
this.parentName = parentName;
331+
}
316332
}

0 commit comments

Comments
 (0)