cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tall...@apache.org
Subject [15/18] Marvin + test changes from master Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
Date Mon, 28 Apr 2014 11:00:16 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_explicit_dedication.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_explicit_dedication.py b/test/integration/component/test_explicit_dedication.py
index c589c6a..4ce5c15 100644
--- a/test/integration/component/test_explicit_dedication.py
+++ b/test/integration/component/test_explicit_dedication.py
@@ -21,9 +21,9 @@ import marvin
 from marvin.cloudstackTestCase import *
 from marvin.cloudstackAPI import *
 from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
 from nose.plugins.attrib import attr
 #Import System modules
 import time
@@ -96,12 +96,13 @@ class TestExplicitDedication(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestExplicitDedication, cls).getClsTestClient().getApiClient()
-        cls.services = Services().services
+        cls.testClient = super(TestExplicitDedication, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
 
+        cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
 
         cls.template = get_template(

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_haproxy.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_haproxy.py b/test/integration/component/test_haproxy.py
index ceea50b..e3b45b5 100644
--- a/test/integration/component/test_haproxy.py
+++ b/test/integration/component/test_haproxy.py
@@ -19,7 +19,7 @@
 # Import Local Modules
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
                                         Account,
                                         ServiceOffering,
                                         VirtualMachine,
@@ -31,11 +31,11 @@ from marvin.integration.lib.base import (
                                         Vpn,
                                         NATRule
                                         )
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
                                         get_zone,
                                         get_template
                                         )
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
                                           random_gen)
 from marvin.cloudstackAPI import createLBStickinessPolicy
 from marvin.sshClient import SshClient
