cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tall...@apache.org
Subject [2/3] git commit: updated refs/heads/master to ca52f15
Date Fri, 05 Dec 2014 14:43:42 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca52f155/test/integration/component/test_deploy_vgpu_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_deploy_vgpu_vm.py b/test/integration/component/test_deploy_vgpu_vm.py
index 0284eab..15ad2d9 100644
--- a/test/integration/component/test_deploy_vgpu_vm.py
+++ b/test/integration/component/test_deploy_vgpu_vm.py
@@ -15,323 +15,375 @@
 # specific language governing permissions and limitations
 # under the License.
 
-#Test from the Marvin - Testing in Python wiki
+# Test from the Marvin - Testing in Python wiki
 
-#All tests inherit from cloudstackTestCase
+# All tests inherit from cloudstackTestCase
 from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.cloudstackAPI import changeServiceForVirtualMachine,updateServiceOffering,listConfigurations,startVirtualMachine
+from marvin.cloudstackAPI import changeServiceForVirtualMachine, startVirtualMachine
 
-#Import Integration Libraries
+# Import Integration Libraries
 
-#base - contains all resources as entities and defines create, delete, list operations on them
-from marvin.lib.base import Account, VirtualMachine, ServiceOffering , Template , Host, VmSnapshot
+# base - contains all resources as entities and defines create, delete,
+# list operations on them
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering, Template, Host, VmSnapshot
 
-#utils - utility classes for common cleanup, external library wrappers etc
-from marvin.lib.utils import cleanup_resources,random_gen
+# utils - utility classes for common cleanup, external library wrappers etc
+from marvin.lib.utils import cleanup_resources
 
-#common - commonly used methods for all tests are listed here
-from marvin.lib.common import get_zone, get_domain, get_template, list_hosts ,list_service_offering, get_windows_template, get_pod, list_clusters, list_virtual_machines
+# common - commonly used methods for all tests are listed here
+from marvin.lib.common import get_zone, get_domain, list_hosts, list_service_offering, get_windows_template, get_pod, list_clusters, list_virtual_machines
 
 from marvin.sshClient import SshClient
 
-from marvin.codes import FAILED, XEN_SERVER
+from marvin.codes import FAILED
 
 from nose.plugins.attrib import attr
 
 import time
 
+
 class TestvGPUWindowsVm(cloudstackTestCase):
+
     """
     Testing vGPU VM with All vGPU service offerings
     """
     @classmethod
     def setUpClass(cls):
-        testClient = super(TestvGPUWindowsVm, cls).getClsTestClient()
+        cls.testClient = super(TestvGPUWindowsVm, cls).getClsTestClient()
         cls.testdata = cls.testClient.getParsedTestDataConfig()
         cls.apiclient = cls.testClient.getApiClient()
         cls._cleanup = []
         cls.cleanup = []
         hosts = list_hosts(
-               cls.apiclient,
-               hypervisor="XenServer"
-               )
+            cls.apiclient,
+            hypervisor="XenServer"
+        )
         if hosts is None:
-            raise unittest.SkipTest("There are no XenServers available. GPU feature is supported only on XenServer.Check listhosts response")
+            raise unittest.SkipTest(
+                "There are no XenServers available. GPU feature is supported only on XenServer.Check listhosts response")
         else:
-             cls.k140qgpuhosts=0
-             cls.k120qgpuhosts=0
-             cls.k100gpuhosts=0
-             cls.k260qgpuhosts=0
-             cls.k240qgpuhosts=0
-             cls.k220qgpuhosts=0
-             cls.k200gpuhosts=0
-             cls.k1passthroughgpuhosts=0
-             cls.k2passthroughgpuhosts=0
-             cls.nongpuhosts=[]
-             cls.k2hosts=0
-             cls.k1hosts=0
-             cls.k100_vgpu_service_offering=[]
-             cls.k200_vgpu_service_offering=[]
-             cls.nonvgpu_service_offering=[]
-             cls.vm_k1_card=[]
-             cls.vm_k2_card=[]
-             cls.vm2_k2_card=[]
-             cls.nonvgpu=[]
-             cls.vmlifecycletest=0
-             cls.vmsnapwomemory=0
-             cls.vmsnapwithmemory=0
-
-             for ghost in hosts :
-                 if ghost.hypervisorversion >= "6.2.0":
-
-                    sshClient = SshClient(host=ghost.ipaddress, port=22, user='root',passwd=cls.testdata["host_password"])
+            cls.k140qgpuhosts = 0
+            cls.k120qgpuhosts = 0
+            cls.k100gpuhosts = 0
+            cls.k260qgpuhosts = 0
+            cls.k240qgpuhosts = 0
+            cls.k220qgpuhosts = 0
+            cls.k200gpuhosts = 0
+            cls.k1passthroughgpuhosts = 0
+            cls.k2passthroughgpuhosts = 0
+            cls.nongpuhosts = []
+            cls.k2hosts = 0
+            cls.k1hosts = 0
+            cls.k100_vgpu_service_offering = []
+            cls.k200_vgpu_service_offering = []
+            cls.nonvgpu_service_offering = []
+            cls.vm_k1_card = []
+            cls.vm_k2_card = []
+            cls.vm2_k2_card = []
+            cls.nonvgpu = []
+            cls.vmlifecycletest = 0
+            cls.vmsnapwomemory = 0
+            cls.vmsnapwithmemory = 0
+
+            for ghost in hosts:
+                if ghost.hypervisorversion >= "6.2.0":
+
+                    sshClient = SshClient(
+                        host=ghost.ipaddress,
+                        port=cls.testdata['configurableData']['host']["publicport"],
+                        user=cls.testdata['configurableData']['host']["username"],
+                        passwd=cls.testdata['configurabledata']['host']["password"])
 
                     if ghost.hypervisorversion == "6.2.0":
-                       res = len(sshClient.execute("xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503"))
-                       if res == 0:
-                           continue
-                    k1card= len(sshClient.execute("lspci | grep \"GRID K1\""))
-                    k2card= len(sshClient.execute("lspci | grep \"GRID K2\""))
-                    cls.debug("k1 card and k2 card details are :%s %s "%(k1card,k2card))
-                    if (k2card==0) and (k1card==0):
-                       cls.nongpuhosts.append(ghost.ipaddress)
-                    if k2card !=0:
-                          cls.k2hosts=cls.k2hosts+1
-                          k260q = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K260Q\""))
-                          k240q = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K240Q\""))
-                          k220q = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K220Q\""))
-                          k200 = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K200\""))
-                          k2passthrough = len(sshClient.execute("xe vgpu-type-list model-name='passthrough'"))
-                          if ((k260q==0) and (k240q==0)  and (k220q==0) and (k200==0) and (k2passthrough== 0)): 
-                              continue
-                          else:
-                               if k260q != 0 :
-                                  cls.k260qgpuhosts=cls.k260qgpuhosts+1
-                               if k240q != 0 :
-                                  cls.k240qgpuhosts=cls.k240qgpuhosts+1
-                               if k220q != 0 :
-                                  cls.k220qgpuhosts=cls.k220qgpuhosts+1
-                               if k200 != 0 :
-                                  cls.k200gpuhosts=cls.k200gpuhosts+1
-                               if k2passthrough != 0:
-                                  cls.k2passthroughgpuhosts=cls.k2passthroughgpuhosts+1
+                        res = len(
+                            sshClient.execute("xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503"))
+                        if res == 0:
+                            continue
+                    k1card = len(sshClient.execute("lspci | grep \"GRID K1\""))
+                    k2card = len(sshClient.execute("lspci | grep \"GRID K2\""))
+                    cls.debug(
+                        "k1 card and k2 card details are :%s %s " %
+                        (k1card, k2card))
+                    if (k2card == 0) and (k1card == 0):
+                        cls.nongpuhosts.append(ghost.ipaddress)
+                    if k2card != 0:
+                        cls.k2hosts = cls.k2hosts + 1
+                        k260q = len(
+                            sshClient.execute("xe vgpu-type-list model-name=\"GRID K260Q\""))
+                        k240q = len(
+                            sshClient.execute("xe vgpu-type-list model-name=\"GRID K240Q\""))
+                        k220q = len(
+                            sshClient.execute("xe vgpu-type-list model-name=\"GRID K220Q\""))
+                        k200 = len(
+                            sshClient.execute("xe vgpu-type-list model-name=\"GRID K200\""))
+                        k2passthrough = len(
+                            sshClient.execute("xe vgpu-type-list model-name='passthrough'"))
+                        if ((k260q == 0) and (k240q == 0) and (k220q == 0)
+                                and (k200 == 0) and (k2passthrough == 0)):
+                            continue
+                        else:
+                            if k260q != 0:
+                                cls.k260qgpuhosts = cls.k260qgpuhosts + 1
+                            if k240q != 0:
+                                cls.k240qgpuhosts = cls.k240qgpuhosts + 1
+                            if k220q != 0:
+                                cls.k220qgpuhosts = cls.k220qgpuhosts + 1
+                            if k200 != 0:
+                                cls.k200gpuhosts = cls.k200gpuhosts + 1
+                            if k2passthrough != 0:
+                                cls.k2passthroughgpuhosts = cls.k2passthroughgpuhosts + \
+                                    1
 
                     if k1card != 0:
-                            cls.k1hosts=cls.k1hosts+1
-                            k100 = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K100\""))
-                            k120q = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K120Q\""))
-                            k140q = len(sshClient.execute("xe vgpu-type-list model-name=\"GRID K140Q\""))
-                            k1passthrough = len(sshClient.execute("xe vgpu-type-list model-name='passthrough'"))
-                            if ((k100 == 0) and (k120q == 0) and (k140q == 0) and (k1passthrough == 0)):
-                                continue
-                            else:
-                                if k140q != 0 :
-                                   cls.k140qgpuhosts=cls.k140qgpuhosts+1
-                                if k120q != 0 :
-                                   cls.k120qgpuhosts=cls.k120qgpuhosts+1
-                                if k100 != 0 :
-                                   cls.k100gpuhosts=cls.k100gpuhosts+1
-                                if k1passthrough != 0 :
-                                   cls.k1passthroughgpuhosts=cls.k1passthroughgpuhosts+1
+                        cls.k1hosts = cls.k1hosts + 1
+                        k100 = len(
+                            sshClient.execute("xe vgpu-type-list model-name=\"GRID K100\""))
+                        k120q = len(
+                            sshClient.execute("xe vgpu-type-list model-name=\"GRID K120Q\""))
+                        k140q = len(
+                            sshClient.execute("xe vgpu-type-list model-name=\"GRID K140Q\""))
+                        k1passthrough = len(
+                            sshClient.execute("xe vgpu-type-list model-name='passthrough'"))
+                        if ((k100 == 0) and (k120q == 0) and (
+                                k140q == 0) and (k1passthrough == 0)):
+                            continue
+                        else:
+                            if k140q != 0:
+                                cls.k140qgpuhosts = cls.k140qgpuhosts + 1
+                            if k120q != 0:
+                                cls.k120qgpuhosts = cls.k120qgpuhosts + 1
+                            if k100 != 0:
+                                cls.k100gpuhosts = cls.k100gpuhosts + 1
+                            if k1passthrough != 0:
+                                cls.k1passthroughgpuhosts = cls.k1passthroughgpuhosts + \
+                                    1
         if (cls.k2hosts == 0) and (cls.k1hosts == 0):
-           raise unittest.SkipTest("No XenServer available with GPU Drivers installed")
+            raise unittest.SkipTest(
+                "No XenServer available with GPU Drivers installed")
 
         cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
         cls.domain = get_domain(cls.apiclient)
         cls.pod = get_pod(cls.apiclient, cls.zone.id)
         cls.account = Account.create(
-               cls.apiclient,
-               cls.testdata["account"],
-               domainid=cls.domain.id
-               )
+            cls.apiclient,
+            cls.testdata["account"],
+            domainid=cls.domain.id
+        )
 
-        cls.template = get_windows_template(cls.apiclient, cls.zone.id ,ostype_desc="Windows 8 (64-bit)")
+        cls.template = get_windows_template(
+            cls.apiclient,
+            cls.zone.id,
+            ostype_desc="Windows 8 (64-bit)")
         #cls.template = get_windows_template(cls.apiclient, cls.zone.id ,ostype_desc="Windows Server 2012 (64-bit)")
 
-        if  cls.template == FAILED:
-            if "http://pleaseupdateURL/dummy.vhd" in cls.testdata["vgpu"] ["templateregister1"]["url"]:
-                raise unittest.SkipTest("Check Test Data file if it has the valid template URL")
+        if cls.template == FAILED:
+            if "http://pleaseupdateURL/dummy.vhd" in cls.testdata[
+                    "vgpu"]["templateregister1"]["url"]:
+                raise unittest.SkipTest(
+                    "Check Test Data file if it has the valid template URL")
             cls.template = Template.register(
-                   cls.apiclient,
-                   cls.testdata["vgpu"] ["templateregister1"],
-                   hypervisor = "XenServer",
-                   zoneid=cls.zone.id,
-                   domainid=cls.account.domainid,
-                   account=cls.account.name
-                   )
+                cls.apiclient,
+                cls.testdata["vgpu"]["templateregister1"],
+                hypervisor="XenServer",
+                zoneid=cls.zone.id,
+                domainid=cls.account.domainid,
+                account=cls.account.name
+            )
             timeout = cls.testdata["vgpu"]["timeout"]
 
             while True:
-                  time.sleep(cls.testdata["vgpu"]["sleep"])
-                  list_template_response = Template.list(
-                       cls.apiclient,
-                       templatefilter=\
-                       cls.testdata["templatefilter"],
-                       id=cls.template.id
-                        )
-                  if (isinstance(list_template_response, list)) is not True:
-                      raise unittest.SkipTest("Check list template api response returns a valid list")
-
-                  if len(list_template_response) is None :
-                      raise unittest.SkipTest("Check template registered is in List Templates")
+                time.sleep(cls.testdata["vgpu"]["sleep"])
+                list_template_response = Template.list(
+                    cls.apiclient,
+                    templatefilter=cls.testdata["templatefilter"],
+                    id=cls.template.id
+                )
+                if (isinstance(list_template_response, list)) is not True:
+                    raise unittest.SkipTest(
+                        "Check list template api response returns a valid list")
 
-                  template_response = list_template_response[0]
-                  if template_response.isready == True:
-                      break
+                if len(list_template_response) is None:
+                    raise unittest.SkipTest(
+                        "Check template registered is in List Templates")
 
-                  if timeout == 0:
-                      raise unittest.SkipTest("Failed to download template(ID: %s). " % template_response.id)
+                template_response = list_template_response[0]
+                if template_response.isready:
+                    break
 
-                  timeout = timeout - 1
+                if timeout == 0:
+                    raise unittest.SkipTest(
+                        "Failed to download template(ID: %s). " %
+                        template_response.id)
 
+                timeout = timeout - 1
 
         cls._cleanup = [
-                         cls.account,
-                         #cls.k100_vgpu_service_offering,
-                         #cls.k200_vgpu_service_offering
-                        ]
+            cls.account,
+            # cls.k100_vgpu_service_offering,
+            # cls.k200_vgpu_service_offering
+        ]
 
-    @attr(tags = ['advanced', 'basic', 'vgpu'], required_hardware="true")
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
     def setUp(self):
         self.testdata = self.testClient.getParsedTestDataConfig()
         self.apiclient = self.testClient.getApiClient()
         self.cleanup = []
         return
 
-
-    def check_host_vgpu_capacity(self,gpucard,gtype):
+    def check_host_vgpu_capacity(self, gpucard, gtype):
         gputhosts = list_hosts(
-               self.apiclient,
-               hypervisor="XenServer"
-               )
-        vgpucapacity=0
+            self.apiclient,
+            hypervisor="XenServer"
+        )
+        vgpucapacity = 0
         for ghost in gputhosts:
             if ghost.gpugroup is not None:
-                        for gp in ghost.gpugroup:
-                            if gp.gpugroupname == gpucard:
-                               for gptype in gp.vgpu:
-                                   if gptype.vgputype == gtype:
-                                     vgpucapacity=vgpucapacity+gptype.remainingcapacity
+                for gp in ghost.gpugroup:
+                    if gp.gpugroupname == gpucard:
+                        for gptype in gp.vgpu:
+                            if gptype.vgputype == gtype:
+                                vgpucapacity = vgpucapacity + \
+                                    gptype.remainingcapacity
 
         return(vgpucapacity)
 
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
+    def vgpu_serviceoffering_creation(self, gtype, nvidiamodel):
+        if gtype == "nonvgpuoffering" and nvidiamodel == "None":
+            self.service_offering = ServiceOffering.create(
+                self.apiclient,
+                self.testdata["vgpu"]["service_offerings"][gtype]
+            )
+            self.debug(
+                "service offering details are:%s" %
+                self.service_offering)
+            list_service_response = ServiceOffering.list(
+                self.apiclient,
+                id=self.service_offering.id
+            )
 
-    @attr(tags = ['advanced', 'basic', 'vgpu'], required_hardware="true")
-    def vgpu_serviceoffering_creation(self,gtype,nvidiamodel):
-        if gtype=="nonvgpuoffering" and nvidiamodel=="None":
-           self.service_offering = ServiceOffering.create(
-                                                       self.apiclient,
-                                                       self.testdata["vgpu"]["service_offerings"][gtype]
-                                                          )
-           self.debug("service offering details are:%s"%self.service_offering)
-           list_service_response = ServiceOffering.list(
-               self.apiclient,
-               id=self.service_offering.id
-               )
-
-           if list_service_response is None:
-               raise unittest.SkipTest("Check Service Offering list for %s service offering" %(gtype))
-
-           self.assertEqual(
-                 list_service_response[0].displaytext,
-                 self.testdata["vgpu"]["service_offerings"][gtype]["displaytext"],
-                 "Check server display text in createServiceOfferings"
-                )
-           self.assertEqual(
-               list_service_response[0].name,
-               self.testdata["vgpu"]["service_offerings"][gtype]["name"],
-               "Check name in createServiceOffering"
-                )
+            if list_service_response is None:
+                raise unittest.SkipTest(
+                    "Check Service Offering list for %s service offering" %
+                    (gtype))
+
+            self.assertEqual(
+                list_service_response[0].displaytext,
+                self.testdata["vgpu"]["service_offerings"][gtype]["displaytext"],
+                "Check server display text in createServiceOfferings")
+            self.assertEqual(
+                list_service_response[0].name,
+                self.testdata["vgpu"]["service_offerings"][gtype]["name"],
+                "Check name in createServiceOffering"
+            )
         else:
-              self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [{'pciDevice': nvidiamodel},
-                                                                                       {'vgpuType':gtype}]
-              self.service_offering = ServiceOffering.create(
-                                                       self.apiclient,
-                                                       self.testdata["vgpu"]["service_offerings"][gtype]
-                                                          )
-              list_service_response = ServiceOffering.list(
-               self.apiclient,
-               id=self.service_offering.id
-               )
-
-              if list_service_response is None:
-                 raise unittest.SkipTest("Check Service Offering list for %s service offering" %(gtype))
-
-              self.assertEqual(
-                 list_service_response[0].serviceofferingdetails.vgpuType,
-                        gtype,
-                    "Failed To Create Service Offering . Check vGPU Service Offering list"
-                  )
-              self.assertEqual(
-                 list_service_response[0].displaytext,
-                 self.testdata["vgpu"]["service_offerings"][gtype]["displaytext"],
-                 "Check server displaytext in createServiceOfferings"
-                )
-              self.assertEqual(
-               list_service_response[0].name,
-               self.testdata["vgpu"]["service_offerings"][gtype]["name"],
-               "Check name in createServiceOffering"
-                )
-        return(self.service_offering)
+            self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [
+                {'pciDevice': nvidiamodel}, {'vgpuType': gtype}]
+            self.service_offering = ServiceOffering.create(
+                self.apiclient,
+                self.testdata["vgpu"]["service_offerings"][gtype]
+            )
+            list_service_response = ServiceOffering.list(
+                self.apiclient,
+                id=self.service_offering.id
+            )
 
+            if list_service_response is None:
+                raise unittest.SkipTest(
+                    "Check Service Offering list for %s service offering" %
+                    (gtype))
+
+            self.assertEqual(
+                list_service_response[0].serviceofferingdetails.vgpuType,
+                gtype,
+                "Failed To Create Service Offering . Check vGPU Service Offering list")
+            self.assertEqual(
+                list_service_response[0].displaytext,
+                self.testdata["vgpu"]["service_offerings"][gtype]["displaytext"],
+                "Check server displaytext in createServiceOfferings")
+            self.assertEqual(
+                list_service_response[0].name,
+                self.testdata["vgpu"]["service_offerings"][gtype]["name"],
+                "Check name in createServiceOffering"
+            )
+        return(self.service_offering)
 
-    @attr(tags = ['advanced', 'basic', 'vgpu'], required_hardware="true")
-    def check_for_vGPU_resource(self,hostid,vminstancename,serviceofferingid,vgputype):
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
+    def check_for_vGPU_resource(
+            self,
+            hostid,
+            vminstancename,
+            serviceofferingid,
+            vgputype):
         """
         Validate the VM for VGPU resources
         """
         """Create SSH Client for Host Connection
         """
         vgpu_host = list_hosts(
-                               self.apiclient,
-                               id=hostid
-                               )
-        ssh_client = SshClient(host=vgpu_host[0].ipaddress, port=22, user='root',passwd=self.testdata["host_password"])
+            self.apiclient,
+            id=hostid
+        )
+        ssh_client = SshClient(
+            host=vgpu_host[0].ipaddress,
+            port=self.testdata['configurabledata']['host']["publicport"],
+            user=self.testdata['configurabledata']['host']["username"],
+            passwd=self.testdata['configurabledata']['host']["password"])
         """
         Get vGPU type model
         """
-        vgpu_type_model = ssh_client.execute("xe vgpu-list vm-name-label=" + vminstancename + " params=type-model-name --minimal")
-        self.debug("vgpu type model is %s and value is %s and length is %s"%(vgpu_type_model,vgpu_type_model[0],len(vgpu_type_model[0])))
+        vgpu_type_model = ssh_client.execute(
+            "xe vgpu-list vm-name-label=" +
+            vminstancename +
+            " params=type-model-name --minimal")
+        self.debug(
+            "vgpu type model is %s and value is %s and length is %s" %
+            (vgpu_type_model, vgpu_type_model[0], len(
+                vgpu_type_model[0])))
         if vgputype is None:
-            if len(vgpu_type_model[0])==0:
+            if len(vgpu_type_model[0]) == 0:
                 self.debug("This is non GPU instance")
                 return
             else:
-                self.fail("Non vGPU VM has GPU cards @ host:%s"%vminstancename)
+                self.fail(
+                    "Non vGPU VM has GPU cards @ host:%s" %
+                    vminstancename)
         self.assertNotEqual(
-                            len(vgpu_type_model),
-                            0,
-                            "The VM is NOT deployed with vGPU cards"
-                        )
+            len(vgpu_type_model),
+            0,
+            "The VM is NOT deployed with vGPU cards"
+        )
         """
         List service offering from which VM is deployed
         """
         list_service_offering_response = ServiceOffering.list(
-               self.apiclient,
-               id=serviceofferingid
-               )
+            self.apiclient,
+            id=serviceofferingid
+        )
         """ Check whether the vgputype in the service offering is same as the one obtained by listing the vgpu type model
         """
-        self.debug("VM vGPU type is: %s and vGPU type on XenServer is : %s"%(list_service_offering_response[0].serviceofferingdetails.vgpuType,vgpu_type_model[0]))
+        self.debug(
+            "VM vGPU type is: %s and vGPU type on XenServer is : %s" %
+            (list_service_offering_response[0].serviceofferingdetails.vgpuType,
+             vgpu_type_model[0]))
         self.assertEqual(
-                      list_service_offering_response[0].serviceofferingdetails.vgpuType,
-                      vgpu_type_model[0],
-                      "VM does not have the correct GPU resources, verified on the host"
-                      )
+            list_service_offering_response[0].serviceofferingdetails.vgpuType,
+            vgpu_type_model[0],
+            "VM does not have the correct GPU resources, verified on the host"
+        )
         """
         Check whether the VM is deployed with the card which was mentioned in the service offering
         """
 
         self.assertEqual(
-                         vgputype,
-                         list_service_offering_response[0].serviceofferingdetails.vgpuType,
-                            "The VM is NOT deployed with correct cards, verified from CS"
-                        )
+            vgputype,
+            list_service_offering_response[0].serviceofferingdetails.vgpuType,
+            "The VM is NOT deployed with correct cards, verified from CS"
+        )
         return
 
-    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
-
-    def deploy_vGPU_windows_vm(self,vgpuofferingid,vgput):
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
+    def deploy_vGPU_windows_vm(self, vgpuofferingid, vgput):
         """
         Validate vGPU K1 windows instances
         """
@@ -343,12 +395,14 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             domainid=self.account.domainid,
             serviceofferingid=vgpuofferingid,
             templateid=self.template.id
-            )
+        )
         time.sleep(self.testdata["vgpu"]["sleep"])
-        list_vms = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id)
+        list_vms = VirtualMachine.list(
+            self.apiclient,
+            id=self.virtual_machine.id)
 
         self.debug(
-            "Verify listVirtualMachines response for virtual machine: %s"\
+            "Verify listVirtualMachines response for virtual machine: %s"
             % self.virtual_machine.id
         )
 
@@ -380,15 +434,15 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             msg="VM is not in Running state"
         )
         if vgput != "nonvgpuoffering":
-           self.assertEqual(
-              vm.vgpu,
-              vgput,
-              msg="Failed to deploy VM with vGPU card"
-           )
+            self.assertEqual(
+                vm.vgpu,
+                vgput,
+                msg="Failed to deploy VM with vGPU card"
+            )
         return
 
-    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
-    def delete_vgpu_service_offering(self,serviceoffering):
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
+    def delete_vgpu_service_offering(self, serviceoffering):
         """
         delete vGPU Service Offering
         """
@@ -397,41 +451,44 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         list_service_response = list_service_offering(
             self.apiclient,
             id=serviceoffering.id
-                         )
+        )
 
         self.assertEqual(
             list_service_response,
             None,
             "Check if service offering exists in listServiceOfferings"
-                    )
+        )
         return
 
-    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
-    def check_for_vm(self,vgpucard,vgpuofferingid,vmid):
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
+    def check_for_vm(self, vgpucard, vgpuofferingid, vmid):
         list_vm_response = list_virtual_machines(
-                                                     self.apiclient,
-                                                     id=vmid
-                                                     )
+            self.apiclient,
+            id=vmid
+        )
 
         if isinstance(list_vm_response, list):
-                vm = list_vm_response[0]
-                if vm.state == 'Running':
-                   self.debug("VM state: %s" % vm.state)
-                else:
-                    self.fail("Failed to start VM (ID: %s)" % vm.id)
-                if vm.serviceofferingid == vgpuofferingid:
-                    self.debug("VM service offering id : %s" % vm.serviceofferingid)
+            vm = list_vm_response[0]
+            if vm.state == 'Running':
+                self.debug("VM state: %s" % vm.state)
+            else:
+                self.fail("Failed to start VM (ID: %s)" % vm.id)
+            if vm.serviceofferingid == vgpuofferingid:
+                self.debug(
+                    "VM service offering id : %s" %
+                    vm.serviceofferingid)
+            else:
+                self.fail("Service Offering is not matching " % vm.id)
+            if vgpucard != "nonvgpuoffering":
+                if vm.vgpu == vgpucard:
+                    self.debug("VM vGPU card is : %s" % vm.vgpu)
                 else:
-                    self.fail("Service Offering is not matching " % vm.id)
-                if vgpucard !="nonvgpuoffering":
-                    if vm.vgpu == vgpucard:
-                        self.debug("VM vGPU card is : %s" % vm.vgpu)
-                    else:
-                        self.fail("Failed to start VM (ID: %s) with %s vGPU card " % (vm.id,vgpucard))
+                    self.fail(
+                        "Failed to start VM (ID: %s) with %s vGPU card " %
+                        (vm.id, vgpucard))
         return(list_vm_response[0])
 
-
-    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
     def destroy_vm(self):
         """Destroy Virtual Machine
         """
