You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by gi...@apache.org on 2013/11/01 13:01:18 UTC

git commit: updated refs/heads/4.2 to ba8be7c

Updated Branches:
  refs/heads/4.2 f9b658f6a -> ba8be7cbe


CLOUDSTACK-3961: Added a function to get free vlan


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ba8be7cb
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ba8be7cb
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ba8be7cb

Branch: refs/heads/4.2
Commit: ba8be7cbed7c180c1a6f2925f6d5ce8d12f9576f
Parents: f9b658f
Author: Girish Shilamkar <gi...@clogeny.com>
Authored: Fri Nov 1 17:27:46 2013 +0530
Committer: Girish Shilamkar <gi...@clogeny.com>
Committed: Fri Nov 1 17:30:48 2013 +0530

----------------------------------------------------------------------
 .../component/test_vpc_vms_deployment.py        | 40 ++++++++++++++++++--
 1 file changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba8be7cb/test/integration/component/test_vpc_vms_deployment.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_vms_deployment.py b/test/integration/component/test_vpc_vms_deployment.py
index 0a1321c..b01137b 100644
--- a/test/integration/component/test_vpc_vms_deployment.py
+++ b/test/integration/component/test_vpc_vms_deployment.py
@@ -272,6 +272,34 @@ class TestVMDeployVPC(cloudstackTestCase):
         self.debug("VPC network validated - %s" % network.name)
         return
 
+    def getFreeVlan(self, apiclient, zoneid):
+        """
+        Find an unallocated VLAN outside the range allocated to the physical network.
+
+        @note: This does not guarantee that the VLAN is available for use in
+        the deployment's network gear
+        @return: physical_network, shared_vlan_tag
+        """
+        list_physical_networks_response = PhysicalNetwork.list(
+            apiclient,
+            zoneid=zoneid
+        )
+        assert isinstance(list_physical_networks_response, list)
+        assert len(list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
+
+        physical_network = list_physical_networks_response[0]
+        vlans = xsplit(physical_network.vlan, ['-', ','])
+
+        assert len(vlans) > 0
+        assert int(vlans[0]) < int(vlans[-1]), "VLAN range  %s was improperly split" % physical_network.vlan
+        shared_ntwk_vlan = int(vlans[-1]) + random.randrange(1, 20)
+        if shared_ntwk_vlan > 4095:
+            shared_ntwk_vlan = int(vlans[0]) - random.randrange(1, 20)
+            assert shared_ntwk_vlan > 0, "VLAN chosen %s is invalid < 0" % shared_ntwk_vlan
+        self.debug("Attempting free VLAN %s for shared network creation" % shared_ntwk_vlan)
+        return shared_ntwk_vlan
+
+
     @attr(tags=["advanced", "intervlan"])
     def test_01_deploy_vms_in_network(self):
         """ Test deploy VMs in VPC networks
@@ -1995,6 +2023,8 @@ class TestVMDeployVPC(cloudstackTestCase):
                                 services=self.services["http_rule"],
                                 traffictype='Egress'
                                 )
+        
+        vlan = self.getFreeVlan(self.api_client, self.zone.id)
 
         self.debug("Creating private gateway in VPC: %s" % vpc.name)
         private_gateway = PrivateGateway.create(
@@ -2002,7 +2032,7 @@ class TestVMDeployVPC(cloudstackTestCase):
                                                 gateway='10.2.3.1',
                                                 ipaddress='10.2.3.2',
                                                 netmask='255.255.255.0',
-                                                vlan=678,
+                                                vlan=vlan,
                                                 vpcid=vpc.id
                                                 )
         self.debug("Check if the private gateway created successfully?")
@@ -2110,7 +2140,8 @@ class TestVMDeployVPC(cloudstackTestCase):
         self.assertEqual(
                          public_ips[0].ipaddress,
                          public_ip_6.ipaddress.ipaddress,
-                         "List public Ip for network should list the Ip addr"
+                         "List public Ips %s for network should list the Ip addr %s"
+                         % (public_ips[0].ipaddress, public_ip_6.ipaddress.ipaddress )
                          )
 
         self.debug("Associating public IP for network: %s" % vpc.name)
@@ -2150,13 +2181,14 @@ class TestVMDeployVPC(cloudstackTestCase):
                                 traffictype='Egress'
                                 )
 
+        vlan = self.getFreeVlan(self.api_client, self.zone.id)
         self.debug("Creating private gateway in VPC: %s" % vpc.name)
         private_gateway = PrivateGateway.create(
                                                 self.apiclient,
                                                 gateway='10.2.4.1',
                                                 ipaddress='10.2.4.2',
                                                 netmask='255.255.255.0',
-                                                vlan=678,
+                                                vlan=vlan,
                                                 vpcid=vpc.id
                                                 )
         self.debug("Check if the private gateway created successfully?")
@@ -2219,6 +2251,8 @@ class TestVMDeployVPC(cloudstackTestCase):
                                         (public_ip_1.ipaddress.ipaddress, e))
 
         result = str(res)
+        self.debug("result = %s, result.count = %s" % (result, result.count("1 received")))
+        self.debug("Public IP = %s" % public_ip_1.ipaddress.ipaddress)
         self.assertEqual(
                          result.count("1 received"),
                          1,