cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject git commit: updated refs/heads/4.2-forward to fb9521c
Date Thu, 29 Aug 2013 08:57:18 GMT
Updated Branches:
  refs/heads/4.2-forward f585c605e -> fb9521c92


Formatting and tab errors in the new test suites for limits

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
(cherry picked from commit f5eb81e669a8a454fc02b90a44c4ce8ffc7ac9ac)


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

Branch: refs/heads/4.2-forward
Commit: fb9521c92fa195eba03b125ae05be946b750b3ec
Parents: f585c60
Author: Prasanna Santhanam <tsp@apache.org>
Authored: Thu Aug 29 14:26:12 2013 +0530
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Thu Aug 29 14:26:54 2013 +0530

----------------------------------------------------------------------
 .../component/cpu_limits/test_cpu_limits.py     | 390 +++++++--------
 .../component/cpu_limits/test_domain_limits.py  | 499 ++++++++++---------
 .../component/cpu_limits/test_maximum_limits.py | 253 +++++-----
 .../component/cpu_limits/test_project_limits.py |  50 +-
 4 files changed, 598 insertions(+), 594 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fb9521c9/test/integration/component/cpu_limits/test_cpu_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/cpu_limits/test_cpu_limits.py b/test/integration/component/cpu_limits/test_cpu_limits.py
index 96be62b..8acf8b7 100644
--- a/test/integration/component/cpu_limits/test_cpu_limits.py
+++ b/test/integration/component/cpu_limits/test_cpu_limits.py
@@ -149,31 +149,31 @@ class TestCPULimits(cloudstackTestCase):
         return
 
     def createInstance(self, service_off, networks=None, api_client=None):
-        """Creates an instance in account"""
+        """Creates an instance in account
+        """
+        if api_client is None:
+            api_client = self.apiclient
 
-   if api_client is None:
-       api_client = self.apiclient
-
-        self.debug("Deploying an instance in account: %s" %
-                                                self.account.name)
-        try:
-            vm = VirtualMachine.create(
-                                api_client,
-                                self.services["virtual_machine"],
-                                templateid=self.template.id,
-                                accountid=self.account.name,
-                                domainid=self.account.domainid,
-                                networkids=networks,
-                                serviceofferingid=service_off.id)
-            vms = VirtualMachine.list(api_client, id=vm.id, listall=True)
-            self.assertIsInstance(vms,
-                                  list,
-                                  "List VMs should return a valid response")
-            self.assertEqual(vms[0].state, "Running",
-                             "Vm state should be running after deployment")
-            return vm
-        except Exception as e:
-            self.fail("Failed to deploy an instance: %s" % e)
+            self.debug("Deploying an instance in account: %s" %
+                       self.account.name)
+            try:
+                vm = VirtualMachine.create(
+                    api_client,
+                    self.services["virtual_machine"],
+                    templateid=self.template.id,
+                    accountid=self.account.name,
+                    domainid=self.account.domainid,
+                    networkids=networks,
+                    serviceofferingid=service_off.id)
+                vms = VirtualMachine.list(api_client, id=vm.id, listall=True)
+                self.assertIsInstance(vms,
+                    list,
+                    "List VMs should return a valid response")
+                self.assertEqual(vms[0].state, "Running",
+                    "Vm state should be running after deployment")
+                return vm
+            except Exception as e:
+                self.fail("Failed to deploy an instance: %s" % e)
 
     @attr(tags=["advanced", "advancedns","simulator"])
     def test_01_multiplecore_start_stop_instance(self):
@@ -396,66 +396,66 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
         return
 
     def createInstance(self, service_off, networks=None, api_client=None):
-        """Creates an instance in account"""
-
-   if api_client is None:
-       api_client = self.apiclient
+        """Creates an instance in account
+        """
+        if api_client is None:
+            api_client = self.apiclient
 
-        self.debug("Deploying an instance in account: %s" %
-                                                self.account.name)
-        try:
-            vm = VirtualMachine.create(
-                                api_client,
-                                self.services["virtual_machine"],
-                                templateid=self.template.id,
-                                accountid=self.account.name,
-                                domainid=self.account.domainid,
-                                networkids=networks,
-                                serviceofferingid=service_off.id)
-            vms = VirtualMachine.list(api_client, id=vm.id, listall=True)
-            self.assertIsInstance(vms,
-                                  list,
-                                  "List VMs should return a valid response")
-            self.assertEqual(vms[0].state, "Running",
-                             "Vm state should be running after deployment")
-            return vm
-        except Exception as e:
-            self.fail("Failed to deploy an instance: %s" % e)
+            self.debug("Deploying an instance in account: %s" %
+                       self.account.name)
+            try:
+                vm = VirtualMachine.create(
+                    api_client,
+                    self.services["virtual_machine"],
+                    templateid=self.template.id,
+                    accountid=self.account.name,
+                    domainid=self.account.domainid,
+                    networkids=networks,
+                    serviceofferingid=service_off.id)
+                vms = VirtualMachine.list(api_client, id=vm.id, listall=True)
+                self.assertIsInstance(vms,
+                    list,
+                    "List VMs should return a valid response")
+                self.assertEqual(vms[0].state, "Running",
+                    "Vm state should be running after deployment")
+                return vm
+            except Exception as e:
+                self.fail("Failed to deploy an instance: %s" % e)
 
     def setupAccounts(self):
 
         self.debug("Creating a sub-domain under: %s" % self.domain.name)
-   self.child_domain_1 = Domain.create(
-               self.apiclient,
-                                services=self.services["domain"],
-                                parentdomainid=self.domain.id
-               )
-   self.child_do_admin_1 = Account.create(
-                                self.apiclient,
-                                self.services["account"],
-                                admin=True,
-                                domainid=self.child_domain_1.id
-                                )
-   # Cleanup the resources created at end of test
-   self.cleanup.append(self.child_do_admin_1)
-   self.cleanup.append(self.child_domain_1)
-
-   self.child_domain_2 = Domain.create(
-                 self.apiclient,
-                              services=self.services["domain"],
-                              parentdomainid=self.domain.id
-                 )
-
-   self.child_do_admin_2 = Account.create(
-                                self.apiclient,
-                                self.services["account"],
-                                admin=True,
-                                domainid=self.child_domain_2.id
-                   )
-
-   # Cleanup the resources created at end of test
-   self.cleanup.append(self.child_do_admin_2)
-   self.cleanup.append(self.child_domain_2)
+        self.child_domain_1 = Domain.create(
+            self.apiclient,
+            services=self.services["domain"],
+            parentdomainid=self.domain.id
+        )
+        self.child_do_admin_1 = Account.create(
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.child_domain_1.id
+        )
+        # Cleanup the resources created at end of test
+        self.cleanup.append(self.child_do_admin_1)
+        self.cleanup.append(self.child_domain_1)
+
+        self.child_domain_2 = Domain.create(
+            self.apiclient,
+            services=self.services["domain"],
+            parentdomainid=self.domain.id
+        )
+
+        self.child_do_admin_2 = Account.create(
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.child_domain_2.id
+        )
+
+        # Cleanup the resources created at end of test
+        self.cleanup.append(self.child_do_admin_2)
+        self.cleanup.append(self.child_domain_2)
 
         return
 
