From d467a6b8ecdf87d5ccd021bca98769a39070c34e Mon Sep 17 00:00:00 2001 From: Frank Maximus Date: Wed, 24 May 2017 12:46:01 +0200 Subject: [PATCH] CLOUDSTACK-9450: Network Offering for VPC based on DB flag Co-Authored-By: Raf Smeets --- .../com/cloud/offering/NetworkOffering.java | 2 + .../network/CreateNetworkOfferingCmd.java | 9 ++ .../configuration/ConfigurationManager.java | 8 +- .../orchestration/NetworkOrchestrator.java | 18 +-- .../cloud/offerings/NetworkOfferingVO.java | 22 +++- .../management/ContrailManagerImpl.java | 4 +- .../network/manager/NuageVspManagerImpl.java | 3 +- .../ConfigurationManagerImpl.java | 43 +++++-- .../cloud/server/ConfigurationServerImpl.java | 16 +-- .../ConfigurationManagerTest.java | 22 +--- .../network/CreatePrivateNetworkTest.java | 18 +-- .../vpc/MockConfigurationManagerImpl.java | 6 +- .../vpc/dao/MockNetworkOfferingDaoImpl.java | 12 +- .../CreateNetworkOfferingTest.java | 20 ++-- setup/db/db/schema-41000to41100.sql | 16 +++ .../plugins/nuagevsp/test_nuage_static_nat.py | 107 ++++++++++++++++++ tools/marvin/marvin/lib/base.py | 2 +- ui/scripts/configuration.js | 13 ++- 18 files changed, 252 insertions(+), 89 deletions(-) diff --git a/api/src/com/cloud/offering/NetworkOffering.java b/api/src/com/cloud/offering/NetworkOffering.java index 402846202e7..3532010f1fa 100644 --- a/api/src/com/cloud/offering/NetworkOffering.java +++ b/api/src/com/cloud/offering/NetworkOffering.java @@ -78,6 +78,8 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity, */ Integer getMulticastRateMbps(); + boolean getForVpc(); + TrafficType getTrafficType(); boolean getSpecifyVlan(); diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java index 259c4905ed1..7c8c46a9c9e 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java @@ -112,6 +112,11 @@ public class CreateNetworkOfferingCmd extends BaseCmd { description = "true if network offering supports persistent networks; defaulted to false if not specified") private Boolean isPersistent; + @Parameter(name = ApiConstants.FOR_VPC, + type = CommandType.BOOLEAN, + description = "true if network offering is meant to be used for VPC, false otherwise.") + private Boolean forVpc; + @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, since = "4.2.0", description = "Network offering details in key/value pairs." + " Supported keys are internallbprovider/publiclbprovider with service provider as a value, and" + " promiscuousmode/macaddresschanges/forgedtransmits with true/false as value to accept/reject the security settings if available for a nic/portgroup") @@ -196,6 +201,10 @@ public class CreateNetworkOfferingCmd extends BaseCmd { return isPersistent == null ? false : isPersistent; } + public Boolean getForVpc() { + return forVpc; + } + public Boolean getEgressDefaultPolicy() { if (egressDefaultPolicy == null) { return true; diff --git a/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java b/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java index eee159523cb..0c7ed3a3dc1 100644 --- a/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java +++ b/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java @@ -204,14 +204,14 @@ public interface ConfigurationManager { * @param isPersistent * ; * @param details TODO - * @param id + * @param forVpc * @return network offering object */ NetworkOfferingVO createNetworkOffering(String name, String displayText, TrafficType trafficType, String tags, boolean specifyVlan, Availability availability, - Integer networkRate, Map> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId, - boolean conserveMode, Map> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent, - Map details, boolean egressDefaultPolicy, Integer maxconn, boolean enableKeepAlive); + Integer networkRate, Map> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId, + boolean conserveMode, Map> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent, + Map details, boolean egressDefaultPolicy, Integer maxconn, boolean enableKeepAlive, Boolean forVpc); Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, String vlanId, boolean bypassVlanOverlapCheck, Domain domain, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr) diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index 755fba2f74c..db0ff980948 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@ -446,7 +446,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra if (_networkOfferingDao.findByUniqueName(NetworkOffering.QuickCloudNoServices) == null) { offering = _configMgr.createNetworkOffering(NetworkOffering.QuickCloudNoServices, "Offering for QuickCloud with no services", TrafficType.Guest, null, true, Availability.Optional, null, new HashMap>(), true, Network.GuestType.Shared, false, null, true, null, true, - false, null, false, null, true); + false, null, false, null, true, false); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -455,7 +455,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedNetworkOfferingWithSGService) == null) { offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedNetworkOfferingWithSGService, "Offering for Shared Security group enabled networks", TrafficType.Guest, null, true, Availability.Optional, null, defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true, - null, true, false, null, false, null, true); + null, true, false, null, false, null, true, false); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -464,7 +464,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedNetworkOffering) == null) { offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedNetworkOffering, "Offering for Shared networks", TrafficType.Guest, null, true, Availability.Optional, null, defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true, null, true, false, null, false, - null, true); + null, true, false); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -474,7 +474,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService, "Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest, null, false, Availability.Required, null, defaultIsolatedSourceNatEnabledNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null, true, null, false, false, null, false, null, - true); + true, false); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); @@ -484,7 +484,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks) == null) { offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks, "Offering for Isolated VPC networks with Source Nat service enabled", TrafficType.Guest, null, false, Availability.Optional, null, - defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true); + defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -495,7 +495,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra defaultVPCOffProviders.remove(Service.Lb); offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB, "Offering for Isolated VPC networks with Source Nat service enabled and LB service disabled", TrafficType.Guest, null, false, Availability.Optional, - null, defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true); + null, defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -504,7 +504,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOffering) == null) { offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOffering, "Offering for Isolated networks with no Source Nat service", TrafficType.Guest, null, true, Availability.Optional, null, defaultIsolatedNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null, - true, null, true, false, null, false, null, true); + true, null, true, false, null, false, null, true, false); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -528,7 +528,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB) == null) { offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB, "Offering for Isolated VPC networks with Internal Lb support", TrafficType.Guest, null, false, Availability.Optional, null, internalLbOffProviders, - true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true); + true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true); offering.setState(NetworkOffering.State.Enabled); offering.setInternalLb(true); offering.setPublicLb(false); @@ -560,7 +560,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedEIPandELBNetworkOffering) == null) { offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedEIPandELBNetworkOffering, "Offering for Shared networks with Elastic IP and Elastic LB capabilities", TrafficType.Guest, null, true, Availability.Optional, null, - netscalerServiceProviders, true, Network.GuestType.Shared, false, null, true, serviceCapabilityMap, true, false, null, false, null, true); + netscalerServiceProviders, true, Network.GuestType.Shared, false, null, true, serviceCapabilityMap, true, false, null, false, null, true, false); offering.setState(NetworkOffering.State.Enabled); offering.setDedicatedLB(false); _networkOfferingDao.update(offering.getId(), offering); diff --git a/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java b/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java index f40f71092e0..f6451fb72c9 100644 --- a/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java +++ b/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java @@ -130,6 +130,9 @@ public class NetworkOfferingVO implements NetworkOffering { @Column(name = "is_persistent") boolean isPersistent; + @Column(name = "for_vpc") + boolean forVpc; + @Column(name = "egress_default_policy") boolean egressdefaultpolicy; @@ -168,6 +171,15 @@ public class NetworkOfferingVO implements NetworkOffering { this.keepAliveEnabled = keepAliveEnabled; } + @Override + public boolean getForVpc() { + return forVpc; + } + + public void setForVpc(boolean isForVpc) { + this.forVpc = isForVpc; + } + @Override public long getId() { return id; @@ -309,7 +321,7 @@ public class NetworkOfferingVO implements NetworkOffering { public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, boolean isDefault, Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, - boolean specifyIpRanges, boolean isPersistent, boolean internalLb, boolean publicLb) { + boolean specifyIpRanges, boolean isPersistent, boolean internalLb, boolean publicLb, boolean isForVpc) { this.name = name; this.displayText = displayText; this.rateMbps = rateMbps; @@ -335,12 +347,13 @@ public class NetworkOfferingVO implements NetworkOffering { this.isPersistent = isPersistent; this.publicLb = publicLb; this.internalLb = internalLb; + this.forVpc = isForVpc; } public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, boolean isDefault, Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean dedicatedLb, boolean sharedSourceNat, boolean redundantRouter, boolean elasticIp, boolean elasticLb, boolean specifyIpRanges, boolean inline, boolean isPersistent, - boolean associatePublicIP, boolean publicLb, boolean internalLb, boolean egressdefaultpolicy, boolean supportsStrechedL2, boolean supportsPublicAccess) { + boolean associatePublicIP, boolean publicLb, boolean internalLb, boolean isForVpc, boolean egressdefaultpolicy, boolean supportsStrechedL2, boolean supportsPublicAccess) { this(name, displayText, trafficType, @@ -356,7 +369,7 @@ public class NetworkOfferingVO implements NetworkOffering { specifyIpRanges, isPersistent, internalLb, - publicLb); + publicLb, isForVpc); this.dedicatedLB = dedicatedLb; this.sharedSourceNat = sharedSourceNat; this.redundantRouter = redundantRouter; @@ -381,7 +394,7 @@ public class NetworkOfferingVO implements NetworkOffering { * TODO */ public NetworkOfferingVO(String name, TrafficType trafficType, boolean specifyIpRanges) { - this(name, "System Offering for " + name, trafficType, true, false, 0, 0, true, Availability.Required, null, null, true, specifyIpRanges, false, false, false); + this(name, "System Offering for " + name, trafficType, true, false, 0, 0, true, Availability.Required, null, null, true, specifyIpRanges, false, false, false, false); this.state = State.Enabled; } @@ -401,6 +414,7 @@ public class NetworkOfferingVO implements NetworkOffering { false, false, false, + false, false); this.state = State.Enabled; } diff --git a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java index a5885ba5562..9a076c6733f 100644 --- a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java +++ b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java @@ -219,7 +219,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager ConfigurationManager configMgr = (ConfigurationManager) _configService; NetworkOfferingVO voffer = configMgr.createNetworkOffering(offeringName, offeringDisplayText, TrafficType.Public, null, true, Availability.Optional, null, serviceProviderMap, true, - Network.GuestType.Shared, false, null, false, null, true, false, null, true, null, false); + Network.GuestType.Shared, false, null, false, null, true, false, null, true, null, false, false); voffer.setState(NetworkOffering.State.Enabled); long id = voffer.getId(); @@ -256,7 +256,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager ConfigurationManager configMgr = (ConfigurationManager)_configService; NetworkOfferingVO voffer = configMgr.createNetworkOffering(offeringName, offeringDisplayText, TrafficType.Guest, null, false, Availability.Optional, null, serviceProviderMap, true, - Network.GuestType.Isolated, false, null, false, null, false, true, null, true, null, false); + Network.GuestType.Isolated, false, null, false, null, false, true, null, true, null, false, offeringName.equals(vpcRouterOfferingName)); voffer.setState(NetworkOffering.State.Enabled); if (offeringName.equals(vpcRouterOfferingName)) { diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java index fb79f09b911..5c64a5793ed 100644 --- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java +++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java @@ -976,7 +976,8 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager, if (sharedNetworkOfferingWithSG == null) { NetworkOfferingVO defaultNuageVspSharedSGNetworkOffering = new NetworkOfferingVO(nuageVspSharedNetworkOfferingWithSGServiceName, "Offering for NuageVsp Shared Security group enabled networks", - Networks.TrafficType.Guest, false, false, null, null, true, NetworkOffering.Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false); + Networks.TrafficType.Guest, false, false, null, null, true, NetworkOffering.Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false, + false); defaultNuageVspSharedSGNetworkOffering.setState(NetworkOffering.State.Enabled); defaultNuageVspSharedSGNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultNuageVspSharedSGNetworkOffering); diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 6af8723afe3..186166371d6 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -34,6 +34,8 @@ import java.util.UUID; import javax.inject.Inject; import javax.naming.ConfigurationException; +import com.google.common.collect.Sets; + import org.apache.cloudstack.acl.SecurityChecker; import org.apache.cloudstack.affinity.AffinityGroup; import org.apache.cloudstack.affinity.AffinityGroupService; @@ -361,6 +363,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati public static final ConfigKey SystemVMUseLocalStorage = new ConfigKey(Boolean.class, "system.vm.use.local.storage", "Advanced", "false", "Indicates whether to use local storage pools or shared storage pools for system VMs.", false, ConfigKey.Scope.Zone, null); + private static final Set VPC_ONLY_PROVIDERS = Sets.newHashSet(Provider.VPCVirtualRouter, Provider.JuniperContrailVpcRouter, Provider.InternalLbVm); + @Override public boolean configure(final String name, final Map params) throws ConfigurationException { final String maxVolumeSizeInGbString = _configDao.getValue(Config.MaxVolumeSize.key()); @@ -3918,6 +3922,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati final boolean isPersistent = cmd.getIsPersistent(); final Map detailsStr = cmd.getDetails(); final Boolean egressDefaultPolicy = cmd.getEgressDefaultPolicy(); + Boolean forVpc = cmd.getForVpc(); + Integer maxconn = null; boolean enableKeepAlive = false; String servicePackageuuid = cmd.getServicePackageId(); @@ -3988,6 +3994,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati throw new InvalidParameterValueException("Invalid service " + serviceName); } + if (forVpc == null) { + if (service == Service.SecurityGroup || service == Service.Firewall) { + forVpc = false; + } else if (service == Service.NetworkACL) { + forVpc = true; + } + } + if (service == Service.SecurityGroup) { // allow security group service for Shared networks only if (guestType != GuestType.Shared) { @@ -3998,6 +4012,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati serviceProviderMap.put(Network.Service.SecurityGroup, sgProviders); continue; } + serviceProviderMap.put(service, defaultProviders); } @@ -4042,6 +4057,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati firewallProvider = Provider.VirtualRouter; } + if (forVpc == null && VPC_ONLY_PROVIDERS.contains(provider)) { + forVpc = true; + } + if (service == Service.Dhcp) { dhcpProvider = provider; } @@ -4159,8 +4178,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } } + if (forVpc == null) { + forVpc = false; + } + final NetworkOffering offering = createNetworkOffering(name, displayText, trafficType, tags, specifyVlan, availability, networkRate, serviceProviderMap, false, guestType, false, - serviceOfferingId, conserveMode, serviceCapabilityMap, specifyIpRanges, isPersistent, details, egressDefaultPolicy, maxconn, enableKeepAlive); + serviceOfferingId, conserveMode, serviceCapabilityMap, specifyIpRanges, isPersistent, details, egressDefaultPolicy, maxconn, enableKeepAlive, forVpc); CallContext.current().setEventDetails(" Id: " + offering.getId() + " Name: " + name); return offering; } @@ -4289,12 +4312,15 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } } } + @Override @DB - public NetworkOfferingVO createNetworkOffering(final String name, final String displayText, final TrafficType trafficType, String tags, final boolean specifyVlan, final Availability availability, - final Integer networkRate, final Map> serviceProviderMap, final boolean isDefault, final Network.GuestType type, final boolean systemOnly, final Long serviceOfferingId, + public NetworkOfferingVO createNetworkOffering(final String name, final String displayText, final TrafficType trafficType, String tags, final boolean specifyVlan, + final Availability availability, + final Integer networkRate, final Map> serviceProviderMap, final boolean isDefault, final GuestType type, final boolean systemOnly, + final Long serviceOfferingId, final boolean conserveMode, final Map> serviceCapabilityMap, final boolean specifyIpRanges, final boolean isPersistent, - final Map details, final boolean egressDefaultPolicy, final Integer maxconn, final boolean enableKeepAlive) { + final Map details, final boolean egressDefaultPolicy, final Integer maxconn, final boolean enableKeepAlive, Boolean forVpc) { String servicePackageUuid; String spDescription = null; @@ -4458,7 +4484,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati final NetworkOfferingVO offeringFinal = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan, networkRate, multicastRate, isDefault, availability, tags, type, conserveMode, dedicatedLb, sharedSourceNat, redundantRouter, elasticIp, elasticLb, specifyIpRanges, inline, isPersistent, associatePublicIp, publicLb, - internalLb, egressDefaultPolicy, strechedL2Subnet, publicAccess); + internalLb, forVpc, egressDefaultPolicy, strechedL2Subnet, publicAccess); if (serviceOfferingId != null) { offeringFinal.setServiceOfferingId(serviceOfferingId); @@ -4809,12 +4835,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati @Override public boolean isOfferingForVpc(final NetworkOffering offering) { - final boolean vpcProvider = _ntwkOffServiceMapDao.isProviderForNetworkOffering(offering.getId(), Provider.VPCVirtualRouter) || - _ntwkOffServiceMapDao.isProviderForNetworkOffering(offering.getId(), Provider.JuniperContrailVpcRouter); - final boolean nuageVpcProvider = _ntwkOffServiceMapDao.getDistinctProviders(offering.getId()).contains(Provider.NuageVsp.getName()) - && offering.getIsPersistent(); - - return vpcProvider || nuageVpcProvider; + return offering.getForVpc(); } @DB diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 27172b47bbc..106aa9e831f 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -1022,7 +1022,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio // Offering #1 NetworkOfferingVO defaultSharedSGNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultSharedNetworkOfferingWithSGService, "Offering for Shared Security group enabled networks", - TrafficType.Guest, false, true, null, null, true, Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false); + TrafficType.Guest, false, true, null, null, true, Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false, false); defaultSharedSGNetworkOffering.setState(NetworkOffering.State.Enabled); defaultSharedSGNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultSharedSGNetworkOffering); @@ -1037,7 +1037,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio // Offering #2 NetworkOfferingVO defaultSharedNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultSharedNetworkOffering, "Offering for Shared networks", TrafficType.Guest, false, true, null, null, true, - Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false); + Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false, false); defaultSharedNetworkOffering.setState(NetworkOffering.State.Enabled); defaultSharedNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultSharedNetworkOffering); @@ -1053,7 +1053,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio NetworkOfferingVO defaultIsolatedSourceNatEnabledNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService, "Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest, false, false, null, null, true, Availability.Required, null, - Network.GuestType.Isolated, true, false, false, false, true); + Network.GuestType.Isolated, true, false, false, false, true, false); defaultIsolatedSourceNatEnabledNetworkOffering.setState(NetworkOffering.State.Enabled); defaultIsolatedSourceNatEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedSourceNatEnabledNetworkOffering); @@ -1069,7 +1069,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio // Offering #4 NetworkOfferingVO defaultIsolatedEnabledNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOffering, "Offering for Isolated networks with no Source Nat service", TrafficType.Guest, - false, true, null, null, true, Availability.Optional, null, Network.GuestType.Isolated, true, true, false, false, false); + false, true, null, null, true, Availability.Optional, null, Network.GuestType.Isolated, true, true, false, false, false, false); defaultIsolatedEnabledNetworkOffering.setState(NetworkOffering.State.Enabled); defaultIsolatedEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedEnabledNetworkOffering); @@ -1085,7 +1085,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio NetworkOfferingVO defaultNetscalerNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultSharedEIPandELBNetworkOffering, "Offering for Shared networks with Elastic IP and Elastic LB capabilities", TrafficType.Guest, false, true, null, null, true, - Availability.Optional, null, Network.GuestType.Shared, true, false, false, false, true, true, true, false, false, true, true, false, false, false, false); + Availability.Optional, null, Network.GuestType.Shared, true, false, false, false, true, true, true, false, false, true, true, false, false, false, false, false); defaultNetscalerNetworkOffering.setState(NetworkOffering.State.Enabled); defaultNetscalerNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetscalerNetworkOffering); @@ -1101,7 +1101,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio NetworkOfferingVO defaultNetworkOfferingForVpcNetworks = new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks, "Offering for Isolated Vpc networks with Source Nat service enabled", TrafficType.Guest, false, false, null, null, true, Availability.Optional, - null, Network.GuestType.Isolated, false, false, false, false, true); + null, Network.GuestType.Isolated, false, false, false, false, true, true); defaultNetworkOfferingForVpcNetworks.setState(NetworkOffering.State.Enabled); defaultNetworkOfferingForVpcNetworks = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworks); @@ -1129,7 +1129,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio NetworkOfferingVO defaultNetworkOfferingForVpcNetworksNoLB = new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB, "Offering for Isolated Vpc networks with Source Nat service enabled and LB service Disabled", TrafficType.Guest, false, false, null, null, true, - Availability.Optional, null, Network.GuestType.Isolated, false, false, false, false, false); + Availability.Optional, null, Network.GuestType.Isolated, false, false, false, false, false, true); defaultNetworkOfferingForVpcNetworksNoLB.setState(NetworkOffering.State.Enabled); defaultNetworkOfferingForVpcNetworksNoLB = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworksNoLB); @@ -1156,7 +1156,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio NetworkOfferingVO internalLbOff = new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB, "Offering for Isolated Vpc networks with Internal LB support", TrafficType.Guest, false, false, null, null, true, Availability.Optional, null, - Network.GuestType.Isolated, false, false, false, true, false); + Network.GuestType.Isolated, false, false, false, true, false, true); internalLbOff.setState(NetworkOffering.State.Enabled); internalLbOff = _networkOfferingDao.persistDefaultNetworkOffering(internalLbOff); diff --git a/server/test/com/cloud/configuration/ConfigurationManagerTest.java b/server/test/com/cloud/configuration/ConfigurationManagerTest.java index 80c184b0bf9..8760c50fe45 100644 --- a/server/test/com/cloud/configuration/ConfigurationManagerTest.java +++ b/server/test/com/cloud/configuration/ConfigurationManagerTest.java @@ -490,20 +490,10 @@ public class ConfigurationManagerTest { @Test public void searchForNetworkOfferingsTest() { - - final NetworkOfferingVO off1 = new NetworkOfferingVO("off1", "off1", Networks.TrafficType.Guest, false, false, null, null, false, - NetworkOffering.Availability.Optional, null, Network.GuestType.Isolated, true, false, false, false, - false); - final NetworkOfferingVO off2 = new NetworkOfferingVO("off2", "off2", Networks.TrafficType.Guest, false, false, null, null, false, - NetworkOffering.Availability.Optional, null, Network.GuestType.Isolated, true, false, false, false, - false); - final NetworkOfferingVO off3 = new NetworkOfferingVO("off3", "off3", Networks.TrafficType.Guest, false, false, null, null, false, - NetworkOffering.Availability.Optional, null, Network.GuestType.Isolated, true, false, false, false, - false); List offerings = Arrays.asList( - off1, - off2, - off3 + new NetworkOfferingVO("off1", "off1", Networks.TrafficType.Guest, false, false, null, null, false, NetworkOffering.Availability.Optional, null, Network.GuestType.Isolated, true, false, false, false, false, false), + new NetworkOfferingVO("off2", "off2", Networks.TrafficType.Guest, false, false, null, null, false, NetworkOffering.Availability.Optional, null, Network.GuestType.Isolated, true, false, false, false, false, false), + new NetworkOfferingVO("off3", "off3", Networks.TrafficType.Guest, false, false, null, null, false, NetworkOffering.Availability.Optional, null, Network.GuestType.Isolated, true, false, false, false, false, true) ); Mockito.when(_networkOfferingDao.createSearchCriteria()).thenReturn(Mockito.mock(SearchCriteria.class)); @@ -514,12 +504,8 @@ public class ConfigurationManagerTest { assertThat(configurationMgr.searchForNetworkOfferings(cmd).second(), is(3)); - ConfigurationManagerImpl spy = Mockito.spy(configurationMgr); - Mockito.doReturn(false).when(spy).isOfferingForVpc(off1); - Mockito.doReturn(false).when(spy).isOfferingForVpc(off2); - Mockito.doReturn(true).when(spy).isOfferingForVpc(off3); Mockito.when(cmd.getForVpc()).thenReturn(Boolean.FALSE); - assertThat(spy.searchForNetworkOfferings(cmd).second(), is(2)); + assertThat(configurationMgr.searchForNetworkOfferings(cmd).second(), is(2)); } @Test diff --git a/server/test/com/cloud/network/CreatePrivateNetworkTest.java b/server/test/com/cloud/network/CreatePrivateNetworkTest.java index 178ed84d748..5b6ead02559 100644 --- a/server/test/com/cloud/network/CreatePrivateNetworkTest.java +++ b/server/test/com/cloud/network/CreatePrivateNetworkTest.java @@ -17,19 +17,12 @@ package com.cloud.network; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.when; +import junit.framework.Assert; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import junit.framework.Assert; - import org.apache.log4j.Logger; import org.junit.Before; import org.junit.Test; @@ -64,6 +57,13 @@ import com.cloud.utils.db.DB; import com.cloud.utils.db.TransactionLegacy; import com.cloud.utils.exception.CloudRuntimeException; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.anyLong; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.when; + //@Ignore("Requires database to be set up") public class CreatePrivateNetworkTest { @@ -103,7 +103,7 @@ public class CreatePrivateNetworkTest { NetworkOfferingVO ntwkOff = new NetworkOfferingVO("offer", "fakeOffer", TrafficType.Guest, true, true, null, null, false, null, null, GuestType.Isolated, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, false); + false, false, false, false, false, false, false, false, false, false, false, false); when(networkService._networkOfferingDao.findById(anyLong())).thenReturn(ntwkOff); List netofferlist = new ArrayList(); netofferlist.add(ntwkOff); diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java index 9ac0648a533..e9e2b322511 100644 --- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java +++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java @@ -428,9 +428,9 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu */ @Override public NetworkOfferingVO createNetworkOffering(String name, String displayText, TrafficType trafficType, String tags, boolean specifyVlan, Availability availability, - Integer networkRate, Map> serviceProviderMap, boolean isDefault, GuestType type, boolean systemOnly, Long serviceOfferingId, - boolean conserveMode, Map> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent, - Map details, boolean egressDefaultPolicy, Integer maxconn, boolean enableKeepAlive) { + Integer networkRate, Map> serviceProviderMap, boolean isDefault, GuestType type, boolean systemOnly, Long serviceOfferingId, + boolean conserveMode, Map> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent, + Map details, boolean egressDefaultPolicy, Integer maxconn, boolean enableKeepAlive, Boolean forVpc) { // TODO Auto-generated method stub return null; } diff --git a/server/test/com/cloud/vpc/dao/MockNetworkOfferingDaoImpl.java b/server/test/com/cloud/vpc/dao/MockNetworkOfferingDaoImpl.java index d77873f014d..cab6afae56c 100644 --- a/server/test/com/cloud/vpc/dao/MockNetworkOfferingDaoImpl.java +++ b/server/test/com/cloud/vpc/dao/MockNetworkOfferingDaoImpl.java @@ -98,33 +98,33 @@ public class MockNetworkOfferingDaoImpl extends NetworkOfferingDaoImpl implement //network offering valid for vpc vo = new NetworkOfferingVO("vpc", "vpc", TrafficType.Guest, false, true, null, null, false, Availability.Optional, null, Network.GuestType.Isolated, false, - false, false, false, false); + false, false, false, false, true); } else if (id.longValue() == 2) { //invalid offering - source nat is not included vo = new NetworkOfferingVO("vpc", "vpc", TrafficType.Guest, false, true, null, null, false, Availability.Optional, null, Network.GuestType.Isolated, false, - false, false, false, false); + false, false, false, false, true); } else if (id.longValue() == 3) { //network offering invalid for vpc (conserve mode off) vo = new NetworkOfferingVO("non vpc", "non vpc", TrafficType.Guest, false, true, null, null, false, Availability.Optional, null, Network.GuestType.Isolated, - true, false, false, false, false); + true, false, false, false, false, false); } else if (id.longValue() == 4) { //network offering invalid for vpc (Shared) vo = new NetworkOfferingVO("non vpc", "non vpc", TrafficType.Guest, false, true, null, null, false, Availability.Optional, null, Network.GuestType.Shared, - false, false, false, false, false); + false, false, false, false, false, false); } else if (id.longValue() == 5) { //network offering invalid for vpc (has redundant router) vo = new NetworkOfferingVO("vpc", "vpc", TrafficType.Guest, false, true, null, null, false, Availability.Optional, null, Network.GuestType.Isolated, false, - false, false, false, false); + false, false, false, false, true); vo.setRedundantRouter(true); } else if (id.longValue() == 6) { //network offering invalid for vpc (has lb service) vo = new NetworkOfferingVO("vpc", "vpc", TrafficType.Guest, false, true, null, null, false, Availability.Optional, null, Network.GuestType.Isolated, false, - false, false, false, false); + false, false, false, false, true); } if (vo != null) { diff --git a/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java b/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java index 1fe58b37184..4a198226c10 100644 --- a/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java +++ b/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java @@ -125,7 +125,7 @@ public class CreateNetworkOfferingTest extends TestCase { public void createSharedNtwkOffWithVlan() { NetworkOfferingVO off = configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, true, Availability.Optional, 200, null, false, Network.GuestType.Shared, false, - null, false, null, true, false, null, false, null, true); + null, false, null, true, false, null, false, null, true, false); assertNotNull("Shared network offering with specifyVlan=true failed to create ", off); } @@ -133,7 +133,7 @@ public class CreateNetworkOfferingTest extends TestCase { public void createSharedNtwkOffWithNoVlan() { NetworkOfferingVO off = configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, false, Availability.Optional, 200, null, false, Network.GuestType.Shared, - false, null, false, null, true, false, null, false, null, true); + false, null, false, null, true, false, null, false, null, true, false); assertNull("Shared network offering with specifyVlan=false was created", off); } @@ -141,7 +141,7 @@ public class CreateNetworkOfferingTest extends TestCase { public void createSharedNtwkOffWithSpecifyIpRanges() { NetworkOfferingVO off = configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, true, Availability.Optional, 200, null, false, Network.GuestType.Shared, false, - null, false, null, true, false, null, false, null, true); + null, false, null, true, false, null, false, null, true, false); assertNotNull("Shared network offering with specifyIpRanges=true failed to create ", off); } @@ -150,7 +150,7 @@ public class CreateNetworkOfferingTest extends TestCase { public void createSharedNtwkOffWithoutSpecifyIpRanges() { NetworkOfferingVO off = configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, true, Availability.Optional, 200, null, false, Network.GuestType.Shared, - false, null, false, null, false, false, null, false, null, true); + false, null, false, null, false, false, null, false, null, true, false); assertNull("Shared network offering with specifyIpRanges=false was created", off); } @@ -163,7 +163,7 @@ public class CreateNetworkOfferingTest extends TestCase { serviceProviderMap.put(Network.Service.SourceNat, vrProvider); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false, - Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true); + Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, false); assertNotNull("Isolated network offering with specifyIpRanges=false failed to create ", off); } @@ -176,7 +176,7 @@ public class CreateNetworkOfferingTest extends TestCase { serviceProviderMap.put(Network.Service.SourceNat, vrProvider); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false, - Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true); + Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, false); assertNotNull("Isolated network offering with specifyVlan=true wasn't created", off); } @@ -189,7 +189,7 @@ public class CreateNetworkOfferingTest extends TestCase { serviceProviderMap.put(Network.Service.SourceNat, vrProvider); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false, - Network.GuestType.Isolated, false, null, false, null, true, false, null, false, null, true); + Network.GuestType.Isolated, false, null, false, null, true, false, null, false, null, true, false); assertNull("Isolated network offering with specifyIpRanges=true and source nat service enabled, was created", off); } @@ -200,7 +200,7 @@ public class CreateNetworkOfferingTest extends TestCase { Set vrProvider = new HashSet(); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false, - Network.GuestType.Isolated, false, null, false, null, true, false, null, false, null, true); + Network.GuestType.Isolated, false, null, false, null, true, false, null, false, null, true, false); assertNotNull("Isolated network offering with specifyIpRanges=true and with no sourceNatService, failed to create", off); } @@ -218,7 +218,7 @@ public class CreateNetworkOfferingTest extends TestCase { serviceProviderMap.put(Network.Service.Lb, vrProvider); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false, - Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true); + Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true); // System.out.println("Creating Vpc Network Offering"); assertNotNull("Vpc Isolated network offering with Vpc provider ", off); } @@ -238,7 +238,7 @@ public class CreateNetworkOfferingTest extends TestCase { serviceProviderMap.put(Network.Service.Lb, lbProvider); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false, - Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true); + Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true); // System.out.println("Creating Vpc Network Offering"); assertNotNull("Vpc Isolated network offering with Vpc and Netscaler provider ", off); } diff --git a/setup/db/db/schema-41000to41100.sql b/setup/db/db/schema-41000to41100.sql index e5e6c0552ee..021076a50ba 100644 --- a/setup/db/db/schema-41000to41100.sql +++ b/setup/db/db/schema-41000to41100.sql @@ -19,6 +19,22 @@ -- Schema upgrade from 4.10.0.0 to 4.11.0.0 --; +-- Add For VPC flag +ALTER TABLE cloud.network_offerings ADD COLUMN for_vpc INT(1) NOT NULL DEFAULT 0; +UPDATE cloud.network_offerings o +SET for_vpc = 1 +where + o.conserve_mode = 0 + and o.guest_type = 'Isolated' + and exists( + SELECT id + from cloud.ntwk_offering_service_map + where network_offering_id = o.id and ( + provider in ('VpcVirtualRouter', 'InternalLbVm', 'JuniperContrailVpcRouter') + or service in ('NetworkACL') + ) + ); + --Alter view template_view DROP VIEW IF EXISTS `cloud`.`template_view`; diff --git a/test/integration/plugins/nuagevsp/test_nuage_static_nat.py b/test/integration/plugins/nuagevsp/test_nuage_static_nat.py index 9d168e93d0f..8601a179bf4 100644 --- a/test/integration/plugins/nuagevsp/test_nuage_static_nat.py +++ b/test/integration/plugins/nuagevsp/test_nuage_static_nat.py @@ -466,6 +466,18 @@ class TestNuageStaticNat(nuageTestCase): net_off_5 = self.create_NetworkOffering(network_offering) self.validate_NetworkOffering(net_off_5, state="Enabled") + self.debug("Creating persistent Nuage VSP Isolated Network offering " + "without VR so no userData and Dns...") + network_offering = copy.deepcopy( + self.test_data["nuagevsp"]["isolated_network_offering"]) + network_offering["ispersistent"] = "True" + network_offering["supportedservices"] = \ + 'Dhcp,SourceNat,Connectivity,StaticNat,Firewall' + del network_offering["serviceProviderList"]["UserData"] + del network_offering["serviceProviderList"]["Dns"] + net_off_6 = self.create_NetworkOffering(network_offering) + self.validate_NetworkOffering(net_off_6, state="Enabled") + # Creating Isolated networks, and deploying VMs self.debug("Creating an Isolated network with Static NAT service " "provider as NuageVsp...") @@ -720,6 +732,57 @@ class TestNuageStaticNat(nuageTestCase): "successfully released in CloudStack") self.delete_VM(vm_5) + self.debug("Creating a persistent Isolated network with Static NAT " + "service without UserData Dns, so without VR") + network_6 = self.create_Network(net_off_6, gateway='10.6.1.1') + self.validate_Network(network_6, state="Implemented") + + self.debug("Deploying a VM in the created Isolated network...") + vm_6 = self.create_VM(network_6) + self.validate_Network(network_6, state="Implemented") + + with self.assertRaises(Exception): + self.get_Router(network_6) + + # VSD verification + self.verify_vsd_network(self.domain.id, network_6) + self.verify_vsd_vm(vm_6) + + # Creating Static NAT rule + self.debug("Creating Static NAT rule in the created Isolated network " + "with its deployed VM...") + public_ip = self.acquire_PublicIPAddress(network_6) + self.validate_PublicIPAddress(public_ip, network_6) + self.create_StaticNatRule_For_VM(vm_6, public_ip, network_6) + + # VSD verification for Static NAT functionality + self.verify_vsd_floating_ip(network_6, vm_6, public_ip.ipaddress) + + # Deleting Static NAT Rule + self.debug("Deleting Static NAT Rule for the deployed VM...") + self.delete_StaticNatRule_For_VM(public_ip) + with self.assertRaises(Exception): + self.validate_PublicIPAddress( + public_ip, network_6, static_nat=True, vm=vm_6) + self.debug("Static NAT Rule for the deployed VM successfully deleted " + "in CloudStack") + + # VSD verification + with self.assertRaises(Exception): + self.verify_vsd_floating_ip(network_6, vm_6, public_ip.ipaddress) + self.debug("Floating IP for the deployed VM successfully deleted in " + "VSD") + + # Releasing acquired public IP + self.debug("Releasing the acquired public IP in the created Isolated " + "network...") + public_ip.delete(self.api_client) + with self.assertRaises(Exception): + self.validate_PublicIPAddress(public_ip, network_6) + self.debug("Acquired public IP in the created Isolated network " + "successfully released in CloudStack") + self.delete_VM(vm_6) + @attr(tags=["advanced", "nuagevsp"], required_hardware="false") def test_04_nuage_StaticNAT_vpc_networks(self): """Test Nuage VSP VPC networks with different combinations of Static @@ -1006,23 +1069,47 @@ class TestNuageStaticNat(nuageTestCase): self.test_data["nuagevsp"]["isolated_network_offering"]) self.validate_NetworkOffering(net_off, state="Enabled") + self.debug("Creating persistent Nuage VSP Isolated Network offering " + "without VR so no userData and Dns...") + network_offering = copy.deepcopy( + self.test_data["nuagevsp"]["isolated_network_offering"]) + network_offering["ispersistent"] = "True" + network_offering["supportedservices"] = \ + 'Dhcp,SourceNat,Connectivity,StaticNat,Firewall' + del network_offering["serviceProviderList"]["UserData"] + del network_offering["serviceProviderList"]["Dns"] + net_off_2 = self.create_NetworkOffering(network_offering) + self.validate_NetworkOffering(net_off_2, state="Enabled") + # Creating Isolated network, deploying VMs, and verifying Static NAT # traffic self.debug("Creating an Isolated network with Static NAT service...") network = self.create_Network(net_off, gateway='10.1.1.1') self.validate_Network(network, state="Allocated") + self.debug("Creating a persistent Isolated network with Static NAT " + "service without UserData Dns, so without VR") + network_2 = self.create_Network(net_off_2, gateway='10.2.1.1') + self.validate_Network(network_2, state="Implemented") + self.debug("Deploying a VM in the created Isolated network...") vm_1 = self.create_VM(network) self.validate_Network(network, state="Implemented") vr = self.get_Router(network) self.check_Router_state(vr, state="Running") self.check_VM_state(vm_1, state="Running") + vm_21 = self.create_VM(network_2) + self.validate_Network(network_2, state="Implemented") + + with self.assertRaises(Exception): + self.get_Router(network_2) # VSD verification self.verify_vsd_network(self.domain.id, network) self.verify_vsd_router(vr) self.verify_vsd_vm(vm_1) + self.verify_vsd_network(self.domain.id, network_2) + self.verify_vsd_vm(vm_21) # Creating Static NAT rule self.debug("Creating Static NAT rule for the deployed VM in the " @@ -1032,23 +1119,34 @@ class TestNuageStaticNat(nuageTestCase): self.create_StaticNatRule_For_VM(vm_1, public_ip_1, network) self.validate_PublicIPAddress( public_ip_1, network, static_nat=True, vm=vm_1) + public_ip_21 = self.acquire_PublicIPAddress(network_2) + self.validate_PublicIPAddress(public_ip_21, network_2) + self.create_StaticNatRule_For_VM(vm_21, public_ip_21, network_2) + self.validate_PublicIPAddress( + public_ip_21, network_2, static_nat=True, vm=vm_21) # VSD verification for Static NAT functionality self.verify_vsd_floating_ip(network, vm_1, public_ip_1.ipaddress) + self.verify_vsd_floating_ip(network_2, vm_21, public_ip_21.ipaddress) # Verifying Static NAT traffic self.verify_StaticNAT_traffic(network, public_ip_1) + self.verify_StaticNAT_traffic(network_2, public_ip_21) # Verifying Static NAT traffic (wget www.google.com) to the Internet # from the deployed VM self.verify_StaticNAT_Internet_traffic(vm_1, network, public_ip_1) + self.verify_StaticNAT_Internet_traffic(vm_21, network_2, public_ip_21) self.debug("Deploying another VM in the created Isolated network...") vm_2 = self.create_VM(network) self.check_VM_state(vm_2, state="Running") + vm_22 = self.create_VM(network_2) + self.check_VM_state(vm_22, state="Running") # VSD verification self.verify_vsd_vm(vm_2) + self.verify_vsd_vm(vm_22) # Creating Static NAT rule self.debug("Creating Static NAT rule for the deployed VM in the " @@ -1059,15 +1157,24 @@ class TestNuageStaticNat(nuageTestCase): self.validate_PublicIPAddress( public_ip_2, network, static_nat=True, vm=vm_2) + public_ip_22 = self.acquire_PublicIPAddress(network_2) + self.validate_PublicIPAddress(public_ip_22, network_2) + self.create_StaticNatRule_For_VM(vm_22, public_ip_22, network_2) + self.validate_PublicIPAddress( + public_ip_22, network_2, static_nat=True, vm=vm_22) + # VSD verification for Static NAT functionality self.verify_vsd_floating_ip(network, vm_2, public_ip_2.ipaddress) + self.verify_vsd_floating_ip(network_2, vm_22, public_ip_22.ipaddress) # Verifying Static NAT traffic self.verify_StaticNAT_traffic(network, public_ip_2) + self.verify_StaticNAT_traffic(network_2, public_ip_22) # Verifying Static NAT traffic (wget www.google.com) to the Internet # from the deployed VM self.verify_StaticNAT_Internet_traffic(vm_2, network, public_ip_2) + self.verify_StaticNAT_Internet_traffic(vm_22, network_2, public_ip_22) @attr(tags=["advanced", "nuagevsp"], required_hardware="true") def test_06_nuage_StaticNAT_vpc_network_traffic(self): diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index f0af048dd21..4bac4e0cd46 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -2209,7 +2209,7 @@ class NetworkOffering: cmd.traffictype = services["traffictype"] if "useVpc" in services: - cmd.useVpc = services["useVpc"] + cmd.forvpc = (services["useVpc"] == "on") cmd.serviceproviderlist = [] if "serviceProviderList" in services: for service, provider in services["serviceProviderList"].items(): diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index 6c3ffd81687..00972b66050 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -3296,9 +3296,11 @@ serviceCapabilityIndex++; } } else if (value != '') { // normal data (serviceData.length ==1), e.g. "name", "displayText", "networkRate", "guestIpType", "lbType" (unwanted), "availability" (unwated when value is "Optional"), "egressdefaultpolicy", "state" (unwanted), "status" (unwanted), "allocationstate" (unwanted) - if (!(key == "lbType" || (key == "availability" && value == "Optional") || key == "state" || key == "status" || key == "allocationstate" || key == "useVpc" )) { - inputData[key] = value; - } + if (key == "useVpc") { + inputData['forvpc'] = value; + } else if (!(key == "lbType" || (key == "availability" && value == "Optional") || key == "state" || key == "status" || key == "allocationstate" || key == "useVpc" )) { + inputData[key] = value; + } } }); @@ -3370,6 +3372,11 @@ } } + if (inputData['forvpc'] == 'on') { + inputData['forvpc'] = true; + } else { + delete inputData.forvpc; //if forVpc checkbox is unchecked, do not pass forVpc parameter to API call since we need to keep API call's size as small as possible (p.s. forVpc is defaulted as false at server-side) + } if (inputData['conservemode'] == 'on') { delete inputData.conservemode; //if ConserveMode checkbox is checked, do not pass conservemode parameter to API call since we need to keep API call's size as small as possible (p.s. conservemode is defaulted as true at server-side)