cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] fmaximus closed pull request #2004: CLOUDSTACK-9832: Do not assign public IP NIC to the VPC VR when the VPC offering does not contain VpcVirtualRouter as a SourceNat provider
Date Thu, 01 Jan 1970 00:00:00 GMT
fmaximus closed pull request #2004: CLOUDSTACK-9832: Do not assign public IP NIC to the VPC
VR when the VPC offering does not contain VpcVirtualRouter as a SourceNat provider
URL: https://github.com/apache/cloudstack/pull/2004
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
index 68531e3ab3d..bb0235b9603 100644
--- a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
@@ -180,6 +180,11 @@ NicProfile prepareNic(VirtualMachineProfile vmProfile, DeployDestination
dest, R
         throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException,
ConcurrentOperationException, InsufficientCapacityException,
         ResourceUnavailableException;
 
+    /**
+     * Removes the provided nic from the given vm
+     * @param vm
+     * @param nic
+     */
     void removeNic(VirtualMachineProfile vm, Nic nic);
 
     /**
diff --git a/engine/components-api/src/com/cloud/network/vpc/VpcManager.java b/engine/components-api/src/com/cloud/network/vpc/VpcManager.java
index 8539871e48b..28ad0524a2a 100644
--- a/engine/components-api/src/com/cloud/network/vpc/VpcManager.java
+++ b/engine/components-api/src/com/cloud/network/vpc/VpcManager.java
@@ -165,4 +165,11 @@
         validateNtwkOffForNtwkInVpc(Long networkId, long newNtwkOffId, String newCidr, String
newNetworkDomain, Vpc vpc, String gateway, Account networkOwner, Long aclId);
 
     List<PrivateGateway> getVpcPrivateGateways(long vpcId);
+
+    /**
+     * Checks if the specified offering needs a public src nat ip or not.
+     * @param vpcOfferingId
+     * @return
+     */
+    boolean isSrcNatIpRequired(long vpcOfferingId);
 }
diff --git a/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java b/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
index 8b1d9fe9852..b4cf809726d 100644
--- a/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
+++ b/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
@@ -21,6 +21,8 @@
 import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.TreeSet;
 
 import javax.annotation.PostConstruct;
