You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2014/07/28 17:41:26 UTC

[09/18] Marvin + test changes from master Signed-off-by: SrikanteswaraRao Talluri

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_vm_iam.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vm_iam.py b/test/integration/smoke/test_vm_iam.py
new file mode 100644
index 0000000..be75a79
--- /dev/null
+++ b/test/integration/smoke/test_vm_iam.py
@@ -0,0 +1,719 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# 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
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+""" BVT tests for Virtual Machine IAM effect
+"""
+#Import Local Modules
+import marvin
+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.codes import FAILED
+from nose.plugins.attrib import attr
+#Import System modules
+import time
+
+_multiprocess_shared_ = True
+class Services:
+    """Test VM Life Cycle Services
+    """
+
+    def __init__(self):
+        self.services = {
+            #data for domains and accounts
+            "domain1": {
+                "name": "Domain1",
+             },
+            "account1A": {
+                "email": "test1A@test.com",
+                "firstname": "test1A",
+                "lastname": "User",
+                "username": "test1A",
+                "password": "password",
+            },
+            "account1B": {
+                "email": "test1B@test.com",
+                "firstname": "test1B",
+                "lastname": "User",
+                "username": "test1B",
+                "password": "password",
+            },                         
+            "domain2": {
+                "name": "Domain2",
+             },
+            "account2A": {
+                "email": "test2A@test.com",
+                "firstname": "test2A",
+                "lastname": "User",
+                "username": "test2A",
+                "password": "password",
+            },
+            #data reqd for virtual machine creation
+            "virtual_machine1A" : {
+                "name" : "test1Avm",
+                "displayname" : "Test1A  VM",
+            },
+            "virtual_machine1B" : {
+                "name" : "test1Bvm",
+                "displayname" : "Test1B  VM",
+            }, 
+            "virtual_machine2A" : {
+                "name" : "test2Avm",
+                "displayname" : "Test2A  VM",
+            },                                                 
+            #small service offering
+            "service_offering": {
+                "small": {
+                    "name": "Small Instance",
+                    "displaytext": "Small Instance",
+                    "cpunumber": 1,
+                    "cpuspeed": 100,
+                    "memory": 128,
+                },
+            },
+            "ostype": 'CentOS 5.6 (64-bit)',
+            # iam group and policy information
+            "service_desk_iam_grp" : {
+                "name" : "Service Desk",
+                "description" : "Service Desk IAM Group"
+            },
+            "vm_readonly_iam_policy" : {
+                "name" : "VM Read Only Access",
+                "description" : "VM read only access iam policy"
+            },
+        }
+
+
+
+class TestVMIam(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(self):
+        testClient = super(TestVMIam, self).getClsTestClient()
+        self.apiclient = testClient.getApiClient()
+        self.services = Services().services
+        
+        # backup default apikey and secretkey
+        self.default_apikey = self.apiclient.connection.apiKey
+        self.default_secretkey = self.apiclient.connection.securityKey
+
+        # Create domains and accounts etc
+        self.domain_1 = Domain.create(
+                                   self.apiclient,
+                                   self.services["domain1"]
+                                   )
+        self.domain_2 = Domain.create(
+                                   self.apiclient,
+                                   self.services["domain2"]
+                                   )
+        # Create two accounts for doamin_1
+        self.account_1A = Account.create(
+                            self.apiclient,
+                            self.services["account1A"],
+                            admin=False,
+                            domainid=self.domain_1.id
+                            )
+        
+        self.account_1B = Account.create(
+                            self.apiclient,
+                            self.services["account1B"],
+                            admin=False,
+                            domainid=self.domain_1.id
+                            )        
+
+        # Create an account for domain_2
+        self.account_2A = Account.create(
+                            self.apiclient,
+                            self.services["account2A"],
+                            admin=False,
+                            domainid=self.domain_2.id
+                            )
+        
+        # Fetch user details to register apiKey for them
+        self.user_1A = User.list(
+                          self.apiclient,
+                          account=self.account_1A.name,
+                          domainid=self.account_1A.domainid
+                          )[0]
+       
+        user_1A_key = User.registerUserKeys(
+                        self.apiclient,
+                        self.user_1A.id
+                      )  
+        self.user_1A_apikey = user_1A_key.apikey
+        self.user_1A_secretkey = user_1A_key.secretkey
+        
+                         
+        self.user_1B = User.list(
+                          self.apiclient,
+                          account=self.account_1B.name,
+                          domainid=self.account_1B.domainid
+                          )[0]
+       
+        user_1B_key = User.registerUserKeys(
+                        self.apiclient,
+                        self.user_1B.id
+                      )  
+       
+        self.user_1B_apikey = user_1B_key.apikey
+        self.user_1B_secretkey = user_1B_key.secretkey                    
+
+ 
+        self.user_2A = User.list(
+                          self.apiclient,
+                          account=self.account_2A.name,
+                          domainid=self.account_2A.domainid
+                          )[0]
+       
+        user_2A_key = User.registerUserKeys(
+                        self.apiclient,
+                        self.user_2A.id
+                      )  
+        self.user_2A_apikey = user_2A_key.apikey
+        self.user_2A_secretkey = user_2A_key.secretkey
+                
+        # create service offering
+        self.service_offering = ServiceOffering.create(
+                                self.apiclient,
+                                self.services["service_offering"]["small"]
+                                )
+        
+        self.zone = get_zone(self.apiclient, testClient.getZoneForTests())
+        self.services['mode'] = self.zone.networktype
+        self.template = get_template(self.apiclient, self.zone.id, self.services["ostype"])
+
+        # deploy 3 VMs for three accounts
+        self.virtual_machine_1A = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine1A"],
+            accountid=self.account_1A.name,
+            zoneid=self.zone.id,
+            domainid=self.account_1A.domainid,
+            serviceofferingid=self.service_offering.id,
+            templateid=self.template.id
+        )  
+        
+        self.virtual_machine_1B = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine1B"],
+            accountid=self.account_1B.name,
+            zoneid=self.zone.id,
+            domainid=self.account_1B.domainid,
+            serviceofferingid=self.service_offering.id,
+            templateid=self.template.id
+        )  
+        
+        self.virtual_machine_2A = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine2A"],
+            accountid=self.account_2A.name,
+            zoneid=self.zone.id,
+            domainid=self.account_2A.domainid,
+            serviceofferingid=self.service_offering.id,
+            templateid=self.template.id
+        )   
+        
+        self.srv_desk_grp = IAMGroup.create(
+            self.apiclient, 
+            self.services["service_desk_iam_grp"]
+        )                             
+
+        self.vm_read_policy = IAMPolicy.create(
+            self.apiclient, 
+            self.services["vm_readonly_iam_policy"]
+        )
+        
+        self.srv_desk_grp.attachPolicy(
+            self.apiclient, [self.vm_read_policy]
+        )
+        
+        vm_grant_policy_params = {}
+        vm_grant_policy_params['name'] = "policyGrantVirtualMachine" + self.virtual_machine_1A.id
+        vm_grant_policy_params['description'] = "Policy to grant permission to VirtualMachine " + self.virtual_machine_1A.id
+        self.vm_grant_policy = IAMPolicy.create(
+            self.apiclient, 
+            vm_grant_policy_params
+        )   
+        
+        self._cleanup = [
+                        self.account_1A,
+                        self.account_1B,
+                        self.domain_1,
+                        self.account_2A,
+                        self.domain_2,
+                        self.service_offering,
+                        self.vm_read_policy,
+                        self.srv_desk_grp,
+                        self.vm_grant_policy
+                        ]
+
+    @classmethod
+    def tearDownClass(self):
+        self.apiclient = super(TestVMIam, self).getClsTestClient().getApiClient()
+        cleanup_resources(self.apiclient, self._cleanup)
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.cleanup = []
+
+    def tearDown(self):
+        # restore back default apikey and secretkey
+        self.apiclient.connection.apiKey = self.default_apikey
+        self.apiclient.connection.securityKey = self.default_secretkey
+        cleanup_resources(self.apiclient, self.cleanup)
+        return
+
+    
+
+    @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+    def test_01_list_own_vm(self):
+        #  listVM command should return owne's VM
+
+        self.debug("Listing VM for account: %s" % self.account_1A.name)
+
+        self.apiclient.connection.apiKey = self.user_1A_apikey
+        self.apiclient.connection.securityKey = self.user_1A_secretkey
+        list_vm_response = list_virtual_machines(
+                                            self.apiclient
+                                            )
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                            len(list_vm_response),
+                            1,
+                            "Check VM available in List Virtual Machines"
+                        )
+
+        self.assertEqual(
+            list_vm_response[0].name,
+            self.virtual_machine_1A.name,
+            "Virtual Machine names do not match"
+        )
+
+        self.debug("Listing VM for account: %s" % self.account_1B.name)
+        self.apiclient.connection.apiKey = self.user_1B_apikey
+        self.apiclient.connection.securityKey = self.user_1B_secretkey
+        list_vm_response = list_virtual_machines(
+                                            self.apiclient
+                                            )
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                            len(list_vm_response),
+                            1,
+                            "Check VM available in List Virtual Machines"
+                        )
+
+        self.assertEqual(
+            list_vm_response[0].name,
+            self.virtual_machine_1B.name,
+            "Virtual Machine names do not match"
+        )
+        
+        self.debug("Listing VM for account: %s" % self.account_2A.name)
+
+        self.apiclient.connection.apiKey = self.user_2A_apikey
+        self.apiclient.connection.securityKey = self.user_2A_secretkey
+        list_vm_response = list_virtual_machines(
+                                            self.apiclient
+                                            )
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                            len(list_vm_response),
+                            1,
+                            "Check VM available in List Virtual Machines"
+                        )
+
+        self.assertEqual(
+            list_vm_response[0].name,
+            self.virtual_machine_2A.name,
+            "Virtual Machine names do not match"
+        )
+                
+        return
+        
+    @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+    def test_02_grant_domain_vm(self):
+ 
+        # Validate the following
+        # 1. Grant domain2 VM access to account_1B
+        # 2. listVM command should return account_1B and domain_2 VMs.
+
+        self.debug("Granting Domain %s VM read only access to account: %s" % (self.domain_2.name, self.account_1B.name))
+        
+        self.srv_desk_grp.addAccount(self.apiclient, [self.account_1B])
+        domain_permission = {}
+        domain_permission['action'] = "listVirtualMachines"
+        domain_permission['entitytype'] = "VirtualMachine"
+        domain_permission['scope'] = "DOMAIN"
+        domain_permission['scopeid'] = self.domain_2.id
+        self.vm_read_policy.addPermission(self.apiclient, domain_permission)
+        
+        self.debug("Listing VM for account: %s" % self.account_1B.name)
+        self.apiclient.connection.apiKey = self.user_1B_apikey
+        self.apiclient.connection.securityKey = self.user_1B_secretkey
+        list_vm_response = list_virtual_machines(
+                                            self.apiclient
+                                            )
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                            len(list_vm_response),
+                            2,
+                            "Check VM available in List Virtual Machines"
+                        )
+
+        list_vm_names = [list_vm_response[0].name, list_vm_response[1].name]
+        
+        self.assertEqual( self.virtual_machine_1B.name in list_vm_names,
+                          True,
+                          "Accessible Virtual Machine names do not match"
+                          )
+        
+        self.assertEqual( self.virtual_machine_2A.name in list_vm_names,
+                          True,
+                          "Accessible Virtual Machine names do not match"
+                          )        
+        
+        return
+
+
+    @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+    def test_03_grant_account_vm(self):
+ 
+        # Validate the following
+        # 1. Grant account_1A VM access to account_1B
+        # 2. listVM command should return account_1A and account_1B VMs.
+
+        self.debug("Granting Account %s VM read only access to account: %s" % (self.account_1A.name, self.account_1B.name))
+        
+        account_permission = {}
+        account_permission['action'] = "listVirtualMachines"
+        account_permission['entitytype'] = "VirtualMachine"
+        account_permission['scope'] = "ACCOUNT"
+        account_permission['scopeid'] = self.account_1A.id
+        self.vm_read_policy.addPermission(self.apiclient, account_permission)
+        
+        self.debug("Listing VM for account: %s" % self.account_1B.name)
+        self.apiclient.connection.apiKey = self.user_1B_apikey
+        self.apiclient.connection.securityKey = self.user_1B_secretkey
+        list_vm_response = list_virtual_machines(
+                                            self.apiclient
+                                            )
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                            len(list_vm_response),
+                            3,
+                            "Check VM available in List Virtual Machines"
+                        )
+
+        list_vm_names = [list_vm_response[0].name, list_vm_response[1].name, list_vm_response[2].name]
+        
+        self.assertEqual( self.virtual_machine_1B.name in list_vm_names,
+                          True,
+                          "Accessible Virtual Machine names do not match"
+                          )
+        
+        self.assertEqual( self.virtual_machine_1A.name in list_vm_names,
+                          True,
+                          "Accessible Virtual Machine names do not match"
+                          )    
+                
+        self.assertEqual( self.virtual_machine_2A.name in list_vm_names,
+                          True,
+                          "Accessible Virtual Machine names do not match"
+                          )        
+        
+        return
+
+
+    @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+    def test_04_revoke_account_vm(self):
+ 
+        # Validate the following
+        # 1. Revoke account_1A VM access from account_1B
+        # 2. listVM command should not return account_1A VMs.
+
+        self.debug("Revoking Account %s VM read only access from account: %s" % (self.account_1A.name, self.account_1B.name))
+        
+        account_permission = {}
+        account_permission['action'] = "listVirtualMachines"
+        account_permission['entitytype'] = "VirtualMachine"
+        account_permission['scope'] = "ACCOUNT"
+        account_permission['scopeid'] = self.account_1A.id
+        self.vm_read_policy.removePermission(self.apiclient, account_permission)
+        
+        self.debug("Listing VM for account: %s" % self.account_1B.name)
+        self.apiclient.connection.apiKey = self.user_1B_apikey
+        self.apiclient.connection.securityKey = self.user_1B_secretkey
+        list_vm_response = list_virtual_machines(
+                                            self.apiclient
+                                            )
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                            len(list_vm_response),
+                            2,
+                            "Check VM available in List Virtual Machines"
+                        )
+
+        list_vm_names = [list_vm_response[0].name, list_vm_response[1].name]
+        
+       
+        self.assertEqual( self.virtual_machine_1A.name in list_vm_names,
+                          False,
+                          "Accessible Virtual Machine names do not match"
+                          )    
+        return
+    
+    
+    @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+    def test_05_revoke_domain_vm(self):
+ 
+        # Validate the following
+        # 1. Revoke account_1A VM access from account_1B
+        # 2. listVM command should not return account_1A VMs.
+
+        self.debug("Revoking Domain %s VM read only access from account: %s" % (self.domain_1.name, self.account_1B.name))
+        
+        domain_permission = {}
+        domain_permission['action'] = "listVirtualMachines"
+        domain_permission['entitytype'] = "VirtualMachine"
+        domain_permission['scope'] = "DOMAIN"
+        domain_permission['scopeid'] = self.domain_2.id
+        self.vm_read_policy.removePermission(self.apiclient, domain_permission)
+        
+        self.debug("Listing VM for account: %s" % self.account_1B.name)
+        self.apiclient.connection.apiKey = self.user_1B_apikey
+        self.apiclient.connection.securityKey = self.user_1B_secretkey
+        list_vm_response = list_virtual_machines(
+                                            self.apiclient
+                                            )
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                            len(list_vm_response),
+                            1,
+                            "Check VM available in List Virtual Machines"
+                        )
+
+        self.assertEqual(
+            list_vm_response[0].name,
+            self.virtual_machine_1B.name,
+            "Virtual Machine names do not match"
+        )
+         
+        return    
+    
+    @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+    def test_06_grant_resource_vm(self):
+ 
+        # Validate the following
+        # 1. Grant a particular vm access to account_1B
+        # 2. listVM command should return account_1B VMs and granted VM.
+
+        self.debug("Granting VM %s read only access to account: %s" % (self.virtual_machine_1A.name, self.account_1B.name))
+        
+        res_permission = {}
+        res_permission['action'] = "listVirtualMachines"
+        res_permission['entitytype'] = "VirtualMachine"
+        res_permission['scope'] = "RESOURCE"
+        res_permission['scopeid'] = self.virtual_machine_1A.id
+        self.vm_read_policy.addPermission(self.apiclient, res_permission)
+        
+        self.debug("Listing VM for account: %s" % self.account_1B.name)
+        self.apiclient.connection.apiKey = self.user_1B_apikey
+        self.apiclient.connection.securityKey = self.user_1B_secretkey
+        list_vm_response = list_virtual_machines(
+                                            self.apiclient
+                                            )
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                            len(list_vm_response),
+                            2,
+                            "Check VM available in List Virtual Machines"
+                        )
+
+        list_vm_names = [list_vm_response[0].name, list_vm_response[1].name]
+        
+        self.assertEqual( self.virtual_machine_1B.name in list_vm_names,
+                          True,
+                          "Accessible Virtual Machine names do not match"
+                          )
+        
+        self.assertEqual( self.virtual_machine_1A.name in list_vm_names,
+                          True,
+                          "Accessible Virtual Machine names do not match"
+                          )    
+                
+        return    
+    
+    @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+    def test_07_revoke_resource_vm(self):
+ 
+        # Validate the following
+        # 1. Grant a particular vm access to account_1B
+        # 2. listVM command should return account_1B VMs and granted VM.
+
+        self.debug("Revoking VM %s read only access from account: %s" % (self.virtual_machine_1A.name, self.account_1B.name))
+        
+        res_permission = {}
+        res_permission['action'] = "listVirtualMachines"
+        res_permission['entitytype'] = "VirtualMachine"
+        res_permission['scope'] = "RESOURCE"
+        res_permission['scopeid'] = self.virtual_machine_1A.id
+        self.vm_read_policy.removePermission(self.apiclient, res_permission)
+        
+        self.debug("Listing VM for account: %s" % self.account_1B.id)
+        self.apiclient.connection.apiKey = self.user_1B_apikey
+        self.apiclient.connection.securityKey = self.user_1B_secretkey
+        list_vm_response = list_virtual_machines(
+                                            self.apiclient
+                                            )
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                            len(list_vm_response),
+                            1,
+                            "Check VM available in List Virtual Machines"
+                        )
+
+        self.assertEqual(
+            list_vm_response[0].name,
+            self.virtual_machine_1B.name,
+            "Virtual Machine names do not match"
+        )
+        
+        return      
+    
+    
+    @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+    def test_08_policy_attach_account(self):
+ 
+        # Validate the following
+        # 1. Grant a particular vm access to account_1B by directly attaching policy to account
+        # 2. listVM command should return account_1B VMs and granted VM.
+
+        self.debug("Granting VM %s read only access to account: %s by attaching policy to account" % (self.virtual_machine_1A.name, self.account_1B.name))
+        
+        res_permission = {}
+        res_permission['action'] = "listVirtualMachines"
+        res_permission['entitytype'] = "VirtualMachine"
+        res_permission['scope'] = "RESOURCE"
+        res_permission['scopeid'] = self.virtual_machine_1A.id
+        self.vm_grant_policy.addPermission(self.apiclient, res_permission)
+        self.vm_grant_policy.attachAccount(self.apiclient, [self.account_1B])
+        
+        self.debug("Listing VM for account: %s" % self.account_1B.id)
+        self.apiclient.connection.apiKey = self.user_1B_apikey
+        self.apiclient.connection.securityKey = self.user_1B_secretkey
+        list_vm_response = list_virtual_machines(
+                                            self.apiclient
+                                            )
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                            len(list_vm_response),
+                            2,
+                            "Check VM available in List Virtual Machines"
+                        )
+
+        list_vm_names = [list_vm_response[0].name, list_vm_response[1].name]
+        
+        self.assertEqual( self.virtual_machine_1B.name in list_vm_names,
+                          True,
+                          "Accessible Virtual Machine names do not match"
+                          )
+        
+        self.assertEqual( self.virtual_machine_1A.name in list_vm_names,
+                          True,
+                          "Accessible Virtual Machine names do not match"
+                          )    
+                
+        return     
+    
+    @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+    def test_09_policy_detach_account(self):
+ 
+        # Validate the following
+        # 1. Revoking a particular vm access from account_1B by detaching policy from account
+        # 2. listVM command should return account_1B VMs.
+
+        self.debug("Revoking VM %s read only access from account: %s by detaching policy from account" % (self.virtual_machine_1A.name, self.account_1B.name))
+        
+        self.vm_grant_policy.detachAccount(self.apiclient, [self.account_1B])
+        
+        self.debug("Listing VM for account: %s" % self.account_1B.id)
+        self.apiclient.connection.apiKey = self.user_1B_apikey
+        self.apiclient.connection.securityKey = self.user_1B_secretkey
+        list_vm_response = list_virtual_machines(
+                                            self.apiclient
+                                            )
+        self.assertEqual(
+                            isinstance(list_vm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                            len(list_vm_response),
+                            1,
+                            "Check VM available in List Virtual Machines"
+                        )
+
+        self.assertEqual(
+            list_vm_response[0].name,
+            self.virtual_machine_1B.name,
+            "Virtual Machine names do not match"
+        )
+        
+        return         
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_vm_life_cycle.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py
index 7d47f70..f114ec9 100644
--- a/test/integration/smoke/test_vm_life_cycle.py
+++ b/test/integration/smoke/test_vm_life_cycle.py
@@ -18,138 +18,28 @@
 """
 #Import Local Modules
 from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.cloudstackAPI import (detachIso,
-                                  attachIso,
-                                  recoverVirtualMachine,
-                                  destroyVirtualMachine)
-from marvin.integration.lib.utils import (cleanup_resources,
-                                           validateList,
-                                           get_hypervisor_type)
-from marvin.integration.lib.base import (Account,
-                                         ServiceOffering,
-                                         VirtualMachine,
-                                         Iso,
-                                         Host)
-from marvin.integration.lib.common import (get_domain,
-                                           get_zone,
-                                           get_template,
-                                           list_virtual_machines,
-                                           list_configurations,
-                                           list_routers,
-                                           list_isos)
-from marvin.codes import PASS
+from marvin.codes import FAILED
+from marvin.cloudstackTestCase import *
+from marvin.cloudstackAPI import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
 from nose.plugins.attrib import attr
 #Import System modules
 import time
 
 _multiprocess_shared_ = True
-class Services:
-    """Test VM Life Cycle Services
-    """
-
-    def __init__(self):
-        self.services = {
-                "disk_offering":{
-                    "displaytext": "Small",
-                    "name": "Small",
-                    "disksize": 1
-                },
-                "account": {
-                    "email": "test@test.com",
-                    "firstname": "Test",
-                    "lastname": "User",
-                    "username": "test",
-                    # Random characters are appended in create account to
-                    # ensure unique username generated each time
-                    "password": "password",
-                },
-                "small":
-                # Create a small virtual machine instance with disk offering
-                {
-                    "displayname": "testserver",
-                    "username": "root", # VM creds for SSH
-                    "password": "password",
-                    "ssh_port": 22,
-                    "hypervisor": 'XenServer',
-                    "privateport": 22,
-                    "publicport": 22,
-                    "protocol": 'TCP',
-                },
-                "medium":   # Create a medium virtual machine instance
-                {
-                    "displayname": "testserver",
-                    "username": "root",
-                    "password": "password",
-                    "ssh_port": 22,
-                    "hypervisor": 'XenServer',
-                    "privateport": 22,
-                    "publicport": 22,
-                    "protocol": 'TCP',
-                },
-                "service_offerings":
-                {
-                 "tiny":
-                   {
-                        "name": "Tiny Instance",
-                        "displaytext": "Tiny Instance",
-                        "cpunumber": 1,
-                        "cpuspeed": 100, # in MHz
-                        "memory": 128, # In MBs
-                    },
-                 "small":
-                    {
-                     # Small service offering ID to for change VM
-                     # service offering from medium to small
-                        "name": "Small Instance",
-                        "displaytext": "Small Instance",
-                        "cpunumber": 1,
-                        "cpuspeed": 100,
-                        "memory": 256,
-                    },
-                "medium":
-                    {
-                    # Medium service offering ID to for
-                    # change VM service offering from small to medium
-                        "name": "Medium Instance",
-                        "displaytext": "Medium Instance",
-                        "cpunumber": 1,
-                        "cpuspeed": 100,
-                        "memory": 256,
-                    }
-                },
-                "iso":  # ISO settings for Attach/Detach ISO tests
-                {
-                    "displaytext": "Test ISO",
-                    "name": "testISO",
-                    "url": "http://people.apache.org/~tsp/dummy.iso",
-                     # Source URL where ISO is located
-                    "ostype": 'CentOS 5.3 (64-bit)',
-                    "mode": 'HTTP_DOWNLOAD', # Downloading existing ISO
-                },
-                "template": {
-                    "displaytext": "Cent OS Template",
-                    "name": "Cent OS Template",
-                    "passwordenabled": True,
-                },
-            "diskdevice": ['/dev/vdc',  '/dev/vdb', '/dev/hdb', '/dev/hdc', '/dev/xvdd', '/dev/cdrom', '/dev/sr0', '/dev/cdrom1' ],
-            # Disk device where ISO is attached to instance
-            "mount_dir": "/mnt/tmp",
-            "sleep": 60,
-            "timeout": 10,
-            #Migrate VM to hostid
-            "ostype": 'CentOS 5.3 (64-bit)',
-            # CentOS 5.3 (64-bit)
-        }
-
 class TestDeployVM(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.services = Services().services
-        cls.apiclient = super(TestDeployVM, cls).getClsTestClient().getApiClient()
+        testClient = super(TestDeployVM, cls).getClsTestClient()
+        cls.apiclient = testClient.getApiClient()
+        cls.services = testClient.getParsedTestDataConfig()
+
         # Get Zone, Domain and templates
-        domain = get_domain(cls.apiclient, cls.services)
-        cls.zone = get_zone(cls.apiclient, cls.services)
+        domain = get_domain(cls.apiclient)
+        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
 
         #If local storage is enabled, alter the offerings to use localstorage
@@ -164,13 +54,16 @@ class TestDeployVM(cloudstackTestCase):
             cls.zone.id,
             cls.services["ostype"]
         )
+        if template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
         # Set Zones and disk offerings
         cls.services["small"]["zoneid"] = cls.zone.id
         cls.services["small"]["template"] = template.id
 
         cls.services["medium"]["zoneid"] = cls.zone.id
         cls.services["medium"]["template"] = template.id
-        cls.services["iso"]["zoneid"] = cls.zone.id
+        cls.services["iso1"]["zoneid"] = cls.zone.id
 
         cls.account = Account.create(
             cls.apiclient,
@@ -303,12 +196,13 @@ class TestVMLifeCycle(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestVMLifeCycle, cls).getClsTestClient().getApiClient()
-        cls.services = Services().services
+        testClient = super(TestVMLifeCycle, cls).getClsTestClient()
+        cls.apiclient = testClient.getApiClient()
+        cls.services = testClient.getParsedTestDataConfig()
 
         # Get Zone, Domain and templates
-        domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        domain = get_domain(cls.apiclient)
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
 
         #if local storage is enabled, alter the offerings to use localstorage
@@ -319,37 +213,40 @@ class TestVMLifeCycle(cloudstackTestCase):
             cls.services["service_offerings"]["medium"]["storagetype"] = 'local'
 
         template = get_template(
-                            cls.api_client,
+                            cls.apiclient,
                             cls.zone.id,
                             cls.services["ostype"]
                             )
+        if template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
         # Set Zones and disk offerings
         cls.services["small"]["zoneid"] = cls.zone.id
         cls.services["small"]["template"] = template.id
 
         cls.services["medium"]["zoneid"] = cls.zone.id
         cls.services["medium"]["template"] = template.id
-        cls.services["iso"]["zoneid"] = cls.zone.id
+        cls.services["iso1"]["zoneid"] = cls.zone.id
 
         # Create VMs, NAT Rules etc
         cls.account = Account.create(
-                            cls.api_client,
+                            cls.apiclient,
                             cls.services["account"],
                             domainid=domain.id
                             )
 
         cls.small_offering = ServiceOffering.create(
-                                    cls.api_client,
+                                    cls.apiclient,
                                     cls.services["service_offerings"]["small"]
                                     )
 
         cls.medium_offering = ServiceOffering.create(
-                                    cls.api_client,
+                                    cls.apiclient,
                                     cls.services["service_offerings"]["medium"]
                                     )
         #create small and large virtual machines
         cls.small_virtual_machine = VirtualMachine.create(
-                                        cls.api_client,
+                                        cls.apiclient,
                                         cls.services["small"],
                                         accountid=cls.account.name,
                                         domainid=cls.account.domainid,
@@ -357,7 +254,7 @@ class TestVMLifeCycle(cloudstackTestCase):
                                         mode=cls.services["mode"]
                                         )
         cls.medium_virtual_machine = VirtualMachine.create(
-                                       cls.api_client,
+                                       cls.apiclient,
                                        cls.services["medium"],
                                        accountid=cls.account.name,
                                        domainid=cls.account.domainid,
@@ -365,7 +262,7 @@ class TestVMLifeCycle(cloudstackTestCase):
                                        mode=cls.services["mode"]
                                     )
         cls.virtual_machine = VirtualMachine.create(
-                                        cls.api_client,
+                                        cls.apiclient,
                                         cls.services["small"],
                                         accountid=cls.account.name,
                                         domainid=cls.account.domainid,
@@ -380,8 +277,8 @@ class TestVMLifeCycle(cloudstackTestCase):
 
     @classmethod
     def tearDownClass(cls):
-        cls.api_client = super(TestVMLifeCycle, cls).getClsTestClient().getApiClient()
-        cleanup_resources(cls.api_client, cls._cleanup)
+        cls.apiclient = super(TestVMLifeCycle, cls).getClsTestClient().getApiClient()
+        cleanup_resources(cls.apiclient, cls._cleanup)
         return
 
     def setUp(self):
@@ -628,7 +525,7 @@ class TestVMLifeCycle(cloudstackTestCase):
 
         #deploy VM on target host
         self.vm_to_migrate = VirtualMachine.create(
-            self.api_client,
+            self.apiclient,
             self.services["small"],
             accountid=self.account.name,
             domainid=self.account.domainid,
@@ -641,7 +538,7 @@ class TestVMLifeCycle(cloudstackTestCase):
                                         migrate_host.id
                                         ))
 
-        self.vm_to_migrate.migrate(self.api_client, migrate_host.id)
+        self.vm_to_migrate.migrate(self.apiclient, migrate_host.id)
 
         list_vm_response = list_virtual_machines(
                                             self.apiclient,
@@ -733,7 +630,7 @@ class TestVMLifeCycle(cloudstackTestCase):
 
         iso = Iso.create(
                          self.apiclient,
-                         self.services["iso"],
+                         self.services["iso1"],
                          account=self.account.name,
                          domainid=self.account.domainid
                          )
@@ -760,12 +657,13 @@ class TestVMLifeCycle(cloudstackTestCase):
         except Exception as e:
             self.fail("SSH failed for virtual machine: %s - %s" %
                                 (self.virtual_machine.ipaddress, e))
-
-        cmds = "mkdir -p %s" % self.services["mount_dir"]
+        
+        mount_dir = "/mnt/tmp"
+        cmds = "mkdir -p %s" % mount_dir
         self.assert_(ssh_client.execute(cmds) == [], "mkdir failed within guest")
 
         for diskdevice in self.services["diskdevice"]:
-            res = ssh_client.execute("mount -rt iso9660 {} {}".format(diskdevice, self.services["mount_dir"]))
+            res = ssh_client.execute("mount -rt iso9660 {} {}".format(diskdevice, mount_dir))
             if res == []:
                 self.services["mount"] = diskdevice
                 break
@@ -790,7 +688,7 @@ class TestVMLifeCycle(cloudstackTestCase):
 
         try:
             #Unmount ISO
-            command = "umount %s" % self.services["mount_dir"]
+            command = "umount %s" % mount_dir
             ssh_client.execute(command)
         except Exception as e:
             self.fail("SSH failed for virtual machine: %s - %s" %

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_vm_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vm_snapshots.py b/test/integration/smoke/test_vm_snapshots.py
index 65a5acb..e884d42 100644
--- a/test/integration/smoke/test_vm_snapshots.py
+++ b/test/integration/smoke/test_vm_snapshots.py
@@ -16,83 +16,33 @@
 # under the License.
 
 # Import Local Modules
-import marvin
+from marvin.codes import FAILED
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import *
 from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-
-class Services:
-    """Test Snapshots Services
-    """
-
-    def __init__(self):
-        self.services = {
-            "account": {
-                "email": "test@test.com",
-                "firstname": "Test",
-                "lastname": "User",
-                "username": "test",
-                # Random characters are appended for unique
-                # username
-                "password": "password",
-            },
-            "service_offering": {
-                "name": "Tiny Instance",
-                "displaytext": "Tiny Instance",
-                "cpunumber": 1,
-                "cpuspeed": 200, # in MHz
-                "memory": 256, # In MBs
-            },
-            "server": {
-                "displayname": "TestVM",
-                "username": "root",
-                "password": "password",
-                "ssh_port": 22,
-                "hypervisor": 'XenServer',
-                "privateport": 22,
-                "publicport": 22,
-                "protocol": 'TCP',
-            },
-            "mgmt_server": {
-                "ipaddress": '1.2.2.152',
-                "username": "root",
-                "password": "password",
-                "port": 22,
-            },
-            "templates": {
-                "displaytext": 'Template',
-                "name": 'Template',
-                "ostype": "CentOS 5.3 (64-bit)",
-                "templatefilter": 'self',
-            },
-            "test_dir": "/tmp",
-            "random_data": "random.data",
-            "snapshot_name": "TestSnapshot",
-            "snapshot_displaytext": "Test",
-            "ostype": "CentOS 5.3 (64-bit)",
-            "sleep": 60,
-            "timeout": 10,
-            "mode": 'advanced', # Networking mode: Advanced, Basic
-        }
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
 
 class TestVmSnapshot(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestVmSnapshot, cls).getClsTestClient().getApiClient()
-        cls.services = Services().services
+	testClient = super(TestVmSnapshot, cls).getClsTestClient()
+        cls.apiclient = testClient.getApiClient()
+        cls.services = testClient.getParsedTestDataConfig()
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.apiclient)
+        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
 
         template = get_template(
-                    cls.api_client,
+                    cls.apiclient,
                     cls.zone.id,
                     cls.services["ostype"]
                     )
+        if template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
         cls.services["domainid"] = cls.domain.id
         cls.services["server"]["zoneid"] = cls.zone.id
         cls.services["templates"]["ostypeid"] = template.ostypeid
@@ -100,27 +50,27 @@ class TestVmSnapshot(cloudstackTestCase):
 
         # Create VMs, NAT Rules etc
         cls.account = Account.create(
-                    cls.api_client,
+                    cls.apiclient,
                     cls.services["account"],
                     domainid=cls.domain.id
                     )
 
-        cls.services["account"] = cls.account.name
-
         cls.service_offering = ServiceOffering.create(
-                            cls.api_client,
-                            cls.services["service_offering"]
+                            cls.apiclient,
+                            cls.services["service_offerings"]
                             )
         cls.virtual_machine = VirtualMachine.create(
-                    cls.api_client,
+                    cls.apiclient,
                     cls.services["server"],
                     templateid=template.id,
                     accountid=cls.account.name,
                     domainid=cls.account.domainid,
                     serviceofferingid=cls.service_offering.id,
-                    mode=cls.services["mode"]
+                    mode=cls.zone.networktype
                     )
         cls.random_data_0 = random_gen(size=100)
+        cls.test_dir = "/tmp"
+        cls.random_data = "random.data"
         cls._cleanup = [
                 cls.service_offering,
                 cls.account,
@@ -131,7 +81,7 @@ class TestVmSnapshot(cloudstackTestCase):
     def tearDownClass(cls):
         try:
             # Cleanup resources used
-            cleanup_resources(cls.api_client, cls._cleanup)
+            cleanup_resources(cls.apiclient, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
@@ -160,8 +110,8 @@ class TestVmSnapshot(cloudstackTestCase):
             ssh_client = self.virtual_machine.get_ssh_client()
 
             cmds = [
-                "echo %s > %s/%s" % (self.random_data_0, self.services["test_dir"], self.services["random_data"]),
-                "cat %s/%s" % (self.services["test_dir"], self.services["random_data"])
+                "echo %s > %s/%s" % (self.random_data_0, self.test_dir, self.random_data),
+                "cat %s/%s" % (self.test_dir, self.random_data)
             ]
 
             for c in cmds:
@@ -184,8 +134,8 @@ class TestVmSnapshot(cloudstackTestCase):
             self.apiclient,
             self.virtual_machine.id,
             "false",
-            self.services["snapshot_name"],
-            self.services["snapshot_displaytext"]
+            "TestSnapshot",
+            "Dsiplay Text"
         )
         self.assertEqual(
             vm_snapshot.state,
@@ -203,8 +153,8 @@ class TestVmSnapshot(cloudstackTestCase):
             ssh_client = self.virtual_machine.get_ssh_client()
 
             cmds = [
-                "rm -rf %s/%s" % (self.services["test_dir"], self.services["random_data"]),
-                "ls %s/%s" % (self.services["test_dir"], self.services["random_data"])
+                "rm -rf %s/%s" % (self.test_dir, self.random_data),
+                "ls %s/%s" % (self.test_dir, self.random_data)
             ]
 
             for c in cmds:
@@ -263,7 +213,7 @@ class TestVmSnapshot(cloudstackTestCase):
             ssh_client = self.virtual_machine.get_ssh_client(reconnect=True)
 
             cmds = [
-                "cat %s/%s" % (self.services["test_dir"], self.services["random_data"])
+                "cat %s/%s" % (self.test_dir, self.random_data)
             ]
 
             for c in cmds:

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py
index d358c8a..f3115af 100644
--- a/test/integration/smoke/test_volumes.py
+++ b/test/integration/smoke/test_volumes.py
@@ -17,14 +17,15 @@
 """ BVT tests for Volumes
 """
 #Import Local Modules
-import marvin
 from marvin.cloudstackTestCase import *
 from marvin.cloudstackException import *
 from marvin.cloudstackAPI import *
 from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from marvin.lib.utils import checkVolumeSize
+from marvin.codes import SUCCESS
 from nose.plugins.attrib import attr
 #Import System modules
 import os
@@ -34,103 +35,55 @@ import tempfile
 
 _multiprocess_shared_ = True
 
-class Services:
-    """Test Volume Services
-    """
-
-    def __init__(self):
-        self.services = {
-                         "account": {
-                                    "email": "test@test.com",
-                                    "firstname": "Test",
-                                    "lastname": "User",
-                                    "username": "test",
-                                    # Random characters are appended for unique
-                                    # username
-                                    "password": "password",
-                         },
-                         "service_offering": {
-                                    "name": "Tiny Instance",
-                                    "displaytext": "Tiny Instance",
-                                    "cpunumber": 1,
-                                    "cpuspeed": 100,    # in MHz
-                                    "memory": 260       # In MBs
-
-                        },
-                        "disk_offering": {
-                                    "displaytext": "Small",
-                                    "name": "Small",
-                                    "disksize": 1
-                        },
-                        'resized_disk_offering': {
-                                    "displaytext": "Resized",
-                                    "name": "Resized",
-                                    "disksize": 3
-                        },
-                        "volume_offerings": {
-                            0: {
-                                "diskname": "TestDiskServ",
-                            },
-                        },
-                        "customdisksize": 1,    # GBs
-                        "username": "root",     # Creds for SSH to VM
-                        "password": "password",
-                        "ssh_port": 22,
-                        "diskname": "TestDiskServ",
-                        "hypervisor": 'KVM',
-                        "privateport": 22,
-                        "publicport": 22,
-                        "protocol": 'TCP',
-                        "ostype": 'CentOS 5.5 (64-bit)',
-                        "sleep": 10,
-                        "timeout": 600,
-                    }
-
-
 class TestCreateVolume(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestCreateVolume, cls).getClsTestClient().getApiClient()
-        cls.services = Services().services
-
+        testClient = super(TestCreateVolume, cls).getClsTestClient()
+        cls.apiclient = testClient.getApiClient()
+        cls.services = testClient.getParsedTestDataConfig()
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.apiclient)
+        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         cls.disk_offering = DiskOffering.create(
-                                    cls.api_client,
+                                    cls.apiclient,
                                     cls.services["disk_offering"]
                                     )
+        cls.sparse_disk_offering = DiskOffering.create(
+                                    cls.apiclient,
+                                    cls.services["sparse_disk_offering"]
+                                    )
         cls.custom_disk_offering = DiskOffering.create(
-                                    cls.api_client,
+                                    cls.apiclient,
                                     cls.services["disk_offering"],
                                     custom=True
                                     )
         template = get_template(
-                            cls.api_client,
+                            cls.apiclient,
                             cls.zone.id,
                             cls.services["ostype"]
                             )
+        if template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
         cls.services["domainid"] = cls.domain.id
         cls.services["zoneid"] = cls.zone.id
         cls.services["template"] = template.id
         cls.services["customdiskofferingid"] = cls.custom_disk_offering.id
-
+        cls.services["diskname"] = cls.services["volume"]["diskname"]
         # Create VMs, NAT Rules etc
         cls.account = Account.create(
-                            cls.api_client,
+                            cls.apiclient,
                             cls.services["account"],
                             domainid=cls.domain.id
                             )
-
-        cls.services["account"] = cls.account.name
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
+                                            cls.apiclient,
+                                            cls.services["service_offerings"]
                                             )
         cls.virtual_machine = VirtualMachine.create(
-                                    cls.api_client,
+                                    cls.apiclient,
                                     cls.services,
                                     accountid=cls.account.name,
                                     domainid=cls.account.domainid,
@@ -172,6 +125,18 @@ class TestCreateVolume(cloudstackTestCase):
             self.debug("Created a volume with ID: %s" % volume.id)
             self.volumes.append(volume)
 
+        if self.virtual_machine.hypervisor == "KVM":
+            sparse_volume = Volume.create(
+                                        self.apiClient,
+                                        self.services,
+                                        zoneid=self.zone.id,
+                                        account=self.account.name,
+                                        domainid=self.account.domainid,
+                                        diskofferingid=self.sparse_disk_offering.id
+                                        )
+            self.debug("Created a sparse volume: %s" % sparse_volume.id)
+            self.volumes.append(sparse_volume)
+
         volume = Volume.create_custom_disk(
                                     self.apiClient,
                                     self.services,
@@ -227,7 +192,6 @@ class TestCreateVolume(cloudstackTestCase):
                                             )
 
                 if isinstance(list_vm_response, list):
-
                     vm = list_vm_response[0]
                     if vm.state == 'Running':
                         self.debug("VM state: %s" % vm.state)
@@ -236,31 +200,17 @@ class TestCreateVolume(cloudstackTestCase):
                 if timeout == 0:
                     raise Exception(
                         "Failed to start VM (ID: %s) " % vm.id)
-
                 timeout = timeout - 1
 
-            try:
-                ssh = self.virtual_machine.get_ssh_client(
+            vol_sz = str(list_volume_response[0].size)
+            ssh = self.virtual_machine.get_ssh_client(
                                                       reconnect=True
                                                       )
-                c = "/sbin/fdisk -l"
-                res = ssh.execute(c)
-
-            except Exception as e:
-                self.fail("SSH access failed for VM: %s - %s" %
-                                (self.virtual_machine.ipaddress, e))
-
-            # Disk /dev/sda doesn't contain a valid partition table
-            # Disk /dev/sda: 21.5 GB, 21474836480 bytes
-            result = str(res)
-            self.debug("fdisk result: %s" % result)
-
-            self.assertEqual(
-                             str(list_volume_response[0].size) in result,
-                             True,
-                             "Check if promised disk size actually available"
-                             )
+            ret = checkVolumeSize(ssh_handle=ssh,size_to_verify=vol_sz)
+            self.debug(" Volume Size Expected %s  Actual :%s" %(vol_sz,ret[1]))
             self.virtual_machine.detach_volume(self.apiClient, volume)
+            self.assertEqual(ret[0],SUCCESS,"Check if promised disk size actually available")
+            time.sleep(self.services["sleep"])
 
     def tearDown(self):
         #Clean up, terminate the created volumes
@@ -270,8 +220,8 @@ class TestCreateVolume(cloudstackTestCase):
     @classmethod
     def tearDownClass(cls):
         try:
-            cls.api_client = super(TestCreateVolume, cls).getClsTestClient().getApiClient()
-            cleanup_resources(cls.api_client, cls._cleanup)
+            cls.apiclient = super(TestCreateVolume, cls).getClsTestClient().getApiClient()
+            cleanup_resources(cls.apiclient, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
 
@@ -280,31 +230,36 @@ class TestVolumes(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestVolumes, cls).getClsTestClient().getApiClient()
-        cls.services = Services().services
+        testClient = super(TestVolumes, cls).getClsTestClient()
+        cls.apiclient = testClient.getApiClient()
+        cls.services = testClient.getParsedTestDataConfig()
+
         # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.apiclient)
+        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         cls.disk_offering = DiskOffering.create(
-                                    cls.api_client,
+                                    cls.apiclient,
                                     cls.services["disk_offering"]
                                     )
         cls.resized_disk_offering = DiskOffering.create(
-                                    cls.api_client,
+                                    cls.apiclient,
                                     cls.services["resized_disk_offering"]
                                     )
         cls.custom_resized_disk_offering = DiskOffering.create(
-                                    cls.api_client,
+                                    cls.apiclient,
                                     cls.services["resized_disk_offering"],
                                     custom=True
                                     )
 
         template = get_template(
-                            cls.api_client,
+                            cls.apiclient,
                             cls.zone.id,
                             cls.services["ostype"]
                             )
+        if template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
         cls.services["domainid"] = cls.domain.id
         cls.services["zoneid"] = cls.zone.id
         cls.services["template"] = template.id
@@ -314,18 +269,16 @@ class TestVolumes(cloudstackTestCase):
 
         # Create VMs, VMs etc
         cls.account = Account.create(
-                            cls.api_client,
+                            cls.apiclient,
                             cls.services["account"],
                             domainid=cls.domain.id
                             )
-
-        cls.services["account"] = cls.account.name
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
+                                            cls.apiclient,
+                                            cls.services["service_offerings"]
                                         )
         cls.virtual_machine = VirtualMachine.create(
-                                    cls.api_client,
+                                    cls.apiclient,
                                     cls.services,
                                     accountid=cls.account.name,
                                     domainid=cls.account.domainid,
@@ -334,7 +287,7 @@ class TestVolumes(cloudstackTestCase):
                                 )
 
         cls.volume = Volume.create(
-                                   cls.api_client,
+                                   cls.apiclient,
                                    cls.services,
                                    account=cls.account.name,
                                    domainid=cls.account.domainid
@@ -351,7 +304,7 @@ class TestVolumes(cloudstackTestCase):
     @classmethod
     def tearDownClass(cls):
         try:
-            cleanup_resources(cls.api_client, cls._cleanup)
+            cleanup_resources(cls.apiclient, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
 
@@ -767,7 +720,7 @@ class TestVolumes(cloudstackTestCase):
         self.debug("Delete Volume ID: %s" % self.volume.id)
 
         self.volume_1 = Volume.create(
-                                   self.api_client,
+                                   self.apiclient,
                                    self.services,
                                    account=self.account.name,
                                    domainid=self.account.domainid

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_vpc_vpn.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vpc_vpn.py b/test/integration/smoke/test_vpc_vpn.py
index d06fd29..1b28447 100644
--- a/test/integration/smoke/test_vpc_vpn.py
+++ b/test/integration/smoke/test_vpc_vpn.py
@@ -17,105 +17,29 @@
 """ Tests for VPN in VPC
 """
 #Import Local Modules
+from marvin.codes import FAILED
 from marvin.cloudstackTestCase import *
 from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
 from nose.plugins.attrib import attr
 
 import time
 
-class Services:
-    def __init__(self):
-        self.services = {
-            "account": {
-                "email": "test@test.com",
-                "firstname": "Test",
-                "lastname": "User",
-                "username": "test",
-                "password": "password",
-            },
-            "virtual_machine": {
-                "displayname": "Test VM",
-                "username": "root",
-                "password": "password",
-                "ssh_port": 22,
-                "hypervisor": 'XenServer',
-                "privateport": 22,
-                "publicport": 22,
-                "protocol": 'TCP',
-            },
-            "ostype": 'CentOS 5.3 (64-bit)',
-            "service_offering": {
-                "name": "Tiny Instance",
-                "displaytext": "Tiny Instance",
-                "cpunumber": 1,
-                "cpuspeed": 100,
-                "memory": 256,
-            },
-            "network_offering": {
-                "name": "Network offering for internal vpc",
-                "displaytext": "Network offering for internal vpc",
-                "guestiptype": "Isolated",
-                "traffictype": "Guest",
-                "supportedservices": "Vpn,Dhcp,Dns,Lb,UserData,SourceNat,StaticNat,PortForwarding,NetworkACL",
-                "serviceProviderList": {
-                    "Dhcp": "VpcVirtualRouter",
-                    "Dns": "VpcVirtualRouter",
-                    "Vpn": "VpcVirtualRouter",
-                    "UserData": "VpcVirtualRouter",
-                    "Lb": "InternalLbVM",
-                    "SourceNat": "VpcVirtualRouter",
-                    "StaticNat": "VpcVirtualRouter",
-                    "PortForwarding": "VpcVirtualRouter",
-                    "NetworkACL": "VpcVirtualRouter",
-                },
-                "serviceCapabilityList": {
-                    "SourceNat": {"SupportedSourceNatTypes": "peraccount"},
-                    "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"}
-                }
-            },
-            "vpn_user": {
-                "username": "test",
-                "password": "password",
-            },
-            "vpc": {
-                "name": "vpc_vpn",
-                "displaytext": "vpc-vpn",
-                "cidr": "10.1.1.0/24"
-            },
-            "ntwk": {
-                "name": "tier1",
-                "displaytext": "vpc-tier1",
-                "gateway" : "10.1.1.1",
-                "netmask" : "255.255.255.192"
-            },
-            "vpc2": {
-                "name": "vpc2_vpn",
-                "displaytext": "vpc2-vpn",
-                "cidr": "10.2.1.0/24"
-            },
-            "ntwk2": {
-                "name": "tier2",
-                "displaytext": "vpc-tier2",
-                "gateway" : "10.2.1.1",
-                "netmask" : "255.255.255.192"
-            }
-        }
-
-
 class TestVpcRemoteAccessVpn(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.apiclient = super(TestVpcRemoteAccessVpn, cls).getClsTestClient().getApiClient()
-        cls.services = Services().services
-        cls.zone = get_zone(cls.apiclient, cls.services)
+        testClient = super(TestVpcRemoteAccessVpn, cls).getClsTestClient()
+        cls.apiclient = testClient.getApiClient()
+        cls.services = testClient.getParsedTestDataConfig()
+
+        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
         cls.domain = get_domain(cls.apiclient)
         cls.service_offering = ServiceOffering.create(
             cls.apiclient,
-            cls.services["service_offering"]
+            cls.services["service_offerings"]
         )
         cls.account = Account.create(cls.apiclient, services=cls.services["account"])
         cls.template = get_template(
@@ -123,6 +47,9 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase):
             cls.zone.id,
             cls.services["ostype"]
         )
+        if cls.template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
         cls.cleanup = [cls.account]
 
     @attr(tags=["advanced", "selfservice"])
@@ -211,13 +138,15 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.apiclient = super(TestVpcSite2SiteVpn, cls).getClsTestClient().getApiClient()
-        cls.services = Services().services
-        cls.zone = get_zone(cls.apiclient, cls.services)
+        testClient = super(TestVpcSite2SiteVpn, cls).getClsTestClient()
+        cls.apiclient = testClient.getApiClient()
+        cls.services = testClient.getParsedTestDataConfig()
+
+        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
         cls.domain = get_domain(cls.apiclient)
         cls.service_offering = ServiceOffering.create(
             cls.apiclient,
-            cls.services["service_offering"]
+            cls.services["service_offerings"]
         )
         cls.account = Account.create(cls.apiclient, services=cls.services["account"])
         cls.template = get_template(
@@ -225,6 +154,9 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
             cls.zone.id,
             cls.services["ostype"]
         )
+        if cls.template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
         cls.cleanup = [cls.account]
 
     @attr(tags=["advanced", "selfservice"], BugId="CLOUDSTACK-6879")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/__init__.py b/tools/marvin/marvin/__init__.py
index 7af168e..7102e3f 100644
--- a/tools/marvin/marvin/__init__.py
+++ b/tools/marvin/marvin/__init__.py
@@ -15,4 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 
-#Marvin - The cloudstack test client
+# Marvin - The cloudstack test client

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/asyncJobMgr.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/asyncJobMgr.py b/tools/marvin/marvin/asyncJobMgr.py
index e24170e..00e8c19 100644
--- a/tools/marvin/marvin/asyncJobMgr.py
+++ b/tools/marvin/marvin/asyncJobMgr.py
@@ -16,7 +16,7 @@
 # under the License.
 
 import threading
-import cloudstackException
+from marvin import cloudstackException
 import time
 import Queue
 import copy
@@ -26,12 +26,14 @@ import datetime
 
 
 class job(object):
+
     def __init__(self):
         self.id = None
         self.cmd = None
 
 
 class jobStatus(object):
+
     def __init__(self):
         self.result = None
         self.status = None
@@ -47,6 +49,7 @@ class jobStatus(object):
 
 
 class workThread(threading.Thread):
+
     def __init__(self, in_queue, outqueue, apiClient, db=None, lock=None):
         threading.Thread.__init__(self)
         self.inqueue = in_queue
@@ -62,7 +65,7 @@ class workThread(threading.Thread):
         try:
             self.lock.acquire()
             result = self.connection.poll(job.jobId, job.responsecls).jobresult
-        except cloudstackException.cloudstackAPIException, e:
+        except cloudstackException.CloudstackAPIException as e:
             result = str(e)
         finally:
             self.lock.release()
@@ -102,7 +105,7 @@ class workThread(threading.Thread):
                     except:
                         pass
                     jobstatus.status = True
-        except cloudstackException.cloudstackAPIException, e:
+        except cloudstackException.CloudstackAPIException as e:
             jobstatus.result = str(e)
             jobstatus.status = False
         except:
@@ -129,6 +132,7 @@ class workThread(threading.Thread):
 
 
 class jobThread(threading.Thread):
+
     def __init__(self, inqueue, interval):
         threading.Thread.__init__(self)
         self.inqueue = inqueue
@@ -149,12 +153,14 @@ class jobThread(threading.Thread):
 
 
 class outputDict(object):
+
     def __init__(self):
         self.lock = threading.Condition()
         self.dict = {}
 
 
 class asyncJobMgr(object):
+
     def __init__(self, apiClient, db):
         self.inqueue = Queue.Queue()
         self.output = outputDict()