Example #1
0
    def setUp(self):
        self.services = self.testClient.getParsedTestDataConfig()
        self.apiclient = self.testClient.getApiClient()
        self.dbclient = self.testClient.getDbConnection()
        # Get Zone, Domain and templates
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        self.services['mode'] = self.zone.networktype
        self.services["domainid"] = self.domain.id
        self.services["iso2"]["zoneid"] = self.zone.id

        self.account = Account.create(self.apiclient,
                                      self.services["account"],
                                      domainid=self.domain.id)
        # Finding the OsTypeId from Ostype
        ostypes = list_os_types(self.apiclient,
                                description=self.services["ostype"])
        if not isinstance(ostypes, list):
            raise unittest.SkipTest("OSTypeId for given description not found")

        self.services["iso1"]["ostypeid"] = ostypes[0].id
        self.services["iso2"]["ostypeid"] = ostypes[0].id
        self.services["ostypeid"] = ostypes[0].id

        self.cleanup = [self.account]
        return
Example #2
0
    def setUp(self):
        self.services = self.testClient.getParsedTestDataConfig()
        self.apiclient = self.testClient.getApiClient()
        self.dbclient = self.testClient.getDbConnection()
        # Get Zone, Domain and templates
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        self.services['mode'] = self.zone.networktype
        self.services["domainid"] = self.domain.id
        self.services["iso2"]["zoneid"] = self.zone.id

        self.account = Account.create(
            self.apiclient,
            self.services["account"],
            domainid=self.domain.id
        )
        # Finding the OsTypeId from Ostype
        ostypes = list_os_types(
            self.apiclient,
            description=self.services["ostype"]
        )
        if not isinstance(ostypes, list):
            raise unittest.SkipTest("OSTypeId for given description not found")

        self.services["iso1"]["ostypeid"] = ostypes[0].id
        self.services["iso2"]["ostypeid"] = ostypes[0].id
        self.services["ostypeid"] = ostypes[0].id

        self.cleanup = [self.account]
        return
Example #3
0
    def setUpClass(cls):
        testClient = super(TestISO, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()
        cls._cleanup = []
        cls.unsupportedHypervisor = False
        cls.hypervisor = get_hypervisor_type(cls.apiclient)
        if cls.hypervisor.lower() in ["simulator", "lxc"]:
            cls.unsupportedHypervisor = True
            return

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())

        cls.services["domainid"] = cls.domain.id
        cls.services["iso1"]["zoneid"] = cls.zone.id
        cls.services["iso2"]["zoneid"] = cls.zone.id
        cls.services["sourcezoneid"] = cls.zone.id
        # populate second zone id for iso copy
        cmd = listZones.listZonesCmd()
        cls.zones = cls.apiclient.listZones(cmd)
        if not isinstance(cls.zones, list):
            raise Exception("Failed to find zones.")

        # Create an account, ISOs etc.
        cls.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     domainid=cls.domain.id)
        cls._cleanup.append(cls.account)
        # Finding the OsTypeId from Ostype
        ostypes = list_os_types(cls.apiclient,
                                description=cls.services["ostype"])
        if not isinstance(ostypes, list):
            raise unittest.SkipTest("OSTypeId for given description not found")

        cls.services["iso1"]["ostypeid"] = ostypes[0].id
        cls.services["iso2"]["ostypeid"] = ostypes[0].id
        cls.services["ostypeid"] = ostypes[0].id

        cls.iso_1 = Iso.create(cls.apiclient,
                               cls.services["iso1"],
                               account=cls.account.name,
                               domainid=cls.account.domainid)
        try:
            cls.iso_1.download(cls.apiclient)
        except Exception as e:
            raise Exception("Exception while downloading ISO %s: %s" %
                            (cls.iso_1.id, e))

        cls.iso_2 = Iso.create(cls.apiclient,
                               cls.services["iso2"],
                               account=cls.account.name,
                               domainid=cls.account.domainid)
        try:
            cls.iso_2.download(cls.apiclient)
        except Exception as e:
            raise Exception("Exception while downloading ISO %s: %s" %
                            (cls.iso_2.id, e))
        return
