Skip to content

Commit bc1b2eb

Browse files
committed
Merge remote-tracking branch 'apache/4.19' into simplify-role-change-check
2 parents 140445c + 7cfeab1 commit bc1b2eb

File tree

232 files changed

+4792
-1465
lines changed

Some content is hidden

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

232 files changed

+4792
-1465
lines changed

api/src/main/java/com/cloud/agent/api/to/PortForwardingRuleTO.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import com.cloud.network.rules.FirewallRule;
2020
import com.cloud.network.rules.PortForwardingRule;
2121
import com.cloud.utils.net.NetUtils;
22+
import org.apache.commons.lang3.StringUtils;
23+
24+
import java.util.List;
2225

2326
/**
2427
* PortForwardingRuleTO specifies one port forwarding rule.
@@ -29,6 +32,8 @@ public class PortForwardingRuleTO extends FirewallRuleTO {
2932
String dstIp;
3033
int[] dstPortRange;
3134

35+
List<String> sourceCidrList;
36+
3237
protected PortForwardingRuleTO() {
3338
super();
3439
}
@@ -37,6 +42,7 @@ public PortForwardingRuleTO(PortForwardingRule rule, String srcVlanTag, String s
3742
super(rule, srcVlanTag, srcIp);
3843
this.dstIp = rule.getDestinationIpAddress().addr();
3944
this.dstPortRange = new int[] {rule.getDestinationPortStart(), rule.getDestinationPortEnd()};
45+
this.sourceCidrList = rule.getSourceCidrList();
4046
}
4147

4248
public PortForwardingRuleTO(long id, String srcIp, int srcPortStart, int srcPortEnd, String dstIp, int dstPortStart, int dstPortEnd, String protocol,
@@ -58,4 +64,11 @@ public String getStringDstPortRange() {
5864
return NetUtils.portRangeToString(dstPortRange);
5965
}
6066

67+
public String getSourceCidrListAsString() {
68+
if (sourceCidrList != null) {
69+
return StringUtils.join(sourceCidrList, ",");
70+
}
71+
return null;
72+
}
73+
6174
}

api/src/main/java/com/cloud/network/NetworkModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public interface NetworkModel {
149149

150150
boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
151151

152-
Network getNetworkWithSGWithFreeIPs(Long zoneId);
152+
Network getNetworkWithSGWithFreeIPs(Account account, Long zoneId);
153153

154154
Network getNetworkWithSecurityGroupEnabled(Long zoneId);
155155

api/src/main/java/com/cloud/network/rules/RulesService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.cloud.user.Account;
2727
import com.cloud.utils.Pair;
2828
import com.cloud.utils.net.Ip;
29+
import org.apache.cloudstack.api.command.user.firewall.UpdatePortForwardingRuleCmd;
2930

3031
public interface RulesService {
3132
Pair<List<? extends FirewallRule>, Integer> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId,
@@ -81,6 +82,8 @@ Pair<List<? extends FirewallRule>, Integer> searchStaticNatRules(Long ipId, Long
8182

8283
boolean disableStaticNat(long ipId) throws ResourceUnavailableException, NetworkRuleConflictException, InsufficientAddressCapacityException;
8384

84-
PortForwardingRule updatePortForwardingRule(long id, Integer privatePort, Integer privateEndPort, Long virtualMachineId, Ip vmGuestIp, String customId, Boolean forDisplay);
85+
PortForwardingRule updatePortForwardingRule(UpdatePortForwardingRuleCmd cmd);
86+
87+
void validatePortForwardingSourceCidrList(List<String> sourceCidrList);
8588

8689
}

api/src/main/java/com/cloud/user/AccountService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ User createUser(String userName, String password, String firstName, String lastN
116116

117117
void checkAccess(Account account, AccessType accessType, boolean sameOwner, String apiName, ControlledEntity... entities) throws PermissionDeniedException;
118118

119+
void validateAccountHasAccessToResource(Account account, AccessType accessType, Object resource);
120+
119121
Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly);
120122

121123
/**

api/src/main/java/org/apache/cloudstack/affinity/AffinityGroupResponse.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public class AffinityGroupResponse extends BaseResponse implements ControlledVie
5656
@Param(description = "the domain name of the affinity group")
5757
private String domainName;
5858

59+
@SerializedName(ApiConstants.DOMAIN_PATH)
60+
@Param(description = "path of the Domain the affinity group belongs to", since = "4.19.2.0")
61+
private String domainPath;
62+
5963
@SerializedName(ApiConstants.PROJECT_ID)
6064
@Param(description = "the project ID of the affinity group")
6165
private String projectId;
@@ -115,6 +119,11 @@ public void setDomainName(String domainName) {
115119
this.domainName = domainName;
116120
}
117121

122+
@Override
123+
public void setDomainPath(String domainPath) {
124+
this.domainPath = domainPath;
125+
}
126+
118127
@Override
119128
public int hashCode() {
120129
final int prime = 31;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ public class ApiConstants {
225225
public static final String ICMP_TYPE = "icmptype";
226226
public static final String ID = "id";
227227
public static final String IDS = "ids";
228+
public static final String IMPORT_INSTANCE_HOST_ID = "importinstancehostid";
228229
public static final String INDEX = "index";
229230
public static final String INSTANCES_DISKS_STATS_RETENTION_ENABLED = "instancesdisksstatsretentionenabled";
230231
public static final String INSTANCES_DISKS_STATS_RETENTION_TIME = "instancesdisksstatsretentiontime";
@@ -426,6 +427,7 @@ public class ApiConstants {
426427
public static final String SNAPSHOT_TYPE = "snapshottype";
427428
public static final String SNAPSHOT_QUIESCEVM = "quiescevm";
428429
public static final String SUPPORTS_STORAGE_SNAPSHOT = "supportsstoragesnapshot";
430+
public static final String SOURCE_CIDR_LIST = "sourcecidrlist";
429431
public static final String SOURCE_ZONE_ID = "sourcezoneid";
430432
public static final String START_DATE = "startdate";
431433
public static final String START_ID = "startid";

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ImportVmCmd.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,19 @@ public class ImportVmCmd extends ImportUnmanagedInstanceCmd {
146146
private String clusterName;
147147

148148
@Parameter(name = ApiConstants.CONVERT_INSTANCE_HOST_ID, type = CommandType.UUID, entityType = HostResponse.class,
149-
description = "(only for importing VMs from VMware to KVM) optional - the host to perform the virt-v2v migration from VMware to KVM.")
149+
description = "(only for importing VMs from VMware to KVM) optional - the host to perform the virt-v2v conversion from VMware to KVM.")
150150
private Long convertInstanceHostId;
151151

152+
@Parameter(name = ApiConstants.IMPORT_INSTANCE_HOST_ID, type = CommandType.UUID, entityType = HostResponse.class, since = "4.19.2",
153+
description = "(only for importing VMs from VMware to KVM) optional - the host to import the converted instance from VMware to KVM.")
154+
private Long importInstanceHostId;
155+
152156
@Parameter(name = ApiConstants.CONVERT_INSTANCE_STORAGE_POOL_ID, type = CommandType.UUID, entityType = StoragePoolResponse.class,
153157
description = "(only for importing VMs from VMware to KVM) optional - the temporary storage pool to perform the virt-v2v migration from VMware to KVM.")
154158
private Long convertStoragePoolId;
155159

156160
@Parameter(name = ApiConstants.FORCE_MS_TO_IMPORT_VM_FILES, type = CommandType.BOOLEAN,
157-
description = "(only for importing VMs from VMware to KVM) optional - if true, forces MS to import VM file(s) to temporary storage, else uses KVM Host if ovftool is available, falls back to MS if not.")
161+
description = "(only for importing VMs from VMware to KVM) optional - if true, forces MS to export OVF from VMware to temporary storage, else uses KVM Host if ovftool is available, falls back to MS if not.")
158162
private Boolean forceMsToImportVmFiles;
159163

160164
/////////////////////////////////////////////////////
@@ -201,6 +205,10 @@ public Long getConvertInstanceHostId() {
201205
return convertInstanceHostId;
202206
}
203207

208+
public Long getImportInstanceHostId() {
209+
return importInstanceHostId;
210+
}
211+
204212
public Long getConvertStoragePoolId() {
205213
return convertStoragePoolId;
206214
}

api/src/main/java/org/apache/cloudstack/api/command/user/account/AddUserToProjectCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public String getEventType() {
103103

104104
@Override
105105
public String getEventDescription() {
106-
return "Adding user "+getUsername()+" to Project "+getProjectId();
106+
return "Adding user " + getUsername() + " to project: " + getProjectId();
107107
}
108108

109109
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/user/account/DeleteUserFromProjectCmd.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public String getEventDescription() {
8383
return "Removing user " + userId + " from project: " + projectId;
8484
}
8585

86-
8786
@Override
8887
public long getEntityOwnerId() {
8988
Project project = _projectService.getProject(projectId);

api/src/main/java/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
107107
description = "the ID of the virtual machine for the port forwarding rule")
108108
private Long virtualMachineId;
109109

110-
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to forward traffic from. Multiple entries must be separated by a single comma character (,). This parameter is deprecated. Do not use.")
111-
private List<String> cidrlist;
110+
@Parameter(name = ApiConstants.CIDR_LIST,
111+
type = CommandType.LIST,
112+
collectionType = CommandType.STRING,
113+
description = " the source CIDR list to allow traffic from; all other CIDRs will be blocked. " +
114+
"Multiple entries must be separated by a single comma character (,). This param will be used only for VPC tiers. By default, all CIDRs are allowed.")
115+
private List<String> sourceCidrList;
112116

113117
@Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN, description = "if true, firewall rule for source/end public port is automatically created; "
114118
+ "if false - firewall rule has to be created explicitly. If not specified 1) defaulted to false when PF"
@@ -157,11 +161,7 @@ public long getVirtualMachineId() {
157161

158162
@Override
159163
public List<String> getSourceCidrList() {
160-
if (cidrlist != null) {
161-
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall "
162-
+ "rule for the specific cidr, please refer to createFirewallRule command");
163-
}
164-
return null;
164+
return sourceCidrList;
165165
}
166166

167167
public Boolean getOpenFirewall() {
@@ -334,19 +334,15 @@ public int getDestinationPortEnd() {
334334

335335
@Override
336336
public void create() {
337-
// cidr list parameter is deprecated
338-
if (cidrlist != null) {
339-
throw new InvalidParameterValueException(
340-
"Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
341-
}
342-
343337
Ip privateIp = getVmSecondaryIp();
344338
if (privateIp != null) {
345339
if (!NetUtils.isValidIp4(privateIp.toString())) {
346340
throw new InvalidParameterValueException("Invalid vm ip address");
347341
}
348342
}
349343

344+
_rulesService.validatePortForwardingSourceCidrList(sourceCidrList);
345+
350346
try {
351347
PortForwardingRule result = _rulesService.createPortForwardingRule(this, virtualMachineId, privateIp, getOpenFirewall(), isDisplay());
352348
setEntityId(result.getId());

0 commit comments

Comments
 (0)