@@ -439,29 +496,29 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         self.virtual_machine.delete(self.apiclient)
 
         list_vm_response = VirtualMachine.list(
-                                            self.apiclient,
-                                            id=self.virtual_machine.id
-                                            )
+            self.apiclient,
+            id=self.virtual_machine.id
+        )
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
 
         self.assertNotEqual(
-                            len(list_vm_response),
-                            0,
-                            "Check VM avaliable in List Virtual Machines"
-                        )
+            len(list_vm_response),
+            0,
+            "Check VM avaliable in List Virtual Machines"
+        )
 
         self.assertEqual(
-                            list_vm_response[0].state,
-                            "Destroyed",
-                            "Check virtual machine is in destroyed state"
-                        )
+            list_vm_response[0].state,
+            "Destroyed",
+            "Check virtual machine is in destroyed state"
+        )
         return
 
-    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
     def stop_vm(self):
         """Stop Virtual Machine
         """
@@ -472,7 +529,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             self.fail("Failed to stop VM: %s" % e)
         return
 
-    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
     def start_vm(self):
         """Start Virtual Machine
         """
@@ -481,45 +538,61 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         self.virtual_machine.start(self.apiclient)
 
         list_vm_response = VirtualMachine.list(
-                                            self.apiclient,
-                                            id=self.virtual_machine.id
-                                            )
+            self.apiclient,
+            id=self.virtual_machine.id
+        )
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
 
         self.assertNotEqual(
-                            len(list_vm_response),
-                            0,
-                            "Check VM available in List Virtual Machines"
-                        )
+            len(list_vm_response),
+            0,
+            "Check VM available in List Virtual Machines"
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-                )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % self.virtual_machine.id
+        )
         self.assertEqual(
-                            list_vm_response[0].state,
-                            "Running",
-                            "Check virtual machine is in running state"
-                        )
+            list_vm_response[0].state,
+            "Running",
+            "Check virtual machine is in running state"
+        )
         return
 
-    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
-    def serviceoffering_upgrade(self,sourcetype,sourcemodel,desttype,destmodel):
-
-        self.sourcevgpuoffering=self.vgpu_serviceoffering_creation(sourcetype,sourcemodel)
-        self.deploy_vGPU_windows_vm(self.sourcevgpuoffering.id,sourcetype)
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
+    def serviceoffering_upgrade(
+            self,
+            sourcetype,
+            sourcemodel,
+            desttype,
+            destmodel):
+
+        self.sourcevgpuoffering = self.vgpu_serviceoffering_creation(
+            sourcetype,
+            sourcemodel)
+        self.deploy_vGPU_windows_vm(self.sourcevgpuoffering.id, sourcetype)
         time.sleep(self.testdata["vgpu"]["sleep"])
 
-        vm=self.check_for_vm(sourcetype,self.sourcevgpuoffering.id,self.virtual_machine.id)
-        self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
+        vm = self.check_for_vm(
+            sourcetype,
+            self.sourcevgpuoffering.id,
+            self.virtual_machine.id)
+        self.check_for_vGPU_resource(
+            vm.hostid,
+            vm.instancename,
+            vm.serviceofferingid,
+            vm.vgpu)
 
         self.stop_vm()
 
-        self.destvgpuoffering=self.vgpu_serviceoffering_creation(desttype,destmodel)
+        self.destvgpuoffering = self.vgpu_serviceoffering_creation(
+            desttype,
+            destmodel)
         cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
         cmd.id = vm.id
         cmd.serviceofferingid = self.destvgpuoffering.id
@@ -529,28 +602,47 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         self.start_vm()
         time.sleep(self.testdata["vgpu"]["sleep"])
 
-            # Ensure that VM is in running state
-        vm=self.check_for_vm(desttype,self.destvgpuoffering.id,vm.id)
-        self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
+        # Ensure that VM is in running state
+        vm = self.check_for_vm(desttype, self.destvgpuoffering.id, vm.id)
+        self.check_for_vGPU_resource(
+            vm.hostid,
+            vm.instancename,
+            vm.serviceofferingid,
+            vm.vgpu)
         self.delete_vgpu_service_offering(self.destvgpuoffering)
         self.delete_vgpu_service_offering(self.sourcevgpuoffering)
         self.destroy_vm()
         return
 
-
-    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
-    def vm_snapshot_serviceoffering_upgrade(self,sourcetype,sourcemodel,desttype,destmodel):
-
-        self.sourcevgpuoffering=self.vgpu_serviceoffering_creation(sourcetype,sourcemodel)
-        self.deploy_vGPU_windows_vm(self.sourcevgpuoffering.id,sourcetype)
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
+    def vm_snapshot_serviceoffering_upgrade(
+            self,
+            sourcetype,
+            sourcemodel,
+            desttype,
+            destmodel):
+
+        self.sourcevgpuoffering = self.vgpu_serviceoffering_creation(
+            sourcetype,
+            sourcemodel)
+        self.deploy_vGPU_windows_vm(self.sourcevgpuoffering.id, sourcetype)
         time.sleep(self.testdata["vgpu"]["sleep"])
 
-        vm=self.check_for_vm(sourcetype,self.sourcevgpuoffering.id,self.virtual_machine.id)
-        self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
+        vm = self.check_for_vm(
+            sourcetype,
+            self.sourcevgpuoffering.id,
+            self.virtual_machine.id)
+        self.check_for_vGPU_resource(
+            vm.hostid,
+            vm.instancename,
+            vm.serviceofferingid,
+            vm.vgpu)
 
         self.stop_vm()
 
-        self.destvgpuoffering=self.vgpu_serviceoffering_creation(desttype,destmodel)
+        self.destvgpuoffering = self.vgpu_serviceoffering_creation(
+            desttype,
+            destmodel)
         cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
         cmd.id = vm.id
         cmd.serviceofferingid = self.destvgpuoffering.id
@@ -560,66 +652,84 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         self.start_vm()
         time.sleep(self.testdata["vgpu"]["sleep"])
 
-            # Ensure that VM is in running state
-        vm=self.check_for_vm(desttype,self.destvgpuoffering.id,vm.id)
-        self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
+        # Ensure that VM is in running state
+        vm = self.check_for_vm(desttype, self.destvgpuoffering.id, vm.id)
+        self.check_for_vGPU_resource(
+            vm.hostid,
+            vm.instancename,
+            vm.serviceofferingid,
+            vm.vgpu)
         self.delete_vgpu_service_offering(self.destvgpuoffering)
         self.delete_vgpu_service_offering(self.sourcevgpuoffering)
         self.destroy_vm()
         return
 
-    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
-    def deploy_vm(self,type,model):
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
+    def deploy_vm(self, type, model):
 
-        self.vgpuoffering=self.vgpu_serviceoffering_creation(type,model)
+        self.vgpuoffering = self.vgpu_serviceoffering_creation(type, model)
         if self.vgpuoffering is not None:
-              self.deploy_vGPU_windows_vm(self.vgpuoffering.id,type)
-              time.sleep(self.testdata["vgpu"]["sleep"])
-              vm=self.check_for_vm(type,self.vgpuoffering.id,self.virtual_machine.id)
-              self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
-              self.destroy_vm()
-              self.delete_vgpu_service_offering(self.vgpuoffering)
+            self.deploy_vGPU_windows_vm(self.vgpuoffering.id, type)
+            time.sleep(self.testdata["vgpu"]["sleep"])
+            vm = self.check_for_vm(
+                type,
+                self.vgpuoffering.id,
+                self.virtual_machine.id)
+            self.check_for_vGPU_resource(
+                vm.hostid,
+                vm.instancename,
+                vm.serviceofferingid,
+                vm.vgpu)
+            self.destroy_vm()
+            self.delete_vgpu_service_offering(self.vgpuoffering)
         return
 
+    def new_template_register(self, guestostype):
 
-    def new_template_register(self,guestostype):
-
-        template1 = get_windows_template(self.apiclient, self.zone.id ,ostype_desc=guestostype)
-
-        if  template1 == FAILED:
-            if "http://pleaseupdateURL/dummy.vhd" in cls.testdata["vgpu"] [guestostype]["url"]:
-                raise unittest.SkipTest("Check Test Data file if it has the valid template URL")
+        template1 = get_windows_template(
+            self.apiclient,
+            self.zone.id,
+            ostype_desc=guestostype)
+
+        if template1 == FAILED:
+            if "http://pleaseupdateURL/dummy.vhd" in self.testdata[
+                    "vgpu"][guestostype]["url"]:
+                raise unittest.SkipTest(
+                    "Check Test Data file if it has the valid template URL")
             template1 = Template.register(
-                   self.apiclient,
-                   self.testdata["vgpu"] [guestostype],
-                   hypervisor = "XenServer",
-                   zoneid=cls.zone.id,
-                   domainid=cls.account.domainid,
-                   account=cls.account.name
-                   )
+                self.apiclient,
+                self.testdata["vgpu"][guestostype],
+                hypervisor="XenServer",
+                zoneid=self.zone.id,
+                domainid=self.account.domainid,
+                account=self.account.name
+            )
             timeout = self.testdata["vgpu"]["timeout"]
 
             while True:
-                  time.sleep(self.testdata["vgpu"]["sleep"])
-                  list_template_response = Template.list(
-                       self.apiclient,
-                       templatefilter=\
-                       self.testdata["templatefilter"],
-                       id=template1.id
-                        )
-                  if (isinstance(list_template_response, list)) is not True:
-                      raise unittest.SkipTest("Check list template api response returns a valid list")
-
-                  if len(list_template_response) is None :
-                      raise unittest.SkipTest("Check template registered is in List Templates")
-
-                  template_response = list_template_response[0]
-                  if template_response.isready == True:
-                      break
-                  if timeout == 0:
-                      raise unittest.SkipTest("Failed to download template(ID: %s)" % template_response.id)
-
-                  timeout = timeout - 1
+                time.sleep(self.testdata["vgpu"]["sleep"])
+                list_template_response = Template.list(
+                    self.apiclient,
+                    templatefilter=self.testdata["templatefilter"],
+                    id=template1.id
+                )
+                if (isinstance(list_template_response, list)) is not True:
+                    raise unittest.SkipTest(
+                        "Check list template api response returns a valid list")
+
+                if len(list_template_response) is None:
+                    raise unittest.SkipTest(
+                        "Check template registered is in List Templates")
+
+                template_response = list_template_response[0]
+                if template_response.isready:
+                    break
+                if timeout == 0:
+                    raise unittest.SkipTest(
+                        "Failed to download template(ID: %s)" %
+                        template_response.id)
+
+                timeout = timeout - 1
         return(template1.id)
 
     def deploy_vm_lifecycle(self):