@@ -478,57 +478,57 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
             self.account = admin
             self.domain = domain
 
-       api_client = self.testClient.createUserApiClient(
-                             UserName=self.account.name,
-                             DomainName=self.account.domain)
+        api_client = self.testClient.createUserApiClient(
+            UserName=self.account.name,
+            DomainName=self.account.domain)
 
-            self.debug("Creating an instance with service offering: %s" %
-                                                    self.service_offering.name)
-            vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
+        self.debug("Creating an instance with service offering: %s" %
+                   self.service_offering.name)
+        vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
 
-            account_list = Account.list(self.apiclient, id=self.account.id)
-            self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
-            resource_count = account_list[0].cputotal
+        account_list = Account.list(self.apiclient, id=self.account.id)
+        self.assertIsInstance(account_list,
+            list,
+            "List Accounts should return a valid response"
+        )
+        resource_count = account_list[0].cputotal
 
-            expected_resource_count = int(self.services["service_offering"]["cpunumber"])
+        expected_resource_count = int(self.services["service_offering"]["cpunumber"])
 
-            self.assertEqual(resource_count, expected_resource_count,
-                         "Initial resource count should match with the expected resource count")
+        self.assertEqual(resource_count, expected_resource_count,
+            "Initial resource count should match with the expected resource count")
 
