Skip to content

Commit 23a53e2

Browse files
authored
Add LB service to Custom Netris VPC/Network offerings (#11410)
* Add LB service to Custom VPC/Network offerings * fix offering * externalize common checks to a utility file * remove trailing spaces
1 parent 9317a46 commit 23a53e2

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

api/src/main/java/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
import static com.cloud.network.Network.Service.UserData;
6262
import static com.cloud.network.Network.Service.Firewall;
6363

64+
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisNatted;
65+
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisRouted;
66+
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNsxWithoutLb;
67+
6468
@APICommand(name = "createNetworkOffering", description = "Creates a network offering.", responseObject = NetworkOfferingResponse.class, since = "3.0.0",
6569
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
6670
public class CreateNetworkOfferingCmd extends BaseCmd {
@@ -297,7 +301,7 @@ public List<String> getSupportedServices() {
297301
SourceNat.getName(),
298302
PortForwarding.getName()));
299303
}
300-
if (getNsxSupportsLbService()) {
304+
if (getNsxSupportsLbService() || (provider != null && isNetrisNatted(getProvider(), getNetworkMode()))) {
301305
services.add(Lb.getName());
302306
}
303307
if (Boolean.TRUE.equals(forVpc)) {
@@ -410,7 +414,7 @@ private void getServiceProviderMapForExternalProvider(Map<String, List<String>>
410414
else if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMode()) || NetworkACL.getName().equalsIgnoreCase(service)) {
411415
serviceProviderMap.put(service, List.of(provider));
412416
}
413-
if (!getNsxSupportsLbService()) {
417+
if (isNsxWithoutLb(getProvider(), getNsxSupportsLbService()) || isNetrisRouted(getProvider(), getNetworkMode())) {
414418
serviceProviderMap.remove(Lb.getName());
415419
}
416420
}

api/src/main/java/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
import static com.cloud.network.Network.Service.UserData;
6363
import static com.cloud.network.Network.Service.Gateway;
6464

65+
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisNatted;
66+
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisRouted;
67+
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNsxWithoutLb;
68+
6569
@APICommand(name = "createVPCOffering", description = "Creates VPC offering", responseObject = VpcOfferingResponse.class,
6670
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
6771
public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
@@ -194,7 +198,7 @@ public List<String> getSupportedServices() {
194198
if (NetworkOffering.NetworkMode.ROUTED.name().equalsIgnoreCase(getNetworkMode())) {
195199
supportedServices.add(Gateway.getName());
196200
}
197-
if (getNsxSupportsLbService()) {
201+
if (getNsxSupportsLbService() || isNetrisNatted(getProvider(), getNetworkMode())) {
198202
supportedServices.add(Lb.getName());
199203
}
200204
}
@@ -259,7 +263,7 @@ else if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMo
259263
serviceProviderMap.put(service, List.of(provider));
260264
}
261265
}
262-
if (!getNsxSupportsLbService()) {
266+
if ((isNsxWithoutLb(getProvider(), getNsxSupportsLbService())) || isNetrisRouted(getProvider(), getNetworkMode())) {
263267
serviceProviderMap.remove(Lb.getName());
264268
}
265269
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.utils;
18+
19+
import com.cloud.offering.NetworkOffering;
20+
21+
public class OfferingUtils {
22+
23+
private OfferingUtils() {
24+
}
25+
26+
public static boolean isNetrisNatted(String provider, String networkMode) {
27+
return "Netris".equalsIgnoreCase(provider) &&
28+
NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(networkMode);
29+
}
30+
31+
public static boolean isNsxWithoutLb(String provider, boolean nsxSupportsLbService) {
32+
return "Nsx".equalsIgnoreCase(provider) && !nsxSupportsLbService;
33+
}
34+
35+
public static boolean isNetrisRouted(String provider, String networkMode) {
36+
return "Netris".equalsIgnoreCase(provider) && NetworkOffering.NetworkMode.ROUTED.name().equalsIgnoreCase(networkMode);
37+
}
38+
}

0 commit comments

Comments
 (0)