@@ -118,12 +118,13 @@ class TestHAProxyStickyness(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestHAProxyStickyness,
-                               cls).getClsTestClient().getApiClient()
+        cls.testClient = super(TestHAProxyStickyness, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
 
         cls.template = get_template(
                             cls.api_client,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_implicit_planner.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_implicit_planner.py b/test/integration/component/test_implicit_planner.py
index 5124e70..9cbd73c 100644
--- a/test/integration/component/test_implicit_planner.py
+++ b/test/integration/component/test_implicit_planner.py
@@ -21,9 +21,9 @@ import marvin
 from marvin.cloudstackTestCase import *
 from marvin.cloudstackAPI import *
 from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
 from nose.plugins.attrib import attr
 #Import System modules
 import time
@@ -91,12 +91,13 @@ class TestImplicitPlanner(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestImplicitPlanner, cls).getClsTestClient().getApiClient()
-        cls.services = Services().services
+        cls.testClient = super(TestImplicitPlanner, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
 
+        cls.services = Services().services
         # Get Zone, Domain and templates
-        domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
 
         template = get_template(

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_ip_reservation.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ip_reservation.py b/test/integration/component/test_ip_reservation.py
index 46b4edb..dea26ab 100644
--- a/test/integration/component/test_ip_reservation.py
+++ b/test/integration/component/test_ip_reservation.py
@@ -23,31 +23,10 @@
     Feature Specifications: https://cwiki.apache.org/confluence/display/CLOUDSTACK/FS+-+IP+Range+Reservation+within+a+Network
 """
 from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.utils import (cleanup_resources,
-                                          validateList,
-                                          verifyRouterState)
-from marvin.integration.lib.base import (Network,
-                                         Account,
-                                         ServiceOffering,
-                                         VirtualMachine,
-                                         Router,
-                                         NetworkOffering,
-                                         VpcOffering,
-                                         VPC)
-from marvin.integration.lib.common import (get_domain,
-                                            get_zone,
-                                            get_template,
-                                            createEnabledNetworkOffering,
-                                            get_free_vlan,
-                                            wait_for_cleanup,
-                                            createNetworkRulesForVM)
-from marvin.codes import (PASS,
-                          NAT_RULE,
-                          STATIC_NAT_RULE,
-                          FAIL,
-                          UNKNOWN,
-                          FAULT,
-                          MASTER)
+from marvin.cloudstackException import CloudstackAPIException
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
 import netaddr
 
 import random
@@ -101,18 +80,22 @@ class TestIpReservation(cloudstackTestCase):
     """
     @classmethod
     def setUpClass(cls):
-        cloudstackTestClient = super(TestIpReservation, cls).getClsTestClient()
-        cls.api_client = cloudstackTestClient.getApiClient()
-        # Fill test data from the external config file
-        cls.testData = cloudstackTestClient.getConfigParser().parsedDict
+        cls.testClient = super(TestIpReservation, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
+        # Fill services from the external config file
+        cls.testData = cls.testClient.getParsedTestDataConfig()
+
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.testData)
-        cls.zone = get_zone(cls.api_client, cls.testData)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
                             cls.testData["ostype"]
                             )
+        if cls.template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.testData["ostype"]
         cls.testData["domainid"] = cls.domain.id
         cls.testData["zoneid"] = cls.zone.id
         cls.testData["virtual_machine"]["zoneid"] = cls.zone.id
@@ -545,18 +528,22 @@ class TestRestartNetwork(cloudstackTestCase):
     """
     @classmethod
     def setUpClass(cls):
-        cloudstackTestClient = super(TestRestartNetwork, cls).getClsTestClient()
-        cls.api_client = cloudstackTestClient.getApiClient()
-        # Fill test data from the external config file
-        cls.testData = cloudstackTestClient.getConfigParser().parsedDict
+        cls.testClient = super(TestRestartNetwork, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
+        # Fill services from the external config file
+        cls.testData = cls.testClient.getParsedTestDataConfig()
+
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.testData)
-        cls.zone = get_zone(cls.api_client, cls.testData)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
                             cls.testData["ostype"]
                             )
+        if cls.template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.testData["ostype"]
         cls.testData["domainid"] = cls.domain.id
         cls.testData["zoneid"] = cls.zone.id
         cls.testData["virtual_machine"]["zoneid"] = cls.zone.id
@@ -666,18 +653,22 @@ class TestUpdateIPReservation(cloudstackTestCase):
     """
     @classmethod
     def setUpClass(cls):
-        cloudstackTestClient = super(TestUpdateIPReservation, cls).getClsTestClient()
-        cls.api_client = cloudstackTestClient.getApiClient()
-        # Fill test data from the external config file
-        cls.testData = cloudstackTestClient.getConfigParser().parsedDict
+        cls.testClient = super(TestUpdateIPReservation, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
+        # Fill services from the external config file
+        cls.testData = cls.testClient.getParsedTestDataConfig()
+
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.testData)
-        cls.zone = get_zone(cls.api_client, cls.testData)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
                             cls.testData["ostype"]
                             )
+        if cls.template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.testData["ostype"]
         cls.testData["domainid"] = cls.domain.id
         cls.testData["zoneid"] = cls.zone.id
         cls.testData["virtual_machine"]["zoneid"] = cls.zone.id
@@ -812,18 +803,22 @@ class TestRouterOperations(cloudstackTestCase):
     """
     @classmethod
     def setUpClass(cls):
-        cloudstackTestClient = super(TestRouterOperations, cls).getClsTestClient()
-        cls.api_client = cloudstackTestClient.getApiClient()
-        # Fill test data from the external config file
-        cls.testData = cloudstackTestClient.getConfigParser().parsedDict
+        cls.testClient = super(TestRouterOperations, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
+        # Fill services from the external config file
+        cls.testData = cls.testClient.getParsedTestDataConfig()
+
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.testData)
-        cls.zone = get_zone(cls.api_client, cls.testData)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
                             cls.testData["ostype"]
                             )
+        if cls.template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.testData["ostype"]
         cls.testData["domainid"] = cls.domain.id
         cls.testData["zoneid"] = cls.zone.id
         cls.testData["virtual_machine"]["zoneid"] = cls.zone.id
@@ -978,18 +973,22 @@ class TestFailureScnarios(cloudstackTestCase):
     """
     @classmethod
     def setUpClass(cls):
-        cloudstackTestClient = super(TestFailureScnarios, cls).getClsTestClient()
-        cls.api_client = cloudstackTestClient.getApiClient()
-        # Fill test data from the external config file
-        cls.testData = cloudstackTestClient.getConfigParser().parsedDict
+        cls.testClient = super(TestFailureScnarios, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
+        # Fill services from the external config file
+        cls.testData = cls.testClient.getParsedTestDataConfig()
+
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.testData)
-        cls.zone = get_zone(cls.api_client, cls.testData)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
                             cls.testData["ostype"]
                             )
+        if cls.template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.testData["ostype"]
         cls.testData["domainid"] = cls.domain.id
         cls.testData["zoneid"] = cls.zone.id
         cls.testData["virtual_machine"]["zoneid"] = cls.zone.id

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_ldap.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ldap.py b/test/integration/component/test_ldap.py
index 965ff36..5dd9692 100644
--- a/test/integration/component/test_ldap.py
+++ b/test/integration/component/test_ldap.py
@@ -29,9 +29,9 @@ import hashlib
 import random
 from marvin.cloudstackAPI import *
 from marvin.cloudstackAPI import login
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
 from nose.plugins.attrib import attr
 import urllib
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_memory_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_memory_limits.py b/test/integration/component/test_memory_limits.py
index 020f89b..5dd3ba0 100644
--- a/test/integration/component/test_memory_limits.py
+++ b/test/integration/component/test_memory_limits.py
@@ -19,21 +19,21 @@
 # Import Local Modules
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
                                         Account,
                                         ServiceOffering,
                                         VirtualMachine,
                                         Resources,
                                         Domain
                                         )
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
                                         get_zone,
                                         get_template,
                                         wait_for_cleanup,
                                         findSuitableHostForMigration,
                                         get_resource_type
                                         )
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
 from marvin.codes import ERROR_NO_HOST_FOR_MIGRATION
 
 class Services:
@@ -91,12 +91,13 @@ class TestMemoryLimits(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestMemoryLimits,
-                               cls).getClsTestClient().getApiClient()
+        cls.testClient = super(TestMemoryLimits, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
 
         cls.services["mode"] = cls.zone.networktype
 
@@ -370,12 +371,13 @@ class TestDomainMemoryLimitsConfiguration(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestDomainMemoryLimitsConfiguration,
-                               cls).getClsTestClient().getApiClient()
+        cls.testClient = super(TestDomainMemoryLimitsConfiguration, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services["mode"] = cls.zone.networktype
 
         cls.template = get_template(
@@ -498,7 +500,7 @@ class TestDomainMemoryLimitsConfiguration(cloudstackTestCase):
             self.account = admin
             self.domain = domain
 
-            api_client = self.testClient.createUserApiClient(
+            api_client = self.testClient.getUserApiClient(
                              UserName=self.account.name,
                              DomainName=self.account.domain)
 
@@ -570,7 +572,7 @@ class TestDomainMemoryLimitsConfiguration(cloudstackTestCase):
             self.account = admin
             self.domain = domain
 
-            api_client = self.testClient.createUserApiClient(
+            api_client = self.testClient.getUserApiClient(
                              UserName=self.account.name,
                              DomainName=self.account.domain)
 
@@ -630,7 +632,7 @@ class TestDomainMemoryLimitsConfiguration(cloudstackTestCase):
             self.account = admin
             self.domain = domain
 
-            api_client = self.testClient.createUserApiClient(
+            api_client = self.testClient.getUserApiClient(
                              UserName=self.account.name,
                              DomainName=self.account.domain)
 
@@ -703,7 +705,7 @@ class TestDomainMemoryLimitsConfiguration(cloudstackTestCase):
             if memory_account_gc[0].max != 8192:
                 self.skipTest("This test case requires configuration value max.account.memory to be 8192")
 
-	        api_client = self.testClient.createUserApiClient(
+	        api_client = self.testClient.getUserApiClient(
                              UserName=self.account.name,
                              DomainName=self.account.domain)
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_mm_domain_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_mm_domain_limits.py b/test/integration/component/test_mm_domain_limits.py
index 0a8e98b..bc8c9ea 100644
--- a/test/integration/component/test_mm_domain_limits.py
+++ b/test/integration/component/test_mm_domain_limits.py
@@ -19,14 +19,14 @@
 # Import Local Modules
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
                                         Account,
                                         ServiceOffering,
                                         VirtualMachine,
                                         Resources,
                                         Domain
                                         )
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
                                         get_zone,
                                         get_template,
 					                    wait_for_cleanup,
@@ -34,7 +34,7 @@ from marvin.integration.lib.common import (get_domain,
                                         get_resource_type,
                                         update_resource_count
                                         )
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
 from marvin.codes import ERROR_NO_HOST_FOR_MIGRATION
 
 class Services:
@@ -92,12 +92,13 @@ class TestDomainMemoryLimits(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestDomainMemoryLimits,
-                               cls).getClsTestClient().getApiClient()
+        cls.testClient = super(TestDomainMemoryLimits, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services["mode"] = cls.zone.networktype
 
         cls.template = get_template(
@@ -234,7 +235,7 @@ class TestDomainMemoryLimits(cloudstackTestCase):
             self.debug("Creating an instance with service offering: %s" %
                                                     self.service_offering.name)
 
-            api_client = self.testClient.createUserApiClient(
+            api_client = self.testClient.getUserApiClient(
                             UserName=self.account.name,
                             DomainName=self.account.domain)
 
@@ -371,7 +372,7 @@ class TestDomainMemoryLimits(cloudstackTestCase):
             self.debug("Creating an instance with service offering: %s" %
                                                     self.service_offering.name)
 
-            api_client = self.testClient.createUserApiClient(
+            api_client = self.testClient.getUserApiClient(
                             UserName=self.account.name,
                             DomainName=self.account.domain)
 
@@ -432,7 +433,7 @@ class TestDomainMemoryLimits(cloudstackTestCase):
             self.debug("Creating an instance with service offering: %s" %
                                                     self.service_offering.name)
 
-            api_client = self.testClient.createUserApiClient(
+            api_client = self.testClient.getUserApiClient(
                             UserName=self.account.name,
                             DomainName=self.account.domain)
 
@@ -492,7 +493,7 @@ class TestDomainMemoryLimits(cloudstackTestCase):
             self.debug("Creating an instance with service offering: %s" %
                                                     self.service_offering.name)
 
-            api_client = self.testClient.createUserApiClient(
+            api_client = self.testClient.getUserApiClient(
                             UserName=self.account.name,
                             DomainName=self.account.domain)
 
@@ -524,12 +525,13 @@ class TestMultipleChildDomainsMemory(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestMultipleChildDomainsMemory,
-                               cls).getClsTestClient().getApiClient()
+        cls.testClient = super(TestMultipleChildDomainsMemory, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services["mode"] = cls.zone.networktype
 
         cls.template = get_template(
@@ -709,11 +711,11 @@ class TestMultipleChildDomainsMemory(cloudstackTestCase):
         self.debug("Setting up account and domain hierarchy")
         self.setupAccounts()
 
-        api_client_cadmin_1 = self.testClient.createUserApiClient(
+        api_client_cadmin_1 = self.testClient.getUserApiClient(
                             UserName=self.cadmin_1.name,
                             DomainName=self.cadmin_1.domain)
 
-        api_client_cadmin_2 = self.testClient.createUserApiClient(
+        api_client_cadmin_2 = self.testClient.getUserApiClient(
                             UserName=self.cadmin_2.name,
                             DomainName=self.cadmin_2.domain)
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_mm_max_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_mm_max_limits.py b/test/integration/component/test_mm_max_limits.py
index 52ff98e..34d4147 100644
--- a/test/integration/component/test_mm_max_limits.py
+++ b/test/integration/component/test_mm_max_limits.py
@@ -19,7 +19,7 @@
 # Import Local Modules
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
                                         Account,
                                         ServiceOffering,
                                         VirtualMachine,
@@ -27,11 +27,11 @@ from marvin.integration.lib.base import (
                                         Domain,
                                         Project
                                         )
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
                                         get_zone,
                                         get_template
                                         )
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
 
 class Services:
     """Test memory resource limit services
@@ -88,12 +88,13 @@ class TestMaxMemoryLimits(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestMaxMemoryLimits,
-                               cls).getClsTestClient().getApiClient()
+        cls.testClient = super(TestMaxMemoryLimits, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services["mode"] = cls.zone.networktype
 
         cls.template = get_template(
@@ -253,7 +254,7 @@ class TestMaxMemoryLimits(cloudstackTestCase):
         self.debug("Setting up account and domain hierarchy")
         self.setupAccounts(account_limit=8, domain_limit=4)
 
-        api_client = self.testClient.createUserApiClient(
+        api_client = self.testClient.getUserApiClient(
                             UserName=self.child_do_admin.name,
                             DomainName=self.child_do_admin.domain)
 
@@ -280,7 +281,7 @@ class TestMaxMemoryLimits(cloudstackTestCase):
         self.debug("Setting up account and domain hierarchy")
         self.setupAccounts(account_limit=7, domain_limit=14)
 
-        api_client = self.testClient.createUserApiClient(
+        api_client = self.testClient.getUserApiClient(
                             UserName=self.child_do_admin.name,
                             DomainName=self.child_do_admin.domain)
 
@@ -310,7 +311,7 @@ class TestMaxMemoryLimits(cloudstackTestCase):
         self.debug("Setting up account and domain hierarchy")
         self.setupAccounts(account_limit=8,domain_limit=8, project_limit=4)
 
-        api_client = self.testClient.createUserApiClient(
+        api_client = self.testClient.getUserApiClient(
                             UserName=self.child_do_admin.name,
                             DomainName=self.child_do_admin.domain)
 
@@ -334,7 +335,7 @@ class TestMaxMemoryLimits(cloudstackTestCase):
         self.debug("Setting up account and domain hierarchy")
         self.setupAccounts(account_limit=6, project_limit=12, domain_limit=12)
 
-        api_client = self.testClient.createUserApiClient(
+        api_client = self.testClient.getUserApiClient(
                             UserName=self.child_do_admin.name,
                             DomainName=self.child_do_admin.domain)
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_mm_project_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_mm_project_limits.py b/test/integration/component/test_mm_project_limits.py
index 00c0ab4..593b2b6 100644
--- a/test/integration/component/test_mm_project_limits.py
+++ b/test/integration/component/test_mm_project_limits.py
@@ -19,21 +19,21 @@
 # Import Local Modules
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
                                         Account,
                                         ServiceOffering,
                                         VirtualMachine,
                                         Domain,
                                         Project
                                         )
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
                                         get_zone,
                                         get_template,
 					                    wait_for_cleanup,
                                         findSuitableHostForMigration,
                                         get_resource_type
                                         )
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
 from marvin.codes import ERROR_NO_HOST_FOR_MIGRATION
 
 class Services:
@@ -91,12 +91,13 @@ class TestProjectsMemoryLimits(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestProjectsMemoryLimits,
-                               cls).getClsTestClient().getApiClient()
+        cls.testClient = super(TestProjectsMemoryLimits, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services["mode"] = cls.zone.networktype
 
         cls.template = get_template(
@@ -137,7 +138,7 @@ class TestProjectsMemoryLimits(cloudstackTestCase):
         self.debug("Setting up account and domain hierarchy")
         self.setupProjectAccounts()
 
-        api_client = self.testClient.createUserApiClient(
+        api_client = self.testClient.getUserApiClient(
                             UserName=self.admin.name,
                             DomainName=self.admin.domain)
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_multiple_ip_ranges.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_multiple_ip_ranges.py b/test/integration/component/test_multiple_ip_ranges.py
index aae90c4..32c39f7 100644
--- a/test/integration/component/test_multiple_ip_ranges.py
+++ b/test/integration/component/test_multiple_ip_ranges.py
@@ -18,10 +18,10 @@
 """
 from marvin.cloudstackTestCase import *
 from marvin.cloudstackAPI import *
-from marvin.cloudstackException import cloudstackAPIException
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.cloudstackException import CloudstackAPIException
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
 from netaddr import *
 
 from nose.plugins.attrib import attr
@@ -78,12 +78,14 @@ class TestMultipleIpRanges(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestMultipleIpRanges, cls).getClsTestClient().getApiClient()
+        cls.testClient = super(TestMultipleIpRanges, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
-        cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+        cls.pod = get_pod(cls.api_client, cls.zone.id)
         cls.services['mode'] = cls.zone.networktype
         cls.services["domainid"] = cls.domain.id
         cls.services["zoneid"] = cls.zone.id
@@ -296,7 +298,7 @@ class TestMultipleIpRanges(cloudstackTestCase):
         #listing vlan ip ranges with the id should through exception , if not mark the test case as failed
         try:
             new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
-        except cloudstackAPIException as cs:
+        except CloudstackAPIException as cs:
             self.debug(cs.errorMsg)
             self.assertTrue(cs.errorMsg.find("entity does not exist")>0, msg="Failed to delete IP range")
         return
@@ -387,7 +389,7 @@ class TestMultipleIpRanges(cloudstackTestCase):
 	self.debug("Adding overlapped ip range")
         try:
             new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
-        except cloudstackAPIException as cs:
+        except CloudstackAPIException as cs:
             self.debug(cs.errorMsg)
             self.assertTrue(cs.errorMsg.find("already has IPs that overlap with the new range")>0, msg="Fail:CS allowed adding overlapped ip ranges in guest cidr")
             return
@@ -443,7 +445,7 @@ class TestMultipleIpRanges(cloudstackTestCase):
 	self.debug("Adding ip range overlapped with two cidrs")
         try:
             new_vlan3 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
-        except cloudstackAPIException as cs:
+        except CloudstackAPIException as cs:
             self.debug(cs.errorMsg)
             self.assertTrue(cs.errorMsg.find("already has IPs that overlap with the new range")>0, msg="Fail:CS allowed adding overlapped ip ranges in guest cidr")
             return
@@ -496,7 +498,7 @@ class TestMultipleIpRanges(cloudstackTestCase):
 	self.debug("Adding IP range super set to existing CIDR")
         try:
             new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
-        except cloudstackAPIException as cs:
+        except CloudstackAPIException as cs:
             self.debug(cs.errorMsg)
             self.assertTrue(cs.errorMsg.find("superset")>0, msg="Fail: CS allowed adding ip range superset to existing CIDR")
             return
@@ -549,7 +551,7 @@ class TestMultipleIpRanges(cloudstackTestCase):
 	self.debug("Adding ip range subset to existing cidr")
         try:
             new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
-        except cloudstackAPIException as cs:
+        except CloudstackAPIException as cs:
             self.debug(cs.errorMsg)
             self.assertTrue(cs.errorMsg.find("subset")>0, msg="Fail: CS allowed adding ip range subset to existing CIDR")
             return

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_multiple_ips_per_nic.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_multiple_ips_per_nic.py b/test/integration/component/test_multiple_ips_per_nic.py
index dcbb453..2739637 100644
--- a/test/integration/component/test_multiple_ips_per_nic.py
+++ b/test/integration/component/test_multiple_ips_per_nic.py
@@ -23,32 +23,14 @@
     Design Document: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Multiple+IP+address+per+NIC
 """
 from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.utils import (cleanup_resources,
-                                          validateList,
-                                          random_gen)
-from marvin.integration.lib.base import (Account,
-                                         ServiceOffering,
-                                         Network,
-                                         VirtualMachine,
-                                         VpcOffering,
-                                         VPC,
-                                         NIC,
-                                         Domain,
-                                         PublicIPAddress,
-                                         StaticNATRule,
-                                         FireWallRule,
-                                         NATRule)
-from marvin.integration.lib.common import (get_domain,
-                                           get_zone,
-                                           get_template,
-                                           get_free_vlan,
-                                           setSharedNetworkParams,
-                                           createEnabledNetworkOffering,
-                                           shouldTestBeSkipped)
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
 
 from nose.plugins.attrib import attr
 from marvin.codes import PASS, ISOLATED_NETWORK, VPC_NETWORK, SHARED_NETWORK, FAIL
 from ddt import ddt, data
+import time
 
 def createNetwork(self, networkType):
     """Create a network of given type (isolated/shared/isolated in VPC)"""
@@ -137,21 +119,23 @@ class TestBasicOperations(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cloudstackTestClient = super(TestBasicOperations,cls).getClsTestClient()
-        cls.api_client = cloudstackTestClient.getApiClient()
+        cls.testClient = super(TestBasicOperations, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
 
         # Fill services from the external config file
-        cls.services = cloudstackTestClient.getConfigParser().parsedDict
+        cls.services = cls.testClient.getParsedTestDataConfig()
 
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
-        cls.mode = str(cls.zone.networktype).lower()
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
                             cls.services["ostype"]
                             )
+        if cls.template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
         cls.services["virtual_machine"]["template"] = cls.template.id
         cls.service_offering = ServiceOffering.create(
@@ -486,21 +470,23 @@ class TestNetworkRules(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cloudstackTestClient = super(TestNetworkRules,cls).getClsTestClient()
-        cls.api_client = cloudstackTestClient.getApiClient()
+        cls.testClient = super(TestNetworkRules, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
 
         # Fill services from the external config file
-        cls.services = cloudstackTestClient.getConfigParser().parsedDict
+        cls.services = cls.testClient.getParsedTestDataConfig()
 
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
-        cls.mode = str(cls.zone.networktype).lower()
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
                             cls.services["ostype"]
                             )
+        if cls.template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
         cls.services["virtual_machine"]["template"] = cls.template.id
         cls.service_offering = ServiceOffering.create(
@@ -851,3 +837,439 @@ class TestNetworkRules(cloudstackTestCase):
 
         public_ip.delete(self.apiclient)
         return
+
+@ddt
+class TestVmNetworkOperations(cloudstackTestCase):
+    """Test VM and Network operations with network rules created on secondary IP
+    """
+
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestVmNetworkOperations, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
+        # Fill services from the external config file
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+        cls.template = get_template(
+                            cls.api_client,
+                            cls.zone.id,
+                            cls.services["ostype"]
+                            )
+        if cls.template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["template"] = cls.template.id
+        cls.service_offering = ServiceOffering.create(
+                                            cls.api_client,
+                                            cls.services["service_offering"]
+                                            )
+        cls._cleanup = [cls.service_offering]
+        cls.services["shared_network_offering"]["specifyVlan"] = "True"
+        cls.services["shared_network_offering"]["specifyIpRanges"] = "True"
+
+        cls.shared_network_offering = CreateEnabledNetworkOffering(cls.api_client, cls.services["shared_network_offering"])
+        cls._cleanup.append(cls.shared_network_offering)
+
+        if cls.mode == "advanced":
+            cls.isolated_network_offering = CreateEnabledNetworkOffering(cls.api_client, cls.services["isolated_network_offering"])
+            cls._cleanup.append(cls.isolated_network_offering)
+            cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(cls.api_client, cls.services["nw_offering_isolated_vpc"])
+            cls._cleanup.append(cls.isolated_network_offering_vpc)
+            cls.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"])
+            cls.vpc_off.update(cls.api_client, state='Enabled')
+            cls._cleanup.append(cls.vpc_off)
+        return
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            # Cleanup resources used
+            cleanup_resources(cls.api_client, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.cleanup = [ ]
+        return
+
+    def tearDown(self):
+        try:
+            # Clean up, terminate the resources created
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    def VerifyStaticNatForPublicIp(self, ipaddressid, natrulestatus):
+        """ List public IP and verify that NAT rule status for the IP is as desired """
+
+        publiciplist = PublicIPAddress.list(self.apiclient, id=ipaddressid, listall=True)
+        self.assertEqual(validateList(publiciplist)[0], PASS, "Public IP list validation failed")
+        self.assertEqual(publiciplist[0].isstaticnat, natrulestatus, "isstaticnat should be %s, it is %s" %
+                (natrulestatus, publiciplist[0].isstaticnat))
+
+        return
+
+    @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+    @attr(tags=["advanced"])
+    def test_delete_vm(self, value):
+        """ Test delete VM and verify network rules are cleaned up"""
+
+        # Steps:
+        # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+        # 2. Deploy a VM in this network and account
+        # 3. Add 2 secondary IPs to the default nic of VM
+        # 4. Acquire 2 public IPs in the network
+        # 5. For 1st public IP create nat rule to 1st private IP, for 2nd public IP, create
+        #    static nat rule to 2nd private IP
+        # 6. Destroy the virtual machine
+        # 7. Verify that nat rule does not exist and static nat is not enabled for
+        #    secondary IP
+
+        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.cleanup.append(self.account)
+
+        network = createNetwork(self, value)
+
+        try:
+            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
+                                                    accountid=self.account.name,domainid=self.account.domainid)
+        except Exception as e:
+            self.fail("vm creation failed: %s" % e)
+
+        # Add secondary IPs to default NIC of VM
+        try:
+            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+        except Exception as e:
+            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+        # Acquire public IP addresses in the network
+        try:
+            public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+                                           zoneid=self.zone.id,domainid=self.account.domainid,
+                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+
+            public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+                                           zoneid=self.zone.id,domainid=self.account.domainid,
+                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+        except Exception as e:
+            self.fail("Exception while acquiring public ip address: %s" % e)
+
+        # Create Firewall and natrule for 1st IP and static nat rule for 2nd IP
+        if value != VPC_NETWORK:
+            FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
+                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
+                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+
+        natrule = NATRule.create(self.api_client, virtual_machine,
+                       self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
+                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+
+        StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
+                    network.id, vmguestip=ipaddress_2.ipaddress)
+
+        # Delete VM
+        virtual_machine.delete(self.apiclient)
+
+        # Wait for VMs to expunge
+        wait_for_cleanup(self.api_client, ["expunge.delay", "expunge.interval"])
+
+        # Make sure the VM is expunged
+        retriesCount = 20
+        while True:
+            vms = VirtualMachine.list(self.apiclient, id=virtual_machine.id)
+            if vms is None:
+                break
+            elif retriesCount == 0:
+                self.fail("Failed to expunge vm even after 20 minutes")
+            time.sleep(60)
+            retriesCount -= 1
+
+        # Try to list nat rule
+        with self.assertRaises(Exception):
+            NATRule.list(self.apiclient, id=natrule.id, listall=True)
+
+        # Verify static nat rule is no longer enabled
+        self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, False)
+        return
+
+    @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+    @attr(tags=["advanced"])
+    def test_recover_vm(self, value):
+        """ Test recover VM operation with VM having secondary IPs"""
+
+        # Steps:
+        # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+        # 2. Deploy a VM in this network and account
+        # 3. Add 2 secondary IPs to the default nic of VM
+        # 4. Acquire 2 public IPs in the network
+        # 5. For 1st public IP create nat rule to 1st private IP, for 2nd public IP, create
+        #    static nat rule to 2nd private IP
+        # 6. Destroy the virtual machine and recover it
+        # 7. Verify that nat and static nat rules exist
+
+        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.cleanup.append(self.account)
+
+        network = createNetwork(self, value)
+
+        try:
+            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
+                                                    accountid=self.account.name,domainid=self.account.domainid)
+        except Exception as e:
+            self.fail("vm creation failed: %s" % e)
+
+        try:
+            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+        except Exception as e:
+            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+        try:
+            public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+                                           zoneid=self.zone.id,domainid=self.account.domainid,
+                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+
+            public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+                                           zoneid=self.zone.id,domainid=self.account.domainid,
+                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+        except Exception as e:
+            self.fail("Exception while acquiring public ip address: %s" % e)
+
+        if value != VPC_NETWORK:
+            FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
+                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
+                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+
+        natrule = NATRule.create(self.api_client, virtual_machine,
+                       self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
+                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+
+        StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
+                    network.id, vmguestip=ipaddress_2.ipaddress)
+
+        virtual_machine.delete(self.apiclient)
+        virtual_machine.recover(self.apiclient)
+
+        retriesCount = 10
+        while True:
+            vms = VirtualMachine.list(self.apiclient, id=virtual_machine.id)
+            self.assertEqual(validateList(vms)[0], PASS, "vms list validation failed")
+            if str(vms[0].state).lower() == "stopped":
+                break
+            elif retriesCount == 0:
+                self.fail("Failed to recover vm even after 10 mins")
+            time.sleep(60)
+            retriesCount -= 1
+
+        natrules = NATRule.list(self.apiclient, id=natrule.id, listall=True)
+        self.assertEqual(validateList(natrules)[0], PASS, "nat rules validation failed")
+
+        self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, True)
+
+        return
+
+    @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+    @attr(tags=["advanced"])
+    def test_network_restart_cleanup_true(self, value):
+        """Test network restart (cleanup True) with VM having secondary IPs and related network rules"""
+
+        # Steps:
+        # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+        # 2. Deploy a VM in this network and account
+        # 3. Add 2 secondary IPs to the default nic of VM
+        # 4. Acquire 2 public IPs in the network
+        # 5. For 1st public IP create nat rule to 1st private IP, for 2nd public IP, create
+        #    static nat rule to 2nd private IP
+        # 6. Restart the network with cleanup option True
+        # 7. Verify that nat and static nat rules exist after network restart
+
+        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.cleanup.append(self.account)
+
+        network = createNetwork(self, value)
+
+        try:
+            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
+                                                    accountid=self.account.name,domainid=self.account.domainid)
+        except Exception as e:
+            self.fail("vm creation failed: %s" % e)
+
+        try:
+            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+        except Exception as e:
+            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+        try:
+            public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+                                           zoneid=self.zone.id,domainid=self.account.domainid,
+                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+
+            public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+                                           zoneid=self.zone.id,domainid=self.account.domainid,
+                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+        except Exception as e:
+            self.fail("Exception while acquiring public ip address: %s" % e)
+
+        if value != VPC_NETWORK:
+            FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
+                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
+                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+
+        natrule = NATRule.create(self.api_client, virtual_machine,
+                       self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
+                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+
+        StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
+                    network.id, vmguestip=ipaddress_2.ipaddress)
+
+        network.restart(self.apiclient, cleanup=True)
+
+        natrulelist = NATRule.list(self.apiclient, id=natrule.id, listall=True)
+        self.assertEqual(validateList(natrulelist)[0], PASS, "nat rules list validation failed")
+
+        self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, True)
+        return
+
+    @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+    @attr(tags=["advanced"])
+    def test_network_restart_cleanup_false(self, value):
+        """Test network restart (cleanup True) with VM having secondary IPs and related network rules"""
+
+        # Steps:
+        # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+        # 2. Deploy a VM in this network and account
+        # 3. Add 2 secondary IPs to the default nic of VM
+        # 4. Acquire 2 public IPs in the network
+        # 5. For 1st public IP create nat rule to 1st private IP, for 2nd public IP, create
+        #    static nat rule to 2nd private IP
+        # 6. Restart the network with cleanup option False
+        # 7. Verify that nat and static nat rules exist after network restart
+
+        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.cleanup.append(self.account)
+
+        network = createNetwork(self, value)
+
+        try:
+            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
+                                                    accountid=self.account.name,domainid=self.account.domainid)
+        except Exception as e:
+            self.fail("vm creation failed: %s" % e)
+
+        try:
+            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+        except Exception as e:
+            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+        try:
+            public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+                                           zoneid=self.zone.id,domainid=self.account.domainid,
+                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+
+            public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+                                           zoneid=self.zone.id,domainid=self.account.domainid,
+                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+        except Exception as e:
+            self.fail("Exception while acquiring public ip address: %s" % e)
+
+        if value != VPC_NETWORK:
+            FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
+                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
+                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+
+        natrule = NATRule.create(self.api_client, virtual_machine,
+                       self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
+                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+
+        StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
+                    network.id, vmguestip=ipaddress_2.ipaddress)
+
+        network.restart(self.apiclient, cleanup=False)
+
+        natrulelist = NATRule.list(self.apiclient, id=natrule.id, listall=True)
+        self.assertEqual(validateList(natrulelist)[0], PASS, "nat rules list validation failed")
+
+        self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, True)
+        return
+
+    @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+    @attr(tags=["advanced"])
+    def test_reboot_router_VM(self, value):
+        """ Test reboot router and persistence of network rules"""
+
+        # Steps:
+        # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+        # 2. Deploy a VM in this network and account
+        # 3. Add 2 secondary IPs to the default nic of VM
+        # 4. Acquire 2 public IPs in the network
+        # 5. For 1st public IP create nat rule to 1st private IP, for 2nd public IP, create
+        #    static nat rule to 2nd private IP
+        # 6. Reboot router VM
+        # 7. Verify that nat and static nat rules exist after router restart
+
+        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.cleanup.append(self.account)
+
+        network = createNetwork(self, value)
+
+        try:
+            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
+                                                    accountid=self.account.name,domainid=self.account.domainid)
+        except Exception as e:
+            self.fail("vm creation failed: %s" % e)
+
+        try:
+            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+        except Exception as e:
+            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+        try:
+            public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+                                           zoneid=self.zone.id,domainid=self.account.domainid,
+                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+
+            public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+                                           zoneid=self.zone.id,domainid=self.account.domainid,
+                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+        except Exception as e:
+            self.fail("Exception while acquiring public ip address: %s" % e)
+
+        if value != VPC_NETWORK:
+            FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
+                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
+                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+
+        natrule = NATRule.create(self.api_client, virtual_machine,
+                       self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
+                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+
+        StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
+                    network.id, vmguestip=ipaddress_2.ipaddress)
+
+        routers = Router.list(self.apiclient, networkid=network.id, listall=True)
+        self.assertEqual(validateList(routers)[0], PASS, "routers list validation failed")
+
+        Router.reboot(self.apiclient, id=routers[0].id)
+
+        natrulelist = NATRule.list(self.apiclient, id=natrule.id, listall=True)
+        self.assertEqual(validateList(natrulelist)[0], PASS, "nat rules list validation failed")
+
+        self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, True)
+        return

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_netscaler_configs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_configs.py b/test/integration/component/test_netscaler_configs.py
index 98613fe..592b351 100644
--- a/test/integration/component/test_netscaler_configs.py
+++ b/test/integration/component/test_netscaler_configs.py
@@ -22,9 +22,9 @@ import marvin
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import *
 from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
 from marvin.sshClient import SshClient
 import datetime
 
@@ -156,14 +156,13 @@ class TestAddNetScaler(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(
-                               TestAddNetScaler,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestAddNetScaler, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls._cleanup = []
         return
 
@@ -282,14 +281,13 @@ class TestInvalidParametersNetscaler(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(
-                               TestInvalidParametersNetscaler,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestInvalidParametersNetscaler, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls._cleanup = []
         return
 
@@ -526,14 +524,13 @@ class TestNetScalerDedicated(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(
-                               TestNetScalerDedicated,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestNetScalerDedicated, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -749,14 +746,13 @@ class TestNetScalerShared(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(
-                               TestNetScalerShared,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestNetScalerShared, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -992,14 +988,13 @@ class TestNetScalerCustomCapacity(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(
-                               TestNetScalerCustomCapacity,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestNetScalerCustomCapacity, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -1265,14 +1260,13 @@ class TestNetScalerNoCapacity(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(
-                               TestNetScalerNoCapacity,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestNetScalerNoCapacity, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -1539,14 +1533,13 @@ class TestGuestNetworkWithNetScaler(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(
-                               TestGuestNetworkWithNetScaler,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestGuestNetworkWithNetScaler, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -2096,14 +2089,13 @@ class TestGuestNetworkShutDown(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         cls._cleanup = []
-        cls.api_client = super(
-                               TestGuestNetworkShutDown,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestGuestNetworkShutDown, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -2502,14 +2494,13 @@ class TestServiceProvider(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(
-                               TestServiceProvider,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestServiceProvider, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -2817,14 +2808,13 @@ class TestDeleteNetscaler(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(
-                               TestDeleteNetscaler,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestDeleteNetscaler, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/404ac549/test/integration/component/test_netscaler_lb.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_lb.py b/test/integration/component/test_netscaler_lb.py
index 26df545..732f0f9 100644
--- a/test/integration/component/test_netscaler_lb.py
+++ b/test/integration/component/test_netscaler_lb.py
@@ -22,9 +22,9 @@ import marvin
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import *
 from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
 from marvin.sshClient import SshClient
 import datetime
 
@@ -150,14 +150,13 @@ class TestLbSourceNat(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         cls._cleanup = []
-        cls.api_client = super(
-                               TestLbSourceNat,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestLbSourceNat, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -359,14 +358,13 @@ class TestLbOnIpWithPf(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         cls._cleanup = []
-        cls.api_client = super(
-                               TestLbOnIpWithPf,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestLbOnIpWithPf, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -572,14 +570,13 @@ class TestPfOnIpWithLb(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         cls._cleanup = []
-        cls.api_client = super(
-                               TestPfOnIpWithLb,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestPfOnIpWithLb, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -786,14 +783,13 @@ class TestLbOnNonSourceNat(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         cls._cleanup = []
-        cls.api_client = super(
-                               TestLbOnNonSourceNat,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestLbOnNonSourceNat, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -1003,14 +999,13 @@ class TestAddMultipleVmsLb(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         cls._cleanup = []
-        cls.api_client = super(
-                               TestAddMultipleVmsLb,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestAddMultipleVmsLb, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -1282,14 +1277,13 @@ class TestMultipleLbRules(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         cls._cleanup = []
-        cls.api_client = super(
-                               TestMultipleLbRules,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestMultipleLbRules, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -1601,14 +1595,13 @@ class TestMultipleLbRulesSameIp(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         cls._cleanup = []
-        cls.api_client = super(
-                               TestMultipleLbRulesSameIp,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestMultipleLbRulesSameIp, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -1926,14 +1919,13 @@ class TestLoadBalancingRule(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         cls._cleanup = []
-        cls.api_client = super(
-                               TestLoadBalancingRule,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestLoadBalancingRule, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -2140,14 +2132,13 @@ class TestDeleteCreateLBRule(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         cls._cleanup = []
-        cls.api_client = super(
-                               TestDeleteCreateLBRule,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestDeleteCreateLBRule, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -2269,14 +2260,13 @@ class TestVmWithLb(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         cls._cleanup = []
-        cls.api_client = super(
-                               TestVmWithLb,
-                               cls
-                               ).getClsTestClient().getApiClient()
+        cls.testClient = super(TestVmWithLb, cls).getClsTestClient()
+        cls.api_client = cls.testClient.getApiClient()
+
         cls.services = Services().services
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.api_client)
+        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,


Mime
View raw message