-            self.debug("Stopping instance: %s" % vm.name)
-            try:
-                vm.stop(self.apiclient)
-            except Exception as e:
-                self.fail("Failed to stop instance: %s" % e)
+        self.debug("Stopping instance: %s" % vm.name)
+        try:
+            vm.stop(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to stop instance: %s" % e)
 
-            account_list = Account.list(self.apiclient, id=self.account.id)
-            self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
-            resource_count_after_stop = account_list[0].cputotal
+        account_list = Account.list(self.apiclient, id=self.account.id)
+        self.assertIsInstance(account_list,
+            list,
+            "List Accounts should return a valid response"
+        )
+        resource_count_after_stop = account_list[0].cputotal
 
-            self.assertEqual(resource_count, resource_count_after_stop,
-                         "Resource count should be same after stopping the instance")
+        self.assertEqual(resource_count, resource_count_after_stop,
+            "Resource count should be same after stopping the instance")
 
-            self.debug("Starting instance: %s" % vm.name)
-            try:
-                vm.start(self.apiclient)
-            except Exception as e:
-                self.fail("Failed to start instance: %s" % e)
+        self.debug("Starting instance: %s" % vm.name)
+        try:
+            vm.start(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to start instance: %s" % e)
 
-            account_list = Account.list(self.apiclient, id=self.account.id)
-            self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
-            resource_count_after_start = account_list[0].cputotal
+        account_list = Account.list(self.apiclient, id=self.account.id)
+        self.assertIsInstance(account_list,
+            list,
+            "List Accounts should return a valid response"
+        )
+        resource_count_after_start = account_list[0].cputotal
 
-            self.assertEqual(resource_count_after_stop, resource_count_after_start,
-                         "Resource count should be same after starting the instance")
+        self.assertEqual(resource_count_after_stop, resource_count_after_start,
+            "Resource count should be same after starting the instance")
         return
 
     @attr(tags=["advanced", "advancedns","simulator"])
@@ -550,43 +550,43 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
             self.account = admin
             self.domain = domain
 
-       api_client = self.testClient.createUserApiClient(
-                             UserName=self.account.name,
-                             DomainName=self.account.domain)
+        api_client = self.testClient.createUserApiClient(
+            UserName=self.account.name,
+            DomainName=self.account.domain)
 
-            self.debug("Creating an instance with service offering: %s" %
-                                                    self.service_offering.name)
-            vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
+        self.debug("Creating an instance with service offering: %s" %
+                   self.service_offering.name)
+        vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
 
-            account_list = Account.list(self.apiclient, id=self.account.id)
-            self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
-            resource_count = account_list[0].cputotal
+        account_list = Account.list(self.apiclient, id=self.account.id)
+        self.assertIsInstance(account_list,
+            list,
+            "List Accounts should return a valid response"
+        )
+        resource_count = account_list[0].cputotal
 
-            expected_resource_count = int(self.services["service_offering"]["cpunumber"])
+        expected_resource_count = int(self.services["service_offering"]["cpunumber"])
 
-            self.assertEqual(resource_count, expected_resource_count,
-                         "Initial resource count should with the expected resource count")
+        self.assertEqual(resource_count, expected_resource_count,
+            "Initial resource count should with the expected resource count")
 
-            host = find_suitable_host(self.apiclient, vm)
-            self.debug("Migrating instance: %s to host: %s" %
-                                                        (vm.name, host.name))
-            try:
-                vm.migrate(self.apiclient, host.id)
-            except Exception as e:
-                self.fail("Failed to migrate instance: %s" % e)
+        host = find_suitable_host(self.apiclient, vm)
+        self.debug("Migrating instance: %s to host: %s" %
+                   (vm.name, host.name))
+        try:
+            vm.migrate(self.apiclient, host.id)
+        except Exception as e:
+            self.fail("Failed to migrate instance: %s" % e)
 
-            account_list = Account.list(self.apiclient, id=self.account.id)
-            self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
-            resource_count_after_migrate = account_list[0].cputotal
+        account_list = Account.list(self.apiclient, id=self.account.id)
+        self.assertIsInstance(account_list,
+            list,
+            "List Accounts should return a valid response"
+        )
+        resource_count_after_migrate = account_list[0].cputotal
 
-            self.assertEqual(resource_count, resource_count_after_migrate,
-                         "Resource count should be same after starting the instance")
+        self.assertEqual(resource_count, resource_count_after_migrate,
+            "Resource count should be same after starting the instance")
         return
 
     @attr(tags=["advanced", "advancedns","simulator"])
@@ -608,47 +608,46 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
             self.account = admin
             self.domain = domain
 
-       api_client = self.testClient.createUserApiClient(
-                             UserName=self.account.name,
-                             DomainName=self.account.domain)
+        api_client = self.testClient.createUserApiClient(
+            UserName=self.account.name,
+            DomainName=self.account.domain)
 
-            self.debug("Creating an instance with service offering: %s" %
-                                                    self.service_offering.name)
-            vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
+        self.debug("Creating an instance with service offering: %s" %
+                   self.service_offering.name)
+        vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
 
-            account_list = Account.list(self.apiclient, id=self.account.id)
-            self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
-            resource_count = account_list[0].cputotal
+        account_list = Account.list(self.apiclient, id=self.account.id)
+        self.assertIsInstance(account_list,
+            list,
+            "List Accounts should return a valid response"
+        )
+        resource_count = account_list[0].cputotal
 
-            expected_resource_count = int(self.services["service_offering"]["cpunumber"])
+        expected_resource_count = int(self.services["service_offering"]["cpunumber"])
 
-            self.assertEqual(resource_count, expected_resource_count,
-                         "Initial resource count should match with the expected resource count")
+        self.assertEqual(resource_count, expected_resource_count,
+            "Initial resource count should match with the expected resource count")
 
-            self.debug("Destroying instance: %s" % vm.name)
-            try:
-                vm.delete(self.apiclient)
-            except Exception as e:
-                self.fail("Failed to delete instance: %s" % e)
+        self.debug("Destroying instance: %s" % vm.name)
+        try:
+            vm.delete(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to delete instance: %s" % e)
 
-            account_list = Account.list(self.apiclient, id=self.account.id)
-            self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
-            resource_count = account_list[0].cputotal
-            self.assertEqual(resource_count, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
+        account_list = Account.list(self.apiclient, id=self.account.id)
+        self.assertIsInstance(account_list,
+            list,
+            "List Accounts should return a valid response"
+        )
+        resource_count = account_list[0].cputotal
+        self.assertEqual(resource_count, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
         return
 
     @attr(tags=["advanced", "advancedns","simulator"])
     @attr(configuration='max.account.cpus')
     def test_04_deploy_multiple_vm_with_multiple_cpus(self):
         """Test Deploy multiple VM with 4 core CPU & verify the usage"""
-   #keep the configuration value - max.account.cpus number = 16
-
+        #keep the configuration value - max.account.cpus number = 16
         # Validate the following
         # 1. Create compute offering with 4 core CPU
         # 2. Deploy multiple VMs with this service offering
@@ -681,12 +680,12 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
             if cpu_account_gc[0].max != 16:
                 self.skipTest("This test case requires configuration value max.account.cpus to be 16")
 
-       api_client = self.testClient.createUserApiClient(
-                             UserName=self.account.name,
-                             DomainName=self.account.domain)
+            api_client = self.testClient.createUserApiClient(
+                UserName=self.account.name,
+                DomainName=self.account.domain)
 
             self.debug("Creating an instance with service offering: %s" %
-                                                    self.service_offering.name)
+                       self.service_offering.name)
             vm_1 = self.createInstance(service_off=self.service_offering, api_client=api_client)
             vm_2 = self.createInstance(service_off=self.service_offering, api_client=api_client)
             self.createInstance(service_off=self.service_offering, api_client=api_client)
@@ -698,15 +697,15 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count = account_list[0].cputotal
 
             expected_resource_count = int(self.services["service_offering"]["cpunumber"]) * 4 #Total 4 vms
 
             self.assertEqual(resource_count, expected_resource_count,
-                         "Initial resource count should with the expected resource count")
+                "Initial resource count should with the expected resource count")
 
             self.debug("Destroying instance: %s" % vm_1.name)
             try:
@@ -716,15 +715,15 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count_after_delete = account_list[0].cputotal
 
             expected_resource_count -= int(self.services["service_offering"]["cpunumber"])
 
             self.assertEqual(resource_count_after_delete, expected_resource_count,
-                         "Resource count should be less than before after deleting the instance")
+                "Resource count should be less than before after deleting the instance")
 
             host = find_suitable_host(self.apiclient, vm_2)
             self.debug("Migrating instance: %s to host: %s" % (vm_2.name,
@@ -736,12 +735,11 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count_after_migrate = account_list[0].cputotal
 
             self.debug(resource_count_after_migrate)
             self.assertEqual(resource_count_after_delete, resource_count_after_migrate,
-                         "Resource count should be same after migrating the instance")
-        return
+                "Resource count should be same after migrating the instance")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fb9521c9/test/integration/component/cpu_limits/test_domain_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/cpu_limits/test_domain_limits.py b/test/integration/component/cpu_limits/test_domain_limits.py
index 057c6b9..2668204 100644
--- a/test/integration/component/cpu_limits/test_domain_limits.py
+++ b/test/integration/component/cpu_limits/test_domain_limits.py
@@ -139,80 +139,81 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
     def createInstance(self, service_off, networks=None, api_client=None):
         """Creates an instance in account"""
 
-   if api_client is None:
-       api_client = self.apiclient
+        if api_client is None:
+            api_client = self.apiclient
 
-        self.debug("Deploying an instance in account: %s" %
-                                                self.account.name)
-        try:
-            vm = VirtualMachine.create(
-                                api_client,
-                                self.services["virtual_machine"],
-                                templateid=self.template.id,
-                                accountid=self.account.name,
-                                domainid=self.account.domainid,
-                                networkids=networks,
-                                serviceofferingid=service_off.id)
-            vms = VirtualMachine.list(api_client, id=vm.id, listall=True)
-            self.assertIsInstance(vms,
-                                  list,
-                                  "List VMs should return a valid response")
-            self.assertEqual(vms[0].state, "Running",
-                             "Vm state should be running after deployment")
-            return vm
-        except Exception as e:
-            self.fail("Failed to deploy an instance: %s" % e)
+            self.debug("Deploying an instance in account: %s" %
+                       self.account.name)
+            try:
+                vm = VirtualMachine.create(
+                    api_client,
+                    self.services["virtual_machine"],
+                    templateid=self.template.id,
+                    accountid=self.account.name,
+                    domainid=self.account.domainid,
+                    networkids=networks,
+                    serviceofferingid=service_off.id)
+                vms = VirtualMachine.list(api_client, id=vm.id, listall=True)
+                self.assertIsInstance(vms,
+                    list,
+                    "List VMs should return a valid response")
+                self.assertEqual(vms[0].state, "Running",
+                    "Vm state should be running after deployment")
+                return vm
+            except Exception as e:
+                self.fail("Failed to deploy an instance: %s" % e)
 
     def setupAccounts(self):
 
         self.debug("Creating a sub-domain under: %s" % self.domain.name)
-   self.child_domain = Domain.create(
-               self.apiclient,
-                                services=self.services["domain"],
-                                parentdomainid=self.domain.id
-               )
-   self.child_do_admin = Account.create(
-                                self.apiclient,
-                                self.services["account"],
-                                admin=True,
-                                domainid=self.child_domain.id
-                                )
-   # Cleanup the resources created at end of test
-   self.cleanup.append(self.child_do_admin)
-   self.cleanup.append(self.child_domain)
-
-   Resources.updateLimit(
-       self.apiclient,
-                resourcetype=8,
-                max=16,
-                account=self.child_do_admin.name,
-                domainid=self.child_do_admin.domainid
-       )
-
-   self.domain = Domain.create(
-           self.apiclient,
-                        services=self.services["domain"],
-                        parentdomainid=self.domain.id
-           )
-
-   self.admin = Account.create(
-                            self.apiclient,
-                            self.services["account"],
-                            admin=True,
-                            domainid=self.domain.id
-               )
-
-   # Cleanup the resources created at end of test
-   self.cleanup.append(self.admin)
-   self.cleanup.append(self.domain)
-
-   Resources.updateLimit(
-             self.apiclient,
-                      resourcetype=8,
-                      max=16,
-                      account=self.admin.name,
-                      domainid=self.admin.domainid
-             )
+
+        self.child_domain = Domain.create(
+            self.apiclient,
+            services=self.services["domain"],
+            parentdomainid=self.domain.id
+        )
+        self.child_do_admin = Account.create(
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.child_domain.id
+        )
+        # Cleanup the resources created at end of test
+        self.cleanup.append(self.child_do_admin)
+        self.cleanup.append(self.child_domain)
+
+        Resources.updateLimit(
+            self.apiclient,
+            resourcetype=8,
+            max=16,
+            account=self.child_do_admin.name,
+            domainid=self.child_do_admin.domainid
+        )
+
+        self.domain = Domain.create(
+            self.apiclient,
+            services=self.services["domain"],
+            parentdomainid=self.domain.id
+        )
+
+        self.admin = Account.create(
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
+
+        # Cleanup the resources created at end of test
+        self.cleanup.append(self.admin)
+        self.cleanup.append(self.domain)
+
+        Resources.updateLimit(
+            self.apiclient,
+            resourcetype=8,
+            max=16,
+            account=self.admin.name,
+            domainid=self.admin.domainid
+        )
         return
 
     @attr(tags=["advanced", "advancedns","simulator"])
@@ -235,25 +236,25 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
             self.account = admin
             self.domain = domain
 
-       api_client = self.testClient.createUserApiClient(
-                             UserName=self.account.name,
-                             DomainName=self.account.domain)
+            api_client = self.testClient.createUserApiClient(
+                UserName=self.account.name,
+                DomainName=self.account.domain)
 
             self.debug("Creating an instance with service offering: %s" %
-                                                    self.service_offering.name)
+                       self.service_offering.name)
             vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count = account_list[0].cputotal
 
             expected_resource_count = int(self.services["service_offering"]["cpunumber"])
 
             self.assertEqual(resource_count, expected_resource_count,
-                             "Initial resource count should match with the expected resource count")
+                "Initial resource count should match with the expected resource count")
 
             self.debug("Stopping instance: %s" % vm.name)
             try:
@@ -263,13 +264,13 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count_after_stop = account_list[0].cputotal
 
             self.assertEqual(resource_count, resource_count_after_stop,
-                             "Resource count should be same as before, after stopping the instance")
+                "Resource count should be same as before, after stopping the instance")
 
             self.debug("Starting instance: %s" % vm.name)
             try:
@@ -279,13 +280,13 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count_after_start = account_list[0].cputotal
 
             self.assertEqual(resource_count_after_stop, resource_count_after_start,
-                             "Resource count should be same as before, after starting the instance")
+                "Resource count should be same as before, after starting the instance")
         return
 
     @attr(tags=["advanced", "advancedns","simulator"])