Example #4
0
    def setUpClass(cls):
        testClient = super(TestISO, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())

        cls.services["domainid"] = cls.domain.id
        cls.services["iso1"]["zoneid"] = cls.zone.id
        cls.services["iso2"]["zoneid"] = cls.zone.id
        cls.services["sourcezoneid"] = cls.zone.id
        # populate second zone id for iso copy
        cmd = listZones.listZonesCmd()
        cls.zones = cls.apiclient.listZones(cmd)
        if not isinstance(cls.zones, list):
            raise Exception("Failed to find zones.")

        # Create an account, ISOs etc.
        cls.account = Account.create(
            cls.apiclient,
            cls.services["account"],
            domainid=cls.domain.id
        )
        # Finding the OsTypeId from Ostype
        ostypes = list_os_types(
            cls.apiclient,
            description=cls.services["ostype"]
        )
        if not isinstance(ostypes, list):
            raise unittest.SkipTest("OSTypeId for given description not found")

        cls.services["iso1"]["ostypeid"] = ostypes[0].id
        cls.services["iso2"]["ostypeid"] = ostypes[0].id
        cls.services["ostypeid"] = ostypes[0].id

        cls.iso_1 = Iso.create(
            cls.apiclient,
            cls.services["iso1"],
            account=cls.account.name,
            domainid=cls.account.domainid
        )
        try:
            cls.iso_1.download(cls.apiclient)
        except Exception as e:
            raise Exception("Exception while downloading ISO %s: %s"
                            % (cls.iso_1.id, e))

        cls.iso_2 = Iso.create(
            cls.apiclient,
            cls.services["iso2"],
            account=cls.account.name,
            domainid=cls.account.domainid
        )
        try:
            cls.iso_2.download(cls.apiclient)
        except Exception as e:
            raise Exception("Exception while downloading ISO %s: %s"
                            % (cls.iso_2.id, e))

        cls._cleanup = [cls.account]
        return
