コード例 #1
0
    def test_09_copy_delete_template(self):
        cmd = listZones.listZonesCmd()
        zones = self.apiclient.listZones(cmd)
        if not isinstance(zones, list):
            raise Exception("Failed to find zones.")
        if len(zones) < 2:
            self.skipTest(
                "Skipping test due to there are less than two zones.")
        return

        self.sourceZone = zones[0]
        self.destZone = zones[1]

        template = Template.create(self.apiclient,
                                   self.services["template"],
                                   self.volume.id,
                                   account=self.account.name,
                                   domainid=self.account.domainid)
        self.cleanup.append(template)

        self.debug("Created template with ID: %s" % template.id)

        list_template_response = Template.list(
                                    self.apiclient,
                                    templatefilter=\
                                    self.services["templatefilter"],
                                    id=template.id
                                    )

        self.assertEqual(isinstance(list_template_response, list), True,
                         "Check list response returns a valid list")
        #Verify template response to check whether template added successfully
        self.assertNotEqual(len(list_template_response), 0,
                            "Check template available in List Templates")
        #Copy template from zone1 to zone2
        copytemplate = Template.copy(cls.apiclient,
                                     zoneid=cls.sourceZone.id,
                                     destzoneid=cls.destZone.id)
        cls._cleanup.append(cls.copytemplate)

        list_template_response = Template.list(
            self.apiclient,
            templatefilter=self.services["template"]["templatefilter"],
            id=self.template.id,
            zoneid=self.destZone.id)
        self.assertEqual(list_template_response, None,
                         "Check template available in List Templates")

        self.deltemplate = list_template_response[0]

        self.debug("Deleting template: %s" % self.deltemplate)
        # Delete the template
        self.deltemplate.delete(self.apiclient)
        self.debug("Delete template: %s successful" % self.deltemplate)

        copytemplate = Template.copy(self.apiclient,
                                     zoneid=self.sourceZone.id,
                                     destzoneid=self.destZone.id)

        removed = cls.dbclient.execute(
            "select removed from template_zone_ref where zone_id='%s' and template_id='%s';"
            % self.destZone.id, self.template.id)

        self.assertEqual(removed, NULL, "Removed state is not correct.")
        return