@@ -308,29 +309,29 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
             self.account = admin
             self.domain = domain
 
-       api_client = self.testClient.createUserApiClient(
-                             UserName=self.account.name,
-                             DomainName=self.account.domain)
+            api_client = self.testClient.createUserApiClient(
+                UserName=self.account.name,
+                DomainName=self.account.domain)
 
             self.debug("Creating an instance with service offering: %s" %
-                                                    self.service_offering.name)
+                       self.service_offering.name)
             vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count = account_list[0].cputotal
 
             expected_resource_count = int(self.services["service_offering"]["cpunumber"])
 
             self.assertEqual(resource_count, expected_resource_count,
-                             "Initial resource count should match with the expected resource count")
+                "Initial resource count should match with the expected resource count")
 
             host = find_suitable_host(self.apiclient, vm)
             self.debug("Migrating instance: %s to host: %s" %
-                                                        (vm.name, host.name))
+                       (vm.name, host.name))
             try:
                 vm.migrate(self.apiclient, host.id)
             except Exception as e:
@@ -338,13 +339,13 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count_after_migrate = account_list[0].cputotal
 
             self.assertEqual(resource_count, resource_count_after_migrate,
-                             "Resource count should be same as before, after migrating the instance")
+                "Resource count should be same as before, after migrating the instance")
         return
 
     @attr(tags=["advanced", "advancedns","simulator"])
@@ -367,25 +368,25 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
             self.account = admin
             self.domain = domain
 
-       api_client = self.testClient.createUserApiClient(
-                             UserName=self.account.name,
-                             DomainName=self.account.domain)
+            api_client = self.testClient.createUserApiClient(
+                UserName=self.account.name,
+                DomainName=self.account.domain)
 
             self.debug("Creating an instance with service offering: %s" %
-                                                    self.service_offering.name)
+                       self.service_offering.name)
             vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count = account_list[0].cputotal
 
             expected_resource_count = int(self.services["service_offering"]["cpunumber"])
 
             self.assertEqual(resource_count, expected_resource_count,
-                             "Initial resource count should with the expected resource count")
+                "Initial resource count should with the expected resource count")
 
             self.debug("Destroying instance: %s" % vm.name)
             try:
@@ -395,12 +396,13 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count_after_delete = account_list[0].cputotal
 
-            self.assertEqual(resource_count_after_delete, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
+            self.assertEqual(resource_count_after_delete, 0,
+                "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
         return
 
     @attr(tags=["advanced", "advancedns","simulator"])
@@ -430,12 +432,12 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
             self.account = admin
             self.domain = domain
 
-       api_client = self.testClient.createUserApiClient(
-                             UserName=self.account.name,
-                             DomainName=self.account.domain)
+            api_client = self.testClient.createUserApiClient(
+                UserName=self.account.name,
+                DomainName=self.account.domain)
 
             self.debug("Creating an instance with service offering: %s" %
-                                                    self.service_offering.name)
+                       self.service_offering.name)
             vm_1 = self.createInstance(service_off=self.service_offering, api_client=api_client)
             vm_2 = self.createInstance(service_off=self.service_offering, api_client=api_client)
             self.createInstance(service_off=self.service_offering, api_client=api_client)
@@ -447,15 +449,15 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count = account_list[0].cputotal
 
             expected_resource_count = int(self.services["service_offering"]["cpunumber"]) * 4 #Total 4 VMs
 
             self.assertEqual(resource_count, expected_resource_count,
-                             "Initial resource count should be 4")
+                "Initial resource count should be 4")
 
             self.debug("Destroying instance: %s" % vm_1.name)
             try:
@@ -465,15 +467,15 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count_after_delete = account_list[0].cputotal
 
             expected_resource_count -= int(self.services["service_offering"]["cpunumber"])
 
             self.assertEqual(resource_count_after_delete, expected_resource_count,
-                            "Resource count should match with the expected count")
+                "Resource count should match with the expected count")
 
             host = find_suitable_host(self.apiclient, vm_2)
             self.debug("Migrating instance: %s to host: %s" % (vm_2.name,
@@ -485,13 +487,13 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
 
             account_list = Account.list(self.apiclient, id=self.account.id)
             self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+                list,
+                "List Accounts should return a valid response"
+            )
             resource_count_after_migrate = account_list[0].cputotal
 
             self.assertEqual(resource_count_after_migrate, resource_count_after_delete,
-                            "Resource count should not change after migrating the instance")
+                "Resource count should not change after migrating the instance")
         return
 
 class TestMultipleChildDomains(cloudstackTestCase):
@@ -542,116 +544,117 @@ class TestMultipleChildDomains(cloudstackTestCase):
     def createInstance(self, account, service_off, networks=None, api_client=None):
         """Creates an instance in account"""
 
-   if api_client is None:
-       api_client = self.apiclient
+        if api_client is None:
+            api_client = self.apiclient
 
-        self.debug("Deploying an instance in account: %s" %
-                                                account.name)
-        try:
-            vm = VirtualMachine.create(
-                                api_client,
-                                self.services["virtual_machine"],
-                                templateid=self.template.id,
-                                accountid=account.name,
-                                domainid=account.domainid,
-                                networkids=networks,
-                                serviceofferingid=service_off.id)
-            vms = VirtualMachine.list(api_client, id=vm.id, listall=True)
-            self.assertIsInstance(vms,
-                                  list,
-                                  "List VMs should return a valid response")
-            self.assertEqual(vms[0].state, "Running",
-                             "Vm state should be running after deployment")
-            return vm
-        except Exception as e:
-            self.fail("Failed to deploy an instance: %s" % e)
+            self.debug("Deploying an instance in account: %s" %
+                       account.name)
+            try:
+                vm = VirtualMachine.create(
+                    api_client,
+                    self.services["virtual_machine"],
+                    templateid=self.template.id,
+                    accountid=account.name,
+                    domainid=account.domainid,
+                    networkids=networks,
+                    serviceofferingid=service_off.id)
+                vms = VirtualMachine.list(api_client, id=vm.id, listall=True)
+                self.assertIsInstance(vms,
+                    list,
+                    "List VMs should return a valid response")
+                self.assertEqual(vms[0].state, "Running",
+                    "Vm state should be running after deployment")
+                return vm
+            except Exception as e:
+                self.fail("Failed to deploy an instance: %s" % e)
 
     def setupAccounts(self):
 
         self.debug("Creating a domain under: %s" % self.domain.name)
-   self.parent_domain = Domain.create(self.apiclient,
-                                services=self.services["domain"],
-                                parentdomainid=self.domain.id)
-   self.parentd_admin = Account.create(
-                    self.apiclient,
-                    self.services["account"],
-                    admin=True,
-                    domainid=self.domain.id
-                    )
-
-   self.debug("Updating the Memory resource limit for domain: %s" %
-                                                    self.domain.name)
-   Resources.updateLimit(self.apiclient,
-                      resourcetype=8,
-                      max=10,
-                      domainid=self.parentd_admin.domainid,
-                      account=self.parentd_admin.name)
-   self.debug("Creating a sub-domain under: %s" % self.parent_domain.name)
-   self.cdomain_1 = Domain.create(self.apiclient,
-                                services=self.services["domain"],
-                                parentdomainid=self.parent_domain.id)
-
-   self.debug("Creating a sub-domain under: %s" % self.parent_domain.name)
-   self.cdomain_2 = Domain.create(self.apiclient,
-                                services=self.services["domain"],
-                                parentdomainid=self.parent_domain.id)
-
-   self.cadmin_1 = Account.create(
-                                self.apiclient,
-                                self.services["account"],
-                                admin=True,
-                                domainid=self.cdomain_1.id
-                                )
-
-   self.debug("Updating the Memory resource count for domain: %s" %
-                                                self.cdomain_1.name)
-   Resources.updateLimit(self.apiclient,
-                      resourcetype=8,
-                      max=4,
-                      domainid=self.cadmin_1.domainid)
+
+        self.parent_domain = Domain.create(self.apiclient,
+            services=self.services["domain"],
+            parentdomainid=self.domain.id)
+        self.parentd_admin = Account.create(
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
+
+        self.debug("Updating the Memory resource limit for domain: %s" %
+                   self.domain.name)
+        Resources.updateLimit(self.apiclient,
+            resourcetype=8,
+            max=10,
+            domainid=self.parentd_admin.domainid,
+            account=self.parentd_admin.name)
+        self.debug("Creating a sub-domain under: %s" % self.parent_domain.name)
+        self.cdomain_1 = Domain.create(self.apiclient,
+            services=self.services["domain"],
+            parentdomainid=self.parent_domain.id)
+
+        self.debug("Creating a sub-domain under: %s" % self.parent_domain.name)
+        self.cdomain_2 = Domain.create(self.apiclient,
+            services=self.services["domain"],
+            parentdomainid=self.parent_domain.id)
+
+        self.cadmin_1 = Account.create(
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.cdomain_1.id
+        )
+
+        self.debug("Updating the Memory resource count for domain: %s" %
+                   self.cdomain_1.name)
+        Resources.updateLimit(self.apiclient,
+            resourcetype=8,
+            max=4,
+            domainid=self.cadmin_1.domainid)
 
         self.debug("Updating the Memory resource count for account: %s" %
-                                                self.cadmin_1.name)
-   Resources.updateLimit(self.apiclient,
-                      resourcetype=8,
-                      max=2,
-                      account=self.cadmin_1.name,
-                      domainid=self.cadmin_1.domainid)
-
-   self.cadmin_2 = Account.create(
-                                self.apiclient,
-                                self.services["account"],
-                                admin=True,
-                                domainid=self.cdomain_2.id
-                                )
+                   self.cadmin_1.name)
+        Resources.updateLimit(self.apiclient,
+            resourcetype=8,
+            max=2,
+            account=self.cadmin_1.name,
+            domainid=self.cadmin_1.domainid)
+
+        self.cadmin_2 = Account.create(
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.cdomain_2.id
+        )
 
         self.debug("Updating the Memory resource count for domain: %s" %
-                                                self.cdomain_2.name)
-   Resources.updateLimit(self.apiclient,
-                      resourcetype=8,
-                      max=5,
-                      domainid=self.cadmin_2.domainid)
+                   self.cdomain_2.name)
+        Resources.updateLimit(self.apiclient,
+            resourcetype=8,
+            max=5,
+            domainid=self.cadmin_2.domainid)
 
         self.debug("Updating the Memory resource count for account: %s" %
-                                                self.cadmin_2.name)
-   Resources.updateLimit(self.apiclient,
-                      resourcetype=8,
-                      max=3,
-                      account=self.cadmin_2.name,
-                      domainid=self.cadmin_2.domainid)
-   # Cleanup the resources created at end of test
-   self.cleanup.append(self.cadmin_1)
-   self.cleanup.append(self.cadmin_2)
-   self.cleanup.append(self.cdomain_1)
-   self.cleanup.append(self.cdomain_2)
-   self.cleanup.append(self.parentd_admin)
-   self.cleanup.append(self.parent_domain)
-
-   users = {
-                self.parent_domain: self.parentd_admin,
+                   self.cadmin_2.name)
+        Resources.updateLimit(self.apiclient,
+            resourcetype=8,
+            max=3,
+            account=self.cadmin_2.name,
+            domainid=self.cadmin_2.domainid)
+        # Cleanup the resources created at end of test
+        self.cleanup.append(self.cadmin_1)
+        self.cleanup.append(self.cadmin_2)
+        self.cleanup.append(self.cdomain_1)
+        self.cleanup.append(self.cdomain_2)
+        self.cleanup.append(self.parentd_admin)
+        self.cleanup.append(self.parent_domain)
+
+        users = {
+            self.parent_domain: self.parentd_admin,
             self.cdomain_1: self.cadmin_1,
             self.cdomain_2: self.cadmin_2
-           }
+        }
         return users
 
     @attr(tags=["advanced", "advancedns","simulator"])
