diff --git a/api/src/main/java/com/cloud/network/Network.java b/api/src/main/java/com/cloud/network/Network.java index 458169c80aa..be0753e3e91 100644 --- a/api/src/main/java/com/cloud/network/Network.java +++ b/api/src/main/java/com/cloud/network/Network.java @@ -205,6 +205,9 @@ public interface Network extends ControlledEntity, StateObject, I //Add Tungsten Fabric provider public static final Provider Tungsten = new Provider("Tungsten", false); + //TODO: should it be true? + public static final Provider Nsx = new Provider("Nsx", false); + private final String name; private final boolean isExternal; diff --git a/api/src/main/java/com/cloud/offering/NetworkOffering.java b/api/src/main/java/com/cloud/offering/NetworkOffering.java index 207880ea28c..7f0dc85b05f 100644 --- a/api/src/main/java/com/cloud/offering/NetworkOffering.java +++ b/api/src/main/java/com/cloud/offering/NetworkOffering.java @@ -52,6 +52,7 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity, public final static String DefaultSharedNetworkOfferingWithSGService = "DefaultSharedNetworkOfferingWithSGService"; public static final String DEFAULT_TUNGSTEN_SHARED_NETWORK_OFFERING_WITH_SGSERVICE = "DefaultTungstenSharedNetworkOfferingWithSGService"; + public static final String DEFAULT_NSX_OFFERING = "DefaultNSXNetworkOffering"; public final static String QuickCloudNoServices = "QuickCloudNoServices"; public final static String DefaultIsolatedNetworkOfferingWithSourceNatService = "DefaultIsolatedNetworkOfferingWithSourceNatService"; public final static String OvsIsolatedNetworkOfferingWithSourceNatService = "OvsIsolatedNetworkOfferingWithSourceNatService"; diff --git a/client/pom.xml b/client/pom.xml index cbe45d88b6c..5c84ce2c02b 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -226,6 +226,11 @@ cloud-plugin-network-tungsten ${project.version} + + org.apache.cloudstack + cloud-plugin-network-nsx + ${project.version} + org.apache.cloudstack cloud-plugin-network-elb diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index 4ff295be78a..77b14d31387 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@ -469,6 +469,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra final Map> defaultSharedNetworkOfferingProviders = new HashMap>(); final Set defaultProviders = new HashSet(); final Set tungstenProvider = new HashSet<>(); + final Set nsxProvider = new HashSet<>(); defaultProviders.add(Network.Provider.VirtualRouter); defaultSharedNetworkOfferingProviders.put(Service.Dhcp, defaultProviders); @@ -502,6 +503,12 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra defaultTungstenSharedSGEnabledNetworkOfferingProviders.put(Service.UserData, tungstenProvider); defaultTungstenSharedSGEnabledNetworkOfferingProviders.put(Service.SecurityGroup, tungstenProvider); + nsxProvider.add(Provider.Nsx); + final Map> defaultNSXEnabledNetworkOfferingProviders = new HashMap<>(); + defaultNSXEnabledNetworkOfferingProviders.put(Service.Connectivity, nsxProvider); + defaultNSXEnabledNetworkOfferingProviders.put(Service.Dhcp, nsxProvider); + defaultNSXEnabledNetworkOfferingProviders.put(Service.Dns, nsxProvider); + final Map> defaultIsolatedSourceNatEnabledNetworkOfferingProviders = new HashMap>(); defaultProviders.clear(); defaultProviders.add(Network.Provider.VirtualRouter); @@ -578,6 +585,14 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true, false, null, null, true, null); } + if (_networkOfferingDao.findByUniqueName(NetworkOffering.DEFAULT_NSX_OFFERING) == null) { + offering = _configMgr.createNetworkOffering(NetworkOffering.DEFAULT_NSX_OFFERING, "Offering for Nsx networks", + TrafficType.Guest, null, false, Availability.Optional, null, + defaultNSXEnabledNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true, false, null, null, true, null); + offering.setState(NetworkOffering.State.Enabled); + _networkOfferingDao.update(offering.getId(), offering); + } + //#6 - default vpc offering with no LB service if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB) == null) { //remove LB service @@ -3793,8 +3808,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra for (final NicVO nic : result) { if (_networkModel.isProviderForNetwork(Provider.NiciraNvp, nic.getNetworkId())) { - //For NSX Based networks, add nsxlogicalswitch, nsxlogicalswitchport to each result - s_logger.info("Listing NSX logical switch and logical switch por for each nic"); + //For Nsx Based networks, add nsxlogicalswitch, nsxlogicalswitchport to each result + s_logger.info("Listing Nsx logical switch and logical switch por for each nic"); final NetworkVO network = _networksDao.findById(nic.getNetworkId()); final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName()); final NetworkGuruAdditionalFunctions guruFunctions = (NetworkGuruAdditionalFunctions) guru; diff --git a/plugins/network-elements/nsx/pom.xml b/plugins/network-elements/nsx/pom.xml new file mode 100644 index 00000000000..9350e2aedaf --- /dev/null +++ b/plugins/network-elements/nsx/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + cloud-plugin-network-nsx + Apache CloudStack Plugin - NSX Network + + + org.apache.cloudstack + cloudstack-plugins + 4.19.0.0-SNAPSHOT + ../../pom.xml + + diff --git a/plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxElement.java b/plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxElement.java new file mode 100644 index 00000000000..c6c305c73e9 --- /dev/null +++ b/plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxElement.java @@ -0,0 +1,178 @@ +package org.apache.cloudstack.service; + +import com.cloud.deploy.DeployDestination; +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.network.Network; +import com.cloud.network.PhysicalNetworkServiceProvider; +import com.cloud.network.element.DhcpServiceProvider; +import com.cloud.network.element.DnsServiceProvider; +import com.cloud.offering.NetworkOffering; +import com.cloud.utils.component.AdapterBase; +import com.cloud.vm.NicProfile; +import com.cloud.vm.ReservationContext; +import com.cloud.vm.VirtualMachineProfile; +import org.apache.log4j.Logger; + +import javax.naming.ConfigurationException; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class NsxElement extends AdapterBase implements DhcpServiceProvider, DnsServiceProvider { + private static final Logger LOGGER = Logger.getLogger(NsxElement.class); + + private final Map> capabilities = initCapabilities(); + + + private static Map> initCapabilities() { + Map> capabilities = new HashMap<>(); + Map dhcpCapabilities = Map.of(Network.Capability.DhcpAccrossMultipleSubnets, "true"); + capabilities.put(Network.Service.Dhcp, dhcpCapabilities); + Map dnsCapabilities = new HashMap<>(); + dnsCapabilities.put(Network.Capability.AllowDnsSuffixModification, "true"); + capabilities.put(Network.Service.Dns, dnsCapabilities); + capabilities.put(Network.Service.Connectivity, null); + return capabilities; + } + @Override + public boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { + return true; + } + + @Override + public boolean configDhcpSupportForSubnet(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { + return true; + } + + @Override + public boolean removeDhcpSupportForSubnet(Network network) throws ResourceUnavailableException { + return true; + } + + @Override + public boolean setExtraDhcpOptions(Network network, long nicId, Map dhcpOptions) { + return true; + } + + @Override + public boolean removeDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile vmProfile) throws ResourceUnavailableException { + return true; + } + + @Override + public boolean addDnsEntry(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { + return true; + } + + @Override + public boolean configDnsSupportForSubnet(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { + return true; + } + + @Override + public boolean removeDnsSupportForSubnet(Network network) throws ResourceUnavailableException { + return true; + } + + @Override + public Map> getCapabilities() { + return capabilities; + } + + @Override + public Network.Provider getProvider() { + return Network.Provider.Nsx; + } + + @Override + public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { + return false; + } + + @Override + public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { + return false; + } + + @Override + public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { + return false; + } + + @Override + public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException { + return false; + } + + @Override + public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { + return false; + } + + @Override + public boolean isReady(PhysicalNetworkServiceProvider provider) { + return false; + } + + @Override + public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { + return false; + } + + @Override + public boolean canEnableIndividualServices() { + return false; + } + + @Override + public boolean verifyServicesCombination(Set services) { + return false; + } + + @Override + public String getName() { + return null; + } + + @Override + public void setName(String name) { + + } + + @Override + public void setConfigParams(Map params) { + + } + + @Override + public Map getConfigParams() { + return null; + } + + @Override + public int getRunLevel() { + return 0; + } + + @Override + public void setRunLevel(int level) { + + } + + @Override + public boolean configure(String name, Map params) throws ConfigurationException { + return false; + } + + @Override + public boolean start() { + return false; + } + + @Override + public boolean stop() { + return false; + } +} diff --git a/plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxService.java b/plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxService.java new file mode 100644 index 00000000000..2782c8f050a --- /dev/null +++ b/plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxService.java @@ -0,0 +1,4 @@ +package org.apache.cloudstack.service; + +public interface NsxService { +} diff --git a/plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxServiceImpl.java b/plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxServiceImpl.java new file mode 100644 index 00000000000..079b35b51f7 --- /dev/null +++ b/plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxServiceImpl.java @@ -0,0 +1,4 @@ +package org.apache.cloudstack.service; + +public class NsxServiceImpl implements NsxService { +} diff --git a/plugins/network-elements/nsx/src/main/resources/META-INF.cloudstack.nsx/module.properties b/plugins/network-elements/nsx/src/main/resources/META-INF.cloudstack.nsx/module.properties new file mode 100644 index 00000000000..0126f2e007f --- /dev/null +++ b/plugins/network-elements/nsx/src/main/resources/META-INF.cloudstack.nsx/module.properties @@ -0,0 +1,21 @@ +# +# 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. +# + +name=nsx +parent=network \ No newline at end of file diff --git a/plugins/network-elements/nsx/src/main/resources/META-INF.cloudstack.nsx/spring-nsx-context.xml b/plugins/network-elements/nsx/src/main/resources/META-INF.cloudstack.nsx/spring-nsx-context.xml new file mode 100644 index 00000000000..c7be491e247 --- /dev/null +++ b/plugins/network-elements/nsx/src/main/resources/META-INF.cloudstack.nsx/spring-nsx-context.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/plugins/pom.xml b/plugins/pom.xml index d0661c01a2c..bc28c777db7 100755 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -110,6 +110,7 @@ network-elements/brocade-vcs network-elements/vxlan network-elements/tungsten + network-elements/nsx outofbandmanagement-drivers/ipmitool outofbandmanagement-drivers/nested-cloudstack diff --git a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java index ac698f69689..c527e6af9a4 100644 --- a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java @@ -4021,6 +4021,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C // Add the config drive provider addConfigDriveToPhysicalNetwork(pNetwork.getId()); + addNSXProviderToPhysicalNetwork(pNetwork.getId()); CallContext.current().putContextParameter(PhysicalNetwork.class, pNetwork.getUuid()); @@ -5417,6 +5418,22 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C } + private PhysicalNetworkServiceProvider addNSXProviderToPhysicalNetwork(long physicalNetworkId) { + PhysicalNetworkVO pvo = _physicalNetworkDao.findById(physicalNetworkId); + DataCenterVO dvo = _dcDao.findById(pvo.getDataCenterId()); + if (dvo.getNetworkType() == NetworkType.Advanced) { + + Provider provider = Network.Provider.getProvider("Nsx"); + if (provider == null) { + return null; + } + + addProviderToPhysicalNetwork(physicalNetworkId, Provider.Nsx.getName(), null, null); + enableProvider(Provider.Nsx.getName()); + } + return null; + } + protected boolean isNetworkSystem(Network network) { NetworkOffering no = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); if (no.isSystemOnly()) {