@@ -83,7 +85,10 @@ public void reallocateRouterNetworks(final RouterDeploymentDefinition vpcRouterD
             throws ConcurrentOperationException, InsufficientCapacityException {
 
         final TreeSet<String> publicVlans = new TreeSet<String>();
-        publicVlans.add(vpcRouterDeploymentDefinition.getSourceNatIP().getVlanTag());
+        if (vpcRouterDeploymentDefinition.isPublicNetwork()) {
+            publicVlans.add(vpcRouterDeploymentDefinition.getSourceNatIP()
+                                                         .getVlanTag());
+        }
 
         //1) allocate nic for control and source nat public ip
         final LinkedHashMap<Network, List<? extends NicProfile>> networks = configureDefaultNics(vpcRouterDeploymentDefinition);
@@ -115,43 +120,51 @@ public void reallocateRouterNetworks(final RouterDeploymentDefinition
vpcRouterD
         final List<IPAddressVO> ips = _ipAddressDao.listByAssociatedVpc(vpcId, false);
         final List<NicProfile> publicNics = new ArrayList<NicProfile>();
         Network publicNetwork = null;
+        final Map<Network.Service, Set<Network.Provider>> vpcOffSvcProvidersMap
= vpcMgr.getVpcOffSvcProvidersMap(vpcRouterDeploymentDefinition.getVpc().getVpcOfferingId());
+
+        boolean vpcIsStaticNatProvider = vpcOffSvcProvidersMap.get(Network.Service.StaticNat)
!= null &&
+                vpcOffSvcProvidersMap.get(Network.Service.StaticNat).contains(Network.Provider.VPCVirtualRouter);
+
+        final ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(vpcRouterDeploymentDefinition.getServiceOfferingId());
+
         for (final IPAddressVO ip : ips) {
-            final PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, _vlanDao.findById(ip.getVlanId()));
-            if ((ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating)
&& vpcMgr.isIpAllocatedToVpc(ip) &&
-                    !publicVlans.contains(publicIp.getVlanTag())) {
-                s_logger.debug("Allocating nic for router in vlan " + publicIp.getVlanTag());
-                final NicProfile publicNic = new NicProfile();
-                publicNic.setDefaultNic(false);
-                publicNic.setIPv4Address(publicIp.getAddress().addr());
-                publicNic.setIPv4Gateway(publicIp.getGateway());
-                publicNic.setIPv4Netmask(publicIp.getNetmask());
-                publicNic.setMacAddress(publicIp.getMacAddress());
-                publicNic.setBroadcastType(BroadcastDomainType.Vlan);
-                publicNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(publicIp.getVlanTag()));
-                publicNic.setIsolationUri(IsolationType.Vlan.toUri(publicIp.getVlanTag()));
-                final NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
-                if (publicNetwork == null) {
-                    final List<? extends Network> publicNetworks = _networkMgr.setupNetwork(s_systemAccount,
publicOffering, vpcRouterDeploymentDefinition.getPlan(), null, null, false);
-                    publicNetwork = publicNetworks.get(0);
+            if (vpcIsStaticNatProvider || !ip.isOneToOneNat()) {
+                final PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, _vlanDao.findById(ip.getVlanId()));
+                if ((ip.getState() == IpAddress.State.Allocated  || ip.getState() == IpAddress.State.Allocating)
+                        && vpcMgr.isIpAllocatedToVpc(ip)
+                        && !publicVlans.contains(publicIp.getVlanTag())) {
+                    s_logger.debug("Allocating nic for router in vlan " + publicIp.getVlanTag());
+                    final NicProfile publicNic = new NicProfile();
+                    publicNic.setDefaultNic(false);
+                    publicNic.setIPv4Address(publicIp.getAddress()
+                                                     .addr());
+                    publicNic.setIPv4Gateway(publicIp.getGateway());
+                    publicNic.setIPv4Netmask(publicIp.getNetmask());
+                    publicNic.setMacAddress(publicIp.getMacAddress());
+                    publicNic.setBroadcastType(BroadcastDomainType.Vlan);
+                    publicNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(publicIp.getVlanTag()));
+                    publicNic.setIsolationUri(IsolationType.Vlan.toUri(publicIp.getVlanTag()));
+                    final NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork)
+                                                                        .get(0);
+                    if (publicNetwork == null) {
+                        final List<? extends Network> publicNetworks = _networkMgr.setupNetwork(s_systemAccount,
publicOffering, vpcRouterDeploymentDefinition.getPlan(), null, null, false);
+                        publicNetwork = publicNetworks.get(0);
+                    }
+                    publicNics.add(publicNic);
+                    publicVlans.add(publicIp.getVlanTag());
                 }
-                publicNics.add(publicNic);
-                publicVlans.add(publicIp.getVlanTag());
             }
-        }
-        if (publicNetwork != null) {
-            if (networks.get(publicNetwork) != null) {
-                @SuppressWarnings("unchecked")
-                final
-                List<NicProfile> publicNicProfiles = (List<NicProfile>)networks.get(publicNetwork);
-                publicNicProfiles.addAll(publicNics);
-                networks.put(publicNetwork, publicNicProfiles);
-            } else {
-                networks.put(publicNetwork, publicNics);
+            if (publicNetwork != null) {
+                if (networks.get(publicNetwork) != null) {
+                    @SuppressWarnings("unchecked") final List<NicProfile> publicNicProfiles
= (List<NicProfile>)networks.get(publicNetwork);
+                    publicNicProfiles.addAll(publicNics);
+                    networks.put(publicNetwork, publicNicProfiles);
+                } else {
+                    networks.put(publicNetwork, publicNics);
+                }
             }
         }
 
-        final ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(vpcRouterDeploymentDefinition.getServiceOfferingId());
-
         _itMgr.allocate(router.getInstanceName(), template, routerOffering, networks, vpcRouterDeploymentDefinition.getPlan(),
hType);
     }
 
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 706f4c4abff..698a7c2bb1d 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -43,14 +43,12 @@
 import org.apache.cloudstack.api.command.user.vpc.ListStaticRoutesCmd;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
-import org.apache.cloudstack.framework.config.ConfigDepot;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.log4j.Logger;
 
 import com.cloud.configuration.Config;