@@ -681,29 +684,29 @@ class TestMultipleChildDomains(cloudstackTestCase):
         self.debug("Setting up account and domain hierarchy")
         self.setupAccounts()
 
-   api_client_cadmin_1 = self.testClient.createUserApiClient(
-                             UserName=self.cadmin_1.name,
-                             DomainName=self.cadmin_1.domain)
+        api_client_cadmin_1 = self.testClient.createUserApiClient(
+            UserName=self.cadmin_1.name,
+            DomainName=self.cadmin_1.domain)
 
-   api_client_cadmin_2 = self.testClient.createUserApiClient(
-                             UserName=self.cadmin_2.name,
-                             DomainName=self.cadmin_2.domain)
+        api_client_cadmin_2 = self.testClient.createUserApiClient(
+            UserName=self.cadmin_2.name,
+            DomainName=self.cadmin_2.domain)
 
         self.debug("Creating an instance with service offering: %s" %
-                                                self.service_offering.name)
+                   self.service_offering.name)
         vm_1 = self.createInstance(account=self.cadmin_1,
-                                  service_off=self.service_offering, api_client=api_client_cadmin_1)
+            service_off=self.service_offering, api_client=api_client_cadmin_1)
 
         vm_2 = self.createInstance(account=self.cadmin_2,
-                                  service_off=self.service_offering, api_client=api_client_cadmin_2)
+            service_off=self.service_offering, api_client=api_client_cadmin_2)
 
         self.debug("Checking resource count for account: %s" % self.cadmin_1.name)
 
         account_list = Account.list(self.apiclient, id=self.cadmin_1.id)
         self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+            list,
+            "List Accounts should return a valid response"
+        )
         resource_count_cadmin_1 = account_list[0].cputotal
 
         self.debug(resource_count_cadmin_1)
@@ -711,9 +714,9 @@ class TestMultipleChildDomains(cloudstackTestCase):
         self.debug("Checking resource count for account: %s" % self.cadmin_2.name)
         account_list = Account.list(self.apiclient, id=self.cadmin_2.id)
         self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+            list,
+            "List Accounts should return a valid response"
+        )
         resource_count_cadmin_2 = account_list[0].cputotal
 
         self.debug(resource_count_cadmin_2)
@@ -722,13 +725,13 @@ class TestMultipleChildDomains(cloudstackTestCase):
             "Creating instance when CPU limit is fully used in child domain 1")
         with self.assertRaises(Exception):
             self.createInstance(account=self.cadmin_1,
-                                  service_off=self.service_offering, api_client=api_client_cadmin_1)
+                service_off=self.service_offering, api_client=api_client_cadmin_1)
 
         self.debug(
             "Creating instance when CPU limit is fully used in child domain 2")
         with self.assertRaises(Exception):
             self.createInstance(account=self.cadmin_2,
-                                  service_off=self.service_offering, api_client=api_client_cadmin_2)
+                service_off=self.service_offering, api_client=api_client_cadmin_2)
         self.debug("Destroying instances: %s, %s" % (vm_1.name, vm_2.name))
         try:
             vm_1.delete(self.apiclient)
@@ -740,22 +743,22 @@ class TestMultipleChildDomains(cloudstackTestCase):
 
         account_list = Account.list(self.apiclient, id=self.cadmin_1.id)
         self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+            list,
+            "List Accounts should return a valid response"
+        )
         resource_count_cadmin_1 = account_list[0].cputotal
 
         self.debug(resource_count_cadmin_1)