コード例 #2
0
    def test_04_copy_template(self):
        """
        @Desc: Test to copy Template from one zone to another
        @steps:
        Step1: Listing Zones available for a user
        Step2: Verifying if the zones listed are greater than 1.
               If Yes continuing.
               If not halting the test.
        Step3: Listing all the templates for a user in zone1
        Step4: Verifying that no templates are listed
        Step5: Listing all the templates for a user in zone2
        Step6: Verifying that no templates are listed
        Step7: Creating a Template in zone 1
        Step8: Listing all the Templates again for a user in zone1
        Step9: Verifying that list size is 1
        Step10: Listing all the templates for a user in zone2
        Step11: Verifying that no templates are listed
        Step12: Copying the template created in step7 from zone1 to zone2
        Step13: Listing all the templates for a user in zone2
        Step14: Verifying that list size is 1
        Step15: Listing all the Templates for a user in zone1
        Step16: Verifying that list size is 1
        """
        # Listing Zones available for a user
        zones_list = Zone.list(self.userapiclient, available=True)
        status = validateList(zones_list)
        self.assertEquals(PASS, status[0], "Failed to list Zones")
        if not len(zones_list) > 1:
            self.fail("Enough zones doesnot exists to copy template")
        else:
            # Listing all the Templates for a User in Zone 1
            list_templates_zone1 = Template.list(
                self.userapiclient,
                listall=self.services["listall"],
                templatefilter=self.services["templatefilter"],
                zoneid=zones_list[0].id)
            # Verifying that no Templates are listed
            self.assertIsNone(
                list_templates_zone1,
                "Templates listed for newly created User in Zone1")
            # Listing all the Templates for a User in Zone 2
            list_templates_zone2 = Template.list(
                self.userapiclient,
                listall=self.services["listall"],
                templatefilter=self.services["templatefilter"],
                zoneid=zones_list[1].id)
            # Verifying that no Templates are listed
            self.assertIsNone(
                list_templates_zone2,
                "Templates listed for newly created User in Zone2")
            self.services["template"][
                "url"] = "http://10.147.28.7/templates/ttylinux_pv.vhd"
            self.services["template"]["format"] = "VHD"
            self.services["template"]["ostype"] = self.services["ostype"]
            #Listing Hypervisors in Zone 1
            hypervisor_list = Hypervisor.list(self.apiClient,
                                              zoneid=zones_list[0].id)
            status = validateList(zones_list)
            self.assertEquals(PASS, status[0],
                              "Failed to list Hypervisors in Zone 1")
            # Creating aTemplate in Zone 1
            template_created = Template.register(
                self.userapiclient,
                self.services["template"],
                zones_list[0].id,
                hypervisor=hypervisor_list[0].name)
            self.assertIsNotNone(template_created, "Template creation failed")
            self.cleanup.append(template_created)
            # Listing all the Templates for a User in Zone 1
            list_templates_zone1 = Template.list(
                self.userapiclient,
                listall=self.services["listall"],
                templatefilter=self.services["templatefilter"],
                zoneid=zones_list[0].id)
            status = validateList(list_templates_zone1)
            self.assertEquals(PASS, status[0],
                              "Templates creation failed in Zone1")
            # Verifying that list size is 1
            self.assertEquals(1, len(list_templates_zone1),
                              "Failed to create a Template")
            # Listing all the Templates for a User in Zone 2
            list_templates_zone2 = Template.list(
                self.userapiclient,
                listall=self.services["listall"],
                templatefilter=self.services["templatefilter"],
                zoneid=zones_list[1].id)
            # Verifying that no Templates are listed
            self.assertIsNone(
                list_templates_zone2,
                "Templates listed for newly created User in Zone2")
            # 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

            # Copying the Template from Zone1 to Zone2
            copied_template = Template.copy(
                self.userapiclient,
                template_created.id,
                sourcezoneid=template_created.zoneid,
                destzoneid=zones_list[1].id)
            self.assertIsNotNone(
                copied_template, "Copying Template from Zone1 to Zone2 failed")
            # Listing all the Templates for a User in Zone 1
            list_templates_zone1 = Template.list(
                self.userapiclient,
                listall=self.services["listall"],
                templatefilter=self.services["templatefilter"],
                zoneid=zones_list[0].id)
            status = validateList(list_templates_zone1)
            self.assertEquals(PASS, status[0],
                              "Templates creation failed in Zone1")
            # Verifying that list size is 1
            self.assertEquals(1, len(list_templates_zone1),
                              "Failed to create a Template")
            # Listing all the Templates for a User in Zone 2
            list_templates_zone2 = Template.list(
                self.userapiclient,
                listall=self.services["listall"],
                templatefilter=self.services["templatefilter"],
                zoneid=zones_list[1].id)
            status = validateList(list_templates_zone2)
            self.assertEquals(PASS, status[0],
                              "Template failed to copy into Zone2")
            # Verifying that list size is 1
            self.assertEquals(1, len(list_templates_zone2),
                              "Template failed to copy into Zone2")
            self.assertNotEquals("Connection refused",
                                 list_templates_zone2[0].status,
                                 "Failed to copy Template")
            self.assertEquals(True, list_templates_zone2[0].isready,
                              "Failed to copy Template")
        del self.services["template"]["url"]
        del self.services["template"]["format"]
        del self.services["template"]["ostype"]
        return
