mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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
This commit is contained in:
parent
9317a46513
commit
23a53e213e
@ -61,6 +61,10 @@ import static com.cloud.network.Network.Service.NetworkACL;
|
|||||||
import static com.cloud.network.Network.Service.UserData;
|
import static com.cloud.network.Network.Service.UserData;
|
||||||
import static com.cloud.network.Network.Service.Firewall;
|
import static com.cloud.network.Network.Service.Firewall;
|
||||||
|
|
||||||
|
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisNatted;
|
||||||
|
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisRouted;
|
||||||
|
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNsxWithoutLb;
|
||||||
|
|
||||||
@APICommand(name = "createNetworkOffering", description = "Creates a network offering.", responseObject = NetworkOfferingResponse.class, since = "3.0.0",
|
@APICommand(name = "createNetworkOffering", description = "Creates a network offering.", responseObject = NetworkOfferingResponse.class, since = "3.0.0",
|
||||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||||
public class CreateNetworkOfferingCmd extends BaseCmd {
|
public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||||
@ -297,7 +301,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
|||||||
SourceNat.getName(),
|
SourceNat.getName(),
|
||||||
PortForwarding.getName()));
|
PortForwarding.getName()));
|
||||||
}
|
}
|
||||||
if (getNsxSupportsLbService()) {
|
if (getNsxSupportsLbService() || (provider != null && isNetrisNatted(getProvider(), getNetworkMode()))) {
|
||||||
services.add(Lb.getName());
|
services.add(Lb.getName());
|
||||||
}
|
}
|
||||||
if (Boolean.TRUE.equals(forVpc)) {
|
if (Boolean.TRUE.equals(forVpc)) {
|
||||||
@ -410,7 +414,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
|||||||
else if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMode()) || NetworkACL.getName().equalsIgnoreCase(service)) {
|
else if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMode()) || NetworkACL.getName().equalsIgnoreCase(service)) {
|
||||||
serviceProviderMap.put(service, List.of(provider));
|
serviceProviderMap.put(service, List.of(provider));
|
||||||
}
|
}
|
||||||
if (!getNsxSupportsLbService()) {
|
if (isNsxWithoutLb(getProvider(), getNsxSupportsLbService()) || isNetrisRouted(getProvider(), getNetworkMode())) {
|
||||||
serviceProviderMap.remove(Lb.getName());
|
serviceProviderMap.remove(Lb.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,6 +62,10 @@ import static com.cloud.network.Network.Service.NetworkACL;
|
|||||||
import static com.cloud.network.Network.Service.UserData;
|
import static com.cloud.network.Network.Service.UserData;
|
||||||
import static com.cloud.network.Network.Service.Gateway;
|
import static com.cloud.network.Network.Service.Gateway;
|
||||||
|
|
||||||
|
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisNatted;
|
||||||
|
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisRouted;
|
||||||
|
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNsxWithoutLb;
|
||||||
|
|
||||||
@APICommand(name = "createVPCOffering", description = "Creates VPC offering", responseObject = VpcOfferingResponse.class,
|
@APICommand(name = "createVPCOffering", description = "Creates VPC offering", responseObject = VpcOfferingResponse.class,
|
||||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||||
public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
|
public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
|
||||||
@ -194,7 +198,7 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
|
|||||||
if (NetworkOffering.NetworkMode.ROUTED.name().equalsIgnoreCase(getNetworkMode())) {
|
if (NetworkOffering.NetworkMode.ROUTED.name().equalsIgnoreCase(getNetworkMode())) {
|
||||||
supportedServices.add(Gateway.getName());
|
supportedServices.add(Gateway.getName());
|
||||||
}
|
}
|
||||||
if (getNsxSupportsLbService()) {
|
if (getNsxSupportsLbService() || isNetrisNatted(getProvider(), getNetworkMode())) {
|
||||||
supportedServices.add(Lb.getName());
|
supportedServices.add(Lb.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,7 +263,7 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
|
|||||||
serviceProviderMap.put(service, List.of(provider));
|
serviceProviderMap.put(service, List.of(provider));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!getNsxSupportsLbService()) {
|
if ((isNsxWithoutLb(getProvider(), getNsxSupportsLbService())) || isNetrisRouted(getProvider(), getNetworkMode())) {
|
||||||
serviceProviderMap.remove(Lb.getName());
|
serviceProviderMap.remove(Lb.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,38 @@
|
|||||||
|
// Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
// or more contributor license agreements. See the NOTICE file
|
||||||
|
// distributed with this work for additional information
|
||||||
|
// regarding copyright ownership. The ASF licenses this file
|
||||||
|
// to you under the Apache License, Version 2.0 (the
|
||||||
|
// "License"); you may not use this file except in compliance
|
||||||
|
// with the License. You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing,
|
||||||
|
// software distributed under the License is distributed on an
|
||||||
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
// KIND, either express or implied. See the License for the
|
||||||
|
// specific language governing permissions and limitations
|
||||||
|
// under the License.
|
||||||
|
package org.apache.cloudstack.api.command.utils;
|
||||||
|
|
||||||
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
|
||||||
|
public class OfferingUtils {
|
||||||
|
|
||||||
|
private OfferingUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNetrisNatted(String provider, String networkMode) {
|
||||||
|
return "Netris".equalsIgnoreCase(provider) &&
|
||||||
|
NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(networkMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNsxWithoutLb(String provider, boolean nsxSupportsLbService) {
|
||||||
|
return "Nsx".equalsIgnoreCase(provider) && !nsxSupportsLbService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNetrisRouted(String provider, String networkMode) {
|
||||||
|
return "Netris".equalsIgnoreCase(provider) && NetworkOffering.NetworkMode.ROUTED.name().equalsIgnoreCase(networkMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user