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 2014/05/07 16:52:28 UTC

[4/4] git commit: updated refs/heads/4.4-forward to ff1c4be

CLOUDSTACK-6536: Code cleanup - removing unnecessary waits after VM stop operation, modifying imports, removing white-spaces, adding try catch blocks whenever necessary


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

Branch: refs/heads/4.4-forward
Commit: ff1c4beec10dc53ede860fb9a36e458b7cef0458
Parents: df65b2e
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Wed Apr 30 03:40:40 2014 -0400
Committer: Girish Shilamkar <gi...@clogeny.com>
Committed: Wed May 7 04:04:02 2014 -0400

----------------------------------------------------------------------
 .../component/test_add_remove_network.py        |  26 +-
 test/integration/component/test_blocker_bugs.py |  40 ++-
 .../component/test_custom_hostname.py           |  17 +-
 .../component/test_dynamic_compute_offering.py  | 234 ++++++--------
 test/integration/component/test_egress_rules.py |  30 +-
 test/integration/component/test_escalations.py  | 264 +++++++--------
 .../component/test_netscaler_configs.py         |  88 ++---
 test/integration/component/test_netscaler_lb.py |  81 ++---
 .../component/test_netscaler_nw_off.py          | 150 ++++-----
 .../component/test_network_offering.py          |  31 +-
 .../component/test_persistent_networks.py       |  52 ++-
 .../component/test_project_resources.py         | 103 +++---
 .../integration/component/test_project_usage.py | 109 ++++---
 .../component/test_redundant_router_cleanups.py |  39 +--
 .../component/test_reset_ssh_keypair.py         | 222 +++++--------
 .../component/test_resource_limits.py           | 168 +++++-----
 .../component/test_security_groups.py           |  68 ++--
 test/integration/component/test_stopped_vm.py   | 104 +++---
 test/integration/component/test_tags.py         | 183 +++++------
 test/integration/component/test_templates.py    | 134 ++++----
 test/integration/component/test_usage.py        | 131 ++++----
 test/integration/component/test_volumes.py      | 319 ++++++++-----------
 test/integration/component/test_vpc_network.py  |   4 -
 .../component/test_vpc_vm_life_cycle.py         |  48 +--
 .../integration/smoke/test_service_offerings.py |  22 +-
 test/integration/smoke/test_templates.py        | 159 ++++-----
 test/integration/smoke/test_vm_life_cycle.py    |  81 ++---
 test/integration/smoke/test_volumes.py          |  59 ++--
 28 files changed, 1326 insertions(+), 1640 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff1c4bee/test/integration/component/test_add_remove_network.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_add_remove_network.py b/test/integration/component/test_add_remove_network.py
index 3e0e78b..c17293d 100644
--- a/test/integration/component/test_add_remove_network.py
+++ b/test/integration/component/test_add_remove_network.py
@@ -347,14 +347,10 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
         # Validate the following:
         # 1. New nic is generated for the added network
 