コード例 #3
0
    def test_09_copy_delete_template(self):
	cmd = listZones.listZonesCmd()
        zones = self.apiclient.listZones(cmd)
        if not isinstance(zones, list):
            raise Exception("Failed to find zones.")
        if len(zones) < 2:
            self.skipTest(
                "Skipping test due to there are less than two zones.")
        return
			
	self.sourceZone = zones[0]
	self.destZone = zones[1]
            
        template = Template.create(
                                self.apiclient,
                                self.services["template"],
                                self.volume.id,
                                account=self.account.name,
                                domainid=self.account.domainid
                                )
        self.cleanup.append(template)

        self.debug("Created template with ID: %s" % template.id)

        list_template_response = Template.list(
                                    self.apiclient,
                                    templatefilter=\
                                    self.services["templatefilter"],
                                    id=template.id
                                    )

        self.assertEqual(
                            isinstance(list_template_response, list),
                            True,
                            "Check list response returns a valid list"
                        )
        #Verify template response to check whether template added successfully
        self.assertNotEqual(
                            len(list_template_response),
                            0,
                            "Check template available in List Templates"
                        )
	#Copy template from zone1 to zone2
        copytemplate = Template.copy(
            cls.apiclient,
            zoneid=cls.sourceZone.id,
            destzoneid = cls.destZone.id
        )
        cls._cleanup.append(cls.copytemplate)

        list_template_response = Template.list(
            self.apiclient,
	    templatefilter=self.services["template"]["templatefilter"],
            id=self.template.id,
            zoneid=self.destZone.id
        )
        self.assertEqual(
            list_template_response,
            None,
            "Check template available in List Templates"
        )

        self.deltemplate = list_template_response[0]

        self.debug("Deleting template: %s" % self.deltemplate)
        # Delete the template
        self.deltemplate.delete(self.apiclient)
        self.debug("Delete template: %s successful" % self.deltemplate)

        copytemplate = Template.copy(
            self.apiclient,
            zoneid=self.sourceZone.id,
            destzoneid = self.destZone.id
        )

        removed = cls.dbclient.execute("select removed from template_zone_ref where zone_id='%s' and template_id='%s';" % self.destZone.id, self.template.id)

        self.assertEqual(
            removed,
            NULL,
            "Removed state is not correct."
        )
        return
