Skip to content

Commit 9b6f9b5

Browse files
committed
Merge release branch 4.20 to main
* 4.20: UI: Tooltip on the host information card to display the CPU speed in MHz and the memory value in MB (to 3 decimal places) (#9971) UI: Allow accounts of the `User` type to add other accounts or users to projects through UI (#9927) enable to create VPC portfowarding rules with source cidr (#7081) Add new column `last_id` to the table volumes (#9759) Allow VMWare import via another host (#9787) Linstor: add support for ISO block devices and direct download (#9792) get expunged VM data for job result (#9949) fix section divider display on auth page (#9966)
2 parents da94ae2 + da54234 commit 9b6f9b5

File tree

51 files changed

+1772
-293
lines changed

Some content is hidden

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

51 files changed

+1772
-293
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/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/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ public class ApiConstants {
244244
public static final String ICMP_TYPE = "icmptype";
245245
public static final String ID = "id";
246246
public static final String IDS = "ids";
247+
public static final String IMPORT_INSTANCE_HOST_ID = "importinstancehostid";
247248
public static final String INDEX = "index";
248249
public static final String INSTANCES_DISKS_STATS_RETENTION_ENABLED = "instancesdisksstatsretentionenabled";
249250
public static final String INSTANCES_DISKS_STATS_RETENTION_TIME = "instancesdisksstatsretentiontime";
@@ -464,6 +465,7 @@ public class ApiConstants {
464465
public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
465466
public static final String SNAPSHOT_TYPE = "snapshottype";
466467
public static final String SNAPSHOT_QUIESCEVM = "quiescevm";
468+
public static final String SOURCE_CIDR_LIST = "sourcecidrlist";
467469
public static final String SOURCE_ZONE_ID = "sourcezoneid";
468470
public static final String SSL_VERIFICATION = "sslverification";
469471
public static final String START_ASN = "startasn";

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
@@ -144,15 +144,19 @@ public class ImportVmCmd extends ImportUnmanagedInstanceCmd {
144144
private String clusterName;
145145

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

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

154158
@Parameter(name = ApiConstants.FORCE_MS_TO_IMPORT_VM_FILES, type = CommandType.BOOLEAN,
155-
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.")
159+
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.")
156160
private Boolean forceMsToImportVmFiles;
157161

158162
/////////////////////////////////////////////////////
@@ -199,6 +203,10 @@ public Long getConvertInstanceHostId() {
199203
return convertInstanceHostId;
200204
}
201205

206+
public Long getImportInstanceHostId() {
207+
return importInstanceHostId;
208+
}
209+
202210
public Long getConvertStoragePoolId() {
203211
return convertStoragePoolId;
204212
}

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
@@ -105,8 +105,12 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
105105
description = "the ID of the virtual machine for the port forwarding rule")
106106
private Long virtualMachineId;
107107

108-
@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.")
109-
private List<String> cidrlist;
108+
@Parameter(name = ApiConstants.CIDR_LIST,
109+
type = CommandType.LIST,
110+
collectionType = CommandType.STRING,
111+
description = " the source CIDR list to allow traffic from; all other CIDRs will be blocked. " +
112+
"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.")
113+
private List<String> sourceCidrList;
110114

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

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

165165
public Boolean getOpenFirewall() {
@@ -332,19 +332,15 @@ public int getDestinationPortEnd() {
332332

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

342+
_rulesService.validatePortForwardingSourceCidrList(sourceCidrList);
343+
348344
try {
349345
PortForwardingRule result = _rulesService.createPortForwardingRule(this, virtualMachineId, privateIp, getOpenFirewall(), isDisplay());
350346
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
@@ -32,6 +32,8 @@
3232
import com.cloud.user.Account;
3333
import com.cloud.utils.net.Ip;
3434

35+
import java.util.List;
36+
3537
@APICommand(name = "updatePortForwardingRule",
3638
responseObject = FirewallRuleResponse.class,
3739
description = "Updates a port forwarding rule. Only the private port and the virtual machine can be updated.", entityType = {PortForwardingRule.class},
@@ -63,6 +65,13 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCustomIdCmd {
6365
@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})
6466
private Boolean display;
6567

68+
@Parameter(name = ApiConstants.CIDR_LIST,
69+
type = CommandType.LIST,
70+
collectionType = CommandType.STRING,
71+
description = " the source CIDR list to allow traffic from; all other CIDRs will be blocked. " +
72+
"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.")
73+
private List<String> sourceCidrList;
74+
6675
/////////////////////////////////////////////////////
6776
/////////////////// Accessors ///////////////////////
6877
/////////////////////////////////////////////////////
@@ -94,6 +103,10 @@ public Boolean getDisplay() {
94103
return display;
95104
}
96105

106+
public List<String> getSourceCidrList() {
107+
return sourceCidrList;
108+
}
109+
97110
/////////////////////////////////////////////////////
98111
/////////////// API Implementation///////////////////
99112
/////////////////////////////////////////////////////
@@ -130,7 +143,7 @@ public void checkUuid() {
130143

131144
@Override
132145
public void execute() {
133-
PortForwardingRule rule = _rulesService.updatePortForwardingRule(getId(), getPrivatePort(), getPrivateEndPort(), getVirtualMachineId(), getVmGuestIp(), getCustomId(), getDisplay());
146+
PortForwardingRule rule = _rulesService.updatePortForwardingRule(this);
134147
FirewallRuleResponse fwResponse = new FirewallRuleResponse();
135148
if (rule != null) {
136149
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
@@ -104,7 +104,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements L
104104
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "the domain ID associated with the load balancer")
105105
private Long domainId;
106106

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

core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
public class ConvertInstanceAnswer extends Answer {
2222

23+
private String temporaryConvertUuid;
24+
2325
public ConvertInstanceAnswer() {
2426
super();
2527
}
@@ -34,6 +36,15 @@ public ConvertInstanceAnswer(Command command, UnmanagedInstanceTO convertedInsta
3436
this.convertedInstance = convertedInstance;
3537
}
3638

39+
public ConvertInstanceAnswer(Command command, String temporaryConvertUuid) {
40+
super(command, true, "");
41+
this.temporaryConvertUuid = temporaryConvertUuid;
42+
}
43+
44+
public String getTemporaryConvertUuid() {
45+
return temporaryConvertUuid;
46+
}
47+
3748
public UnmanagedInstanceTO getConvertedInstance() {
3849
return convertedInstance;
3950
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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 com.cloud.agent.api;
18+
19+
import org.apache.cloudstack.vm.UnmanagedInstanceTO;
20+
21+
public class ImportConvertedInstanceAnswer extends Answer {
22+
23+
public ImportConvertedInstanceAnswer() {
24+
super();
25+
}
26+
private UnmanagedInstanceTO convertedInstance;
27+
28+
public ImportConvertedInstanceAnswer(Command command, boolean success, String details) {
29+
super(command, success, details);
30+
}
31+
32+
public ImportConvertedInstanceAnswer(Command command, UnmanagedInstanceTO convertedInstance) {
33+
super(command, true, "");
34+
this.convertedInstance = convertedInstance;
35+
}
36+
37+
public UnmanagedInstanceTO getConvertedInstance() {
38+
return convertedInstance;
39+
}
40+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 com.cloud.agent.api;
18+
19+
import com.cloud.agent.api.to.DataStoreTO;
20+
import com.cloud.agent.api.to.RemoteInstanceTO;
21+
22+
import java.util.List;
23+
24+
public class ImportConvertedInstanceCommand extends Command {
25+
26+
private RemoteInstanceTO sourceInstance;
27+
private List<String> destinationStoragePools;
28+
private DataStoreTO conversionTemporaryLocation;
29+
private String temporaryConvertUuid;
30+
31+
public ImportConvertedInstanceCommand() {
32+
}
33+
34+
public ImportConvertedInstanceCommand(RemoteInstanceTO sourceInstance,
35+
List<String> destinationStoragePools,
36+
DataStoreTO conversionTemporaryLocation, String temporaryConvertUuid) {
37+
this.sourceInstance = sourceInstance;
38+
this.destinationStoragePools = destinationStoragePools;
39+
this.conversionTemporaryLocation = conversionTemporaryLocation;
40+
this.temporaryConvertUuid = temporaryConvertUuid;
41+
}
42+
43+
public RemoteInstanceTO getSourceInstance() {
44+
return sourceInstance;
45+
}
46+
47+
public List<String> getDestinationStoragePools() {
48+
return destinationStoragePools;
49+
}
50+
51+
public DataStoreTO getConversionTemporaryLocation() {
52+
return conversionTemporaryLocation;
53+
}
54+
55+
public String getTemporaryConvertUuid() {
56+
return temporaryConvertUuid;
57+
}
58+
59+
@Override
60+
public boolean executeInSequence() {
61+
return false;
62+
}
63+
}

0 commit comments

Comments
 (0)