-import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenterVO;
@@ -88,8 +86,6 @@
 import com.cloud.network.dao.IPAddressVO;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.NetworkVO;
-import com.cloud.network.dao.PhysicalNetworkDao;
-import com.cloud.network.dao.Site2SiteVpnGatewayDao;
 import com.cloud.network.element.NetworkElement;
 import com.cloud.network.element.StaticNatServiceProvider;
 import com.cloud.network.element.VpcProvider;
@@ -108,7 +104,6 @@
 import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
 import com.cloud.org.Grouping;
 import com.cloud.projects.Project.ListProjectResourcesCriteria;
-import com.cloud.server.ConfigurationServer;
 import com.cloud.server.ResourceTag.ResourceObjectType;
 import com.cloud.tags.ResourceTagVO;
 import com.cloud.tags.dao.ResourceTagDao;
@@ -140,7 +135,6 @@
 import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.ReservationContextImpl;
-import com.cloud.vm.dao.DomainRouterDao;
 
 public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvisioningService,
VpcService {
     private static final Logger s_logger = Logger.getLogger(VpcManagerImpl.class);
@@ -162,8 +156,6 @@
     @Inject
     ConfigurationDao _configDao;
     @Inject
-    ConfigurationManager _configMgr;
-    @Inject
     AccountManager _accountMgr;
     @Inject
     NetworkDao _ntwkDao;
@@ -176,8 +168,6 @@
     @Inject
     IPAddressDao _ipAddressDao;
     @Inject
-    DomainRouterDao _routerDao;
-    @Inject
     VpcGatewayDao _vpcGatewayDao;
     @Inject
     PrivateIpDao _privateIpDao;
@@ -188,14 +178,10 @@
     @Inject
     VpcOfferingServiceMapDao _vpcOffServiceDao;
     @Inject
-    PhysicalNetworkDao _pNtwkDao;
-    @Inject
     ResourceTagDao _resourceTagDao;
     @Inject
     FirewallRulesDao _firewallDao;
     @Inject
-    Site2SiteVpnGatewayDao _vpnGatewayDao;
-    @Inject
     Site2SiteVpnManager _s2sVpnMgr;
     @Inject
     VlanDao _vlanDao = null;
@@ -206,17 +192,11 @@
     @Inject
     DataCenterDao _dcDao;
     @Inject
-    ConfigurationServer _configServer;
-    @Inject
     NetworkACLDao _networkAclDao;
     @Inject
-    NetworkACLItemDao _networkACLItemDao;
-    @Inject
     NetworkACLManager _networkAclMgr;
     @Inject
     IpAddressManager _ipAddrMgr;
-    @Inject
-    ConfigDepot _configDepot;
 
     @Inject
     private VpcPrivateGatewayTransactionCallable vpcTxCallable;
@@ -2266,14 +2246,9 @@ public IpAddress associateIPToVpc(final long ipId, final long vpcId)
throws Reso
         // check permissions
         _accountMgr.checkAccess(caller, null, true, owner, vpc);
 
-        boolean isSourceNat = false;
-        if (getExistingSourceNatInVpc(owner.getId(), vpcId) == null) {
-            isSourceNat = true;
-        }
-
         s_logger.debug("Associating ip " + ipToAssoc + " to vpc " + vpc);
 
-        final boolean isSourceNatFinal = isSourceNat;
+        final boolean isSourceNatFinal = isSrcNatIpRequired(vpc.getVpcOfferingId()) &&
getExistingSourceNatInVpc(owner.getId(), vpcId) == null;
         Transaction.execute(new TransactionCallbackNoReturn() {
             @Override
             public void doInTransactionWithoutResult(final TransactionStatus status) {
@@ -2449,4 +2424,10 @@ public boolean applyStaticRoute(final long routeId) throws ResourceUnavailableEx
         final StaticRoute route = _staticRouteDao.findById(routeId);
         return applyStaticRoutesForVpc(route.getVpcId());
     }
+
+    @Override
+    public boolean isSrcNatIpRequired(long vpcOfferingId) {
+        final Map<Network.Service, Set<Network.Provider>> vpcOffSvcProvidersMap
= getVpcOffSvcProvidersMap(vpcOfferingId);
+        return vpcOffSvcProvidersMap.get(Network.Service.SourceNat).contains(Network.Provider.VPCVirtualRouter);
+    }
 }
diff --git a/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
b/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
index 26f2379804e..8ccecce619a 100644
--- a/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
+++ b/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
@@ -73,11 +73,6 @@ public boolean isVpcRouter() {
     }
 
     @Override
-    public boolean isPublicNetwork() {
-        return true;
-    }
-
-    @Override
     protected void lock() {
         final Vpc vpcLock = vpcDao.acquireInLockTable(vpc.getId());
         if (vpcLock == null) {
@@ -115,12 +110,19 @@ protected void checkPreconditions() {
      */
     @Override
     protected boolean prepareDeployment() {
+        //Check if the VR is the src NAT provider...
+        isPublicNetwork = vpcMgr.isSrcNatIpRequired(vpc.getVpcOfferingId());
+
+        // Check if public network has to be set on VR
         return true;
     }
 
     @Override
     protected void findSourceNatIP() throws InsufficientAddressCapacityException, ConcurrentOperationException
{
-        sourceNatIp = vpcMgr.assignSourceNatIpAddressToVpc(owner, vpc);
+        sourceNatIp = null;
+        if (isPublicNetwork) {
+            sourceNatIp = vpcMgr.assignSourceNatIpAddressToVpc(owner, vpc);
+        }
     }
 
     @Override
diff --git a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
index 13c20ae7e50..e4ef9f5fc27 100644
--- a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
+++ b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
@@ -168,9 +168,30 @@ public void testGetNumberOfRoutersToDeploy() {
         assertEquals("If there is already a router found, there is no need to deploy more",
0, deployment.getNumberOfRoutersToDeploy());
     }
 
+    protected void driveTestPrepareDeployment(final boolean isRedundant, final boolean isPublicNw)
{
+        // Prepare
+        when(vpcMgr.isSrcNatIpRequired(mockVpc.getVpcOfferingId())).thenReturn(isPublicNw);
+
+        // Execute
+        final boolean canProceedDeployment = deployment.prepareDeployment();
+        // Assert
+        assertTrue("There are no preconditions for Vpc Deployment, thus it should always
pass", canProceedDeployment);
+        assertEquals(isPublicNw, deployment.isPublicNetwork());
+    }
+
+    @Test
+    public void testPrepareDeploymentPublicNw() {
+        driveTestPrepareDeployment(true, true);
+    }
+
+    @Test
+    public void testPrepareDeploymentNonRedundant() {
+        driveTestPrepareDeployment(false, true);
+    }
+
     @Test
-    public void testPrepareDeployment() {
-        assertTrue("There are no preconditions for Vpc Deployment, thus it should always
pass", deployment.prepareDeployment());
+    public void testPrepareDeploymentRedundantNonPublicNw() {
+        driveTestPrepareDeployment(true, false);
     }
 
     @Test
@@ -246,6 +267,7 @@ public void testFindSourceNatIP() throws InsufficientAddressCapacityException,
C
         // Prepare
         final PublicIp publicIp = mock(PublicIp.class);
         when(vpcMgr.assignSourceNatIpAddressToVpc(mockOwner, mockVpc)).thenReturn(publicIp);
+        deployment.isPublicNetwork = true;
 
         // Execute
         deployment.findSourceNatIP();
diff --git a/test/integration/plugins/nuagevsp/nuageTestCase.py b/test/integration/plugins/nuagevsp/nuageTestCase.py
index c673a9b31c4..de6161cc3ce 100644
--- a/test/integration/plugins/nuagevsp/nuageTestCase.py
+++ b/test/integration/plugins/nuagevsp/nuageTestCase.py
@@ -848,6 +848,34 @@ def validate_PublicIPAddress(self, public_ip, network, static_nat=False,
         self.debug("Successfully validated the assignment and state of public "
                    "IP address - %s" % public_ip.ipaddress.ipaddress)
 
+    # verify_VRWithoutPublicIPNIC - Verifies that the given Virtual Router has
+    # no public IP and NIC
+    def verify_VRWithoutPublicIPNIC(self, vr):
+        """Verifies VR without Public IP and NIC"""
+        self.debug("Verifies that there is no public IP and NIC in Virtual "
+                   "Router - %s" % vr.name)
+        self.assertEqual(vr.publicip, None,
+                         "Virtual router has public IP"
+                         )
+        for nic in vr.nic:
+            self.assertNotEqual(nic.traffictype, "Public",
+                                "Virtual router has public NIC"
+                                )
+        self.debug("Successfully verified that there is no public IP and NIC "
+                   "in Virtual Router - %s" % vr.name)
+
+    def verify_vpc_has_no_src_nat(self, vpc, account=None):
+        if not account:
+            account = self.account
+        self.debug("Verify that there is no src NAT ip address "
+                   "allocated for the vpc")
+        src_nat_ip = PublicIPAddress.list(
+            self.api_client,
+            vpcid=vpc.id,
+            issourcenat=True,
+            account=account.name)
+        self.assertEqual(src_nat_ip, None, "VPC has a source NAT ip!")
+
     # VSD verifications; VSD is a programmable policy and analytics engine of
     # Nuage VSP SDN platform
 
@@ -984,10 +1012,10 @@ def verify_vsd_object_status(self, cs_object, stopped):
         expected_status = cs_object.state.upper() if not stopped \
             else "DELETE_PENDING"
         tries = 0
-        while (vsd_object.status != expected_status) and (tries < 10):
+        while (vsd_object.status != expected_status) and (tries < 120):
             self.debug("Waiting for the CloudStack object " + cs_object.name +
                        " to be fully resolved in VSD...")
-            time.sleep(30)
+            time.sleep(5)
             self.debug("Rechecking the CloudStack object " + cs_object.name +
                        " status in VSD...")
             vsd_object = self.vsd.get_vm(
diff --git a/test/integration/plugins/nuagevsp/test_nuage_static_nat.py b/test/integration/plugins/nuagevsp/test_nuage_static_nat.py
index 9e6cdde4dc9..74d3a5d6a0f 100644
--- a/test/integration/plugins/nuagevsp/test_nuage_static_nat.py
+++ b/test/integration/plugins/nuagevsp/test_nuage_static_nat.py
@@ -26,8 +26,11 @@
 from marvin.cloudstackAPI import (enableNuageUnderlayVlanIpRange,
                                   disableNuageUnderlayVlanIpRange,
                                   listNuageUnderlayVlanIpRanges)
+from marvin.lib.common import list_virtual_machines
+
 # Import System Modules
 from nose.plugins.attrib import attr
+import threading
 import copy
 import time
 
@@ -150,7 +153,7 @@ def verify_StaticNAT_traffic(self, network, public_ip, vpc=None,
 
         # wget from VM
         tries = 0
-        max_tries = 3 if non_default_nic else 10
+        max_tries = 3 if non_default_nic else 120
         filename = None
         headers = None
         while tries < max_tries:
@@ -162,7 +165,7 @@ def verify_StaticNAT_traffic(self, network, public_ip, vpc=None,
             except Exception as e:
                 self.debug("Failed to wget from VM - %s" % e)
                 self.debug("Retrying wget from VM after some time...")
-                time.sleep(60)
+                time.sleep(5)
                 tries += 1
 
         if not filename and not headers:
@@ -293,6 +296,17 @@ def verify_StaticNAT_Internet_traffic(self, vm, network, public_ip,
                            "(wget www.google.com) test from VM as there is no "
                            "Internet connectivity in the data center")
 
+    # enable_staticNat_on_a_starting_vm - Enables Static Nat on a starting VM
+    # in the given network with the given public IP.
+    def enable_staticNat_on_a_starting_vm(self):
+        self.debug("Enables Static Nat on a starting VM in the network - %s "
+                   "with the given public IP - %s" %
+                   (self.network, self.public_ip))
+        time.sleep(15)
+        vm_list = list_virtual_machines(self.api_client, listall=True)
+        self.create_StaticNatRule_For_VM(
+            vm_list[0], self.public_ip, self.network)
+
     @attr(tags=["advanced", "nuagevsp"], required_hardware="false")
     def test_01_nuage_StaticNAT_public_ip_range(self):
         """Test Nuage VSP Public IP Range creation and deletion
@@ -2086,3 +2100,74 @@ def test_10_nuage_StaticNAT_network_restarts_traffic(self):
         # from the deployed VM
         self.verify_StaticNAT_Internet_traffic(
             vpc_vm, vpc_tier, public_ip_2, vpc=vpc)
+
+    # Bug CLOUDSTACK-9751
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="true")
+    def test_11_nuage_enable_staticNat_when_vr_is_in_starting_state(self):
+        """Test Nuage VSP Static NAT functionality by enabling Static Nat when
+        VR is in starting state
+        """
+
+        # 1. Create a Nuage VSP Isolated network offering.
+        # 2. Create an Isolated network with above created offering.
+        # 3. Deploy a VM in the above created Isolated network,
+        #    which starts a VR.
+        # 4. While VR is in the starting state, acquire a public IP and enable
+        #    static nat in another thread.
+        # 5. Verify that Static NAT is successfully enabled in both CloudStack
+        #    and VSD.
+        # 6. Delete all the created objects (cleanup).
+
+        # Creating network offering
+        self.debug("Creating Nuage VSP Isolated Network offering with Static "
+                   "NAT service provider as NuageVsp...")
+        net_off = self.create_NetworkOffering(
+            self.test_data["nuagevsp"]["isolated_network_offering"])
+        self.validate_NetworkOffering(net_off, state="Enabled")
+
+        # Creating an Isolated network
+        self.debug("Creating an Isolated network with Static NAT service...")
+        self.network = self.create_Network(net_off, gateway='10.1.1.1')
+        self.validate_Network(self.network, state="Allocated")
+
+        # Acquiring a Public IP
+        self.debug("Acquiring a Public IP in the created Isolated network...")
+        self.public_ip = self.acquire_PublicIPAddress(self.network)
+        self.validate_PublicIPAddress(self.public_ip, self.network)
+
+        # Enabling Static NAT on a starting VM
+        self.debug("Creating a thread for enabling Static Nat on a starting "
+                   "VM...")
+        static_nat_thread = threading.Thread(
+            name='enable_static_nat',
+            target=self.enable_staticNat_on_a_starting_vm)
+        static_nat_thread.start()
+
+        vm = self.create_VM(self.network)
+
+        # Check the status of Static Nat thread and if it is not finished then
+        # below command will wait for it to finish
+        self.debug("Waiting for for enabling Static Nat on a starting VM "
+                   "thread to finish...")
+        static_nat_thread.join()
+
+        # CloudStack verification for the implemented Isolated Network
+        self.validate_Network(self.network, state="Implemented")
+        vr = self.get_Router(self.network)
+        self.check_Router_state(vr, state="Running")
+        self.check_VM_state(vm, state="Running")
+
+        # VSD verification for the implemented Isolated Network
+        self.verify_vsd_network(self.domain.id, self.network)
+        self.verify_vsd_router(vr)
+        self.verify_vsd_vm(vm)
+
+        # CloudStack verification for Static NAT functionality
+        self.validate_PublicIPAddress(
+            self.public_ip, self.network, static_nat=True, vm=vm)
+
+        # VSD verification for Static NAT functionality
+        self.verify_vsd_floating_ip(self.network, vm, self.public_ip.ipaddress)
+
+        # Verifying Static NAT traffic
+        self.verify_StaticNAT_traffic(self.network, self.public_ip)
diff --git a/test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py b/test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py
index 97319aa2b1f..8a2ea4f179e 100644
--- a/test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py
+++ b/test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py
@@ -1428,6 +1428,7 @@ def test_05_nuage_internallb_traffic(self):
             http_rule["publicport"])
 
         # Verifying Internal LB (wget) traffic tests
+        # Bug CLOUDSTACK-9749
         self.verify_lb_wget_file(
             wget_file_1, [internal_vm_1, internal_vm_1_1, internal_vm_1_2])
         self.verify_lb_wget_file(
@@ -1908,9 +1909,17 @@ def test_07_nuage_internallb_vpc_network_restarts_traffic(self):
 
         # Internal LB (wget) traffic test
         ssh_client = self.ssh_into_VM(public_vm, public_ip)
-        wget_file = self.wget_from_vm_cmd(
-            ssh_client, int_lb_rule_1.sourceipaddress,
-            self.test_data["http_rule"]["publicport"])
+        tries = 0
+        while tries < 120:
+            wget_file = self.wget_from_vm_cmd(
+                ssh_client, int_lb_rule_1.sourceipaddress,
+                self.test_data["http_rule"]["publicport"])
+            if wget_file != "":
+                break
+            self.debug("Waiting for the InternalLbVm in the Internal tier to "
+                       "be fully resolved for (wget) traffic test...")
+            time.sleep(5)
+            tries += 1
 
         # Verifying Internal LB (wget) traffic test
         self.verify_lb_wget_file(
@@ -1954,9 +1963,17 @@ def test_07_nuage_internallb_vpc_network_restarts_traffic(self):
 
         # Internal LB (wget) traffic test
         ssh_client = self.ssh_into_VM(public_vm, public_ip)
-        wget_file = self.wget_from_vm_cmd(
-            ssh_client, int_lb_rule_1.sourceipaddress,
-            self.test_data["http_rule"]["publicport"])
+        tries = 0
+        while tries < 120:
+            wget_file = self.wget_from_vm_cmd(
+                ssh_client, int_lb_rule_1.sourceipaddress,
+                self.test_data["http_rule"]["publicport"])
+            if wget_file != "":
+                break
+            self.debug("Waiting for the InternalLbVm in the Internal tier to "
+                       "be fully resolved for (wget) traffic test...")
+            time.sleep(5)
+            tries += 1
 
         # Verifying Internal LB (wget) traffic test
         self.verify_lb_wget_file(
@@ -2128,16 +2145,15 @@ def test_07_nuage_internallb_vpc_network_restarts_traffic(self):
         # Internal LB (wget) traffic test
         ssh_client = self.ssh_into_VM(public_vm, public_ip)
         tries = 0
-        while tries < 25:
+        while tries < 120:
             wget_file = self.wget_from_vm_cmd(
                 ssh_client, int_lb_rule_1.sourceipaddress,
                 self.test_data["http_rule"]["publicport"])
             if wget_file != "":
                 break
-            self.debug("Waiting for the InternalLbVm and all the VMs in the "
-                       "Internal tier to be fully resolved for (wget) traffic "
-                       "test...")
-            time.sleep(60)
+            self.debug("Waiting for the InternalLbVm in the Internal tier to "
+                       "be fully resolved for (wget) traffic test...")
+            time.sleep(5)
             tries += 1
 
         # Verifying Internal LB (wget) traffic test
@@ -2489,11 +2505,20 @@ def test_08_nuage_internallb_appliance_operations_traffic(self):
 
         # Internal LB (wget) traffic test
         ssh_client = self.ssh_into_VM(public_vm, public_ip)
-        wget_file = self.wget_from_vm_cmd(
-            ssh_client, int_lb_rule_1.sourceipaddress,
-            self.test_data["http_rule"]["publicport"])
+        tries = 0
+        while tries < 120:
+            wget_file = self.wget_from_vm_cmd(
+                ssh_client, int_lb_rule_1.sourceipaddress,
+                self.test_data["http_rule"]["publicport"])
+            if wget_file != "":
+                break
+            self.debug("Waiting for the InternalLbVm in the Internal tier to "
+                       "be fully resolved for (wget) traffic test...")
+            time.sleep(5)
+            tries += 1
 
         # Verifying Internal LB (wget) traffic test
+        # Bug CLOUDSTACK-9837
         self.verify_lb_wget_file(
             wget_file, [internal_vm, internal_vm_1, internal_vm_2])
 
@@ -2556,9 +2581,17 @@ def test_08_nuage_internallb_appliance_operations_traffic(self):
 
         # Internal LB (wget) traffic test
         ssh_client = self.ssh_into_VM(public_vm, public_ip)
-        wget_file = self.wget_from_vm_cmd(
-            ssh_client, int_lb_rule_1.sourceipaddress,
-            self.test_data["http_rule"]["publicport"])
+        tries = 0
+        while tries < 120:
+            wget_file = self.wget_from_vm_cmd(
+                ssh_client, int_lb_rule_1.sourceipaddress,
+                self.test_data["http_rule"]["publicport"])
+            if wget_file != "":
+                break
+            self.debug("Waiting for the InternalLbVm in the Internal tier to "
+                       "be fully resolved for (wget) traffic test...")
+            time.sleep(5)
+            tries += 1
 
         # Verifying Internal LB (wget) traffic test
         self.verify_lb_wget_file(
@@ -2611,9 +2644,17 @@ def test_08_nuage_internallb_appliance_operations_traffic(self):
 
         # Internal LB (wget) traffic test
         ssh_client = self.ssh_into_VM(public_vm, public_ip)
-        wget_file = self.wget_from_vm_cmd(
-            ssh_client, int_lb_rule_1.sourceipaddress,
-            self.test_data["http_rule"]["publicport"])
+        tries = 0
+        while tries < 120:
+            wget_file = self.wget_from_vm_cmd(
+                ssh_client, int_lb_rule_1.sourceipaddress,
+                self.test_data["http_rule"]["publicport"])
+            if wget_file != "":
+                break
+            self.debug("Waiting for the InternalLbVm in the Internal tier to "
+                       "be fully resolved for (wget) traffic test...")
+            time.sleep(5)
+            tries += 1
 
         # Verifying Internal LB (wget) traffic test
         self.verify_lb_wget_file(
diff --git a/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py b/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py
index 088517756f7..e1b51287096 100644
--- a/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py
+++ b/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py
@@ -59,11 +59,13 @@ def test_nuage_vpc_network(self):
         # 5. Create a VPC Network with Nuage VSP VPC Network offering and the
         #    created ACL list, check if it is successfully created, is in the
         #    "Implemented" state, and is added to the VPC VR.
-        # 6. Deploy a VM in the created VPC network, check if the VM is
+        # 6. Verify that the VPC VR has no Public IP and NIC as it is not the
+        #    Source NAT service provider.
+        # 7. Deploy a VM in the created VPC network, check if the VM is
         #    successfully deployed and is in the "Running" state.
-        # 7. Verify that the created ACL item is successfully implemented in
+        # 8. Verify that the created ACL item is successfully implemented in
         #    Nuage VSP.
-        # 8. Delete all the created objects (cleanup).
+        # 9. Delete all the created objects (cleanup).
 
         # Creating a VPC offering
         self.debug("Creating Nuage VSP VPC offering...")
@@ -99,6 +101,11 @@ def test_nuage_vpc_network(self):
         vr = self.get_Router(vpc_network)
         self.check_Router_state(vr, state="Running")
 
+        # Verifying that the VPC VR has no public IP and NIC
+        self.verify_VRWithoutPublicIPNIC(vr)
+        # Verifying that the VPC has no src NAT ip
+        self.verify_vpc_has_no_src_nat(vpc)
+
         # Deploying a VM in the VPC network
         vm = self.create_VM(vpc_network)
         self.check_VM_state(vm, state="Running")
diff --git a/test/integration/plugins/nuagevsp/test_nuage_vsp.py b/test/integration/plugins/nuagevsp/test_nuage_vsp.py
index 9f2d1f23456..54656fd1694 100644
--- a/test/integration/plugins/nuagevsp/test_nuage_vsp.py
+++ b/test/integration/plugins/nuagevsp/test_nuage_vsp.py
@@ -173,11 +173,13 @@ def test_nuage_vsp(self):
         # 4. Deploy a VM in the created Isolated network, check if the Isolated
         #    network state is changed to "Implemented", and both the VM & VR
         #    are successfully deployed and are in the "Running" state.
-        # 5. Deploy one more VM in the created Isolated network, check if the
+        # 5. Verify that the VPC VR has no Public IP and NIC as it is not the
+        #    Source NAT service provider.
+        # 6. Deploy one more VM in the created Isolated network, check if the
         #    VM is successfully deployed and is in the "Running" state.
-        # 6. Delete the created Isolated Network after destroying its VMs,
+        # 7. Delete the created Isolated Network after destroying its VMs,
         #    check if the Isolated network is successfully deleted.
-        # 7. Delete all the created objects (cleanup).
+        # 8. Delete all the created objects (cleanup).
 
         for zone in self.zones:
             self.debug("Zone - %s" % zone.name)
@@ -206,6 +208,9 @@ def test_nuage_vsp(self):
             self.check_Router_state(vr, state="Running")
             self.check_VM_state(vm_1, state="Running")
 
+            # Verifying that the VR has no public IP and NIC
+            self.verify_VRWithoutPublicIPNIC(vr)
+
             # VSD verification
             self.verify_vsd_network(self.domain.id, network)
             self.verify_vsd_router(vr)


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message