@@ -632,49 +742,50 @@ class TestvGPUWindowsVm(cloudstackTestCase):
                 gtype = "GRID K140Q"
             elif(self.k120qgpuhosts != 0):
                 gtype = "GRID K120Q"
-            elif(self.k100gpuhosts !=0):
+            elif(self.k100gpuhosts != 0):
                 gtype = "GRID K100"
             else:
                 gtype = "passthrough"
 
-            self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [{'pciDevice':'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'},
-                                                                                       {'vgpuType':gtype}]
+            self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [
+                {'pciDevice': 'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'}, {'vgpuType': gtype}]
             try:
-               self.__class__.k100_vgpu_service_offering = ServiceOffering.create(
-                                                                    self.apiclient,
-                                                                    self.testdata["vgpu"]["service_offerings"][gtype]
-                                                                    )
+                self.__class__.k100_vgpu_service_offering = ServiceOffering.create(
+                    self.apiclient,
+                    self.testdata["vgpu"]["service_offerings"][gtype]
+                )
             except Exception as e:
-               self.fail("Failed to create the service offering, %s" % e)
+                self.fail("Failed to create the service offering, %s" % e)
 
         if(self.k2hosts != 0):
             if(self.k240qgpuhosts != 0):
                 gtype = "GRID K240Q"
-            elif(cls.k220qgpuhosts != 0):
+            elif(self.k220qgpuhosts != 0):
                 gtype = "GRID K220Q"
-            elif(self.k200gpuhosts !=0):
+            elif(self.k200gpuhosts != 0):
                 gtype = "GRID K200"
             else:
                 gtype = "passthrough"
 
-            self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [{'pciDevice': 'Group of NVIDIA Corporation GK104GL [GRID K2] GPUs'},
-                                                                                       {'vgpuType':gtype}]
+            self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [
+                {'pciDevice': 'Group of NVIDIA Corporation GK104GL [GRID K2] GPUs'}, {'vgpuType': gtype}]
             try:
-               self.__class__.k200_vgpu_service_offering = ServiceOffering.create(
-                                                                    self.apiclient,
-                                                                    self.testdata["vgpu"]["service_offerings"][gtype]
-                                                                    )
+                self.__class__.k200_vgpu_service_offering = ServiceOffering.create(
+                    self.apiclient,
+                    self.testdata["vgpu"]["service_offerings"][gtype]
+                )
             except Exception as e:
-              self.fail("Failed to create the service offering, %s" % e)
+                self.fail("Failed to create the service offering, %s" % e)
 
