Ejemplo n.º 1
0
    def test_04_create_and_delete_template_from_snapshot_bypassed(self):
        ''' Create template from snapshot which is bypassed
            (snapshot - created with uuid
            template created with globalid
            )
        '''
        onStorpool = True
        self.helper.bypass_secondary(onStorpool)
        template = self.helper.create_template_from_snapshot(
            self.services, snapshotid=self.snapshot_bypassed.id)

        storpoolGlId = self.helper.create_vm_from_template(
            template, onStorpool)
        cfg.logger.info("Created snapshot for a template in StorPool %s" %
                        storpoolGlId)

        cmd = deleteTemplate.deleteTemplateCmd()
        cmd.id = template.id
        cmd.zoneid = self.zone.id
        deleted = self.apiclient.deleteTemplate(cmd)

        self.assertTrue(deleted, "Template was not deleted from CS")
        isTemplateDeleted = self.helper.check_snapshot_is_deleted_from_storpool(
            storpoolGlId)
        self.assertTrue(isTemplateDeleted,
                        "Template was not deleted from StorPool")
Ejemplo n.º 2
0
 def test_04_delete_all_templates(self):
     templates = list_templates(self.apiclient, templatefilter='featured')
     for t in templates:
         if t.name.startswith("StorPool"):
             try:
                 cmd = deleteTemplate.deleteTemplateCmd()
                 cmd.id = t.id
                 self.apiclient.deleteTemplate(cmd)
             except Exception as e:
                 continue
Ejemplo n.º 3
0
    def test_06_copy_template(self):
        """Test for copy template from one zone to another"""

        # Validate the following
        # 1. copy template should be successful and
        #    secondary storage should contain new copied template.

        if len(self.zones) <= 1:
            self.skipTest(
                "Not enough zones available to perform copy template")

        self.services["destzoneid"] = filter(
            lambda z: z.id != self.services["sourcezoneid"], self.zones)[0].id

        self.debug(
            "Copy template from Zone: %s to %s" %
            (self.services["sourcezoneid"], self.services["destzoneid"]))
        cmd = copyTemplate.copyTemplateCmd()
        cmd.id = self.template_2.id
        cmd.destzoneid = self.services["destzoneid"]
        cmd.sourcezoneid = self.services["sourcezoneid"]
        self.apiclient.copyTemplate(cmd)

        # Verify template is copied to another zone using ListTemplates
        list_template_response = Template.list(
                                    self.apiclient,
                                    templatefilter=\
                                    self.services["templatefilter"],
                                    id=self.template_2.id,
                                    zoneid=self.services["destzoneid"]
                                    )
        self.assertEqual(isinstance(list_template_response, list), True,
                         "Check list response returns a valid list")
        self.assertNotEqual(len(list_template_response), 0,
                            "Check template extracted in List Templates")

        template_response = list_template_response[0]
        self.assertEqual(template_response.id, self.template_2.id,
                         "Check ID of the downloaded template")
        self.assertEqual(template_response.zoneid, self.services["destzoneid"],
                         "Check zone ID of the copied template")

        # Cleanup- Delete the copied template
        timeout = self.services["timeout"]
        while True:
            time.sleep(self.services["sleep"])
            list_template_response = Template.list(
                                        self.apiclient,
                                        templatefilter=\
                                        self.services["templatefilter"],
                                        id=self.template_2.id,
                                        zoneid=self.services["destzoneid"]
                                        )
            self.assertEqual(isinstance(list_template_response, list), True,
                             "Check list response returns a valid list")
            self.assertNotEqual(len(list_template_response), 0,
                                "Check template extracted in List Templates")

            template_response = list_template_response[0]
            if template_response.isready == True:
                break

            if timeout == 0:
                raise Exception("Failed to download copied template(ID: %s)" %
                                template_response.id)

            timeout = timeout - 1
        cmd = deleteTemplate.deleteTemplateCmd()
        cmd.id = template_response.id
        cmd.zoneid = self.services["destzoneid"]
        self.apiclient.deleteTemplate(cmd)
        return
Ejemplo n.º 4
0
    def test_06_copy_template(self):
        """Test for copy template from one zone to another"""

        # Validate the following
        # 1. copy template should be successful and
        #    secondary storage should contain new copied template.

        if len(self.zones) <= 1:
            self.skipTest("Not enough zones available to perform copy template")

        self.services["destzoneid"] = filter(lambda z: z.id != self.services["sourcezoneid"], self.zones)[0].id

        self.debug("Copy template from Zone: %s to %s" % (
                                            self.services["sourcezoneid"],
                                            self.services["destzoneid"]
                                            ))
        cmd = copyTemplate.copyTemplateCmd()
        cmd.id = self.template_2.id
        cmd.destzoneid = self.services["destzoneid"]
        cmd.sourcezoneid = self.services["sourcezoneid"]
        self.apiclient.copyTemplate(cmd)

        # Verify template is copied to another zone using ListTemplates
        list_template_response = Template.list(
                                    self.apiclient,
                                    templatefilter=\
                                    self.services["templatefilter"],
                                    id=self.template_2.id,
                                    zoneid=self.services["destzoneid"]
                                    )
        self.assertEqual(
                            isinstance(list_template_response, list),
                            True,
                            "Check list response returns a valid list"
                        )
        self.assertNotEqual(
                            len(list_template_response),
                            0,
                            "Check template extracted in List Templates"
                        )

        template_response = list_template_response[0]
        self.assertEqual(
                            template_response.id,
                            self.template_2.id,
                            "Check ID of the downloaded template"
                        )
        self.assertEqual(
                            template_response.zoneid,
                            self.services["destzoneid"],
                            "Check zone ID of the copied template"
                        )

        # Cleanup- Delete the copied template
        timeout = self.services["timeout"]
        while True:
            time.sleep(self.services["sleep"])
            list_template_response = Template.list(
                                        self.apiclient,
                                        templatefilter=\
                                        self.services["templatefilter"],
                                        id=self.template_2.id,
                                        zoneid=self.services["destzoneid"]
                                        )
            self.assertEqual(
                                isinstance(list_template_response, list),
                                True,
                                "Check list response returns a valid list"
                            )
            self.assertNotEqual(
                                len(list_template_response),
                                0,
                                "Check template extracted in List Templates"
                            )
    
            template_response = list_template_response[0]
            if template_response.isready == True:
                break

            if timeout == 0:
                raise Exception(
                        "Failed to download copied template(ID: %s)" % template_response.id)

            timeout = timeout - 1
        cmd = deleteTemplate.deleteTemplateCmd()
        cmd.id = template_response.id
        cmd.zoneid = self.services["destzoneid"]
        self.apiclient.deleteTemplate(cmd)
        return