コード例 #4
0
    def test_04_copy_template(self):
        """
        @Desc: Test to copy Template from one zone to another
        @steps:
        Step1: Listing Zones available for a user
        Step2: Verifying if the zones listed are greater than 1.
               If Yes continuing.
               If not halting the test.
        Step3: Listing all the templates for a user in zone1
        Step4: Verifying that no templates are listed
        Step5: Listing all the templates for a user in zone2
        Step6: Verifying that no templates are listed
        Step7: Creating a Template in zone 1
        Step8: Listing all the Templates again for a user in zone1
        Step9: Verifying that list size is 1
        Step10: Listing all the templates for a user in zone2
        Step11: Verifying that no templates are listed
        Step12: Copying the template created in step7 from zone1 to zone2
        Step13: Listing all the templates for a user in zone2
        Step14: Verifying that list size is 1
        Step15: Listing all the Templates for a user in zone1
        Step16: Verifying that list size is 1
        """
        # Listing Zones available for a user
        zones_list = Zone.list(
                               self.userapiclient,
                               available=True
                               )
        status = validateList(zones_list)
        self.assertEquals(
                          PASS,
                          status[0],
                          "Failed to list Zones"
                          )
        if not len(zones_list) > 1:
            self.fail("Enough zones doesnot exists to copy template")
        else:
            # Listing all the Templates for a User in Zone 1
            list_templates_zone1 = Template.list(
                                                 self.userapiclient,
                                                 listall=self.services["listall"],
                                                 templatefilter=self.services["templatefilter"],
                                                 zoneid=zones_list[0].id
                                                 )
            # Verifying that no Templates are listed
            self.assertIsNone(
                              list_templates_zone1,
                              "Templates listed for newly created User in Zone1"
                              )
            # Listing all the Templates for a User in Zone 2
            list_templates_zone2 = Template.list(
                                                 self.userapiclient,
                                                 listall=self.services["listall"],
                                                 templatefilter=self.services["templatefilter"],
                                                 zoneid=zones_list[1].id
                                                 )
            # Verifying that no Templates are listed
            self.assertIsNone(
                              list_templates_zone2,
                              "Templates listed for newly created User in Zone2"
                              )
            self.services["template"]["url"] = "http://10.147.28.7/templates/ttylinux_pv.vhd"
            self.services["template"]["format"] = "VHD"
            self.services["template"]["ostype"] = self.services["ostype"]
            #Listing Hypervisors in Zone 1
            hypervisor_list = Hypervisor.list(
                                              self.apiClient,
                                              zoneid=zones_list[0].id
                                              )
            status = validateList(zones_list)
            self.assertEquals(
                              PASS,
                              status[0],
                              "Failed to list Hypervisors in Zone 1"
                              )
            # Creating aTemplate in Zone 1
            template_created = Template.register(
                                                 self.userapiclient,
                                                 self.services["template"],
                                                 zones_list[0].id,
                                                 hypervisor=hypervisor_list[0].name
                                                 )
            self.assertIsNotNone(
                                 template_created,
                                 "Template creation failed"
                                 )
            self.cleanup.append(template_created)
            # Listing all the Templates for a User in Zone 1
            list_templates_zone1 = Template.list(
                                                 self.userapiclient,
                                                 listall=self.services["listall"],
                                                 templatefilter=self.services["templatefilter"],
                                                 zoneid=zones_list[0].id
                                                 )
            status = validateList(list_templates_zone1)
            self.assertEquals(
                              PASS,
                              status[0],
                              "Templates creation failed in Zone1"
                              )
            # Verifying that list size is 1
            self.assertEquals(
                              1,
                              len(list_templates_zone1),
                              "Failed to create a Template"
                              )
            # Listing all the Templates for a User in Zone 2
            list_templates_zone2 = Template.list(
                                                 self.userapiclient,
                                                 listall=self.services["listall"],
                                                 templatefilter=self.services["templatefilter"],
                                                 zoneid=zones_list[1].id
                                                 )
            # Verifying that no Templates are listed
            self.assertIsNone(
                              list_templates_zone2,
                              "Templates listed for newly created User in Zone2"
                              )
            # 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

            # Copying the Template from Zone1 to Zone2
            copied_template = Template.copy(
                                            self.userapiclient,
                                            template_created.id,
                                            sourcezoneid=template_created.zoneid,
                                            destzoneid=zones_list[1].id
                                            )
            self.assertIsNotNone(
                                 copied_template,
                                 "Copying Template from Zone1 to Zone2 failed"
                                 )
            # Listing all the Templates for a User in Zone 1
            list_templates_zone1 = Template.list(
                                                 self.userapiclient,
                                                 listall=self.services["listall"],
                                                 templatefilter=self.services["templatefilter"],
                                                 zoneid=zones_list[0].id
                                                 )
            status = validateList(list_templates_zone1)
            self.assertEquals(
                              PASS,
                              status[0],
                              "Templates creation failed in Zone1"
                              )
            # Verifying that list size is 1
            self.assertEquals(
                              1,
                              len(list_templates_zone1),
                              "Failed to create a Template"
                              )
            # Listing all the Templates for a User in Zone 2
            list_templates_zone2 = Template.list(
                                                 self.userapiclient,
                                                 listall=self.services["listall"],
                                                 templatefilter=self.services["templatefilter"],
                                                 zoneid=zones_list[1].id
                                                 )
            status = validateList(list_templates_zone2)
            self.assertEquals(
                              PASS,
                              status[0],
                              "Template failed to copy into Zone2"
                              )
            # Verifying that list size is 1
            self.assertEquals(
                              1,
                              len(list_templates_zone2),
                              "Template failed to copy into Zone2"
                              )
            self.assertNotEquals(
                                 "Connection refused",
                                 list_templates_zone2[0].status,
                                 "Failed to copy Template"
                                 )
            self.assertEquals(
                              True,
                              list_templates_zone2[0].isready,
                              "Failed to copy Template"
                              )
        del self.services["template"]["url"]
        del self.services["template"]["format"]
        del self.services["template"]["ostype"]
        return