-        win8templateid=self.new_template_register("Windows 8 (64-bit)")
-        win2012templateid=self.new_template_register("Windows Server 2012 (64-bit)")
-        win7templateid=self.new_template_register("Windows 7 (64-bit)")
+        win8templateid = self.new_template_register("Windows 8 (64-bit)")
+        win2012templateid = self.new_template_register(
+            "Windows Server 2012 (64-bit)")
+        win7templateid = self.new_template_register("Windows 7 (64-bit)")
 
         self.__class__.nonvgpu_service_offering = ServiceOffering.create(
-                                                                    self.apiclient,
-                                                                    self.testdata["vgpu"]["service_offerings"]["nonvgpuoffering"]
-                                                                    )
+            self.apiclient,
+            self.testdata["vgpu"]["service_offerings"]["nonvgpuoffering"]
+        )
 
         """
         Create Virtual Machines for Both K1 and K2 cards to be used for VM life cycle tests
@@ -682,34 +793,34 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
         if(self.k1hosts != 0):
             self.__class__.vm_k1_card = VirtualMachine.create(
-            self.apiclient,
-            self.testdata["virtual_machine"],
-            accountid=self.account.name,
-            zoneid=self.zone.id,
-            domainid=self.account.domainid,
-            serviceofferingid=self.k100_vgpu_service_offering.id,
-            templateid=win8templateid
+                self.apiclient,
+                self.testdata["virtual_machine"],
+                accountid=self.account.name,
+                zoneid=self.zone.id,
+                domainid=self.account.domainid,
+                serviceofferingid=self.k100_vgpu_service_offering.id,
+                templateid=win8templateid
             )
 
-        if(self.k2hosts !=0):
+        if(self.k2hosts != 0):
             self.__class__.vm_k2_card = VirtualMachine.create(
-            self.apiclient,
-            self.testdata["virtual_machine"],
-            accountid=self.account.name,
-            zoneid=self.zone.id,
-            domainid=self.account.domainid,
-            serviceofferingid=self.k200_vgpu_service_offering.id,
-            templateid=win2012templateid
+                self.apiclient,
+                self.testdata["virtual_machine"],
+                accountid=self.account.name,
+                zoneid=self.zone.id,
+                domainid=self.account.domainid,
+                serviceofferingid=self.k200_vgpu_service_offering.id,
+                templateid=win2012templateid
             )
-        if(self.k2hosts !=0):
+        if(self.k2hosts != 0):
             self.__class__.vm2_k2_card = VirtualMachine.create(
-            self.apiclient,
-            self.testdata["virtual_machine"],
-            accountid=self.account.name,
-            zoneid=self.zone.id,
-            domainid=self.account.domainid,
-            serviceofferingid=self.k200_vgpu_service_offering.id,
-            templateid=win7templateid
+                self.apiclient,
+                self.testdata["virtual_machine"],
+                accountid=self.account.name,
+                zoneid=self.zone.id,
+                domainid=self.account.domainid,
+                serviceofferingid=self.k200_vgpu_service_offering.id,
+                templateid=win7templateid
             )
 
         self.__class__.nonvgpu = VirtualMachine.create(
@@ -720,174 +831,191 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             domainid=self.account.domainid,
             serviceofferingid=self.__class__.nonvgpu_service_offering.id,
             templateid=win7templateid
-            )
+        )
 
         return
 
-
-    def check_gpu_resources_released_vm(self,gpuhostid,vm_vgpu_type,rcapacity):
+    def check_gpu_resources_released_vm(
+            self,
+            gpuhostid,
+            vm_vgpu_type,
+            rcapacity):
         hhosts = list_hosts(
-               self.apiclient,
-               hypervisor="XenServer",
-               id=gpuhostid
-               )
+            self.apiclient,
+            hypervisor="XenServer",
+            id=gpuhostid
+        )
         self.assertEqual(
-                            isinstance(hhosts, list),
-                            True,
-                            "Check list hosts response returns a valid list"
-                        )
+            isinstance(hhosts, list),
+            True,
+            "Check list hosts response returns a valid list"
+        )
 
         self.assertNotEqual(
-                            len(hhosts),
-                            0,
-                            "Check Host details are available in List Hosts"
-                        )
+            len(hhosts),
+            0,
+            "Check Host details are available in List Hosts"
+        )
         for ggroup in hhosts:
-               if ggroup.ipaddress not in self.nongpuhosts:
-                  for gp in ggroup.gpugroup:
-                      #if gp.gpugroupname == "Group of NVIDIA Corporation GK104GL [GRID K2] GPUs":
-                         for gptype in gp.vgpu:
-                             if gptype.vgputype==vm_vgpu_type:
-                                self.debug("Latest remainingcapacity is %s and before remainingcapacity is %s"%(gptype.remainingcapacity,rcapacity))
-                                if gptype.remainingcapacity != rcapacity+1:
-                                   self.fail("Host capacity is not updated .GPU resources should be released when VM is stopped/Destroyed ")
+            if ggroup.ipaddress not in self.nongpuhosts:
+                for gp in ggroup.gpugroup:
+                    # if gp.gpugroupname == "Group of NVIDIA Corporation
+                    # GK104GL [GRID K2] GPUs":
+                    for gptype in gp.vgpu:
+                        if gptype.vgputype == vm_vgpu_type:
+                            self.debug(
+                                "Latest remainingcapacity is %s and before remainingcapacity is %s" %
+                                (gptype.remainingcapacity, rcapacity))
+                            if gptype.remainingcapacity != rcapacity + 1:
+                                self.fail(
+                                    "Host capacity is not updated .GPU resources should be released when VM is stopped/Destroyed ")
         return
 
-    def check_vm_state(self,vmid):
+    def check_vm_state(self, vmid):
         list_vm_response = list_virtual_machines(
-                                                     self.apiclient,
-                                                     id=vmid
-                                                     )
+            self.apiclient,
+            id=vmid
+        )
 
         if list_vm_response is None:
             return("Expunge")
         return(list_vm_response[0].state)
 
-    def check_host_vgpu_remaining_capacity(self,gpuhostid,gtype):
+    def check_host_vgpu_remaining_capacity(self, gpuhostid, gtype):
         gputhosts = list_hosts(
-               self.apiclient,
-               hypervisor="XenServer",
-               id=gpuhostid
-               )
-        vgpucapacity=0
+            self.apiclient,
+            hypervisor="XenServer",
+            id=gpuhostid
+        )
+        vgpucapacity = 0
         for ghost in gputhosts:
             if ghost.gpugroup is not None:
-                        for gp in ghost.gpugroup:
-                            #if gp.gpugroupname == gpucard:
-                               for gptype in gp.vgpu:
-                                   if gptype.vgputype == gtype:
-                                      vgpucapacity=vgpucapacity+gptype.remainingcapacity
+                for gp in ghost.gpugroup:
+                    # if gp.gpugroupname == gpucard:
+                    for gptype in gp.vgpu:
+                        if gptype.vgputype == gtype:
+                            vgpucapacity = vgpucapacity + \
+                                gptype.remainingcapacity
 
         return(vgpucapacity)
 
-    def verify_vm(self,vm_gpu_card):
+    def verify_vm(self, vm_gpu_card):
         if(vm_gpu_card):
-           vm_gpu_card.getState(
-                                   self.apiclient,
-                                   "Running")
-           time.sleep(self.testdata["vgpu"]["sleep"]*3)
-           self.check_for_vGPU_resource(vm_gpu_card.hostid,vm_gpu_card.instancename,vm_gpu_card.serviceofferingid,vm_gpu_card.vgpu)
-
-    def stop_life_cycle_vm (self,vm_gpu_card):
+            vm_gpu_card.getState(
+                self.apiclient,
+                "Running")
+            time.sleep(self.testdata["vgpu"]["sleep"] * 3)
+            self.check_for_vGPU_resource(
+                vm_gpu_card.hostid,
+                vm_gpu_card.instancename,
+                vm_gpu_card.serviceofferingid,
+                vm_gpu_card.vgpu)
+
+    def stop_life_cycle_vm(self, vm_gpu_card):
 
         if(vm_gpu_card):
-          vm_gpu_card.stop(self.apiclient)
-          time.sleep(self.testdata["vgpu"]["sleep"])
-          vm_gpu_card.getState(
-                                   self.apiclient,
-                                   "Stopped")
+            vm_gpu_card.stop(self.apiclient)
+            time.sleep(self.testdata["vgpu"]["sleep"])
+            vm_gpu_card.getState(
+                self.apiclient,
+                "Stopped")
 
-    def start_life_cycle_vm(self,vm_gpu_card):
+    def start_life_cycle_vm(self, vm_gpu_card):
 
         if(vm_gpu_card):
-          vm_gpu_card.start(self.apiclient)
-          time.sleep(self.testdata["vgpu"]["sleep"])
-          vm_gpu_card.getState(
-                                   self.apiclient,
-                                   "Running")
+            vm_gpu_card.start(self.apiclient)
+            time.sleep(self.testdata["vgpu"]["sleep"])
+            vm_gpu_card.getState(
+                self.apiclient,
+                "Running")
 
-
-    def restore_life_cycle_vm(self,vm_gpu_card):
+    def restore_life_cycle_vm(self, vm_gpu_card):
         if(vm_gpu_card):
-          vm_gpu_card.restore(self.apiclient)
-          time.sleep(self.testdata["vgpu"]["sleep"])
+            vm_gpu_card.restore(self.apiclient)
+            time.sleep(self.testdata["vgpu"]["sleep"])
 
-    def reboot_life_cycle_vm(self,vm_gpu_card):
+    def reboot_life_cycle_vm(self, vm_gpu_card):
 
         if(vm_gpu_card):
-          vm_gpu_card.reboot(self.apiclient)
-          time.sleep(self.testdata["vgpu"]["sleep"])
+            vm_gpu_card.reboot(self.apiclient)
+            time.sleep(self.testdata["vgpu"]["sleep"])
 
-    def delete_vm_life_cycle_vm(self,vm_gpu_card):
+    def delete_vm_life_cycle_vm(self, vm_gpu_card):
         if(vm_gpu_card):
-          vm_gpu_card.delete(self.apiclient)
-          time.sleep(self.testdata["vgpu"]["sleep"])
-          vm_gpu_card.getState(
-                                   self.apiclient,
-                                   "Destroyed")
+            vm_gpu_card.delete(self.apiclient)
+            time.sleep(self.testdata["vgpu"]["sleep"])
+            vm_gpu_card.getState(
+                self.apiclient,
+                "Destroyed")
 
-    def recover_vm_life_cycle_vm(self,vm_gpu_card):
+    def recover_vm_life_cycle_vm(self, vm_gpu_card):
         if(vm_gpu_card):
-          vm_gpu_card.recover(self.apiclient)
-          vm_gpu_card.getState(
-                                   self.apiclient,
-                                   "Stopped")
-
+            vm_gpu_card.recover(self.apiclient)
+            vm_gpu_card.getState(
+                self.apiclient,
+                "Stopped")
 
-    def recovervm(self,vm_gpu_card):
-        if self.check_vm_state(vm_gpu_card.id)=="Expunge":
+    def recovervm(self, vm_gpu_card):
+        if self.check_vm_state(vm_gpu_card.id) == "Expunge":
             raise unittest.SkipTest("VM is already deleted hence skipping")
         self.recover_vm_life_cycle_vm(vm_gpu_card)
         self.start_life_cycle_vm(vm_gpu_card)
         self.verify_vm(vm_gpu_card)
         return
 
-
-    def startvm(self,vm_gpu_card):
+    def startvm(self, vm_gpu_card):
 
         self.start_life_cycle_vm(vm_gpu_card)
         self.verify_vm(vm_gpu_card)
         return
 
-    def stopvm(self,vm_gpu_card):
+    def stopvm(self, vm_gpu_card):
 
-        rcapacity=self.check_host_vgpu_remaining_capacity(vm_gpu_card.hostid,vm_gpu_card.vgpu)
+        rcapacity = self.check_host_vgpu_remaining_capacity(
+            vm_gpu_card.hostid,
+            vm_gpu_card.vgpu)
         self.stop_life_cycle_vm(vm_gpu_card)
-        time.sleep(self.testdata["vgpu"]["sleep"]*3)
-        self.check_gpu_resources_released_vm(vm_gpu_card.hostid,vm_gpu_card.vgpu,rcapacity)
+        time.sleep(self.testdata["vgpu"]["sleep"] * 3)
+        self.check_gpu_resources_released_vm(
+            vm_gpu_card.hostid,
+            vm_gpu_card.vgpu,
+            rcapacity)
         return
 
-    def deletevm(self,vm_gpu_card):
+    def deletevm(self, vm_gpu_card):
 
-        rcapacity=self.check_host_vgpu_remaining_capacity(vm_gpu_card.hostid,vm_gpu_card.vgpu)
-        hostid=vm_gpu_card.hostid
-        vgputype=vm_gpu_card.vgpu
+        rcapacity = self.check_host_vgpu_remaining_capacity(
+            vm_gpu_card.hostid,
+            vm_gpu_card.vgpu)
+        hostid = vm_gpu_card.hostid
+        vgputype = vm_gpu_card.vgpu
         self.delete_vm_life_cycle_vm(vm_gpu_card)
-        time.sleep(self.testdata["vgpu"]["sleep"]*3)
-        self.check_gpu_resources_released_vm(hostid,vgputype,rcapacity)
+        time.sleep(self.testdata["vgpu"]["sleep"] * 3)
+        self.check_gpu_resources_released_vm(hostid, vgputype, rcapacity)
         return
 
-    def restorevm(self,vm_gpu_card):
+    def restorevm(self, vm_gpu_card):
 
         self.restore_life_cycle_vm(vm_gpu_card)
         self.verify_vm(vm_gpu_card)
         return
 
-
-
-
-    def create_vm_snapshot(self,vmcard):
+    def create_vm_snapshot(self, vmcard):
 
         self.debug("Check if deployed VMs are in running state?")
         if(vmcard):
-           vmcard.getState(
-                                   self.apiclient,
-                                   "Running")
-
-        if hasattr(vmcard,"vgpu"):
-           self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
-
-        vm_snapshot = VmSnapshot.create(
+            vmcard.getState(
+                self.apiclient,
+                "Running")
+
+        if hasattr(vmcard, "vgpu"):
+            self.check_for_vGPU_resource(
+                vmcard.hostid,
+                vmcard.instancename,
+                vmcard.serviceofferingid,
+                vmcard.vgpu)
+
+        VmSnapshot.create(
             self.apiclient,
             vmcard.id,
             "false",
@@ -895,7 +1023,10 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             "Display Text"
         )
 
-        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
+        list_snapshot_response = VmSnapshot.list(
+            self.apiclient,
+            virtualmachineid=vmcard.id,
+            listall=True)
 
         self.assertEqual(
             isinstance(list_snapshot_response, list),
@@ -915,37 +1046,51 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         )
 
         vgpu_host = list_hosts(
-                               self.apiclient,
-                               id=vmcard.hostid
-                               )
-        ssh_client = SshClient(host=vgpu_host[0].ipaddress, port=22, user='root',passwd=self.testdata["host_password"])
+            self.apiclient,
+            id=vmcard.hostid
+        )
+        ssh_client = SshClient(
+            host=vgpu_host[0].ipaddress,
+            port=self.testdata['configurabledata']['host']["publicport"],
+            user=self.testdata['configurabledata']['host']["username"],
+            passwd=self.testdata['configurabledata']['host']["password"])
         """
         Get vGPU type model
         """
-        vgpu_snapshot = ssh_client.execute("xe snapshot-list name-label=" + list_snapshot_response[0].name + " --minimal")
+        vgpu_snapshot = ssh_client.execute(
+            "xe snapshot-list name-label=" +
+            list_snapshot_response[0].name +
+            " --minimal")
         #vgpu_snapshot = ssh_client.execute("xe snapshot-param-get param-name=name-label uuid="+vgpu_snapshot_uuid[0]+ " params=type-model-name --minimal")
 
 #        self.debug("vgpu type model is %s and value is %s and length is %s"%(vgpu_type_model,vgpu_type_model[0],len(vgpu_type_model[0])))
 
         self.assertNotEqual(
-                            len(vgpu_snapshot[0]),
-                            0,
-                            "VM Snapshot is not created"
-                        )
-        self.__class__.vmsnapwomemory=1
+            len(vgpu_snapshot[0]),
+            0,
+            "VM Snapshot is not created"
+        )
+        self.__class__.vmsnapwomemory = 1
         return
 
-    def revert_vm_snapshot(self,vmcard):
+    def revert_vm_snapshot(self, vmcard):
 
         self.debug("Check if deployed VMs are in running state?")
-        #if(vmcard):
-         #  vmcard.getState(
-          #                         self.apiclient,
-          #                         "Running")
-        if hasattr(vmcard,"vgpu"):
-           self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
-
-        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
+        # if(vmcard):
+        #  vmcard.getState(
+        #                         self.apiclient,
+        #                         "Running")
+        if hasattr(vmcard, "vgpu"):
+            self.check_for_vGPU_resource(
+                vmcard.hostid,
+                vmcard.instancename,
+                vmcard.serviceofferingid,
+                vmcard.vgpu)
+
+        list_snapshot_response = VmSnapshot.list(
+            self.apiclient,
+            virtualmachineid=vmcard.id,
+            listall=True)
 
         self.assertEqual(
             isinstance(list_snapshot_response, list),
@@ -964,13 +1109,15 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             "Check the snapshot of vm is ready!"
         )
 
-        VmSnapshot.revertToSnapshot(self.apiclient, list_snapshot_response[0].id)
+        VmSnapshot.revertToSnapshot(
+            self.apiclient,
+            list_snapshot_response[0].id)
         time.sleep(self.testdata["vgpu"]["sleep"])
         list_vm_response = list_virtual_machines(
             self.apiclient,
             id=vmcard.id
         )
-        vm=list_vm_response[0]
+        vm = list_vm_response[0]
         self.assertEqual(
             list_vm_response[0].state,
             "Stopped",
@@ -986,22 +1133,28 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             self.apiclient,
             id=vm.id
         )
-        vm=list_vm_response[0]
+        vm = list_vm_response[0]
         if vm is None:
             self.fail("Failed to list VM details after Vm Snapshot")
         self.assertEqual(
-             vm.state,
+            vm.state,
             "Running",
             "Check the state of vm is Running"
         )
 
-        if hasattr(vmcard,"vgpu"):
-           self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
+        if hasattr(vmcard, "vgpu"):
+            self.check_for_vGPU_resource(
+                vmcard.hostid,
+                vmcard.instancename,
+                vmcard.serviceofferingid,
+                vmcard.vgpu)
 
+    def delete_vm_snapshot(self, vmcard):
 
-    def delete_vm_snapshot(self,vmcard):
-
-        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
+        list_snapshot_response = VmSnapshot.list(
+            self.apiclient,
+            virtualmachineid=vmcard.id,
+            listall=True)
 
         self.assertEqual(
             isinstance(list_snapshot_response, list),
@@ -1013,13 +1166,20 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             None,
             "Check if snapshot exists in ListSnapshot"
         )
-        Tobedeletedsnapname=list_snapshot_response[0].name
-        VmSnapshot.deleteVMSnapshot(self.apiclient, list_snapshot_response[0].id)
+        Tobedeletedsnapname = list_snapshot_response[0].name
+        VmSnapshot.deleteVMSnapshot(
+            self.apiclient,
+            list_snapshot_response[0].id)
 
         time.sleep(self.testdata["vgpu"]["sleep"])
 
-        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
-        self.debug("List Snapshot response after snapshot deletion %s"%list_snapshot_response)
+        list_snapshot_response = VmSnapshot.list(
+            self.apiclient,
+            virtualmachineid=vmcard.id,
+            listall=True)
+        self.debug(
+            "List Snapshot response after snapshot deletion %s" %
+            list_snapshot_response)
         self.assertEqual(
             list_snapshot_response,
             None,
@@ -1027,35 +1187,47 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         )
 
         vgpu_host = list_hosts(
-                               self.apiclient,
-                               id=vmcard.hostid
-                               )
-        ssh_client = SshClient(host=vgpu_host[0].ipaddress, port=22, user='root',passwd=self.testdata["host_password"])
-
-        vgpu_snapshot = ssh_client.execute("xe snapshot-list name-label=" +Tobedeletedsnapname + " --minimal")
+            self.apiclient,
+            id=vmcard.hostid
+        )
+        ssh_client = SshClient(
+            host=vgpu_host[0].ipaddress,
+            port=self.testdata['configurabledata']['host']["publicport"],
+            user=self.testdata['configurabledata']['host']["username"],
+            passwd=self.testdata['configurabledata']['host']["password"])
+
+        vgpu_snapshot = ssh_client.execute(
+            "xe snapshot-list name-label=" +
+            Tobedeletedsnapname +
+            " --minimal")
         #vgpu_snapshot = ssh_client.execute("xe snapshot-param-get param-name=name-label uuid="+vgpu_snapshot_uuid[0]+ " params=type-model-name --minimal")
 
 #        self.debug("vgpu type model is %s and value is %s and length is %s"%(vgpu_type_model,vgpu_type_model[0],len(vgpu_type_model[0])))
-        self.debug("List Snapshot response after snapshot deletion is %s %s"%(vgpu_snapshot,vgpu_snapshot[0]))
+        self.debug(
+            "List Snapshot response after snapshot deletion is %s %s" %
+            (vgpu_snapshot, vgpu_snapshot[0]))
         self.assertEqual(
-                            len(vgpu_snapshot[0]),
-                            0,
-                            "check if VM Snapshot is not deleted"
-                        )
+            len(vgpu_snapshot[0]),
+            0,
+            "check if VM Snapshot is not deleted"
+        )
 
         return
 
-
-    def create_vm_snapshot_with_memory(self,vmcard):
+    def create_vm_snapshot_with_memory(self, vmcard):
 
         self.debug("Check if deployed VMs are in running state?")
         if(vmcard):
-          vmcard.getState(
-                                   self.apiclient,
-                                   "Running")
-          self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
-
-        vm_snapshot = VmSnapshot.create(
+            vmcard.getState(
+                self.apiclient,
+                "Running")
+            self.check_for_vGPU_resource(
+                vmcard.hostid,
+                vmcard.instancename,
+                vmcard.serviceofferingid,
+                vmcard.vgpu)
+
+        VmSnapshot.create(
             self.apiclient,
             vmcard.id,
             "true",
@@ -1065,7 +1237,10 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
         time.sleep(self.testdata["vgpu"]["sleep"] * 3)
 
-        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
+        list_snapshot_response = VmSnapshot.list(
+            self.apiclient,
+            virtualmachineid=vmcard.id,
+            listall=True)
 
         self.assertEqual(
             isinstance(list_snapshot_response, list),
@@ -1085,35 +1260,48 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         )
 
         vgpu_host = list_hosts(
-                               self.apiclient,
-                               id=vmcard.hostid
-                               )
-        ssh_client = SshClient(host=vgpu_host[0].ipaddress, port=22, user='root',passwd=self.testdata["host_password"])
-
-        vgpu_snapshot = ssh_client.execute("xe snapshot-list name-label=" + list_snapshot_response[0].name + " --minimal")
+            self.apiclient,
+            id=vmcard.hostid
+        )
+        ssh_client = SshClient(
+            host=vgpu_host[0].ipaddress,
+            port=self.testdata['configurabledata']['host']["publicport"],
+            user=self.testdata['configurabledata']['host']["username"],
+            passwd=self.testdata['configurabledata']['host']["password"])
+
+        vgpu_snapshot = ssh_client.execute(
+            "xe snapshot-list name-label=" +
+            list_snapshot_response[0].name +
+            " --minimal")
         #vgpu_snapshot = ssh_client.execute("xe snapshot-param-get param-name=name-label uuid="+vgpu_snapshot_uuid[0]+ " params=type-model-name --minimal")
 
 #        self.debug("vgpu type model is %s and value is %s and length is %s"%(vgpu_type_model,vgpu_type_model[0],len(vgpu_type_model[0])))
 
         self.assertNotEqual(
-                            len(vgpu_snapshot[0]),
-                            0,
-                            "VM Snapshot is not created"
-                        )
-        self.__class__.vmsnapwithmemory=1
+            len(vgpu_snapshot[0]),
+            0,
+            "VM Snapshot is not created"
+        )
+        self.__class__.vmsnapwithmemory = 1
         return
 
-    def revert_vm_snapshot_with_memory(self,vmcard):
+    def revert_vm_snapshot_with_memory(self, vmcard):
 
         self.debug("Check if deployed VMs are in running state?")
         if(vmcard):
-          vmcard.getState(
-                                   self.apiclient,
-                                   "Running")
-          self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
-
-
-        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
+            vmcard.getState(
+                self.apiclient,
+                "Running")
+            self.check_for_vGPU_resource(
+                vmcard.hostid,
+                vmcard.instancename,
+                vmcard.serviceofferingid,
+                vmcard.vgpu)
+
+        list_snapshot_response = VmSnapshot.list(
+            self.apiclient,
+            virtualmachineid=vmcard.id,
+            listall=True)
 
         self.assertEqual(
             isinstance(list_snapshot_response, list),
@@ -1132,40 +1320,51 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             "Check the snapshot of vm is ready!"
         )
 
-        VmSnapshot.revertToSnapshot(self.apiclient, list_snapshot_response[0].id)
+        VmSnapshot.revertToSnapshot(
+            self.apiclient,
+            list_snapshot_response[0].id)
 
         list_vm_response = list_virtual_machines(
             self.apiclient,
             id=vmcard.id
         )
-        vm=list_vm_response[0]
+        vm = list_vm_response[0]
         if vm is None:
             self.fail("Failed to list VM details after Vm Snapshot")
         self.assertEqual(
-             vm.state,
+            vm.state,
             "Running",
             "Check the state of vm is Running"
         )
 
-        self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
-
+        self.check_for_vGPU_resource(
+            vmcard.hostid,
+            vmcard.instancename,
+            vmcard.serviceofferingid,
+            vmcard.vgpu)
 
         return
 
-
-    def rebootvm(self,vm_vgpu_card):
+    def rebootvm(self, vm_vgpu_card):
 
         self.reboot_life_cycle_vm(vm_vgpu_card)
         self.verify_vm(vm_vgpu_card)
         return
 
-
     @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
-    def  vm_snapshot_vgpu(self,vmcard,sourcetype,sourcemodel,desttype,destmodel):
+    def vm_snapshot_vgpu(
+            self,
+            vmcard,
+            sourcetype,
+            sourcemodel,
+            desttype,
+            destmodel):
 
         self.create_vm_snapshot(vmcard)
         self.start_life_cycle_vm(vmcard)
-        self.destvgpuoffering=self.vgpu_serviceoffering_creation(desttype,destmodel)
+        self.destvgpuoffering = self.vgpu_serviceoffering_creation(
+            desttype,
+            destmodel)
         self.stop_life_cycle_vm(vmcard)
         cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
         cmd.id = vmcard.id
@@ -1175,317 +1374,366 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         self.debug("Starting VM - ID: %s" % vmcard.id)
         self.start_life_cycle_vm(vmcard)
         time.sleep(self.testdata["vgpu"]["sleep"])
-        vm=self.check_for_vm(desttype,self.destvgpuoffering.id,vmcard.id)
-            # Ensure that VM is in running state
-        if destmodel!="None":
-           self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
+        vm = self.check_for_vm(desttype, self.destvgpuoffering.id, vmcard.id)
+        # Ensure that VM is in running state
+        if destmodel != "None":
+            self.check_for_vGPU_resource(
+                vm.hostid,
+                vm.instancename,
+                vm.serviceofferingid,
+                vm.vgpu)
 
         self.revert_vm_snapshot(vm)
 
         self.delete_vm_snapshot(vm)
 
-
-
     def test_01_list_vgpu_host_details(self):
         """   list vGPU host details  """
         hhosts = list_hosts(
-               self.apiclient,
-               hypervisor="XenServer",
-               )
+            self.apiclient,
+            hypervisor="XenServer",
+        )
         self.assertEqual(
-                            isinstance(hhosts, list),
-                            True,
-                            "Check list hosts response returns a valid list"
-                        )
+            isinstance(hhosts, list),
+            True,
+            "Check list hosts response returns a valid list"
+        )
 
         self.assertNotEqual(
-                            len(hhosts),
-                            0,
-                            "Check Host details are available in List Hosts"
-                        )
-        k260q=0
-        k240q=0
-        k220q=0
-        k200=0
-        k2pass=0
-
-        k140q=0
-        k120q=0
-        k100=0
-        k1pass=0
+            len(hhosts),
+            0,
+            "Check Host details are available in List Hosts"
+        )
+        k260q = 0
+        k240q = 0
+        k220q = 0
+        k200 = 0
+        k2pass = 0
+
+        k140q = 0
+        k120q = 0
+        k100 = 0
+        k1pass = 0
 
         for ggroup in hhosts:
             if ggroup.ipaddress not in self.nongpuhosts:
-               for gp in ggroup.gpugroup:
-                   if gp.gpugroupname == "Group of NVIDIA Corporation GK104GL [GRID K2] GPUs":
-                      for gptype in gp.vgpu:
-                         if gptype.vgputype == "GRID K260Q":
-                             k260q=k260q+1
-                         if gptype.vgputype == "GRID K220Q":
-                               k220q=k220q+1
-                         if gptype.vgputype == "GRID K240Q":
-                              k240q=k240q+1
-                         if gptype.vgputype == "GRID K200":
-                               k200=k200+1
-                         if gptype.vgputype != "passthrough":
-                              k2pass=k2pass+1
-                   if gp.gpugroupname == "Group of NVIDIA Corporation GK107GL [GRID K1] GPUs":
-                      for gptype in gp.vgpu:
-                          if gptype.vgputype == "GRID K140Q":
-                             k140q=k140q+1
-                          if gptype.vgputype == "GRID K120Q":
-                             k120q=k120q+1
-                          if gptype.vgputype == "GRID K100":
-                             k100=k100+1
-                          if gptype.vgputype == "passthrough":
-                             k1pass=k1pass+1
+                for gp in ggroup.gpugroup:
+                    if gp.gpugroupname == "Group of NVIDIA Corporation GK104GL [GRID K2] GPUs":
+                        for gptype in gp.vgpu:
+                            if gptype.vgputype == "GRID K260Q":
+                                k260q = k260q + 1
+                            if gptype.vgputype == "GRID K220Q":
+                                k220q = k220q + 1
+                            if gptype.vgputype == "GRID K240Q":
+                                k240q = k240q + 1
+                            if gptype.vgputype == "GRID K200":
+                                k200 = k200 + 1
+                            if gptype.vgputype != "passthrough":
+                                k2pass = k2pass + 1
+                    if gp.gpugroupname == "Group of NVIDIA Corporation GK107GL [GRID K1] GPUs":
+                        for gptype in gp.vgpu:
+                            if gptype.vgputype == "GRID K140Q":
+                                k140q = k140q + 1
+                            if gptype.vgputype == "GRID K120Q":
+                                k120q = k120q + 1
+                            if gptype.vgputype == "GRID K100":
+                                k100 = k100 + 1
+                            if gptype.vgputype == "passthrough":
+                                k1pass = k1pass + 1
             else:
-                self.debug("This is nongpuhost:%s"%(ggroup.ipaddress))
-        if self.k260qgpuhosts>0:
-           if not k260q:
-               self.fail("list host details with K260Q vgpu are not correct")
-        if self.k240qgpuhosts>0:
-           if not k240q:
-               self.fail("list host details with K240Q vgpu are not correct")
-        if self.k220qgpuhosts>0:
-           if not k220q:
-               self.fail("list host details with K220Q vgpu are not correct")
-        if self.k200gpuhosts>0:
-           if not k200:
-               self.fail("list host details with K200 vgpu are not correct")
-        if self.k2passthroughgpuhosts>0:
+                self.debug("This is nongpuhost:%s" % (ggroup.ipaddress))
+        if self.k260qgpuhosts > 0:
+            if not k260q:
+                self.fail("list host details with K260Q vgpu are not correct")
+        if self.k240qgpuhosts > 0:
+            if not k240q:
+                self.fail("list host details with K240Q vgpu are not correct")
+        if self.k220qgpuhosts > 0:
+            if not k220q:
+                self.fail("list host details with K220Q vgpu are not correct")
+        if self.k200gpuhosts > 0:
+            if not k200:
+                self.fail("list host details with K200 vgpu are not correct")
+        if self.k2passthroughgpuhosts > 0:
             if not k2pass:
-               self.fail("list host details with K2 passthrough vgpu are not correct")
-        if self.k140qgpuhosts>0:
-           if not k140q:
-               self.fail("list host details with K140Q vgpu are not correct")
-        if self.k120qgpuhosts>0:
-           if not k120q:
-               self.fail("list host details with K120Q vgpu are not correct")
-        if self.k100gpuhosts>0:
-           if not k100:
-               self.fail("list host details with K100 vgpu are not correct")
-        if self.k1passthroughgpuhosts>0:
-           if not k1pass:
-               self.fail("list host details with K1 Passthrough vgpu are not correct")
-
-    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
-
+                self.fail(
+                    "list host details with K2 passthrough vgpu are not correct")
+        if self.k140qgpuhosts > 0:
+            if not k140q:
+                self.fail("list host details with K140Q vgpu are not correct")
+        if self.k120qgpuhosts > 0:
+            if not k120q:
+                self.fail("list host details with K120Q vgpu are not correct")
+        if self.k100gpuhosts > 0:
+            if not k100:
+                self.fail("list host details with K100 vgpu are not correct")
+        if self.k1passthroughgpuhosts > 0:
+            if not k1pass:
+                self.fail(
+                    "list host details with K1 Passthrough vgpu are not correct")
+
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
     def test_02_create_deploy_windows_vm_with_k100_vgpu_service_offering(self):
         """Test to create and deploy vm with K100 vGPU service offering"""
 
-        k100capacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs","GRID K100")
+        k100capacity = self.check_host_vgpu_capacity(
+            "Group of NVIDIA Corporation GK107GL [GRID K1] GPUs",
+            "GRID K100")
 
         if (self.k100gpuhosts == 0) or (k100capacity == 0):
-           raise unittest.SkipTest("No XenServer available with K100 vGPU Drivers installed")
-
-        self.deploy_vm("GRID K100","Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
+            raise unittest.SkipTest(
+                "No XenServer available with K100 vGPU Drivers installed")
 
-    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
+        self.deploy_vm(
+            "GRID K100",
+            "Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
 
-    def test_03_create_deploy_windows_vm_with_k120q_vgpu_service_offering(self):
+    @attr(tags=['advanced', 'basic', 'vgpu'], required_hardware="true")
+    def test_03_create_deploy_windows_vm_with_k120q_vgpu_service_offering(
+            self):
         """Test to create and deploy vm with K120Q vGPU service offering"""
 
-        k120qcapa

<TRUNCATED>

Mime
View raw message