Example #5
0
    def test_03_edit_template_details(self):
        """
        @Desc: Test to Edit Template name, displaytext, OSType
        @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: Editing the template name
        Step8: Verifying that Template name is edited
        Step9: Editing the template displaytext
        Step10: Verifying that Template displaytext is edited
        Step11: Editing the template ostypeid
        Step12: Verifying that Template ostypeid is edited
        Step13: Editing the template name, displaytext
        Step14: Verifying that Template name, displaytext are edited
        Step15: Editing the template name, displaytext, ostypeid
        Step16: Verifying that Template name, displaytext and ostypeid are edited
        """
        # 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"]
        # 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

        # Editing the Template name
        edited_template = Template.update(
            template_created,
            self.userapiclient,
            name="NewTemplateName"
        )
        self.assertIsNotNone(
            edited_template,
            "Editing Template failed"
        )
        # Verifying the details of edited template
        expected_dict = {
            "id": template_created.id,
            "name": "NewTemplateName",
            "displaytest": template_created.displaytext,
            "account": template_created.account,
            "domainid": template_created.domainid,
            "format": template_created.format,
            "ostypeid": template_created.ostypeid,
            "templatetype": template_created.templatetype,
        }
        actual_dict = {
            "id": edited_template.id,
            "name": edited_template.name,
            "displaytest": edited_template.displaytext,
            "account": edited_template.account,
            "domainid": edited_template.domainid,
            "format": edited_template.format,
            "ostypeid": edited_template.ostypeid,
            "templatetype": edited_template.templatetype,
        }
        edit_template_status = self.__verify_values(
            expected_dict,
            actual_dict
        )
        self.assertEqual(
            True,
            edit_template_status,
            "Edited Template details are not as expected"
        )
        # Editing the Template displaytext
        edited_template = Template.update(
            template_created,
            self.userapiclient,
            displaytext="TemplateDisplaytext"
        )
        self.assertIsNotNone(
            edited_template,
            "Editing Template failed"
        )
        # Verifying the details of edited template
        expected_dict = {
            "id": template_created.id,
            "name": "NewTemplateName",
            "displaytest": "TemplateDisplaytext",
            "account": template_created.account,
            "domainid": template_created.domainid,
            "format": template_created.format,
            "ostypeid": template_created.ostypeid,
            "templatetype": template_created.templatetype,
        }
        actual_dict = {
            "id": edited_template.id,
            "name": edited_template.name,
            "displaytest": edited_template.displaytext,
            "account": edited_template.account,
            "domainid": edited_template.domainid,
            "format": edited_template.format,
            "ostypeid": edited_template.ostypeid,
            "templatetype": edited_template.templatetype,
        }
        edit_template_status = self.__verify_values(
            expected_dict,
            actual_dict
        )
        self.assertEqual(
            True,
            edit_template_status,
            "Edited Template details are not as expected"
        )
        # Editing the Template ostypeid
        ostype_list = list_os_types(self.userapiclient)
        status = validateList(ostype_list)
        self.assertEquals(
            PASS,
            status[0],
            "Failed to list OS Types"
        )
        for i in range(0, len(ostype_list)):
            if ostype_list[i].id != template_created.ostypeid:
                newostypeid = ostype_list[i].id
                break

        edited_template = Template.update(
            template_created,
            self.userapiclient,
            ostypeid=newostypeid
        )
        self.assertIsNotNone(
            edited_template,
            "Editing Template failed"
        )
        # Verifying the details of edited template
        expected_dict = {
            "id": template_created.id,
            "name": "NewTemplateName",
            "displaytest": "TemplateDisplaytext",
            "account": template_created.account,
            "domainid": template_created.domainid,
            "format": template_created.format,
            "ostypeid": newostypeid,
            "templatetype": template_created.templatetype,
        }
        actual_dict = {
            "id": edited_template.id,
            "name": edited_template.name,
            "displaytest": edited_template.displaytext,
            "account": edited_template.account,
            "domainid": edited_template.domainid,
            "format": edited_template.format,
            "ostypeid": edited_template.ostypeid,
            "templatetype": edited_template.templatetype,
        }
        edit_template_status = self.__verify_values(
            expected_dict,
            actual_dict
        )
        self.assertEqual(
            True,
            edit_template_status,
            "Edited Template details are not as expected"
        )
        # Editing the Template name, displaytext
        edited_template = Template.update(
            template_created,
            self.userapiclient,
            name=template_created.name,
            displaytext=template_created.displaytext
        )
        self.assertIsNotNone(
            edited_template,
            "Editing Template failed"
        )
        # Verifying the details of edited template
        expected_dict = {
            "id": template_created.id,
            "name": template_created.name,
            "displaytest": template_created.displaytext,
            "account": template_created.account,
            "domainid": template_created.domainid,
            "format": template_created.format,
            "ostypeid": newostypeid,
            "templatetype": template_created.templatetype,
        }
        actual_dict = {
            "id": edited_template.id,
            "name": edited_template.name,
            "displaytest": edited_template.displaytext,
            "account": edited_template.account,
            "domainid": edited_template.domainid,
            "format": edited_template.format,
            "ostypeid": edited_template.ostypeid,
            "templatetype": edited_template.templatetype,
        }
        edit_template_status = self.__verify_values(
            expected_dict,
            actual_dict
        )
        self.assertEqual(
            True,
            edit_template_status,
            "Edited Template details are not as expected"
        )
        # Editing the Template name, displaytext, ostypeid
        edited_template = Template.update(
            template_created,
            self.userapiclient,
            name="NewTemplateName",
            displaytext="TemplateDisplaytext",
            ostypeid=template_created.ostypeid
        )
        self.assertIsNotNone(
            edited_template,
            "Editing Template failed"
        )
        # Verifying the details of edited template
        expected_dict = {
            "id": template_created.id,
            "name": "NewTemplateName",
            "displaytest": "TemplateDisplaytext",
            "account": template_created.account,
            "domainid": template_created.domainid,
            "format": template_created.format,
            "ostypeid": template_created.ostypeid,
            "templatetype": template_created.templatetype,
        }
        actual_dict = {
            "id": edited_template.id,
            "name": edited_template.name,
            "displaytest": edited_template.displaytext,
            "account": edited_template.account,
            "domainid": edited_template.domainid,
            "format": edited_template.format,
            "ostypeid": edited_template.ostypeid,
            "templatetype": edited_template.templatetype,
        }
        edit_template_status = self.__verify_values(
            expected_dict,
            actual_dict
        )
        self.assertEqual(
            True,
            edit_template_status,
            "Edited Template details are not as expected"
        )
        del self.services["privatetemplate"]["ostype"]
        return
