Example #1
0
    def test_06_copy_iso(self):
        """Test for copy ISO from one zone to another"""

        # Validate the following
        # 1. copy ISO should be successful and secondary storage
        #   should contain new copied ISO.
        if len(self.zones) <= 1:
            self.skipTest(
                "Not enough zones available to perform copy template")

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

        self.debug("Copy ISO from %s to %s" %
                   (self.zone.id, self.services["destzoneid"]))

        cmd = copyIso.copyIsoCmd()
        cmd.id = self.iso_2.id
        cmd.destzoneid = self.services["destzoneid"]
        cmd.sourcezoneid = self.zone.id
        self.apiclient.copyIso(cmd)

        # Verify ISO is copied to another zone using ListIsos
        list_iso_response = list_isos(self.apiclient,
                                      id=self.iso_2.id,
                                      zoneid=self.services["destzoneid"])
        self.assertEqual(isinstance(list_iso_response, list), True,
                         "Check list response returns a valid list")

        self.assertNotEqual(len(list_iso_response), 0,
                            "Check template extracted in List ISO")
        iso_response = list_iso_response[0]

        self.assertEqual(iso_response.id, self.iso_2.id,
                         "Check ID of the downloaded ISO")
        self.assertEqual(iso_response.zoneid, self.services["destzoneid"],
                         "Check zone ID of the copied ISO")

        self.debug("Cleanup copied ISO: %s" % iso_response.id)
        # Cleanup- Delete the copied ISO
        timeout = self.services["timeout"]
        while True:
            time.sleep(self.services["sleep"])
            list_iso_response = list_isos(self.apiclient,
                                          id=self.iso_2.id,
                                          zoneid=self.services["destzoneid"])
            self.assertEqual(isinstance(list_iso_response, list), True,
                             "Check list response returns a valid list")

            self.assertNotEqual(len(list_iso_response), 0,
                                "Check template extracted in List ISO")

            iso_response = list_iso_response[0]
            if iso_response.isready:
                break

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

            timeout = timeout - 1
        cmd = deleteIso.deleteIsoCmd()
        cmd.id = iso_response.id
        cmd.zoneid = self.services["destzoneid"]
        self.apiclient.deleteIso(cmd)
        return
Example #2
0
    def test_06_copy_iso(self):
        """Test for copy ISO from one zone to another"""

        # Validate the following
        # 1. copy ISO should be successful and secondary storage
        #   should contain new copied ISO.
        if len(self.zones) <= 1:
            self.skipTest(
                "Not enough zones available to perform copy template")

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

        self.debug("Copy ISO from %s to %s" % (
            self.zone.id,
            self.services["destzoneid"]
        ))

        cmd = copyIso.copyIsoCmd()
        cmd.id = self.iso_2.id
        cmd.destzoneid = self.services["destzoneid"]
        cmd.sourcezoneid = self.zone.id
        self.apiclient.copyIso(cmd)

        # Verify ISO is copied to another zone using ListIsos
        list_iso_response = list_isos(
            self.apiclient,
            id=self.iso_2.id,
            zoneid=self.services["destzoneid"]
        )
        self.assertEqual(
            isinstance(list_iso_response, list),
            True,
            "Check list response returns a valid list"
        )

        self.assertNotEqual(
            len(list_iso_response),
            0,
            "Check template extracted in List ISO"
        )
        iso_response = list_iso_response[0]

        self.assertEqual(
            iso_response.id,
            self.iso_2.id,
            "Check ID of the downloaded ISO"
        )
        self.assertEqual(
            iso_response.zoneid,
            self.services["destzoneid"],
            "Check zone ID of the copied ISO"
        )

        self.debug("Cleanup copied ISO: %s" % iso_response.id)
        # Cleanup- Delete the copied ISO
        timeout = self.services["timeout"]
        while True:
            time.sleep(self.services["sleep"])
            list_iso_response = list_isos(
                self.apiclient,
                id=self.iso_2.id,
                zoneid=self.services["destzoneid"]
            )
            self.assertEqual(
                isinstance(list_iso_response, list),
                True,
                "Check list response returns a valid list"
            )

            self.assertNotEqual(
                len(list_iso_response),
                0,
                "Check template extracted in List ISO"
            )

            iso_response = list_iso_response[0]
            if iso_response.isready:
                break

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

            timeout = timeout - 1
        cmd = deleteIso.deleteIsoCmd()
        cmd.id = iso_response.id
        cmd.zoneid = self.services["destzoneid"]
        self.apiclient.deleteIso(cmd)
        return