Skip to content

Commit e662e55

Browse files
authored
Merge branch '4.19' into ui-allow-fa-usage
2 parents 4e5150b + 7cfeab1 commit e662e55

File tree

146 files changed

+4037
-1343
lines changed

Some content is hidden

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

146 files changed

+4037
-1343
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/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/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());

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import com.cloud.user.Account;
3434
import com.cloud.utils.net.Ip;
3535

36+
import java.util.List;
37+
3638
@APICommand(name = "updatePortForwardingRule",
3739
responseObject = FirewallRuleResponse.class,
3840
description = "Updates a port forwarding rule. Only the private port and the virtual machine can be updated.", entityType = {PortForwardingRule.class},
@@ -65,6 +67,13 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCustomIdCmd {
6567
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin})
6668
private Boolean display;
6769

70+
@Parameter(name = ApiConstants.CIDR_LIST,
71+
type = CommandType.LIST,
72+
collectionType = CommandType.STRING,
73+
description = " the source CIDR list to allow traffic from; all other CIDRs will be blocked. " +
74+
"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.")
75+
private List<String> sourceCidrList;
76+
6877
/////////////////////////////////////////////////////
6978
/////////////////// Accessors ///////////////////////
7079
/////////////////////////////////////////////////////
@@ -96,6 +105,10 @@ public Boolean getDisplay() {
96105
return display;
97106
}
98107

108+
public List<String> getSourceCidrList() {
109+
return sourceCidrList;
110+
}
111+
99112
/////////////////////////////////////////////////////
100113
/////////////// API Implementation///////////////////
101114
/////////////////////////////////////////////////////
@@ -132,7 +145,7 @@ public void checkUuid() {
132145

133146
@Override
134147
public void execute() {
135-
PortForwardingRule rule = _rulesService.updatePortForwardingRule(getId(), getPrivatePort(), getPrivateEndPort(), getVirtualMachineId(), getVmGuestIp(), getCustomId(), getDisplay());
148+
PortForwardingRule rule = _rulesService.updatePortForwardingRule(this);
136149
FirewallRuleResponse fwResponse = new FirewallRuleResponse();
137150
if (rule != null) {
138151
fwResponse = _responseGenerator.createPortForwardingRuleResponse(rule);

api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements L
106106
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "the domain ID associated with the load balancer")
107107
private Long domainId;
108108

109-
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, since = "4.18.0.0", description = "the CIDR list to allow traffic, "
109+
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, since = "4.18.0.0", description = "the source CIDR list to allow traffic from; "
110110
+ "all other CIDRs will be blocked. Multiple entries must be separated by a single comma character (,). By default, all CIDRs are allowed.")
111111
private List<String> cidrlist;
112112

client/pom.xml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,7 @@
2727
<artifactId>cloudstack</artifactId>
2828
<version>4.19.2.0-SNAPSHOT</version>
2929
</parent>
30-
<repositories>
31-
<repository>
32-
<id>juniper-tungsten-api</id>
33-
<url>https://github.com/radu-todirica/tungsten-api/raw/master</url>
34-
</repository>
35-
</repositories>
3630
<dependencies>
37-
<dependency>
38-
<groupId>net.juniper.tungsten</groupId>
39-
<artifactId>juniper-tungsten-api</artifactId>
40-
<version>2.0</version>
41-
</dependency>
4231
<dependency>
4332
<groupId>javax.servlet</groupId>
4433
<artifactId>javax.servlet-api</artifactId>
@@ -282,11 +271,6 @@
282271
<artifactId>cloud-plugin-network-ovs</artifactId>
283272
<version>${project.version}</version>
284273
</dependency>
285-
<dependency>
286-
<groupId>org.apache.cloudstack</groupId>
287-
<artifactId>cloud-plugin-network-tungsten</artifactId>
288-
<version>${project.version}</version>
289-
</dependency>
290274
<dependency>
291275
<groupId>org.apache.cloudstack</groupId>
292276
<artifactId>cloud-plugin-network-elb</artifactId>
@@ -1088,6 +1072,11 @@
10881072
<artifactId>cloud-plugin-network-cisco-vnmc</artifactId>
10891073
<version>${project.version}</version>
10901074
</dependency>
1075+
<dependency>
1076+
<groupId>org.apache.cloudstack</groupId>
1077+
<artifactId>cloud-plugin-network-tungsten</artifactId>
1078+
<version>${project.version}</version>
1079+
</dependency>
10911080
<dependency>
10921081
<groupId>org.apache.cloudstack</groupId>
10931082
<artifactId>cloud-plugin-api-vmware-sioc</artifactId>

0 commit comments

Comments
 (0)