-        self.assertEqual(resource_count_cadmin_1, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
+        self.assertEqual(resource_count_cadmin_1, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
 
         self.debug("Checking resource count for account: %s" % self.cadmin_2.name)
         account_list = Account.list(self.apiclient, id=self.cadmin_2.id)
         self.assertIsInstance(account_list,
-                                  list,
-                                  "List Accounts should return a valid response"
-                                  )
+            list,
+            "List Accounts should return a valid response"
+        )
         resource_count_cadmin_2 = account_list[0].cputotal
 
         self.debug(resource_count_cadmin_2)
-        self.assertEqual(resource_count_cadmin_2, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
+        self.assertEqual(resource_count_cadmin_2, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
         return

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fb9521c9/test/integration/component/cpu_limits/test_maximum_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/cpu_limits/test_maximum_limits.py b/test/integration/component/cpu_limits/test_maximum_limits.py
index dec8413..2302504 100644
--- a/test/integration/component/cpu_limits/test_maximum_limits.py
+++ b/test/integration/component/cpu_limits/test_maximum_limits.py
@@ -134,97 +134,96 @@ class TestMaxCPULimits(cloudstackTestCase):
                         project=None, networks=None, api_client=None):
         """Creates an instance in account"""
 
-   if api_client is None:
-       api_client = self.apiclient
-
-        self.debug("Deploying instance")
-        try:
-            if account:
-                vm = VirtualMachine.create(
-                                api_client,
-                                self.services["virtual_machine"],
-                                templateid=self.template.id,
-                                accountid=account.name,
-                                domainid=account.domainid,
-                                networkids=networks,
-                                serviceofferingid=service_off.id)
-            elif project:
-                vm = VirtualMachine.create(
-                                api_client,
-                                self.services["virtual_machine"],
-                                templateid=self.template.id,
-                                projectid=project.id,
-                                networkids=networks,
-                                serviceofferingid=service_off.id)
-            vms = VirtualMachine.list(api_client, id=vm.id, listall=True)
-            self.assertIsInstance(vms,
-                                  list,
-                                  "List VMs should return a valid response")
-            self.assertEqual(vms[0].state, "Running",
-                             "Vm state should be running after deployment")
-            return vm
-        except Exception as e:
-            self.fail("Failed to deploy an instance: %s" % e)
+        if api_client is None:
+            api_client = self.apiclient
+
+            self.debug("Deploying instance")
+            try:
+                if account:
+                    vm = VirtualMachine.create(
+                        api_client,
+                        self.services["virtual_machine"],
+                        templateid=self.template.id,
+                        accountid=account.name,
+                        domainid=account.domainid,
+                        networkids=networks,
+                        serviceofferingid=service_off.id)
+                elif project:
+                    vm = VirtualMachine.create(
+                        api_client,
+                        self.services["virtual_machine"],
+                        templateid=self.template.id,
+                        projectid=project.id,
+                        networkids=networks,
+                        serviceofferingid=service_off.id)
+                vms = VirtualMachine.list(api_client, id=vm.id, listall=True)
+                self.assertIsInstance(vms,
+                    list,
+                    "List VMs should return a valid response")
+                self.assertEqual(vms[0].state, "Running",
+                    "Vm state should be running after deployment")
+                return vm
+            except Exception as e:
+                self.fail("Failed to deploy an instance: %s" % e)
 
     def setupAccounts(self, account_limit=2, domain_limit=2, project_limit=2):
 
-   self.debug("Creating a domain under: %s" % self.domain.name)
-   self.child_domain = Domain.create(self.apiclient,
-                                     services=self.services["domain"],
-                                 parentdomainid=self.domain.id)
-
-
-   self.debug("domain crated with domain id %s" % self.child_domain.id)
-
-   self.child_do_admin = Account.create(self.apiclient,
-                                self.services["account"],
-                                admin=True,
-                                domainid=self.child_domain.id)
-
-   self.debug("domain admin created for domain id %s" %
-                self.child_do_admin.domainid)
-
-   # Create project as a domain admin
-   self.project = Project.create(self.apiclient,
-                             self.services["project"],
-                             account=self.child_do_admin.name,
-                             domainid=self.child_do_admin.domainid)
-   # Cleanup created project at end of test
-   self.cleanup.append(self.project)
-
-   # Cleanup accounts created
-   self.cleanup.append(self.child_do_admin)
-   self.cleanup.append(self.child_domain)
-
-   self.debug("Updating the CPU resource count for domain: %s" %
-                                                self.child_domain.name)
-   # Update resource limits for account 1
-   responses = Resources.updateLimit(self.apiclient,
-                             resourcetype=8,
-                             max=account_limit,
-                             account=self.child_do_admin.name,
-                             domainid=self.child_do_admin.domainid)
-
-   self.debug("CPU Resource count for child domain admin account is now: %s" %
-                                                                 responses.max)
-
-   self.debug("Updating the CPU limit for project")
-   responses = Resources.updateLimit(self.apiclient,
-                             resourcetype=8,
-                             max=project_limit,
-                             projectid=self.project.id)
-
-   self.debug("CPU Resource count for project is now")
-   self.debug(responses.max)
-
-   self.debug("Updating the CPU limit for domain only")
-   responses = Resources.updateLimit(self.apiclient,
-                                 resourcetype=8,
-                             max=domain_limit,
-                             domainid=self.child_domain.id)
-
-   self.debug("CPU Resource count for domain %s with id %s is now %s" %
-                    (responses.domain, responses.domainid, responses.max))
+        self.debug("Creating a domain under: %s" % self.domain.name)
+        self.child_domain = Domain.create(self.apiclient,
+            services=self.services["domain"],
+            parentdomainid=self.domain.id)
+
+        self.debug("domain crated with domain id %s" % self.child_domain.id)
+
+        self.child_do_admin = Account.create(self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.child_domain.id)
+
+        self.debug("domain admin created for domain id %s" %
+                   self.child_do_admin.domainid)
+
+        # Create project as a domain admin
+        self.project = Project.create(self.apiclient,
+            self.services["project"],
+            account=self.child_do_admin.name,
+            domainid=self.child_do_admin.domainid)
+        # Cleanup created project at end of test
+        self.cleanup.append(self.project)
+
+        # Cleanup accounts created
+        self.cleanup.append(self.child_do_admin)
+        self.cleanup.append(self.child_domain)
+
+        self.debug("Updating the CPU resource count for domain: %s" %
+                   self.child_domain.name)
+        # Update resource limits for account 1
+        responses = Resources.updateLimit(self.apiclient,
+            resourcetype=8,
+            max=account_limit,
+            account=self.child_do_admin.name,
+            domainid=self.child_do_admin.domainid)
+
+        self.debug("CPU Resource count for child domain admin account is now: %s" %
+                   responses.max)
+
+        self.debug("Updating the CPU limit for project")
+        responses = Resources.updateLimit(self.apiclient,
+            resourcetype=8,
+            max=project_limit,
+            projectid=self.project.id)
+
+        self.debug("CPU Resource count for project is now")
+        self.debug(responses.max)
+
+        self.debug("Updating the CPU limit for domain only")
+        responses = Resources.updateLimit(self.apiclient,
+            resourcetype=8,
+            max=domain_limit,
+            domainid=self.child_domain.id)
+
+        self.debug("CPU Resource count for domain %s with id %s is now %s" %
+                   (responses.domain, responses.domainid, responses.max))
 
         return
 
@@ -240,24 +239,25 @@ class TestMaxCPULimits(cloudstackTestCase):
         #    with "resource limit exceeds"
 
         self.debug("Creating service offering with 3 CPU cores")
-   self.services["service_offering"]["cpunumber"] = 3
+
+        self.services["service_offering"]["cpunumber"] = 3
         self.service_offering = ServiceOffering.create(
-                                            self.apiclient,
-                                            self.services["service_offering"]
-                                            )
+            self.apiclient,
+            self.services["service_offering"]
+        )
         # Adding to cleanup list after execution
         self.cleanup.append(self.service_offering)
 
         self.debug("Setting up account and domain hierarchy")
         self.setupAccounts(account_limit=4, domain_limit=2)
 
-   api_client_admin = self.testClient.createUserApiClient(
-                           UserName=self.child_do_admin.name,
-                           DomainName=self.child_do_admin.domain)
+        api_client_admin = self.testClient.createUserApiClient(
+            UserName=self.child_do_admin.name,
+            DomainName=self.child_do_admin.domain)
 
         with self.assertRaises(Exception):
             self.createInstance(account=self.child_do_admin,
-                                  service_off=self.service_offering, api_client=api_client_admin)
+                service_off=self.service_offering, api_client=api_client_admin)
         return
 
     @attr(tags=["advanced", "advancedns","simulator"])
@@ -272,32 +272,33 @@ class TestMaxCPULimits(cloudstackTestCase):
         #    with "resource limit exceeds"
 
         self.debug("Creating service offering with 4 CPU cores")
-   self.services["service_offering"]["cpunumber"] = 4
+
+        self.services["service_offering"]["cpunumber"] = 4
         self.service_offering = ServiceOffering.create(
-                                            self.apiclient,
-                                            self.services["service_offering"]
-                                            )
+            self.apiclient,
+            self.services["service_offering"]
+        )
         # Adding to cleanup list after execution
         self.cleanup.append(self.service_offering)
 
         self.debug("Setting up account and domain hierarchy")
         self.setupAccounts(account_limit=6, domain_limit=8)
 