Example #6
0
    def test_03_edit_iso_details(self):
        """
        @Desc: Test to Edit ISO name, displaytext, OSType
        @steps:
        Step1: Listing all the ISO's for a user
        Step2: Verifying that no ISO's are listed
        Step3: Creating an ISO
        Step4: Listing all the ISO's again for a user
        Step5: Verifying that list size is 1
        Step6: Verifying if the ISO is in ready state.
                If yes the continuing
                If not waiting and checking for template to be ready till timeout
        Step7: Editing the ISO's name, displaytext
        Step8: Verifying that ISO name and displaytext are edited
        Step9: Editing the ISO name, displaytext, ostypeid
        Step10: Verifying that ISO name, displaytext and ostypeid are edited
        """
        # Listing all the ISO's for a User
        list_iso_before = Iso.list(
                                   self.userapiclient,
                                   listall=self.services["listall"],
                                   isofilter=self.services["templatefilter"]
                                   )
        # Verifying that no ISOs are listed
        self.assertIsNone(
                          list_iso_before,
                          "ISOs listed for newly created User"
                          )
        self.services["iso"]["zoneid"] = self.zone.id
        # Creating an ISO's
        iso_created = Iso.create(
                                 self.userapiclient,
                                 self.services["iso"]
                                 )
        self.assertIsNotNone(
                             iso_created,
                             "ISO creation failed"
                             )
        self.cleanup.append(iso_created)
        # Listing all the ISO's for a User
        list_iso_after = Iso.list(
                                  self.userapiclient,
                                  listall=self.services["listall"],
                                  isofilter=self.services["templatefilter"]
                                  )
        status = validateList(list_iso_after)
        self.assertEquals(
                          PASS,
                          status[0],
                          "ISO's creation failed"
                          )
        # Verifying that list size is 1
        self.assertEquals(
                          1,
                          len(list_iso_after),
                          "Failed to create an ISO's"
                          )
        # Verifying the state of the ISO to be ready. If not waiting for state to become ready
        iso_ready = False
        count = 0
        while iso_ready is False:
            list_iso = Iso.list(
                                self.userapiclient,
                                listall=self.services["listall"],
                                isofilter=self.services["templatefilter"],
                                id=iso_created.id
                                )
            status = validateList(list_iso)
            self.assertEquals(
                              PASS,
                              status[0],
                              "Failed to list ISO by Id"
                              )
            if list_iso[0].isready is True:
                iso_ready = True
            elif (str(list_iso[0].status) == "Error"):
                self.fail("Created ISO is in Errored state")
                break
            elif count > 10:
                self.fail("Timed out before ISO came into ready state")
                break
            else:
                time.sleep(self.services["sleep"])
                count = count + 1

        # Editing the ISO name, displaytext
        edited_iso = Iso.update(
                                iso_created,
                                self.userapiclient,
                                name="NewISOName",
                                displaytext="NewISODisplayText"
                                )
        self.assertIsNotNone(
                             edited_iso,
                             "Editing ISO failed"
                             )
         # Verifying the details of edited template
        expected_dict = {
                         "id":iso_created.id,
                         "name":"NewISOName",
                         "displaytest":"NewISODisplayText",
                         "account":iso_created.account,
                         "domainid":iso_created.domainid,
                         "isfeatured":iso_created.isfeatured,
                         "ostypeid":iso_created.ostypeid,
                         "ispublic":iso_created.ispublic,
                         }
        actual_dict = {
                       "id":edited_iso.id,
                       "name":edited_iso.name,
                       "displaytest":edited_iso.displaytext,
                       "account":edited_iso.account,
                       "domainid":edited_iso.domainid,
                       "isfeatured":edited_iso.isfeatured,
                       "ostypeid":edited_iso.ostypeid,
                       "ispublic":edited_iso.ispublic,
                       }
        edit_iso_status = self.__verify_values(
                                               expected_dict,
                                               actual_dict
                                               )
        self.assertEqual(
                         True,
                         edit_iso_status,
                         "Edited ISO details are not as expected"
                         )
        # Editing the ISO name, displaytext, ostypeid
        ostype_list = list_os_types(self.userapiclient)
        status = validateList(ostype_list)
        self.assertEquals(
                          PASS,
                          status[0],
                          "Failed to list OS Types"
                          )
        for i in range(0, len(ostype_list)):
            if ostype_list[i].id != iso_created.ostypeid:
                newostypeid = ostype_list[i].id
                break

        edited_iso = Iso.update(
                                iso_created,
                                self.userapiclient,
                                name=iso_created.name,
                                displaytext=iso_created.displaytext,
                                ostypeid=newostypeid
                                )
        self.assertIsNotNone(
                             edited_iso,
                             "Editing ISO failed"
                             )
        # Verifying the details of edited template
        expected_dict = {
                         "id":iso_created.id,
                         "name":iso_created.name,
                         "displaytest":iso_created.displaytext,
                         "account":iso_created.account,
                         "domainid":iso_created.domainid,
                         "isfeatured":iso_created.isfeatured,
                         "ostypeid":newostypeid,
                         "ispublic":iso_created.ispublic,
                         }
        actual_dict = {
                       "id":edited_iso.id,
                       "name":edited_iso.name,
                       "displaytest":edited_iso.displaytext,
                       "account":edited_iso.account,
                       "domainid":edited_iso.domainid,
                       "isfeatured":edited_iso.isfeatured,
                       "ostypeid":edited_iso.ostypeid,
                       "ispublic":edited_iso.ispublic,
                       }
        edit_iso_status = self.__verify_values(
                                               expected_dict,
                                               actual_dict
                                               )
        self.assertEqual(
                         True,
                         edit_iso_status,
                         "Edited ISO details are not as expected"
                         )
        del self.services["iso"]["zoneid"]
        return