-        self.debug("Stopping Virtual Machine: %s" % self.virtual_machine.id)
-        self.virtual_machine.stop(self.apiclient)
-
-        vm_list = list_virtual_machines(self.apiclient,id=self.virtual_machine.id)
-        vm_list_validation_result = validateList(vm_list)
-        self.assertEqual(vm_list_validation_result[0], PASS, "vm list validation failed due to %s" %
-			 vm_list_validation_result[2])
-        self.assertTrue(vm_list[0].state == 'Stopped', "Failed to stop VM, the state is %s" % vm_list[0].state)
+        try:
+            self.virtual_machine.stop(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to stop VM: %s" % e)
 
         network = None #The network which we are adding to the vm
         if value == "isolated":
@@ -451,16 +447,10 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
         # Validate the following:
         # 1. Adding VPC to vm should fail
 
-        self.debug("Stopping Virtual Machine: %s" % self.virtual_machine.id)
-        self.virtual_machine.stop(self.apiclient)
-
-        vm_list = list_virtual_machines(self.apiclient,id=self.virtual_machine.id)
-        #validation vm list
-        vm_list_validation_result = validateList(vm_list)
-        self.assertEqual(vm_list_validation_result[0], PASS, "vm list validation failed due to %s" %
-			 vm_list_validation_result[2])
-
-        self.assertTrue(vm_list[0].state == 'Stopped', "Failed to stop VM, the state is %s" % vm_list[0].state)
+        try:
+            self.virtual_machine.stop(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to stop virtual machine: %s" % e)
 
         self.addNetworkToVm(self.isolated_network, self.virtual_machine)
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff1c4bee/test/integration/component/test_blocker_bugs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_blocker_bugs.py b/test/integration/component/test_blocker_bugs.py
index ba2602c..ba15b18 100644
--- a/test/integration/component/test_blocker_bugs.py
+++ b/test/integration/component/test_blocker_bugs.py
@@ -28,7 +28,7 @@ from marvin.lib.base import (Snapshot,
                              StaticNATRule,
                              FireWallRule,
                              Volume)
-from marvin.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources, validateList
 from marvin.lib.common import (get_zone,
                                get_domain,
                                get_template,
@@ -36,8 +36,9 @@ from marvin.lib.common import (get_zone,
                                get_builtin_template_info)
 
 #Import Local Modules
-from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackTestCase import cloudstackTestCase, unittest
 from marvin.cloudstackAPI import restartNetwork
+from marvin.codes import PASS
 import time
 
 
@@ -744,20 +745,24 @@ class TestTemplates(cloudstackTestCase):
                             cls.services["ostype"]
                             )
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-        cls.account = Account.create(
+        cls._cleanup = []
+        try:
+            cls.account = Account.create(
                             cls.api_client,
                             cls.services["account"],
                             domainid=cls.domain.id
                             )
+            cls._cleanup.append(cls.account)
 
-        cls.services["account"] = cls.account.name
-        cls.service_offering = ServiceOffering.create(
+            cls.services["account"] = cls.account.name
+            cls.service_offering = ServiceOffering.create(
                                             cls.api_client,
                                             cls.services["service_offering"],
                                         )
+            cls._cleanup.append(cls.service_offering)
 
-        # create virtual machine
-        cls.virtual_machine = VirtualMachine.create(
+            # create virtual machine
+            cls.virtual_machine = VirtualMachine.create(
                                     cls.api_client,
                                     cls.services["virtual_machine"],
                                     templateid=template.id,
@@ -765,27 +770,20 @@ class TestTemplates(cloudstackTestCase):
                                     domainid=cls.account.domainid,
                                     serviceofferingid=cls.service_offering.id,
                                     )
-        #Stop virtual machine
-        cls.virtual_machine.stop(cls.api_client)
+            #Stop virtual machine
+            cls.virtual_machine.stop(cls.api_client)
 
-        #Wait before server has be successfully stopped
-        time.sleep(30)
-        list_volume = Volume.list(
+            listvolumes = Volume.list(
                                    cls.api_client,
                                    virtualmachineid=cls.virtual_machine.id,
                                    type='ROOT',
                                    listall=True
                                    )
-        try:
-            if isinstance(list_volume, list):
-                cls.volume = list_volume[0]
+            assert validateList(listvolumes)[0] == PASS, "volumes list is empty"
+            cls.volume = listvolumes[0]
         except Exception as e:
-            raise Exception("Warning: Exception during setup : %s" % e)
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.account,
-                        ]
+            cls.tearDownClass()
+            raise unittest.SkipTest("Exception in setUpClass: %s" % e)
 
     @classmethod
     def tearDownClass(cls):

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff1c4bee/test/integration/component/test_custom_hostname.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_custom_hostname.py b/test/integration/component/test_custom_hostname.py
index 7eeda49..637be86 100644
--- a/test/integration/component/test_custom_hostname.py
+++ b/test/integration/component/test_custom_hostname.py
@@ -17,12 +17,19 @@
 """ P1 tests for user provide hostname cases
 """
 #Import Local Modules
-import marvin
+
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import (cleanup_resources,
+                              random_gen)
+from marvin.lib.base import (ServiceOffering,
+                             Configurations,
+                             VirtualMachine,
+                             Account)
+from marvin.lib.common import (get_domain,
+                               get_zone,
+                               get_template,
+                               is_config_suitable)
 
 
 class Services:

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff1c4bee/test/integration/component/test_dynamic_compute_offering.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_dynamic_compute_offering.py b/test/integration/component/test_dynamic_compute_offering.py
index 95be65f..0a07e6c 100644
--- a/test/integration/component/test_dynamic_compute_offering.py
+++ b/test/integration/component/test_dynamic_compute_offering.py
@@ -24,21 +24,22 @@
     Feature Specifications: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Dynamic+Compute+Offering+FS
 """
 from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.lib.utils import cleanup_resources, validateList, random_gen
+from marvin.lib.utils import (cleanup_resources,
+                              validateList,
+                              random_gen)
 from marvin.lib.base import (Account,
-                             ServiceOffering,
                              VirtualMachine,
+                             ServiceOffering,
                              Resources,
                              AffinityGroup,
                              Host)
-from marvin.lib.common import (get_domain,
-                               get_zone,
+from marvin.lib.common import (get_zone,
+                               get_domain,
                                get_template,
                                verifyComputeOfferingCreation)
 from nose.plugins.attrib import attr
 from marvin.codes import PASS, ADMIN_ACCOUNT, USER_ACCOUNT, FAILED
 from ddt import ddt, data
-import time
 
 @ddt
 class TestDynamicServiceOffering(cloudstackTestCase):
@@ -468,27 +469,6 @@ class TestScaleVmDynamicServiceOffering(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    def stopVM(self, vm):
-        """Stop VM and verify that it is indeed in stopped state"""
-        try:
-            vm.stop(self.apiclient)
-        except Exception as e:
-            self.fail("Failed to stop VM: %s" % e)
-
-        retriesCount = 10
-        while True:
-            vmlist = VirtualMachine.list(self.apiclient, id=vm.id)
-            if str(vmlist[0].state).lower() == "stopped":
-                break
-            elif retriesCount == 0:
-                self.fail("Failed to stop VM even after 10 minutes")
-            else:
-                retriesCount -= 1
-                time.sleep(60)
-                continue
-        # End while
-        return
-
     @data(ADMIN_ACCOUNT, USER_ACCOUNT)
     @attr(tags=["basic","advanced"])
     def test_change_so_stopped_vm_static_to_static(self, value):
@@ -508,46 +488,43 @@ class TestScaleVmDynamicServiceOffering(cloudstackTestCase):
         if value == USER_ACCOUNT:
             isadmin=False
 
-        # Create Account
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id, admin=isadmin)
-        apiclient = self.testClient.getUserApiClient(
+        try:
+            # Create Account
+            self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id, admin=isadmin)
+            self.cleanup.append(self.account)
+            apiclient = self.testClient.getUserApiClient(
                                     UserName=self.account.name,
                                     DomainName=self.account.domain)
-        self.cleanup.append(self.account)
 
-        # Create static service offerings (Second offering should have
-        # one of the custom values greater than 1st one, scaling down is not allowed
-        self.services["service_offering"]["cpunumber"] = "2"
-        self.services["service_offering"]["cpuspeed"] = "256"
-        self.services["service_offering"]["memory"] = "128"
+            # Create static service offerings (Second offering should have
+            # one of the custom values greater than 1st one, scaling down is not allowed
+            self.services["service_offering"]["cpunumber"] = "2"
+            self.services["service_offering"]["cpuspeed"] = "256"
+            self.services["service_offering"]["memory"] = "128"
 
-        serviceOffering_static_1 = ServiceOffering.create(self.apiclient,
+            serviceOffering_static_1 = ServiceOffering.create(self.apiclient,
                                                  self.services["service_offering"])
 
-        self.services["service_offering"]["cpunumber"] = "4"
+            self.services["service_offering"]["cpunumber"] = "4"
 
-        serviceOffering_static_2 = ServiceOffering.create(self.apiclient,
+            serviceOffering_static_2 = ServiceOffering.create(self.apiclient,
                                                  self.services["service_offering"])
 
-        self.cleanup_co.append(serviceOffering_static_1)
-        self.cleanup_co.append(serviceOffering_static_2)
+            self.cleanup_co.append(serviceOffering_static_1)
+            self.cleanup_co.append(serviceOffering_static_2)
 
-        # Deploy VM
-        try:
+            # Deploy VM
             virtualMachine = VirtualMachine.create(apiclient,self.services["virtual_machine"],
                 serviceofferingid=serviceOffering_static_1.id,
                 accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
 
-        # Stop VM and verify it is in stopped state
-        self.stopVM(virtualMachine)
+            # Stop VM
+            virtualMachine.stop(apiclient)
 
-        # Scale VM to new static service offering
-        try:
+            # Scale VM to new static service offering
             virtualMachine.scale(apiclient, serviceOfferingId=serviceOffering_static_2.id)
         except Exception as e:
-            self.fail("Failure while changing service offering: %s" % e)
+            self.fail("Exception occured: %s" % e)
         return
 
     @data(ADMIN_ACCOUNT, USER_ACCOUNT)
@@ -573,69 +550,59 @@ class TestScaleVmDynamicServiceOffering(cloudstackTestCase):
         if value == USER_ACCOUNT:
             isadmin=False
 
-        # Create Account and api client
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id, admin=isadmin)
-        apiclient = self.testClient.getUserApiClient(
+        try:
+            # Create Account and api client
+            self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id, admin=isadmin)
+            apiclient = self.testClient.getUserApiClient(
                                     UserName=self.account.name,
                                     DomainName=self.account.domain)
-        self.cleanup.append(self.account)
+            self.cleanup.append(self.account)
 
-        # Create static and dynamic service offerings
-        self.services["service_offering"]["cpunumber"] = "2"
-        self.services["service_offering"]["cpuspeed"] = "256"
-        self.services["service_offering"]["memory"] = "128"
+            # Create static and dynamic service offerings
+            self.services["service_offering"]["cpunumber"] = "2"
+            self.services["service_offering"]["cpuspeed"] = "256"
+            self.services["service_offering"]["memory"] = "128"
 
-        serviceOffering_static = ServiceOffering.create(self.apiclient,
+            serviceOffering_static = ServiceOffering.create(self.apiclient,
                                                  self.services["service_offering"])
 
 
-        self.services["service_offering"]["cpunumber"] = ""
-        self.services["service_offering"]["cpuspeed"] = ""
-        self.services["service_offering"]["memory"] = ""
+            self.services["service_offering"]["cpunumber"] = ""
+            self.services["service_offering"]["cpuspeed"] = ""
+            self.services["service_offering"]["memory"] = ""
 
-        serviceOffering_dynamic = ServiceOffering.create(self.apiclient,
+            serviceOffering_dynamic = ServiceOffering.create(self.apiclient,
                                                  self.services["service_offering"])
 
-        self.cleanup_co.append(serviceOffering_static)
-        self.cleanup_co.append(serviceOffering_dynamic)
+            self.cleanup_co.append(serviceOffering_static)
+            self.cleanup_co.append(serviceOffering_dynamic)
 
-        # Deploy VM with static service offering
-        try:
+            # Deploy VM with static service offering
             virtualMachine_1 = VirtualMachine.create(apiclient,self.services["virtual_machine"],
                 serviceofferingid=serviceOffering_static.id,
                 accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
 
-        # Stop VM and verify it is in stopped state
-        self.stopVM(virtualMachine_1)
+            # Stop VM
+            virtualMachine_1.stop(apiclient)
 
-        # Scale VM to dynamic service offering proving all custom values
-        try:
+            # Scale VM to dynamic service offering proving all custom values
             virtualMachine_1.scale(apiclient, serviceOfferingId=serviceOffering_dynamic.id,
                                  customcpunumber=4, customcpuspeed=256, custommemory=128)
-        except Exception as e:
-            self.fail("Failure while changing service offering: %s" % e)
 
-        # Deploy VM with static service offering
-        try:
+            # Deploy VM with static service offering
             virtualMachine_2 = VirtualMachine.create(apiclient,self.services["virtual_machine"],
                 serviceofferingid=serviceOffering_static.id,
                 accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
 
-        # Stop VM and verify it is in stopped state
-        self.stopVM(virtualMachine_2)
+            # Stop VM
+            virtualMachine_2.stop(apiclient)
+        except Exception as e:
+            self.fail("Exception occuered: %s" % e)
 
-        # Scale VM to dynamic service offering proving only custom cpu number
-        try:
+            # Scale VM to dynamic service offering proving only custom cpu number
+        with self.assertRaises(Exception):
             virtualMachine_2.scale(apiclient, serviceOfferingId=serviceOffering_dynamic.id,
                                  customcpunumber=4)
-            self.fail("Changing service offering with incomplete data should have failed, it succeded")
-        except Exception as e:
-            self.debug("Failure while changing service offering as expected: %s" % e)
-
         return
 
     @data(ADMIN_ACCOUNT, USER_ACCOUNT)
@@ -657,48 +624,45 @@ class TestScaleVmDynamicServiceOffering(cloudstackTestCase):
         if value == USER_ACCOUNT:
             isadmin=False
 
-        # Create account and api client
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id, admin=isadmin)
-        apiclient = self.testClient.getUserApiClient(
+        try:
+            # Create account and api client
+            self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id, admin=isadmin)
+            apiclient = self.testClient.getUserApiClient(
                                     UserName=self.account.name,
                                     DomainName=self.account.domain)
-        self.cleanup.append(self.account)
+            self.cleanup.append(self.account)
 
-        # Create dynamic and static service offering
-        self.services["service_offering"]["cpunumber"] = ""
-        self.services["service_offering"]["cpuspeed"] = ""
-        self.services["service_offering"]["memory"] = ""
+            # Create dynamic and static service offering
+            self.services["service_offering"]["cpunumber"] = ""
+            self.services["service_offering"]["cpuspeed"] = ""
+            self.services["service_offering"]["memory"] = ""
 
-        serviceOffering_dynamic = ServiceOffering.create(self.apiclient,
+            serviceOffering_dynamic = ServiceOffering.create(self.apiclient,
                                                  self.services["service_offering"])
 
-        self.services["service_offering"]["cpunumber"] = "4"
-        self.services["service_offering"]["cpuspeed"] = "256"
-        self.services["service_offering"]["memory"] = "128"
+            self.services["service_offering"]["cpunumber"] = "4"
+            self.services["service_offering"]["cpuspeed"] = "256"
+            self.services["service_offering"]["memory"] = "128"
 
-        serviceOffering_static = ServiceOffering.create(self.apiclient,
+            serviceOffering_static = ServiceOffering.create(self.apiclient,
                                                  self.services["service_offering"])
 
-        self.cleanup_co.append(serviceOffering_static)
-        self.cleanup_co.append(serviceOffering_dynamic)
+            self.cleanup_co.append(serviceOffering_static)
+            self.cleanup_co.append(serviceOffering_dynamic)
 
-        # Deploy VM with dynamic service offering
-        try:
+            # Deploy VM with dynamic service offering
             virtualMachine = VirtualMachine.create(apiclient,self.services["virtual_machine"],
                 serviceofferingid=serviceOffering_dynamic.id,
                 accountid=self.account.name,domainid=self.account.domainid,
                 customcpunumber=2, customcpuspeed=256, custommemory=128)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
 
-        # Stop VM and verify that it is in stopped state
-        self.stopVM(virtualMachine)
+            # Stop VM and verify that it is in stopped state
+            virtualMachine.stop(apiclient)
 
-        # Scale VM to static service offering
-        try:
+            # Scale VM to static service offering
             virtualMachine.scale(apiclient, serviceOfferingId=serviceOffering_static.id)
         except Exception as e:
-            self.fail("Failure while changing service offering: %s" % e)
+            self.fail("Exception occured: %s" % e)
         return
 
     @data(ADMIN_ACCOUNT, USER_ACCOUNT)
@@ -725,62 +689,52 @@ class TestScaleVmDynamicServiceOffering(cloudstackTestCase):
         if value == USER_ACCOUNT:
             isadmin=False
 
-        # Create Account
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id, admin=isadmin)
-        apiclient = self.testClient.getUserApiClient(
+        try:
+            # Create Account
+            self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id, admin=isadmin)
+            apiclient = self.testClient.getUserApiClient(
                                     UserName=self.account.name,
                                     DomainName=self.account.domain)
-        self.cleanup.append(self.account)
+            self.cleanup.append(self.account)
 
-        # Create dynamic service offerings
-        self.services["service_offering"]["cpunumber"] = ""
-        self.services["service_offering"]["cpuspeed"] = ""
-        self.services["service_offering"]["memory"] = ""
+            # Create dynamic service offerings
+            self.services["service_offering"]["cpunumber"] = ""
+            self.services["service_offering"]["cpuspeed"] = ""
+            self.services["service_offering"]["memory"] = ""
 
-        serviceOffering_dynamic_1 = ServiceOffering.create(self.apiclient,
+            serviceOffering_dynamic_1 = ServiceOffering.create(self.apiclient,
                                                  self.services["service_offering"])
 
-        serviceOffering_dynamic_2 = ServiceOffering.create(self.apiclient,
+            serviceOffering_dynamic_2 = ServiceOffering.create(self.apiclient,
                                                  self.services["service_offering"])
 
-        self.cleanup_co.append(serviceOffering_dynamic_1)
-        self.cleanup_co.append(serviceOffering_dynamic_2)
+            self.cleanup_co.append(serviceOffering_dynamic_1)
+            self.cleanup_co.append(serviceOffering_dynamic_2)
 
-        # Deploy VM with dynamic service offering
-        try:
+            # Deploy VM with dynamic service offering
             virtualMachine = VirtualMachine.create(apiclient,self.services["virtual_machine"],
                 serviceofferingid=serviceOffering_dynamic_1.id,
                 accountid=self.account.name,domainid=self.account.domainid,
                 customcpunumber=2, customcpuspeed=256, custommemory=128)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
 
-        # Stop VM and verify that it is in stopped state
-        self.stopVM(virtualMachine)
+            # Stop VM
+            virtualMachine.stop(apiclient)
 
-        # Scale VM with same dynamic service offering
-        try:
+            # Scale VM with same dynamic service offering
             virtualMachine.scale(apiclient, serviceOfferingId=serviceOffering_dynamic_1.id,
                                  customcpunumber=4, customcpuspeed=512, custommemory=256)
-        except Exception as e:
-            self.fail("Failure while changing service offering: %s" % e)
 
-        # Scale VM with other dynamic service offering
-        try:
+            # Scale VM with other dynamic service offering
             virtualMachine.scale(apiclient, serviceOfferingId=serviceOffering_dynamic_2.id,
                                  customcpunumber=4, customcpuspeed=512, custommemory=256)
         except Exception as e:
-            self.fail("Failure while changing service offering: %s" % e)
+            self.fail("Exception occured: %s" % e)
 
         # Scale VM with dynamic service offering proving custom value
         # only for cpu number
-        try:
+        with self.assertRaises(Exception):
             virtualMachine.scale(apiclient, serviceOfferingId=serviceOffering_dynamic_1.id,
                                  customcpunumber=4)
-            self.fail("Changing service offering should have failed, it succeded")
-        except Exception as e:
-            self.debug("Failure while changing service offering: %s" % e)
-
         return
 
     @data(ADMIN_ACCOUNT, USER_ACCOUNT)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff1c4bee/test/integration/component/test_egress_rules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_egress_rules.py b/test/integration/component/test_egress_rules.py
index f0b98e4..0f05c07 100644
--- a/test/integration/component/test_egress_rules.py
+++ b/test/integration/component/test_egress_rules.py
@@ -5,9 +5,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -1901,27 +1901,11 @@ class TestStartStopVMWithEgressRule(cloudstackTestCase):
                           "Check egress rule created properly"
                     )
 
-        # Stop virtual machine
-        self.debug("Stopping virtual machine: %s" % self.virtual_machine.id)
-        self.virtual_machine.stop(self.apiclient)
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  id=self.virtual_machine.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List VM should return a valid list"
-                         )
-        vm = vms[0]
-        self.assertEqual(
-                         vm.state,
-                         "Stopped",
-                         "VM state should be stopped"
-                         )
-        self.debug("VM: %s state: %s" % (vm.id, vm.state))
+        try:
+            # Stop virtual machine
+            self.virtual_machine.stop(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to stop instance: %s" % e)
 
         # Start virtual machine
         self.debug("Starting virtual machine: %s" % self.virtual_machine.id)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff1c4bee/test/integration/component/test_escalations.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_escalations.py b/test/integration/component/test_escalations.py
index e994579..1b596a7 100644
--- a/test/integration/component/test_escalations.py
+++ b/test/integration/component/test_escalations.py
@@ -16,23 +16,44 @@
 # under the License.
 
 #Import Local Modules
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackException import *
-from marvin.cloudstackAPI import *
-from marvin.sshClient import SshClient
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
-from marvin.lib.utils import checkVolumeSize
-from marvin.codes import SUCCESS
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (createVolume,
+                                  createTemplate)
+from marvin.lib.base import (Volume,
+                             Iso,
+                             VirtualMachine,
+                             Template,
+                             Snapshot,
+                             SecurityGroup,
+                             Account,
+                             Zone,
+                             Network,
+                             NetworkOffering,
+                             DiskOffering,
+                             ServiceOffering,
+                             VmSnapshot,
+                             SnapshotPolicy,
+                             SSHKeyPair,
+                             Resources,
+                             Configurations,
+                             VpnCustomerGateway,
+                             Hypervisor)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_os_types)
+from marvin.lib.utils import (validateList,
+                              cleanup_resources,
+                              random_gen)
+from marvin.codes import (PASS, EMPTY_LIST)
 from nose.plugins.attrib import attr
-from time import sleep
+import time
 
 class TestVolumes(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-       
+
         cls.testClient = super(TestVolumes, cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
         cls.services = cls.testClient.getParsedTestDataConfig()
@@ -112,9 +133,9 @@ class TestVolumes(cloudstackTestCase):
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
 
-   
+
     def __verify_values(self, expected_vals, actual_vals):
-        """  
+        """
         @summary: Function to verify expected and actual values
         Step1: Initializing return flag to True
         Step1: Verifying length of expected and actual dictionaries is matching.
@@ -2142,7 +2163,7 @@ class TestListInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "selfservice"])
     def test_04_list_Destroyed_vm(self):
-        """  
+        """
         @Desc: Test List Destroyed VM's
         @Steps:
         Step1: Listing all the Destroyed VMs for a user
@@ -2250,7 +2271,7 @@ class TestListInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "selfservice"])
     def test_05_list_vm_by_id(self):
-        """  
+        """
         @Desc: Test List VM by Id
         @Steps:
         Step1: Listing all the VMs for a user
@@ -2352,7 +2373,7 @@ class TestListInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "selfservice"])
     def test_06_list_vm_by_name(self):
-        """  
+        """
         @Desc: Test List VM's by Name
         @Steps:
         Step1: Listing all the VMs for a user
@@ -2394,7 +2415,7 @@ class TestListInstances(cloudstackTestCase):
                                  )
             self.cleanup.append(vm_created)
             vms.update({i: vm_created})
-  
+
         # Listing all the VM's for a User
         list_vms_after = VirtualMachine.list(
                                              self.userapiclient,
@@ -3198,22 +3219,6 @@ class TestListInstances(cloudstackTestCase):
                         self.userapiclient,
                         forced=True
                         )
-        # Listing VM details
-        list_vm = VirtualMachine.list(
-                                      self.userapiclient,
-                                      id=vm_created.id
-                                     )
-        status = validateList(list_vm)
-        self.assertEquals(
-                          PASS,
-                          status[0],
-                          "Listing of VM failed"
-                          )
-        self.assertEquals(
-                          "Stopped",
-                          list_vm[0].state,
-                          "Stopped VM is not in stopped state"
-                          )
         # Listing all the SSH Key pairs
         list_keypairs_before = SSHKeyPair.list(
                                                self.userapiclient
@@ -3284,7 +3289,7 @@ class TestListInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "provisioning"])
     def test_12_vm_nics(self):
-        """  
+        """
         @Desc: Test to verify Nics for a VM
         @Steps:
         Step1: Deploying a VM
@@ -3293,7 +3298,7 @@ class TestListInstances(cloudstackTestCase):
         Step4: Creating 1 network
         Step5: Listing all the networks again
         Step6: Verifying that the list size is 2
-        Step7: Verifying that VM deployed in step1 has only 1 nic 
+        Step7: Verifying that VM deployed in step1 has only 1 nic
                 and it is same as network listed in step3
         Step8: Adding the networks created in step4 to VM deployed in step1
         Step9: Verifying that VM deployed in step1 has 2 nics
@@ -3465,7 +3470,6 @@ class TestListInstances(cloudstackTestCase):
                 default_nic = vm_nics_after[i]
             else:
                 non_default_nic = vm_nics_after[i]
-     
         self.assertEquals(
                           1,
                           default_count,
@@ -3513,7 +3517,7 @@ class TestListInstances(cloudstackTestCase):
                 default_nic = vm_nics_after[i]
             else:
                 non_default_nic = vm_nics_after[i]
-     
+
         self.assertEquals(
                           1,
                           default_count,
@@ -3566,7 +3570,7 @@ class TestInstances(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         try:
-            cls._cleanup = []        
+            cls._cleanup = []
             cls.testClient = super(TestInstances, cls).getClsTestClient()
             cls.api_client = cls.testClient.getApiClient()
             cls.services = cls.testClient.getParsedTestDataConfig()
@@ -3587,13 +3591,13 @@ class TestInstances(cloudstackTestCase):
                 cls.storagetype = 'shared'
                 cls.services["service_offerings"]["tiny"]["storagetype"] = 'shared'
                 cls.services["disk_offering"]["storagetype"] = 'shared'
-   
+
             cls.services['mode'] = cls.zone.networktype
             cls.services["virtual_machine"]["hypervisor"] = cls.testClient.getHypervisorInfo()
             cls.services["virtual_machine"]["zoneid"] = cls.zone.id
             cls.services["virtual_machine"]["template"] = cls.template.id
             cls.services["custom_volume"]["zoneid"] = cls.zone.id
-   
+
             # Creating Disk offering, Service Offering and Account
             cls.disk_offering = DiskOffering.create(
                                                     cls.api_client,
@@ -3648,7 +3652,7 @@ class TestInstances(cloudstackTestCase):
         return
 
     def __verify_values(self, expected_vals, actual_vals):
-        """  
+        """
         @Desc: Function to verify expected and actual values
         @Steps:
         Step1: Initializing return flag to True
@@ -3660,10 +3664,10 @@ class TestInstances(cloudstackTestCase):
         Step4: returning the return flag after all the values are verified
         """
         return_flag = True
-   
+
         if len(expected_vals) != len(actual_vals):
             return False
-   
+
         keys = expected_vals.keys()
         for i in range(0, len(expected_vals)):
             exp_val = expected_vals[keys[i]]
@@ -3680,8 +3684,8 @@ class TestInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_13_attach_detach_iso(self):
-        """  
-        @Desc: Test Attach ISO to VM and Detach ISO from VM. 
+        """
+        @Desc: Test Attach ISO to VM and Detach ISO from VM.
         @Steps:
         Step1: Listing all the VMs for a user
         Step2: Verifying that the size of the list is 0
@@ -3808,15 +3812,15 @@ class TestInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_14_vm_snapshot_pagination(self):
-        """  
-        @Desc: Test VM Snapshots pagination. 
+        """
+        @Desc: Test VM Snapshots pagination.
         @Steps:
         Step1: Deploying a VM
         Step2: Listing all the Snapshots of the VM deployed in Step 1
         Step3: Verifying that the list size is 0
         Step4: Creating (pagesize + 1) number of Snapshots for the VM
         Step5: Listing all the Snapshots of the VM deployed in Step 1
-        Step6: Verifying that the list size is (pagesize + 1) 
+        Step6: Verifying that the list size is (pagesize + 1)
         Step7: Listing all the VM snapshots in Page 1 with page size
         Step8: Verifying that size of the list is same as page size
         Step9: Listing all the VM snapshots in Page 2 with page size
@@ -3965,8 +3969,8 @@ class TestInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_15_revert_vm_to_snapshot(self):
-        """  
-        @Desc: Test Revert VM to Snapshot functionality. 
+        """
+        @Desc: Test Revert VM to Snapshot functionality.
         @Steps:
         Step1: Deploying a VM
         Step2: Listing all the Snapshots of the VM deployed in Step 1
@@ -4064,14 +4068,14 @@ class TestInstances(cloudstackTestCase):
                           len(list_snapshots_after),
                           "Count of VM Snapshots is not matching"
                           )
-        # Verifying that only 1 snapshot is having current flag set to true 
+        # Verifying that only 1 snapshot is having current flag set to true
         # and that snapshot is the latest snapshot created (snapshot2)
         current_count = 0
         for i in range(0, len(list_snapshots_after)):
             if(list_snapshots_after[i].current is True):
                 current_count = current_count + 1
                 current_snapshot = list_snapshots_after[i]
-  
+
         self.assertEquals(
                           1,
                           current_count,
@@ -4104,7 +4108,7 @@ class TestInstances(cloudstackTestCase):
                           len(list_snapshots_after),
                           "Count of VM Snapshots is not matching"
                           )
-        # Verifying that only 1 snapshot is having current flag set to true 
+        # Verifying that only 1 snapshot is having current flag set to true
         # and that snapshot is snapshot1
         current_count = 0
         for i in range(0, len(list_snapshots_after)):
@@ -4125,7 +4129,7 @@ class TestInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "selfservice"])
     def test_16_list_vm_volumes_pagination(self):
-        """  
+        """
         @Desc: Test to verify pagination of Volumes for a VM
         @Steps:
         Step1: Deploying a VM
@@ -4218,7 +4222,7 @@ class TestInstances(cloudstackTestCase):
                                      self.userapiclient,
                                      volume_created
                                      )
-  
+
         # List all the volumes for the VM again
         list_volumes_after = Volume.list(
                                           self.userapiclient,
@@ -4299,7 +4303,7 @@ class TestInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_17_running_vm_scaleup(self):
-        """  
+        """
         @Desc: Test to verify change service for Running VM
         @Steps:
         Step1: Checking if dynamic scaling of virtual machines is enabled in zone and template.
@@ -4437,7 +4441,7 @@ class TestInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_18_stopped_vm_change_service(self):
-        """  
+        """
         @Desc: Test to verify change service for Stopped VM
         @Steps:
         Step1: Deploying a VM
@@ -4504,22 +4508,6 @@ class TestInstances(cloudstackTestCase):
                         self.userapiclient,
                         forced=True
                         )
-        # Listing VM details
-        list_vm = VirtualMachine.list(
-                                      self.userapiclient,
-                                      id=vm_created.id
-                                     )
-        status = validateList(list_vms_after)
-        self.assertEquals(
-                          PASS,
-                          status[0],
-                          "Listing of VM failed"
-                          )
-        self.assertEquals(
-                          "Stopped",
-                          list_vm[0].state,
-                          "Stopped VM is not in stopped state"
-                          )
         # Listing all the service offerings
         service_offerings_list = ServiceOffering.list(
                                                       self.userapiclient,
@@ -4573,7 +4561,7 @@ class TestInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_19_create_reset_vm_sshkey(self):
-        """  
+        """
         @Desc: Test to verify creation and reset of SSH Key for VM
         @Steps:
         Step1: Deploying a VM
@@ -4629,22 +4617,6 @@ class TestInstances(cloudstackTestCase):
                         self.userapiclient,
                         forced=True
                         )
-        # Listing VM details
-        list_vm = VirtualMachine.list(
-                                      self.userapiclient,
-                                      id=vm_created.id
-                                     )
-        status = validateList(list_vm)
-        self.assertEquals(
-                          PASS,
-                          status[0],
-                          "Listing of VM failed"
-                          )
-        self.assertEquals(
-                          "Stopped",
-                          list_vm[0].state,
-                          "Stopped VM is not in stopped state"
-                          )
         # Listing all the SSH Key pairs
         list_keypairs_before = SSHKeyPair.list(
                                                self.userapiclient
@@ -4652,7 +4624,7 @@ class TestInstances(cloudstackTestCase):
         list_keypairs_before_size = 0
         if list_keypairs_before is not None:
             list_keypairs_before_size = len(list_keypairs_before)
-  
+
         # Creating a new Key pair
         new_keypair = SSHKeyPair.create(
                                         self.userapiclient,
@@ -4716,7 +4688,7 @@ class TestInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "selfservice"])
     def test_20_update_vm_displayname_group(self):
-        """  
+        """
         @Desc: Test to verify Update VM details
         @Steps:
         Step1: List all the VM's for a user
@@ -4817,7 +4789,7 @@ class TestInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_21_restore_vm(self):
-        """  
+        """
         @Desc: Test to verify Restore VM
         @Steps:
         Step1: List all the VM's for a user
@@ -4904,7 +4876,7 @@ class TestInstances(cloudstackTestCase):
 
     @attr(tags=["advanced", "selfservice"])
     def test_22_deploy_vm_multiple_networks(self):
-        """  
+        """
         @Desc: Test to verify deploy VM with multiple networks
         @Steps:
         Step1: List all the networks for user
@@ -4924,7 +4896,7 @@ class TestInstances(cloudstackTestCase):
         networks_list_size = 0
         if networks_list_before is not None:
             networks_list_size = len(networks_list_before)
-     
+
         # Listing Network Offerings
         network_offerings_list = NetworkOffering.list(
                                                       self.apiClient,
@@ -4956,7 +4928,7 @@ class TestInstances(cloudstackTestCase):
                                  )
             self.cleanup.append(network)
             networks_list_size = networks_list_size + 1
- 
+
         # Listing the networks again
         networks_list_after = Network.list(
                                            self.userapiclient,
@@ -5036,7 +5008,7 @@ class TestInstances(cloudstackTestCase):
 
     @attr(tags=["basic", "provisioning"])
     def test_23_deploy_vm_multiple_securitygroups(self):
-        """  
+        """
         @Desc: Test to verify deploy VM with multiple Security Groups
         @Steps:
         Step1: List all the security groups for user
@@ -5057,7 +5029,7 @@ class TestInstances(cloudstackTestCase):
         security_groups_list_size = 0
         if security_groups_list is not None:
             security_groups_list_size = len(security_groups_list)
-     
+
         while security_groups_list_size < 2:
             # Creating a security group
             security_group = SecurityGroup.create(
@@ -5072,7 +5044,7 @@ class TestInstances(cloudstackTestCase):
                                  )
             self.cleanup.append(security_group)
             security_groups_list_size = security_groups_list_size + 1
-     
+
         # Listing the networks again
         security_groups_list = SecurityGroup.list(
                                                   self.userapiclient,
@@ -5142,7 +5114,7 @@ class TestInstances(cloudstackTestCase):
                 (vm_securitygroups[i].id != security_groups_list[1].id)):
                 vm_securitygroups_flag = False
                 break
-     
+
         self.assertEquals(
                           True,
                           vm_securitygroups_flag,
@@ -5155,7 +5127,7 @@ class TestSnapshots(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         try:
-            cls._cleanup = []        
+            cls._cleanup = []
             cls.testClient = super(TestSnapshots, cls).getClsTestClient()
             cls.api_client = cls.testClient.getApiClient()
             cls.services = cls.testClient.getParsedTestDataConfig()
@@ -5175,7 +5147,7 @@ class TestSnapshots(cloudstackTestCase):
                 cls.storagetype = 'shared'
                 cls.services["service_offerings"]["tiny"]["storagetype"] = 'shared'
                 cls.services["disk_offering"]["storagetype"] = 'shared'
-    
+
             cls.services['mode'] = cls.zone.networktype
             cls.services["virtual_machine"]["hypervisor"] = cls.testClient.getHypervisorInfo()
             cls.services["virtual_machine"]["zoneid"] = cls.zone.id
@@ -5235,7 +5207,7 @@ class TestSnapshots(cloudstackTestCase):
         return
 
     def __verify_values(self, expected_vals, actual_vals):
-        """  
+        """
         @Desc: Function to verify expected and actual values
         @Steps:
         Step1: Initializing return flag to True
@@ -5267,7 +5239,7 @@ class TestSnapshots(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_01_list_volume_snapshots_pagination(self):
-        """  
+        """
         @Desc: Test to List Volume Snapshots pagination
         @steps:
         Step1: Listing all the volume snapshots for a user
@@ -5399,7 +5371,7 @@ class TestSnapshots(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_02_list_volume_snapshots_byid(self):
-        """  
+        """
         @Desc: Test to List Volume Snapshots by Id
         @Steps:
         Step1: Listing all the volume snapshots for a user
@@ -5517,7 +5489,7 @@ class TestSnapshots(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_03_list_vm_snapshots_pagination(self):
-        """  
+        """
         @Desc: Test to List VM Snapshots pagination
         @Steps:
         Step1: Listing all the VM snapshots for a user
@@ -5653,7 +5625,7 @@ class TestSnapshots(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_04_list_vm_snapshots_byid(self):
-        """  
+        """
         @summary: Test to List VM Snapshots by Id
 
         Step1: Listing all the VM snapshots for a user
@@ -5749,7 +5721,7 @@ class TestSecurityGroups(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         try:
-            cls._cleanup = []        
+            cls._cleanup = []
             cls.testClient = super(TestSecurityGroups, cls).getClsTestClient()
             cls.api_client = cls.testClient.getApiClient()
             cls.services = cls.testClient.getParsedTestDataConfig()
@@ -5796,7 +5768,7 @@ class TestSecurityGroups(cloudstackTestCase):
         return
 
     def __verify_values(self, expected_vals, actual_vals):
-        """  
+        """
         @Desc: Function to verify expected and actual values
         @Steps:
         Step1: Initializing return flag to True
@@ -5828,11 +5800,11 @@ class TestSecurityGroups(cloudstackTestCase):
 
     @attr(tags=["basic", "provisioning"])
     def test_01_list_securitygroups_pagination(self):
-        """  
+        """
         @Desc: Test to List Security Groups pagination
         @steps:
         Step1: Listing all the Security Groups for a user
-        Step2: Verifying that list size is 1 
+        Step2: Verifying that list size is 1
         Step3: Creating (page size) number of Security Groups
         Step4: Listing all the Security Groups again for a user
         Step5: Verifying that list size is (page size + 1)
@@ -5953,11 +5925,11 @@ class TestSecurityGroups(cloudstackTestCase):
 
     @attr(tags=["basic", "provisioning"])
     def test_02_securitygroups_authorize_revoke_ingress(self):
-        """  
+        """
         @Desc: Test to Authorize and Revoke Ingress for Security Group
         @steps:
         Step1: Listing all the Security Groups for a user
-        Step2: Verifying that list size is 1 
+        Step2: Verifying that list size is 1
         Step3: Creating a Security Groups
         Step4: Listing all the Security Groups again for a user
         Step5: Verifying that list size is 2
@@ -6117,11 +6089,11 @@ class TestSecurityGroups(cloudstackTestCase):
 
     @attr(tags=["basic", "provisioning"])
     def test_03_securitygroups_authorize_revoke_egress(self):
-        """  
+        """
         @Desc: Test to Authorize and Revoke Egress for Security Group
         @steps:
         Step1: Listing all the Security Groups for a user
-        Step2: Verifying that list size is 1 
+        Step2: Verifying that list size is 1
         Step3: Creating a Security Groups
         Step4: Listing all the Security Groups again for a user
         Step5: Verifying that list size is 2
@@ -6284,7 +6256,7 @@ class TestVpnCustomerGateways(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         try:
-            cls._cleanup = []        
+            cls._cleanup = []
             cls.testClient = super(TestVpnCustomerGateways, cls).getClsTestClient()
             cls.api_client = cls.testClient.getApiClient()
             cls.services = cls.testClient.getParsedTestDataConfig()
@@ -6331,7 +6303,7 @@ class TestVpnCustomerGateways(cloudstackTestCase):
         return
 
     def __verify_values(self, expected_vals, actual_vals):
-        """  
+        """
         @Desc: Function to verify expected and actual values
         @Steps:
         Step1: Initializing return flag to True
@@ -6363,7 +6335,7 @@ class TestVpnCustomerGateways(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_01_list_vpncustomergateways_pagination(self):
-        """  
+        """
         @Desc: Test to List VPN Customer Gateways pagination
         @steps:
         Step1: Listing all the VPN Customer Gateways for a user
@@ -6483,7 +6455,7 @@ class TestVpnCustomerGateways(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_02_update_vpncustomergateways(self):
-        """  
+        """
         @Desc: Test to update VPN Customer Gateways pagination
         @steps:
         Step1: Listing all the VPN Customer Gateways for a user
@@ -6613,7 +6585,7 @@ class TestTemplates(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         try:
-            cls._cleanup = []        
+            cls._cleanup = []
             cls.testClient = super(TestTemplates, cls).getClsTestClient()
             cls.api_client = cls.testClient.getApiClient()
             cls.services = cls.testClient.getParsedTestDataConfig()
@@ -6661,7 +6633,7 @@ class TestTemplates(cloudstackTestCase):
         return
 
     def __verify_values(self, expected_vals, actual_vals):
-        """  
+        """
         @Desc: Function to verify expected and actual values
         @Steps:
         Step1: Initializing return flag to True
@@ -6693,7 +6665,7 @@ class TestTemplates(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_01_list_templates_pagination(self):
-        """  
+        """
         @Desc: Test to List Templates pagination
         @steps:
         Step1: Listing all the Templates for a user
@@ -6706,8 +6678,8 @@ class TestTemplates(cloudstackTestCase):
         Step8: Listing all the Templates in page2
         Step9: Verifying that list size is 1
         Step10: Listing the template by Id
-        Step11: Verifying if the template is downloaded and ready. 
-                If yes the continuing 
+        Step11: Verifying if the template is downloaded and ready.
+                If yes the continuing
                 If not waiting and checking for template to be ready till timeout
         Step12: Deleting the Template present in page 2
         Step13: Listing all the Templates in page2
@@ -6853,7 +6825,7 @@ class TestTemplates(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_02_download_template(self):
-        """  
+        """
         @Desc: Test to Download Template
         @steps:
         Step1: Listing all the Templates for a user
@@ -6861,8 +6833,8 @@ class TestTemplates(cloudstackTestCase):
         Step3: Creating a Templates
         Step4: Listing all the Templates again for a user
         Step5: Verifying that list size is 1
-        Step6: Verifying if the template is in ready state. 
-                If yes the continuing 
+        Step6: Verifying if the template is in ready state.
+                If yes the continuing
                 If not waiting and checking for template to be ready till timeout
         Step7: Downloading the template (Extract)
         Step8: Verifying that Template is downloaded
@@ -6974,7 +6946,7 @@ class TestTemplates(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_03_edit_template_details(self):
-        """  
+        """
         @Desc: Test to Edit Template name, displaytext, OSType
         @steps:
         Step1: Listing all the Templates for a user
@@ -6982,8 +6954,8 @@ class TestTemplates(cloudstackTestCase):
         Step3: Creating a Templates
         Step4: Listing all the Templates again for a user
         Step5: Verifying that list size is 1
-        Step6: Verifying if the template is in ready state. 
-                If yes the continuing 
+        Step6: Verifying if the template is in ready state.
+                If yes the continuing
                 If not waiting and checking for template to be ready till timeout
         Step7: Editing the template name
         Step8: Verifying that Template name is edited
@@ -7160,7 +7132,7 @@ class TestTemplates(cloudstackTestCase):
             if ostype_list[i].id != template_created.ostypeid:
                 newostypeid = ostype_list[i].id
                 break
- 
+
         edited_template = Template.update(
                                           template_created,
                                           self.userapiclient,
@@ -7290,7 +7262,7 @@ class TestTemplates(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_04_copy_template(self):
-        """  
+        """
         @Desc: Test to copy Template from one zone to another
         @steps:
         Step1: Listing Zones available for a user
@@ -7504,7 +7476,7 @@ class TestIsos(cloudstackTestCase):
     @classmethod
     def setUpClass(cls):
         try:
-            cls._cleanup = []        
+            cls._cleanup = []
             cls.testClient = super(TestIsos, cls).getClsTestClient()
             cls.api_client = cls.testClient.getApiClient()
             cls.services = cls.testClient.getParsedTestDataConfig()
@@ -7552,7 +7524,7 @@ class TestIsos(cloudstackTestCase):
         return
 
     def __verify_values(self, expected_vals, actual_vals):
-        """  
+        """
         @Desc: Function to verify expected and actual values
         @Steps:
         Step1: Initializing return flag to True
@@ -7584,7 +7556,7 @@ class TestIsos(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_01_list_isos_pagination(self):
-        """  
+        """
         @Desc: Test to List ISO's pagination
         @steps:
         Step1: Listing all the ISO's for a user
@@ -7597,8 +7569,8 @@ class TestIsos(cloudstackTestCase):
         Step8: Listing all the ISO's in page2
         Step9: Verifying that list size is 1
         Step10: Listing the ISO's by Id
-        Step11: Verifying if the ISO is downloaded and ready. 
-                If yes the continuing 
+        Step11: Verifying if the ISO is downloaded and ready.
+                If yes the continuing
                 If not waiting and checking for iso to be ready till timeout
         Step12: Deleting the ISO present in page 2
         Step13: Listing all the ISO's in page2
@@ -7738,7 +7710,7 @@ class TestIsos(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_02_download_iso(self):
-        """  
+        """
         @Desc: Test to Download ISO
         @steps:
         Step1: Listing all the ISO's for a user
@@ -7746,8 +7718,8 @@ class TestIsos(cloudstackTestCase):
         Step3: Creating an ISO
         Step4: Listing all the ISO's again for a user
         Step5: Verifying that list size is 1
-        Step6: Verifying if the ISO is in ready state. 
-                If yes the continuing 
+        Step6: Verifying if the ISO is in ready state.
+                If yes the continuing
                 If not waiting and checking for template to be ready till timeout
         Step7: Downloading the ISO (Extract)
         Step8: Verifying the details of downloaded ISO
@@ -7853,7 +7825,7 @@ class TestIsos(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_03_edit_iso_details(self):
-        """  
+        """
         @Desc: Test to Edit ISO name, displaytext, OSType
         @steps:
         Step1: Listing all the ISO's for a user
@@ -7861,8 +7833,8 @@ class TestIsos(cloudstackTestCase):
         Step3: Creating an ISO
         Step4: Listing all the ISO's again for a user
         Step5: Verifying that list size is 1
-        Step6: Verifying if the ISO is in ready state. 
-                If yes the continuing 
+        Step6: Verifying if the ISO is in ready state.
+                If yes the continuing
                 If not waiting and checking for template to be ready till timeout
         Step7: Editing the ISO's name, displaytext
         Step8: Verifying that ISO name and displaytext are edited
@@ -7990,7 +7962,7 @@ class TestIsos(cloudstackTestCase):
             if ostype_list[i].id != iso_created.ostypeid:
                 newostypeid = ostype_list[i].id
                 break
-   
+
         edited_iso = Iso.update(
                                 iso_created,
                                 self.userapiclient,
@@ -8037,7 +8009,7 @@ class TestIsos(cloudstackTestCase):
 
     @attr(tags=["advanced", "basic", "provisioning"])
     def test_04_copy_iso(self):
-        """  
+        """
         @Desc: Test to copy ISO from one zone to another
         @steps:
         Step1: Listing Zones available for a user
@@ -8227,4 +8199,4 @@ class TestIsos(cloudstackTestCase):
                               "Failed to copy ISO"
                               )
         del self.services["iso"]["zoneid"]
-        return
\ No newline at end of file
+        return

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff1c4bee/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 592b351..6d85609 100644
--- a/test/integration/component/test_netscaler_configs.py
+++ b/test/integration/component/test_netscaler_configs.py
@@ -18,15 +18,28 @@
 """ P1 tests for netscaler configurations
 """
 #Import Local Modules
-import marvin
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
+from marvin.cloudstackTestCase import cloudstackTestCase
+#from marvin.cloudstackAPI import *
+from marvin.lib.utils import (cleanup_resources,
+                              random_gen)
+from marvin.lib.base import (VirtualMachine,
+                             NetworkServiceProvider,
+                             PublicIPAddress,
+                             Account,
+                             Network,
+                             NetScaler,
+                             LoadBalancerRule,
+                             NetworkOffering,
+                             ServiceOffering,
+                             PhysicalNetwork,
+                             Configurations)
+from marvin.lib.common import (get_domain,
+                               get_zone,
+                               get_template,
+                               add_netscaler)
 from marvin.sshClient import SshClient
-import datetime
+import time
 
 
 class Services:
@@ -559,7 +572,7 @@ class TestNetScalerDedicated(cloudstackTestCase):
             netscaler_provider = nw_service_providers[0]
 
         if netscaler_provider.state != 'Enabled':
-            response = NetworkServiceProvider.update(
+            NetworkServiceProvider.update(
                                           cls.api_client,
                                           id=netscaler_provider.id,
                                           state='Enabled'
@@ -621,11 +634,11 @@ class TestNetScalerDedicated(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -781,7 +794,7 @@ class TestNetScalerShared(cloudstackTestCase):
             netscaler_provider = nw_service_providers[0]
 
         if netscaler_provider.state != 'Enabled':
-            response = NetworkServiceProvider.update(
+            NetworkServiceProvider.update(
                                           cls.api_client,
                                           id=netscaler_provider.id,
                                           state='Enabled'
@@ -839,11 +852,11 @@ class TestNetScalerShared(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -1023,7 +1036,7 @@ class TestNetScalerCustomCapacity(cloudstackTestCase):
             netscaler_provider = nw_service_providers[0]
 
         if netscaler_provider.state != 'Enabled':
-            response = NetworkServiceProvider.update(
+            NetworkServiceProvider.update(
                                           cls.api_client,
                                           id=netscaler_provider.id,
                                           state='Enabled'
@@ -1087,11 +1100,11 @@ class TestNetScalerCustomCapacity(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -1244,7 +1257,7 @@ class TestNetScalerCustomCapacity(cloudstackTestCase):
         self.debug("Deploying VM in account: %s" % self.account_3.name)
         with self.assertRaises(Exception):
             # Spawn an instance in that network
-            virtual_machine_3 = VirtualMachine.create(
+            VirtualMachine.create(
                                   self.apiclient,
                                   self.services["virtual_machine"],
                                   accountid=self.account_3.name,
@@ -1295,7 +1308,7 @@ class TestNetScalerNoCapacity(cloudstackTestCase):
             netscaler_provider = nw_service_providers[0]
 
         if netscaler_provider.state != 'Enabled':
-            response = NetworkServiceProvider.update(
+            NetworkServiceProvider.update(
                                           cls.api_client,
                                           id=netscaler_provider.id,
                                           state='Enabled'
@@ -1359,11 +1372,11 @@ class TestNetScalerNoCapacity(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -1517,7 +1530,7 @@ class TestNetScalerNoCapacity(cloudstackTestCase):
         self.debug("Deploying VM in account: %s" % self.account_3.name)
         with self.assertRaises(Exception):
             # Spawn an instance in that network
-            virtual_machine_3 = VirtualMachine.create(
+            VirtualMachine.create(
                                   self.apiclient,
                                   self.services["virtual_machine"],
                                   accountid=self.account_3.name,
@@ -1568,7 +1581,7 @@ class TestGuestNetworkWithNetScaler(cloudstackTestCase):
             netscaler_provider = nw_service_providers[0]
 
         if netscaler_provider.state != 'Enabled':
-            response = NetworkServiceProvider.update(
+            NetworkServiceProvider.update(
                                           cls.api_client,
                                           id=netscaler_provider.id,
                                           state='Enabled'
@@ -1626,11 +1639,11 @@ class TestGuestNetworkWithNetScaler(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -2030,11 +2043,11 @@ class TestGuestNetworkWithNetScaler(cloudstackTestCase):
         self.debug("Account: %s is deleted!" % self.account_1.name)
 
         self.debug("Waiting for network.gc.interval & network.gc.wait..")
-        interval = list_configurations(
+        interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-        wait = list_configurations(
+        wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -2223,15 +2236,18 @@ class TestGuestNetworkShutDown(cloudstackTestCase):
             "Stopping all the VM instances for the account: %s" %
                                                     self.account.name)
 
-        self.vm_1.stop(self.apiclient)
-        self.vm_2.stop(self.apiclient)
+        try:
+            self.vm_1.stop(self.apiclient)
+            self.vm_2.stop(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to stop instance: %s" % e)
 
         self.debug("Sleep for network.gc.interval + network.gc.wait")
-        interval = list_configurations(
+        interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-        wait = list_configurations(
+        wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -2529,7 +2545,7 @@ class TestServiceProvider(cloudstackTestCase):
             cls.netscaler_provider = nw_service_providers[0]
 
         if cls.netscaler_provider.state != 'Enabled':
-            response = NetworkServiceProvider.update(
+            NetworkServiceProvider.update(
                                           cls.api_client,
                                           id=cls.netscaler_provider.id,
                                           state='Enabled'
@@ -2586,11 +2602,11 @@ class TestServiceProvider(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -2843,7 +2859,7 @@ class TestDeleteNetscaler(cloudstackTestCase):
             netscaler_provider = nw_service_providers[0]
 
         if netscaler_provider.state != 'Enabled':
-            response = NetworkServiceProvider.update(
+            NetworkServiceProvider.update(
                                           cls.api_client,
                                           id=netscaler_provider.id,
                                           state='Enabled'
@@ -2901,11 +2917,11 @@ class TestDeleteNetscaler(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff1c4bee/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 732f0f9..4c99aa3 100644
--- a/test/integration/component/test_netscaler_lb.py
+++ b/test/integration/component/test_netscaler_lb.py
@@ -18,15 +18,27 @@
 """ P1 tests for netscaler load balancing
 """
 #Import Local Modules
-import marvin
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import migrateVirtualMachine
+from marvin.lib.utils import (cleanup_resources,
+                              random_gen)
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             PublicIPAddress,
+                             LoadBalancerRule,
+                             ServiceOffering,
+                             NetworkOffering,
+                             Host,
+                             Network,
+                             NATRule,
+                             Configurations)
+from marvin.lib.common import (get_domain,
+                               get_zone,
+                               get_template,
+                               add_netscaler)
 from marvin.sshClient import SshClient
-import datetime
+import time
 
 
 class Services:
@@ -209,11 +221,11 @@ class TestLbSourceNat(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -418,11 +430,11 @@ class TestLbOnIpWithPf(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -630,11 +642,11 @@ class TestPfOnIpWithLb(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -771,7 +783,7 @@ class TestPfOnIpWithLb(cloudstackTestCase):
         with self.assertRaises(Exception):
             NATRule.create(
                          self.apiclient,
-                         virtual_machine,
+                         virtual_machine_1,
                          self.services["natrule"],
                          ipaddressid=ip_with_lb_rule.ipaddress.id
                       )
@@ -843,11 +855,11 @@ class TestLbOnNonSourceNat(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -1059,11 +1071,11 @@ class TestAddMultipleVmsLb(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -1338,11 +1350,11 @@ class TestMultipleLbRules(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -1656,11 +1668,11 @@ class TestMultipleLbRulesSameIp(cloudstackTestCase):
             self.debug("Cleaning up the resources")
             #Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
+            interval = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.interval'
                                     )
-            wait = list_configurations(
+            wait = Configurations.list(
                                     self.apiclient,
                                     name='network.gc.wait'
                                     )
@@ -2246,7 +2258,7 @@ class TestDeleteCreateLBRule(cloudstackTestCase):
 
         self.debug("Create a new LB rule with different public port")
         self.services["lbrule"]["publicport"] = 23
-        lb_rule = LoadBalancerRule.create(
+        LoadBalancerRule.create(
                                     self.apiclient,
                                     self.services["lbrule"],
                                     ipaddressid=self.public_ip.ipaddress.id,
@@ -2462,18 +2474,11 @@ class TestVmWithLb(cloudstackTestCase):
         # 4. In netscaler, LB rules for this VM  still remain configured.But
         #    it will be marked as being down
 
-        self.debug("Adding instances: %s, %s to LB rule: %s" % (
-                                                        self.vm_1.name,
-                                                        self.vm_2.name,
-                                                        self.lb_rule_1.name))
-        self.lb_rule_1.assign(self.apiclient, [self.vm_1, self.vm_2])
-        self.debug("Assigned instances: %s, %s to LB rule: %s" % (
-                                                        self.vm_1.name,
-                                                        self.vm_2.name,
-                                                        self.lb_rule_1.name))
-        self.debug("Stopping VM instance: %s" % self.vm_2.name)
-        self.vm_2.stop(self.apiclient)
-        self.debug("Stopped VM: %s" % self.vm_2.name)
+        try:
+            self.lb_rule_1.assign(self.apiclient, [self.vm_1, self.vm_2])
+            self.vm_2.stop(self.apiclient)
+        except Exception as e:
+            self.fail("Exception occured: %s" % e)
 
         try:
             self.debug(
@@ -2642,7 +2647,7 @@ class TestVmWithLb(cloudstackTestCase):
         cmd.virtualmachineid = self.vm_2.id
         self.apiclient.migrateVirtualMachine(cmd)
 
-        list_vm_response = list_virtual_machines(
+        list_vm_response = VirtualMachine.list(
                                             self.apiclient,
                                             id=self.vm_2.id
                                             )
@@ -2852,11 +2857,11 @@ class TestVmWithLb(cloudstackTestCase):
             self.fail("Exception occured during SSH: %s - %s" % (
                                         self.public_ip_1.ipaddress.ipaddress,
                                         e))
-        delay = list_configurations(
+        delay = Configurations.list(
                                     self.apiclient,
                                     name='expunge.delay'
                                     )
-        wait = list_configurations(
+        wait = Configurations.list(
                                     self.apiclient,
                                     name='expunge.interval'
                                     )