Skip to content

Commit 0753d6d

Browse files
committed
Merge remote-tracking branch 'apache/main' into 4.20-routed-mode-improvement
2 parents b5360ae + bf2cede commit 0753d6d

File tree

41 files changed

+720
-321
lines changed

Some content is hidden

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

41 files changed

+720
-321
lines changed

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

Lines changed: 2 additions & 2 deletions
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

@@ -360,6 +360,6 @@ List<String[]> generateVmData(String userData, String userDataDetails, String se
360360

361361
boolean isSecurityGroupSupportedForZone(Long zoneId);
362362

363-
boolean checkSecurityGroupSupportForNetwork(DataCenter zone, List<Long> networkIds,
363+
boolean checkSecurityGroupSupportForNetwork(Account account, DataCenter zone, List<Long> networkIds,
364364
List<Long> securityGroupsIds);
365365
}

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.20.0.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>
@@ -1113,6 +1097,11 @@
11131097
<artifactId>cloud-plugin-network-nsx</artifactId>
11141098
<version>${project.version}</version>
11151099
</dependency>
1100+
<dependency>
1101+
<groupId>org.apache.cloudstack</groupId>
1102+
<artifactId>cloud-plugin-network-tungsten</artifactId>
1103+
<version>${project.version}</version>
1104+
</dependency>
11161105
<dependency>
11171106
<groupId>org.apache.cloudstack</groupId>
11181107
<artifactId>cloud-plugin-api-vmware-sioc</artifactId>

core/src/main/java/com/cloud/network/HAProxyConfigurator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ private List<String> getRulesForPool(final LoadBalancerTO lbTO, final boolean ke
485485
sb.append("\tbind ").append(publicIP).append(":").append(publicPort);
486486
result.add(sb.toString());
487487
sb = new StringBuilder();
488-
sb.append("\t").append("balance ").append(algorithm);
488+
sb.append("\t").append("balance ").append(algorithm.toLowerCase());
489489
result.add(sb.toString());
490490

491491
int i = 0;

engine/schema/src/main/java/com/cloud/upgrade/SystemVmTemplateRegistration.java

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@
4949
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
5050
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
5151
import org.apache.cloudstack.framework.config.dao.ConfigurationDaoImpl;
52+
import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
5253
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
5354
import org.apache.cloudstack.storage.datastore.db.ImageStoreDaoImpl;
55+
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
56+
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDaoImpl;
5457
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
5558
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
5659
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
@@ -117,6 +120,8 @@ public class SystemVmTemplateRegistration {
117120
@Inject
118121
ImageStoreDao imageStoreDao;
119122
@Inject
123+
ImageStoreDetailsDao imageStoreDetailsDao;
124+
@Inject
120125
ClusterDao clusterDao;
121126
@Inject
122127
ConfigurationDao configurationDao;
@@ -130,6 +135,7 @@ public SystemVmTemplateRegistration() {
130135
templateDataStoreDao = new BasicTemplateDataStoreDaoImpl();
131136
vmInstanceDao = new VMInstanceDaoImpl();
132137
imageStoreDao = new ImageStoreDaoImpl();
138+
imageStoreDetailsDao = new ImageStoreDetailsDaoImpl();
133139
clusterDao = new ClusterDaoImpl();
134140
configurationDao = new ConfigurationDaoImpl();
135141
}
@@ -142,6 +148,14 @@ public SystemVmTemplateRegistration(String systemVmTemplateVersion) {
142148
this.systemVmTemplateVersion = systemVmTemplateVersion;
143149
}
144150

151+
public static String getMountCommand(String nfsVersion, String device, String dir) {
152+
String cmd = "sudo mount -t nfs";
153+
if (StringUtils.isNotBlank(nfsVersion)) {
154+
cmd = String.format("%s -o vers=%s", cmd, nfsVersion);
155+
}
156+
return String.format("%s %s %s", cmd, device, dir);
157+
}
158+
145159
public String getSystemVmTemplateVersion() {
146160
if (StringUtils.isEmpty(systemVmTemplateVersion)) {
147161
return String.format("%s.%s", CS_MAJOR_VERSION, CS_TINY_VERSION);
@@ -320,14 +334,14 @@ public void setUpdated(Date updated) {
320334
}
321335
};
322336

323-
public static boolean validateIfSeeded(String url, String path) {
337+
public static boolean validateIfSeeded(String url, String path, String nfsVersion) {
324338
String filePath = null;
325339
try {
326340
filePath = Files.createTempDirectory(TEMPORARY_SECONDARY_STORE).toString();
327341
if (filePath == null) {
328342
throw new CloudRuntimeException("Failed to create temporary directory to mount secondary store");
329343
}
330-
mountStore(url, filePath);
344+
mountStore(url, filePath, nfsVersion);
331345
int lastIdx = path.lastIndexOf(File.separator);
332346
String partialDirPath = path.substring(0, lastIdx);
333347
String templatePath = filePath + File.separator + partialDirPath;
@@ -427,14 +441,13 @@ private Pair<String, Long> getNfsStoreInZone(Long zoneId) {
427441
return new Pair<>(url, storeId);
428442
}
429443

430-
public static void mountStore(String storeUrl, String path) {
444+
public static void mountStore(String storeUrl, String path, String nfsVersion) {
431445
try {
432446
if (storeUrl != null) {
433447
URI uri = new URI(UriUtils.encodeURIComponent(storeUrl));
434448
String host = uri.getHost();
435449
String mountPath = uri.getPath();
436-
String mount = String.format(MOUNT_COMMAND, host + ":" + mountPath, path);
437-
Script.runSimpleBashScript(mount);
450+
Script.runSimpleBashScript(getMountCommand(nfsVersion, host + ":" + mountPath, path));
438451
}
439452
} catch (Exception e) {
440453
String msg = "NFS Store URL is not in the correct format";
@@ -773,7 +786,8 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
773786
throw new CloudRuntimeException("Failed to create temporary file path to mount the store");
774787
}
775788
Pair<String, Long> storeUrlAndId = getNfsStoreInZone(zoneId);
776-
mountStore(storeUrlAndId.first(), filePath);
789+
String nfsVersion = getNfsVersion(storeUrlAndId.second());
790+
mountStore(storeUrlAndId.first(), filePath, nfsVersion);
777791
List<String> hypervisorList = fetchAllHypervisors(zoneId);
778792
for (String hypervisor : hypervisorList) {
779793
Hypervisor.HypervisorType name = Hypervisor.HypervisorType.getType(hypervisor);
@@ -784,7 +798,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
784798
VMTemplateVO templateVO = vmTemplateDao.findById(templateId);
785799
TemplateDataStoreVO templateDataStoreVO = templateDataStoreDao.findByTemplate(templateId, DataStoreRole.Image);
786800
String installPath = templateDataStoreVO.getInstallPath();
787-
if (validateIfSeeded(storeUrlAndId.first(), installPath)) {
801+
if (validateIfSeeded(storeUrlAndId.first(), installPath, nfsVersion)) {
788802
continue;
789803
} else if (templateVO != null) {
790804
registerTemplate(hypervisorAndTemplateName, storeUrlAndId, templateVO, templateDataStoreVO, filePath);
@@ -889,4 +903,17 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
889903
}
890904
});
891905
}
906+
907+
public String getNfsVersion(long storeId) {
908+
final String configKey = "secstorage.nfs.version";
909+
final Map<String, String> storeDetails = imageStoreDetailsDao.getDetails(storeId);
910+
if (storeDetails != null && storeDetails.containsKey(configKey)) {
911+
return storeDetails.get(configKey);
912+
}
913+
ConfigurationVO globalNfsVersion = configurationDao.findByName(configKey);
914+
if (globalNfsVersion != null) {
915+
return globalNfsVersion.getValue();
916+
}
917+
return null;
918+
}
892919
}

plugins/hypervisors/kvm/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@
8383
<version>${project.version}</version>
8484
<scope>compile</scope>
8585
</dependency>
86-
<dependency>
87-
<groupId>org.apache.cloudstack</groupId>
88-
<artifactId>cloud-plugin-network-tungsten</artifactId>
89-
<version>${project.version}</version>
90-
</dependency>
9186
</dependencies>
9287
<build>
9388
<plugins>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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.network.tungsten.agent.api;
18+
19+
import com.cloud.agent.api.Command;
20+
21+
import java.util.Objects;
22+
23+
public class SetupTfRouteCommand extends Command {
24+
private final String privateIp;
25+
private final String publicIp;
26+
private final String srcNetwork;
27+
28+
public SetupTfRouteCommand(final String privateIp, final String publicIp, final String srcNetwork) {
29+
this.privateIp = privateIp;
30+
this.publicIp = publicIp;
31+
this.srcNetwork = srcNetwork;
32+
}
33+
34+
public String getPrivateIp() {
35+
return privateIp;
36+
}
37+
38+
public String getPublicIp() {
39+
return publicIp;
40+
}
41+
42+
public String getSrcNetwork() {
43+
return srcNetwork;
44+
}
45+
46+
@Override
47+
public boolean equals(Object o) {
48+
if (this == o) return true;
49+
if (o == null || getClass() != o.getClass()) return false;
50+
if (!super.equals(o)) return false;
51+
SetupTfRouteCommand that = (SetupTfRouteCommand) o;
52+
return Objects.equals(privateIp, that.privateIp) && Objects.equals(publicIp, that.publicIp) && Objects.equals(srcNetwork, that.srcNetwork);
53+
}
54+
55+
@Override
56+
public int hashCode() {
57+
return Objects.hash(super.hashCode(), privateIp, publicIp, srcNetwork);
58+
}
59+
60+
@Override
61+
public boolean executeInSequence() {
62+
return false;
63+
}
64+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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.network.tungsten.agent.api;
18+
19+
import com.cloud.agent.api.Command;
20+
21+
import java.util.Objects;
22+
23+
public class SetupTungstenVRouterCommand extends Command {
24+
private final String oper;
25+
private final String inf;
26+
private final String subnet;
27+
private final String route;
28+
private final String vrf;
29+
30+
public SetupTungstenVRouterCommand(final String oper, final String inf, final String subnet, final String route,
31+
final String vrf) {
32+
this.oper = oper;
33+
this.inf = inf;
34+
this.subnet = subnet;
35+
this.route = route;
36+
this.vrf = vrf;
37+
}
38+
39+
public String getOper() {
40+
return oper;
41+
}
42+
43+
public String getInf() {
44+
return inf;
45+
}
46+
47+
public String getSubnet() {
48+
return subnet;
49+
}
50+
51+
public String getRoute() {
52+
return route;
53+
}
54+
55+
public String getVrf() {
56+
return vrf;
57+
}
58+
59+
@Override
60+
public boolean equals(Object o) {
61+
if (this == o) return true;
62+
if (o == null || getClass() != o.getClass()) return false;
63+
if (!super.equals(o)) return false;
64+
SetupTungstenVRouterCommand that = (SetupTungstenVRouterCommand) o;
65+
return Objects.equals(oper, that.oper) && Objects.equals(inf, that.inf) && Objects.equals(subnet, that.subnet) && Objects.equals(route, that.route) && Objects.equals(vrf, that.vrf);
66+
}
67+
68+
@Override
69+
public int hashCode() {
70+
return Objects.hash(super.hashCode(), oper, inf, subnet, route, vrf);
71+
}
72+
73+
@Override
74+
public boolean executeInSequence() {
75+
return false;
76+
}
77+
}

0 commit comments

Comments
 (0)