def setUpClass(cls):
        testClient = super(TestXDCCPInterop, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.services['mode'] = cls.zone.networktype

        hosts = list_hosts(cls.apiclient, type="Routing")

        if hosts is None:
            raise unittest.SkipTest(
                "There are no hypervisor's available.Check list hosts response"
            )
        for hypervisorhost in hosts:
            if hypervisorhost.hypervisor == "XenServer":
                cls.uploadtemplateformat = "VHD"
                break
            elif hypervisorhost.hypervisor == "VMware":
                cls.uploadtemplateformat = "OVA"
                break
            elif hypervisorhost.hypervisor == "KVM":
                cls.uploadtemplateformat = "KVM"
            break

        if cls.uploadtemplateformat == "KVM":
            raise unittest.SkipTest("Interop is not supported on KVM")

        cls.uploadurl = cls.services["interop"][
            cls.uploadtemplateformat]["url"]

        cls.xtemplate = get_template(cls.apiclient, cls.zone.id,
                                     cls.services["ostype"])
        if cls.xtemplate == FAILED:
            assert False, "get_template() failed to return template with description %s" % cls.services[
                "ostype"]

        cls.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     domainid=cls.domain.id,
                                     admin=False)
        cls.debug(cls.account.id)

        cls.service_offering = ServiceOffering.create(
            cls.apiclient, cls.services["service_offerings"]["large"])

        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/" in cls.uploadurl:
                raise unittest.SkipTest(
                    "Check Test Data file if it has the valid template URL")
            cls.template = Template.register(
                cls.apiclient,
                cls.services["interop"][cls.uploadtemplateformat],
                zoneid=cls.zone.id,
                domainid=cls.account.domainid,
                account=cls.account.name)
            timeout = cls.services["vgpu"]["timeout"]

            while True:
                time.sleep(cls.services["vgpu"]["sleep"])
                list_template_response = Template.list(
                    cls.apiclient,
                    templatefilter=cls.services["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")

                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
        cls.volume = []

        # Set Zones and disk offerings
        cls.services["small"]["zoneid"] = cls.zone.id
        cls.services["small"]["template"] = cls.template.id

        user_data = ''.join(
            random.choice(string.ascii_uppercase + string.digits)
            for x in range(2500))
        cls.services["virtual_machine"]["userdata"] = user_data

        #        cls.services["large"]["zoneid"] = cls.zone.id
        #        cls.services["large"]["template"] = cls.template.id

        cls.virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services["small"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            mode=cls.services['mode'],
            startvm="false")
        cls.user_api_client = cls.testClient.getUserApiClient(
            UserName=cls.account.name, DomainName=cls.account.domain)

        cls.cleanup = [cls.service_offering, cls.account]
    def setUpClass(cls):
        testClient = super(TestvGPUWindowsVm, cls).getClsTestClient()
        cls.testdata = cls.testClient.getParsedTestDataConfig()
        cls.apiclient = cls.testClient.getApiClient()
        cls._cleanup = []
        hosts = list_hosts(
               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")
        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
             k2hosts=0
             k1hosts=0

             for ghost in hosts :
                 if ghost.hypervisorversion >= "6.2.0":
                    sshClient = SshClient(host=ghost.ipaddress, port=22, user='******',passwd="host_password")

                    if ghost.hypervisorversion == "6.2.0":
                       res = sshClient.execute("xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503")
                       if len(res) == 0:
                           continue
                    k1card= sshClient.execute("lspci | grep \"GRID K1\"")
                    k2card= sshClient.execute("lspci | grep \"GRID K2\"")

                    if len(k2card) !=0:
                          k2hosts=k2hosts+1
                          k260q = sshClient.execute("xe vgpu-type-list model-name=\"GRID K260Q\"")
                          k240q = sshClient.execute("xe vgpu-type-list model-name=\"GRID K240Q\"")
                          k220q = sshClient.execute("xe vgpu-type-list model-name=\"GRID K220Q\"")
                          k200 = sshClient.execute("xe vgpu-type-list model-name=\"GRID K200\"")
                          k2passthrough = sshClient.execute("xe vgpu-type-list model-name='passthrough'")
                          if (len(k260q) == 0) and len(k240q) == 0  and len(k220q) == 0 and len(k200) == 0 and len(k2passthrough) == 0: 
                              continue
                          else:
                               if len(k260q) != 0 :
                                  cls.k260qgpuhosts=cls.k260qgpuhosts+1
                               if len(k240q) != 0 :
                                  cls.k240qgpuhosts=cls.k240qgpuhosts+1
                               if len(k220q) != 0 :
                                  cls.k220qgpuhosts=cls.k220qgpuhosts+1
                               if len(k200) != 0 :
                                  cls.k200gpuhosts=cls.k200gpuhosts+1
                               if len(k2passthrough) != 0:
                                  cls.k2passthroughgpuhosts=cls.k2passthroughgpuhosts+1

                    if len(k1card) != 0:
                            k1hosts=k1hosts+1
                            k100 = sshClient.execute("xe vgpu-type-list model-name=\"GRID K100\"")
                            k120q = sshClient.execute("xe vgpu-type-list model-name=\"GRID K120Q\"")
                            k140q = sshClient.execute("xe vgpu-type-list model-name=\"GRID K140Q\"")
                            k1passthrough = sshClient.execute("xe vgpu-type-list model-name='passthrough'")
                            if len(k100) == 0 and len(k120q) == 0 and len(k140q) == 0 and len(k1passthrough) == 0:
                                continue
                            else:
                                if len(k140q) != 0 :
                                   cls.k140qgpuhosts=cls.k140qgpuhosts+1
                                if len(k120q) != 0 :
                                   cls.k120qgpuhosts=cls.k120qgpuhosts+1
                                if len(k100) != 0 :
                                   cls.k100gpuhosts=cls.k100gpuhosts+1
                                if len(k1passthrough) != 0 :
                                   cls.k1passthroughgpuhosts=cls.k1passthroughgpuhosts+1

        if (k1hosts == 0) and (k2hosts == 0):
           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.account = Account.create(
               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)")

        if  cls.template == FAILED:
            cls.template = Template.register(
                   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")

                  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

        cls._cleanup = [
                         cls.account
                        ]
예제 #3
0
    def setUpClass(cls):
        testClient = super(TestXDCCPInterop, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.services['mode'] = cls.zone.networktype

        hosts = list_hosts(
               cls.apiclient,
               type="Routing"
           )
   
        if hosts is None:
               raise unittest.SkipTest(
                   "There are no hypervisor's available.Check list hosts response")
        for hypervisorhost in hosts :
                    if hypervisorhost.hypervisor == "XenServer":
                        cls.uploadtemplateformat="VHD"
                        break
                    elif hypervisorhost.hypervisor== "VMware":
                        cls.uploadtemplateformat="OVA"
                        break
                    elif hypervisorhost.hypervisor== "KVM":
                       cls.uploadtemplateformat="KVM"
                    break

        if cls.uploadtemplateformat=="KVM":
            assert False, "Interop is not supported on KVM"

        cls.uploadurl=cls.services["interop"][cls.uploadtemplateformat]["url"]
  
        cls.xtemplate = get_template(
            cls.apiclient,
            cls.zone.id,
            cls.services["ostype"]
        )
        if cls.xtemplate == FAILED:
            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]

        cls.account = Account.create(
            cls.apiclient,
            cls.services["account"],
            domainid=cls.domain.id,
            admin=False
        )
        cls.debug(cls.account.id)

        cls.service_offering = ServiceOffering.create(
            cls.apiclient,
            cls.services["service_offerings"]["large"]
        )

        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/" in cls.uploadurl:
                raise unittest.SkipTest(
                    "Check Test Data file if it has the valid template URL")
            cls.template = Template.register(
                cls.apiclient,
                cls.services["interop"][cls.uploadtemplateformat],
                zoneid=cls.zone.id,
                domainid=cls.account.domainid,
                account=cls.account.name
            )
            timeout = cls.services["vgpu"]["timeout"]

            while True:
                time.sleep(cls.services["vgpu"]["sleep"]) 
                list_template_response = Template.list(
                    cls.apiclient,
                    templatefilter=cls.services["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")

                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
        cls.volume=[]

        # Set Zones and disk offerings
        cls.services["small"]["zoneid"] = cls.zone.id
        cls.services["small"]["template"] = cls.template.id

        user_data = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(2500))
        cls.services["virtual_machine"]["userdata"] = user_data


#        cls.services["large"]["zoneid"] = cls.zone.id
#        cls.services["large"]["template"] = cls.template.id

        cls.virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services["small"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,  
            mode=cls.services['mode'],
            startvm="false"
        )
        cls.user_api_client = cls.testClient.getUserApiClient(
            UserName=cls.account.name,
            DomainName=cls.account.domain
        )


        cls.cleanup = [
            cls.service_offering,
            cls.account
        ]
    def setUpClass(cls):
        testClient = super(TestvGPUWindowsVm, cls).getClsTestClient()
        cls.testdata = cls.testClient.getParsedTestDataConfig()
        cls.apiclient = cls.testClient.getApiClient()
        cls._cleanup = []
        hosts = list_hosts(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"
            )
        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
            k2hosts = 0
            k1hosts = 0

            for ghost in hosts:
                if ghost.hypervisorversion >= "6.2.0":
                    sshClient = SshClient(host=ghost.ipaddress,
                                          port=22,
                                          user='******',
                                          passwd="host_password")

                    if ghost.hypervisorversion == "6.2.0":
                        res = sshClient.execute(
                            "xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503"
                        )
                        if len(res) == 0:
                            continue
                    k1card = sshClient.execute("lspci | grep \"GRID K1\"")
                    k2card = sshClient.execute("lspci | grep \"GRID K2\"")

                    if len(k2card) != 0:
                        k2hosts = k2hosts + 1
                        k260q = sshClient.execute(
                            "xe vgpu-type-list model-name=\"GRID K260Q\"")
                        k240q = sshClient.execute(
                            "xe vgpu-type-list model-name=\"GRID K240Q\"")
                        k220q = sshClient.execute(
                            "xe vgpu-type-list model-name=\"GRID K220Q\"")
                        k200 = sshClient.execute(
                            "xe vgpu-type-list model-name=\"GRID K200\"")
                        k2passthrough = sshClient.execute(
                            "xe vgpu-type-list model-name='passthrough'")
                        if (len(k260q) == 0
                            ) and len(k240q) == 0 and len(k220q) == 0 and len(
                                k200) == 0 and len(k2passthrough) == 0:
                            continue
                        else:
                            if len(k260q) != 0:
                                cls.k260qgpuhosts = cls.k260qgpuhosts + 1
                            if len(k240q) != 0:
                                cls.k240qgpuhosts = cls.k240qgpuhosts + 1
                            if len(k220q) != 0:
                                cls.k220qgpuhosts = cls.k220qgpuhosts + 1
                            if len(k200) != 0:
                                cls.k200gpuhosts = cls.k200gpuhosts + 1
                            if len(k2passthrough) != 0:
                                cls.k2passthroughgpuhosts = cls.k2passthroughgpuhosts + 1

                    if len(k1card) != 0:
                        k1hosts = k1hosts + 1
                        k100 = sshClient.execute(
                            "xe vgpu-type-list model-name=\"GRID K100\"")
                        k120q = sshClient.execute(
                            "xe vgpu-type-list model-name=\"GRID K120Q\"")
                        k140q = sshClient.execute(
                            "xe vgpu-type-list model-name=\"GRID K140Q\"")
                        k1passthrough = sshClient.execute(
                            "xe vgpu-type-list model-name='passthrough'")
                        if len(k100) == 0 and len(k120q) == 0 and len(
                                k140q) == 0 and len(k1passthrough) == 0:
                            continue
                        else:
                            if len(k140q) != 0:
                                cls.k140qgpuhosts = cls.k140qgpuhosts + 1
                            if len(k120q) != 0:
                                cls.k120qgpuhosts = cls.k120qgpuhosts + 1
                            if len(k100) != 0:
                                cls.k100gpuhosts = cls.k100gpuhosts + 1
                            if len(k1passthrough) != 0:
                                cls.k1passthroughgpuhosts = cls.k1passthroughgpuhosts + 1

        if (k1hosts == 0) and (k2hosts == 0):
            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.account = Account.create(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)")

        if cls.template == FAILED:
            cls.template = Template.register(
                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")

                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

        cls._cleanup = [cls.account]