-   api_client_admin = self.testClient.createUserApiClient(
-                             UserName=self.child_do_admin.name,
-                             DomainName=self.child_do_admin.domain)
+        api_client_admin = self.testClient.createUserApiClient(
+            UserName=self.child_do_admin.name,
+            DomainName=self.child_do_admin.domain)
 
-   self.debug("Deploying instance with account: %s" %
-                                                    self.child_do_admin.name)
+        self.debug("Deploying instance with account: %s" %
+                   self.child_do_admin.name)
 
         self.createInstance(account=self.child_do_admin,
-                                  service_off=self.service_offering, api_client=api_client_admin)
+            service_off=self.service_offering, api_client=api_client_admin)
 
         self.debug("Deploying instance when CPU limit is reached in account")
 
         with self.assertRaises(Exception):
             self.createInstance(account=self.chid_do_admin,
-                                  service_off=self.service_offering, api_client=api_client_admin)
+                service_off=self.service_offering, api_client=api_client_admin)
         return
 
     @attr(tags=["advanced", "advancedns","simulator"])
@@ -312,26 +313,27 @@ class TestMaxCPULimits(cloudstackTestCase):
         #    with "resource limit exceeds"
 
         self.debug("Creating service offering with 3 CPU cores")
-   self.services["service_offering"]["cpunumber"] = 3
+
+        self.services["service_offering"]["cpunumber"] = 3
         self.service_offering = ServiceOffering.create(
-                                            self.apiclient,
-                                            self.services["service_offering"]
-                                            )
+            self.apiclient,
+            self.services["service_offering"]
+        )
         # Adding to cleanup list after execution
         self.cleanup.append(self.service_offering)
 
         self.debug("Setting up account and domain hierarchy")
         self.setupAccounts(account_limit=4, domain_limit=4, project_limit=2)
 
-   api_client_admin = self.testClient.createUserApiClient(
-                             UserName=self.child_do_admin.name,
-                             DomainName=self.child_do_admin.domain)
+        api_client_admin = self.testClient.createUserApiClient(
+            UserName=self.child_do_admin.name,
+            DomainName=self.child_do_admin.domain)
 
         self.debug("Deploying instance in account 2 when CPU limit is reached")
 
         with self.assertRaises(Exception):
             self.createInstance(project=self.project,
-                                  service_off=self.service_offering, api_client=api_client_admin)
+                service_off=self.service_offering, api_client=api_client_admin)
         return
 
     @attr(tags=["advanced", "advancedns","simulator"])
@@ -346,29 +348,30 @@ class TestMaxCPULimits(cloudstackTestCase):
         #    with "resource limit exceeds"
 
         self.debug("Creating service offering with 4 CPU cores")
-   self.services["service_offering"]["cpunumber"] = 4
+
+        self.services["service_offering"]["cpunumber"] = 4
         self.service_offering = ServiceOffering.create(
-                                            self.apiclient,
-                                            self.services["service_offering"]
-                                            )
+            self.apiclient,
+            self.services["service_offering"]
+        )
         # Adding to cleanup list after execution
         self.cleanup.append(self.service_offering)
 
         self.debug("Setting up account and domain hierarchy")
         self.setupAccounts(account_limit=6, domain_limit=6, project_limit=6)
 
-   api_client_admin = self.testClient.createUserApiClient(
-                             UserName=self.child_do_admin.name,
-                             DomainName=self.child_do_admin.domain)
+        api_client_admin = self.testClient.createUserApiClient(
+            UserName=self.child_do_admin.name,
+            DomainName=self.child_do_admin.domain)
 
         self.debug("Deploying instance with account: %s" %
-                                                    self.child_do_admin.name)
+                   self.child_do_admin.name)
         self.createInstance(account=self.child_do_admin,
-                                  service_off=self.service_offering, api_client=api_client_admin)
+            service_off=self.service_offering, api_client=api_client_admin)
 
         self.debug("Deploying instance in project when CPU limit is reached in account")
 
         with self.assertRaises(Exception):
             self.createInstance(project=self.project,
-                                  service_off=self.service_offering)
+                service_off=self.service_offering)
         return

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fb9521c9/test/integration/component/cpu_limits/test_project_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/cpu_limits/test_project_limits.py b/test/integration/component/cpu_limits/test_project_limits.py
index 9bf3328..3c432db 100644
--- a/test/integration/component/cpu_limits/test_project_limits.py
+++ b/test/integration/component/cpu_limits/test_project_limits.py
@@ -136,14 +136,14 @@ class TestProjectsCPULimits(cloudstackTestCase):
         self.debug("Setting up account and domain hierarchy")
         self.setupProjectAccounts()
 
-   api_client = self.testClient.createUserApiClient(
-                             UserName=self.admin.name,
-                             DomainName=self.admin.domain)
+        api_client = self.testClient.createUserApiClient(
+            UserName=self.admin.name,
+            DomainName=self.admin.domain)
 
         self.debug("Creating an instance with service offering: %s" %
-                                                    self.service_offering.name)
+                   self.service_offering.name)
         self.vm = self.createInstance(project=self.project,
-                                  service_off=self.service_offering, api_client=api_client)
+            service_off=self.service_offering, api_client=api_client)
 
         return
 
@@ -159,26 +159,26 @@ class TestProjectsCPULimits(cloudstackTestCase):
     def createInstance(self, project, service_off, networks=None, api_client=None):
         """Creates an instance in account"""
 
-   if api_client is None:
-       api_client = self.api_client
-
-        try:
-            self.vm = VirtualMachine.create(
-                                api_client,
-                                self.services["virtual_machine"],
-                                templateid=self.template.id,
-                                projectid=project.id,
-                                networkids=networks,
-                                serviceofferingid=service_off.id)
-            vms = VirtualMachine.list(api_client, id=self.vm.id, listall=True)
-            self.assertIsInstance(vms,
-                                  list,
-                                  "List VMs should return a valid response")
-            self.assertEqual(vms[0].state, "Running",
-                             "Vm state should be running after deployment")
-            return self.vm
-        except Exception as e:
-            self.fail("Failed to deploy an instance: %s" % e)
+        if api_client is None:
+            api_client = self.api_client
+
+            try:
+                self.vm = VirtualMachine.create(
+                    api_client,
+                    self.services["virtual_machine"],
+                    templateid=self.template.id,
+                    projectid=project.id,
+                    networkids=networks,
+                    serviceofferingid=service_off.id)
+                vms = VirtualMachine.list(api_client, id=self.vm.id, listall=True)
+                self.assertIsInstance(vms,
+                    list,
+                    "List VMs should return a valid response")
+                self.assertEqual(vms[0].state, "Running",
+                    "Vm state should be running after deployment")
+                return self.vm
+            except Exception as e:
+                self.fail("Failed to deploy an instance: %s" % e)
 
     def setupProjectAccounts(self):
 


Mime
View raw message