当前位置: 首页>>代码示例>>Python>>正文


Python Template.extract方法代码示例

本文整理汇总了Python中marvin.lib.base.Template.extract方法的典型用法代码示例。如果您正苦于以下问题:Python Template.extract方法的具体用法?Python Template.extract怎么用?Python Template.extract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marvin.lib.base.Template的用法示例。


在下文中一共展示了Template.extract方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_builtin_template_info

# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import extract [as 别名]
def get_builtin_template_info(apiclient, zoneid):
    """Returns hypervisor specific infor for templates"""

    list_template_response = Template.list(apiclient, templatefilter="featured", zoneid=zoneid)

    for b_template in list_template_response:
        if b_template.templatetype == "BUILTIN":
            break

    extract_response = Template.extract(apiclient, b_template.id, "HTTP_DOWNLOAD", zoneid)

    return extract_response.url, b_template.hypervisor, b_template.format
开发者ID:rafaelthedevops,项目名称:cloudstack,代码行数:14,代码来源:common.py

示例2: test_04_extract_template

# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import extract [as 别名]
    def test_04_extract_template(self):
        "Test for extract template"

        # Validate the following
        # 1. Admin should able  extract and download the templates
        # 2. ListTemplates should display all the public templates
        #    for all kind of users
        # 3 .ListTemplates should not display the system templates

        self.debug("Extracting template with ID: %s" % self.template_2.id)
        list_extract_response = Template.extract(self.apiclient,
                                                 id=self.template_2.id,
                                                 mode= self.services["template_2"]["mode"],
                                                 zoneid=self.zone.id)

        try:
            # Format URL to ASCII to retrieve response code
            formatted_url = urllib.unquote_plus(list_extract_response.url)
            url_response = urllib.urlopen(formatted_url)
            response_code = url_response.getcode()

        except Exception:
            self.fail(
                "Extract Template Failed with invalid URL %s (template id: %s)" \
                % (formatted_url, self.template_2.id)
            )
        self.assertEqual(
                            list_extract_response.id,
                            self.template_2.id,
                            "Check ID of the extracted template"
                        )
        self.assertEqual(
                            list_extract_response.extractMode,
                            self.services["template_2"]["mode"],
                            "Check mode of extraction"
                        )
        self.assertEqual(
                            list_extract_response.zoneid,
                            self.services["template_2"]["zoneid"],
                            "Check zone ID of extraction"
                        )
        self.assertEqual(
                         response_code,
                         200,
                         "Check for a valid response download URL"
                         )
        return
开发者ID:krissterckx,项目名称:cloudstack,代码行数:49,代码来源:test_templates.py

示例3: test_02_download_template

# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import extract [as 别名]
    def test_02_download_template(self):
        """
        @Desc: Test to Download Template
        @steps:
        Step1: Listing all the Templates for a user
        Step2: Verifying that no Templates are listed
        Step3: Creating a Templates
        Step4: Listing all the Templates again for a user
        Step5: Verifying that list size is 1
        Step6: Verifying if the template is in ready state.
                If yes the continuing
                If not waiting and checking for template to be ready till timeout
        Step7: Downloading the template (Extract)
        Step8: Verifying that Template is downloaded
        """
        # Listing all the Templates for a User
        list_templates_before = Template.list(
            self.userapiclient,
            listall=self.services["listall"],
            templatefilter=self.services["templatefilter"]
        )
        # Verifying that no Templates are listed
        self.assertIsNone(
            list_templates_before,
            "Templates listed for newly created User"
        )
        self.services["privatetemplate"]["ostype"] = self.services["ostype"]
        self.services["privatetemplate"]["isextractable"] = True
        # Creating aTemplate
        template_created = Template.register(
            self.userapiclient,
            self.services["privatetemplate"],
            self.zone.id,
            hypervisor=self.hypervisor
        )
        self.assertIsNotNone(
            template_created,
            "Template creation failed"
        )
        # Listing all the Templates for a User
        list_templates_after = Template.list(
            self.userapiclient,
            listall=self.services["listall"],
            templatefilter=self.services["templatefilter"]
        )
        status = validateList(list_templates_after)
        self.assertEquals(
            PASS,
            status[0],
            "Templates creation failed"
        )
        # Verifying that list size is 1
        self.assertEquals(
            1,
            len(list_templates_after),
            "Failed to create a Template"
        )
        # Verifying the state of the template to be ready. If not waiting for
        # state to become ready till time out
        template_ready = False
        count = 0
        while template_ready is False:
            list_template = Template.list(
                self.userapiclient,
                id=template_created.id,
                listall=self.services["listall"],
                templatefilter=self.services["templatefilter"],
            )
            status = validateList(list_template)
            self.assertEquals(
                PASS,
                status[0],
                "Failed to list Templates by Id"
            )
            if list_template[0].isready is True:
                template_ready = True
            elif (str(list_template[0].status) == "Error"):
                self.fail("Created Template is in Errored state")
                break
            elif count > 10:
                self.fail("Timed out before Template came into ready state")
                break
            else:
                time.sleep(self.services["sleep"])
                count = count + 1

        # Downloading the Template name
        download_template = Template.extract(
            self.userapiclient,
            template_created.id,
            mode="HTTP_DOWNLOAD",
            zoneid=self.zone.id
        )
        self.assertIsNotNone(
            download_template,
            "Download Template failed"
        )
        # Verifying the details of downloaded template
        self.assertEquals(
            "DOWNLOAD_URL_CREATED",
#.........这里部分代码省略.........
开发者ID:K0zka,项目名称:cloudstack,代码行数:103,代码来源:test_escalations_templates.py

示例4: test01_template_download_URL_expire

# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import extract [as 别名]
 def test01_template_download_URL_expire(self):
     """
     @Desc:Template files are deleted from secondary storage after download URL expires
     Step1:Deploy vm with default cent os template
     Step2:Stop the vm
     Step3:Create template from the vm's root volume
     Step4:Extract Template and wait for the download url to expire
     Step5:Deploy another vm with the template created at Step3
     Step6:Verify that vm deployment succeeds
     """
     params = ["extract.url.expiration.interval", "extract.url.cleanup.interval"]
     wait_time = 0
     for param in params:
         config = Configurations.list(self.apiClient, name=param)
         self.assertEqual(validateList(config)[0], PASS, "Config list returned invalid response")
         wait_time = wait_time + int(config[0].value)
     self.debug("Total wait time for url expiry: %s" % wait_time)
     # Creating Virtual Machine
     self.virtual_machine = VirtualMachine.create(
         self.userapiclient,
         self.services["virtual_machine"],
         accountid=self.account.name,
         domainid=self.account.domainid,
         serviceofferingid=self.service_offering.id,
     )
     self.assertIsNotNone(self.virtual_machine, "Virtual Machine creation failed")
     self.cleanup.append(self.virtual_machine)
     # Stop virtual machine
     self.virtual_machine.stop(self.userapiclient)
     list_volume = Volume.list(
         self.userapiclient, virtualmachineid=self.virtual_machine.id, type="ROOT", listall=True
     )
     self.assertEqual(validateList(list_volume)[0], PASS, "list volumes with type ROOT returned invalid list")
     self.volume = list_volume[0]
     self.create_template = Template.create(
         self.userapiclient,
         self.services["template"],
         volumeid=self.volume.id,
         account=self.account.name,
         domainid=self.account.domainid,
     )
     self.assertIsNotNone(self.create_template, "Failed to create template from root volume")
     self.cleanup.append(self.create_template)
     """
     Extract template
     """
     try:
         Template.extract(self.userapiclient, self.create_template.id, "HTTP_DOWNLOAD", self.zone.id)
     except Exception as e:
         self.fail("Extract template failed with error %s" % e)
     self.debug("Waiting for %s seconds for url to expire" % repr(wait_time + 20))
     time.sleep(wait_time + 20)
     self.debug("Waited for %s seconds for url to expire" % repr(wait_time + 20))
     """
     Deploy vm with the template created from the volume. After url expiration interval only
     url should be deleted not the template. To validate this deploy vm with the template
     """
     try:
         self.vm = VirtualMachine.create(
             self.userapiclient,
             self.services["virtual_machine"],
             accountid=self.account.name,
             domainid=self.account.domainid,
             serviceofferingid=self.service_offering.id,
             templateid=self.create_template.id,
         )
         self.cleanup.append(self.vm)
     except Exception as e:
         self.fail(
             "Template is automatically deleted after URL expired.\
                   So vm deployment failed with error: %s"
             % e
         )
     return
开发者ID:tianshangjun,项目名称:cloudstack,代码行数:76,代码来源:test_escalations_templates.py


注:本文中的marvin.lib.base.Template.extract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。