Ejemplo n.º 1
0
class ITC0701030102_CreateTemplate_SD(BaseTestCase):
    '''
    @summary: 07模板管理-01基本操作-03创建模板-01成功创建-02指定存储域
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
    
    def test_CreateTemplate_SD(self):
        '''
        @summary: 创建模板,指定存储域
        @note: 操作成功,验证返回状态码和返回信息
        '''
        self.tempapi = TemplatesAPIs()
        LogPrint().info("Test: Create template %s."%self.dm.temp_name)
        r = self.tempapi.createTemplate(self.dm.temp_info)
        print r
        def is_temp_ok():
            return self.tempapi.getTemplateInfo(temp_name=self.dm.temp_name)['result']['template']['status']['state']=='ok'
        if r['status_code'] == self.dm.expected_status_code:
            if wait_until(is_temp_ok, 600, 10):
                LogPrint().info("PASS: Create Template ok.")
            else:
                LogPrint().error("FAIL: Create Template overtime")
                self.assertTrue(False)
        else:
            LogPrint().error("FAIL: Create Template failed.Status-code is WRONG.")
            self.assertTrue(False)
            
    def tearDown(self):
        LogPrint().info("Post-Test: Delete template %s."%self.dm.temp_name)
        self.assertTrue(smart_delete_template(self.dm.temp_name)) 
Ejemplo n.º 2
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     self.temp_api = TemplatesAPIs()
     LogPrint().info("Pre-Test: Create a template %s for TC." %
                     self.dm.temp_name)
     self.assertTrue(
         smart_create_template(self.dm.temp_name, self.dm.temp_info))
Ejemplo n.º 3
0
    def test_CreateTemplate_SD(self):
        '''
        @summary: 创建模板,指定存储域
        @note: 操作成功,验证返回状态码和返回信息
        '''
        self.tempapi = TemplatesAPIs()
        LogPrint().info("Test: Create template %s." % self.dm.temp_name)
        r = self.tempapi.createTemplate(self.dm.temp_info)
        print r

        def is_temp_ok():
            return self.tempapi.getTemplateInfo(
                temp_name=self.dm.temp_name
            )['result']['template']['status']['state'] == 'ok'

        if r['status_code'] == self.dm.expected_status_code:
            if wait_until(is_temp_ok, 600, 10):
                LogPrint().info("PASS: Create Template ok.")
            else:
                LogPrint().error("FAIL: Create Template overtime")
                self.assertTrue(False)
        else:
            LogPrint().error(
                "FAIL: Create Template failed.Status-code is WRONG.")
            self.assertTrue(False)
Ejemplo n.º 4
0
    def test_CreateTemplate_NoRequired(self):
        '''
        @summary: 创建模板,缺少必填项
        @note: 操作失败,验证返回状态码和返回信息
        '''
        self.tempapi = TemplatesAPIs()
        self.expected_result_index = 0

        @BaseTestCase.drive_data(self, self.dm.temp_info)
        def do_test(xml_info):
            self.flag = True
            r = self.tempapi.createTemplate(xml_info)
            if r['status_code'] == self.dm.expected_status_code:
                dictCompare = DictCompare()
                if dictCompare.isSubsetDict(
                        xmltodict.parse(self.dm.expected_info_list[
                            self.expected_result_index]), r['result']):
                    LogPrint().info(
                        "PASS: The returned status code and messages are CORRECT."
                    )
                else:
                    LogPrint().error(
                        "FAIL: The returned messages are INCORRECT.")
                    self.flag = False
            else:
                LogPrint().error(
                    "FAIL: The returned status code is '%s' while it should be '%s'."
                    % (r['status_code'], self.dm.expected_status_code))
                self.flag = False
            self.assertTrue(self.flag)
            self.expected_result_index += 1

        do_test()
Ejemplo n.º 5
0
class ITC070105_DeleteTemplate(BaseTestCase):
    '''
    @summary: 07模板管理-01基本操作-05删除模板
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        LogPrint().info("Pre-Test: Create a template %s for TC."%self.dm.temp_name)
        self.assertTrue(smart_create_template(self.dm.temp_name, self.dm.temp_info))
            
    def test_DeleteTemplate(self):
        '''
        @summary: 删除模板
        @note: 操作成功,验证返回状态码和返回信息
        '''
        self.flag=True
        self.tempapi = TemplatesAPIs()
        LogPrint().info("Test: Delete template %s."%self.dm.temp_name)
        r = self.tempapi.delTemplate(self.dm.temp_name)
        def temp_not_exist():
            return self.tempapi.searchTemplateByName(self.dm.temp_name)['result']['templates'] ==None
        if r['status_code'] == self.dm.expected_status_code:
            if wait_until(temp_not_exist,300, 5):
                LogPrint().info("PASS: Delete Template SUCCESS.")
            else:
                LogPrint().info("FAIL: Delete Template failed.The Template still exist")
                self.flag=False
        else:
            LogPrint().info("FAIL: Delete Template failed.The status_code is WRONG")
            self.flag=False
        self.assertTrue(self.flag)
Ejemplo n.º 6
0
    def test_DeleteTemplate(self):
        '''
        @summary: 删除模板
        @note: 操作成功,验证返回状态码和返回信息
        '''
        self.flag = True
        self.tempapi = TemplatesAPIs()
        LogPrint().info("Test: Delete template %s." % self.dm.temp_name)
        r = self.tempapi.delTemplate(self.dm.temp_name)

        def temp_not_exist():
            return self.tempapi.searchTemplateByName(
                self.dm.temp_name)['result']['templates'] == None

        if r['status_code'] == self.dm.expected_status_code:
            if wait_until(temp_not_exist, 300, 5):
                LogPrint().info("PASS: Delete Template SUCCESS.")
            else:
                LogPrint().info(
                    "FAIL: Delete Template failed.The Template still exist")
                self.flag = False
        else:
            LogPrint().info(
                "FAIL: Delete Template failed.The status_code is WRONG")
            self.flag = False
        self.assertTrue(self.flag)
Ejemplo n.º 7
0
class ITC0701030101_CreateTemplate(BaseTestCase):
    '''
    @summary: 07模板管理-01基本操作-03创建模板-01成功创建-01最小测试集
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()

    def test_CreateTemplate(self):
        '''
        @summary: 创建模板
        @note: 操作成功,验证返回状态码和返回信息
        '''
        self.tempapi = TemplatesAPIs()
        self.expected_result_index = 0

        @BaseTestCase.drive_data(self, self.dm.temp_info)
        def do_test(xml_info):
            self.flag = True
            LogPrint().info("Test: Create template %s." %
                            self.dm.temp_name[self.expected_result_index])
            r = self.tempapi.createTemplate(xml_info)

            def is_temp_ok():
                return self.tempapi.getTemplateInfo(
                    temp_name=self.dm.temp_name[self.expected_result_index]
                )['result']['template']['status']['state'] == 'ok'

            if r['status_code'] == self.dm.expected_status_code:
                if wait_until(is_temp_ok, 600, 10):
                    LogPrint().info(
                        "PASS: Create Template '%s'ok." %
                        self.dm.temp_name[self.expected_result_index])
                else:
                    LogPrint().error(
                        "FAIL: Create Template '%s'overtime" %
                        self.dm.temp_name[self.expected_result_index])
                    self.flag = False
            else:
                LogPrint().error(
                    "FAIL: Create Template '%s'failed.Status-code is WRONG." %
                    self.dm.temp_name[self.expected_result_index])
                self.flag = False
            self.assertTrue(self.flag)
            self.expected_result_index += 1

        do_test()

    def tearDown(self):
        for index in range(0, 5):
            LogPrint().info("Post-Test: Delete template %s." %
                            self.dm.temp_name[index])
            self.assertTrue(smart_delete_template(self.dm.temp_name[index]))
Ejemplo n.º 8
0
 def test_GetTemplateList(self):
     '''
     @summary: 获取模板列表
     @note: 操作成功,验证返回状态码
     '''
     temp_api = TemplatesAPIs()
     LogPrint().info("Test: Get template list.")
     r = temp_api.getTemplatesList()
     if r['status_code'] == 200:
         LogPrint().info("PASS: Get TemplateList SUCCESS.")
         self.assertTrue(True)
     else:
         LogPrint().error("FAIL: Returned status code is WRONG.")
         self.assertTrue(False)
Ejemplo n.º 9
0
 def test_GetTemplateList(self):
     '''
     @summary: 获取模板列表
     @note: 操作成功,验证返回状态码
     '''
     temp_api = TemplatesAPIs()
     LogPrint().info("Test: Get template list.")
     r = temp_api.getTemplatesList()
     if r['status_code'] == 200:
         LogPrint().info("PASS: Get TemplateList SUCCESS.")
         self.assertTrue(True)
     else:
         LogPrint().error("FAIL: Returned status code is WRONG.")
         self.assertTrue(False)
Ejemplo n.º 10
0
class ITC070102_GetTemplateInfo(BaseTestCase):
    '''
    @summary: 07模板管理-01基本操作-02获取模板详情
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.temp_api = TemplatesAPIs()
        LogPrint().info("Pre-Test: Create a template %s for TC." %
                        self.dm.temp_name)
        self.assertTrue(
            smart_create_template(self.dm.temp_name, self.dm.temp_info))

    def test_GetTemplateInfo(self):
        '''
        @summary: 获取模板详情
        @note: 操作成功,验证返回状态码和返回信息
        '''
        self.flag = True
        LogPrint().info("Test: Get info of template %s." % self.dm.temp_name)
        r = self.temp_api.getTemplateInfo(self.dm.temp_name)
        if r['status_code'] == self.dm.expected_status_code:
            LogPrint().info("PASS: Get TemplateInfo SUCCESS.")
        else:
            LogPrint().error(
                "FAIL: Get TemplateInfo fail.The Template info is WRONOG.")
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        LogPrint().info("Post-Test: Delete template %s." % self.dm.temp_name)
        self.assertTrue(smart_delete_template(self.dm.temp_name))
Ejemplo n.º 11
0
class ITC0701030202_CreateTemplate_VerifyName(BaseTestCase):
    '''
    @summary: 07模板管理-01基本操作-03创建模板-02创建失败-02验证名称合法性
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
            
    def test_CreateTemplate_VerifyName(self):
        '''
        @summary: 创建模板,名称不合法
        @note: 操作失败,验证返回状态码和返回信息
        '''
        self.tempapi = TemplatesAPIs()
        LogPrint().info("Test: Create template %s."%self.dm.temp_name)
        r = self.tempapi.createTemplate(self.dm.temp_info)
        if r['status_code'] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            d1 = xmltodict.parse(self.dm.expected_info)
            if dictCompare.isSubsetDict(d1, r['result']):
                LogPrint().info("PASS: Returned status code and messages are CORRECT when create host with dup name.")
            else:
                LogPrint().error("FAIL: Returned messages are incorrectly.")
                self.flag = False
        else:
            LogPrint().error("FAIL: Status-code is WRONG.")
            self.assertTrue(False)
Ejemplo n.º 12
0
class ITC0701030203_CreateTemplate_NoRequired(BaseTestCase):
    '''
    @summary: 07模板管理-01基本操作-03创建模板-02创建失败-03验证参数完整性
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
            
    def test_CreateTemplate_NoRequired(self):
        '''
        @summary: 创建模板,缺少必填项
        @note: 操作失败,验证返回状态码和返回信息
        '''
        self.tempapi = TemplatesAPIs()
        self.expected_result_index = 0
        @BaseTestCase.drive_data(self, self.dm.temp_info)
        def do_test(xml_info):
            self.flag = True
            r = self.tempapi.createTemplate(xml_info)
            if r['status_code'] == self.dm.expected_status_code:
                dictCompare = DictCompare()
                if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info_list[self.expected_result_index]), r['result']):
                    LogPrint().info("PASS: The returned status code and messages are CORRECT.")
                else:
                    LogPrint().error("FAIL: The returned messages are INCORRECT.")
                    self.flag = False
            else:
                LogPrint().error("FAIL: The returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code))
                self.flag = False
            self.assertTrue(self.flag)
            self.expected_result_index += 1
        do_test()
Ejemplo n.º 13
0
class ITC0701030202_CreateTemplate_VerifyName(BaseTestCase):
    '''
    @summary: 07模板管理-01基本操作-03创建模板-02创建失败-02验证名称合法性
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()

    def test_CreateTemplate_VerifyName(self):
        '''
        @summary: 创建模板,名称不合法
        @note: 操作失败,验证返回状态码和返回信息
        '''
        self.tempapi = TemplatesAPIs()
        LogPrint().info("Test: Create template %s." % self.dm.temp_name)
        r = self.tempapi.createTemplate(self.dm.temp_info)
        if r['status_code'] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            d1 = xmltodict.parse(self.dm.expected_info)
            if dictCompare.isSubsetDict(d1, r['result']):
                LogPrint().info(
                    "PASS: Returned status code and messages are CORRECT when create host with dup name."
                )
            else:
                LogPrint().error("FAIL: Returned messages are incorrectly.")
                self.flag = False
        else:
            LogPrint().error("FAIL: Status-code is WRONG.")
            self.assertTrue(False)
Ejemplo n.º 14
0
class ITC070102_GetTemplateInfo(BaseTestCase):
    '''
    @summary: 07模板管理-01基本操作-02获取模板详情
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.temp_api = TemplatesAPIs()
        LogPrint().info("Pre-Test: Create a template %s for TC."%self.dm.temp_name)
        self.assertTrue(smart_create_template(self.dm.temp_name, self.dm.temp_info))
 
    def test_GetTemplateInfo(self):
        '''
        @summary: 获取模板详情
        @note: 操作成功,验证返回状态码和返回信息
        '''
        self.flag=True
        LogPrint().info("Test: Get info of template %s."%self.dm.temp_name)
        r = self.temp_api.getTemplateInfo(self.dm.temp_name)
        if r['status_code'] == self.dm.expected_status_code:
            LogPrint().info("PASS: Get TemplateInfo SUCCESS.")
        else:
            LogPrint().error("FAIL: Get TemplateInfo fail.The Template info is WRONOG.")
            self.flag=False
        self.assertTrue(self.flag)
    def tearDown(self):
        LogPrint().info("Post-Test: Delete template %s."%self.dm.temp_name)
        self.assertTrue(smart_delete_template(self.dm.temp_name))
Ejemplo n.º 15
0
 def test_CreateTemplate(self):
     '''
     @summary: 创建模板
     @note: 操作成功,验证返回状态码和返回信息
     '''
     self.tempapi = TemplatesAPIs()
     self.expected_result_index = 0
     @BaseTestCase.drive_data(self, self.dm.temp_info)
     def do_test(xml_info):
         self.flag=True
         LogPrint().info("Test: Create template %s."%self.dm.temp_name[self.expected_result_index])
         r = self.tempapi.createTemplate(xml_info)
         def is_temp_ok():
             return self.tempapi.getTemplateInfo(temp_name=self.dm.temp_name[self.expected_result_index])['result']['template']['status']['state']=='ok'
         if r['status_code'] == self.dm.expected_status_code:
             if wait_until(is_temp_ok, 600, 10):
                 LogPrint().info("PASS: Create Template '%s'ok."%self.dm.temp_name[self.expected_result_index])
             else:
                 LogPrint().error("FAIL: Create Template '%s'overtime"%self.dm.temp_name[self.expected_result_index])
                 self.flag=False
         else:
             LogPrint().error("FAIL: Create Template '%s'failed.Status-code is WRONG."%self.dm.temp_name[self.expected_result_index])
             self.flag=False
         self.assertTrue(self.flag)
         self.expected_result_index += 1
     do_test()
Ejemplo n.º 16
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     #创建一个虚拟机
     LogPrint().info("Pre-Test-1: Create vm %s for TC."% self.dm.vm_name)
     self.assertTrue(smart_create_vm(self.dm.vm_name, self.dm.vm_info))    
     #创建一块磁盘
     '''
     @note: 创建磁盘时,磁盘的sharable属性必须为false,因为共享磁盘不作为模板的一部份
     '''
     LogPrint().info("Pre-Test-2: Create a disk for TC.")
     r= smart_create_disk(self.dm.disk_info, self.dm.disk_name)
     self.assertTrue(r[0])
     self.disk_id = r[1]    
     #将该磁盘附加到虚拟机上
     LogPrint().info("Pre-Test-3: Attach disk %s to vm %s for TC."% (self.dm.disk_name
                                                              ,self.dm.vm_name))
     self.vmdiskapi = VmDiskAPIs()
     r=self.vmdiskapi.attachDiskToVm(self.dm.vm_name, self.disk_id)
     if r['status_code'] == 200:
         LogPrint().info("Attach Disk to vm success.")
     else:
         LogPrint().error("Attach Disk to vm fail.Status-code is wrong.")
         self.assertTrue(False)    
     #该虚拟机创建模板   
     LogPrint().info("Pre-Test-4: Create template for vm %s for TC."% self.dm.vm_name)
     self.tempapi = TemplatesAPIs()
     self.vm_id = VirtualMachineAPIs().getVmIdByName(self.dm.vm_name)
     r = self.tempapi.createTemplate(self.dm.temp_info, self.vm_id)
     def is_temp_ok():
         return self.tempapi.getTemplateInfo(temp_name=self.dm.temp_name)['result']['template']['status']['state']=='ok'
     if r['status_code'] == 202:
         if wait_until(is_temp_ok, 600, 10):
             LogPrint().info("Create Template ok.")
         else:
             LogPrint().error("Create Template overtime")
             self.assertTrue(False)
     else:
         LogPrint().error("Create Template failed.Status-code is wrong.")
         self.assertTrue(False)
     #获得模板关联的磁盘id
     r = TemplateDisksAPIs().getTemplateDiskInfo(self.dm.temp_name, self.dm.disk_name) 
     if r['status_code'] == 200:
         self.disk_id_temp = r['result']['disk']['@id']
     else:
         self.assertTrue(False)
Ejemplo n.º 17
0
    def test_CreateTemplate(self):
        '''
        @summary: 创建模板
        @note: 操作成功,验证返回状态码和返回信息
        '''
        self.tempapi = TemplatesAPIs()
        self.expected_result_index = 0

        @BaseTestCase.drive_data(self, self.dm.temp_info)
        def do_test(xml_info):
            self.flag = True
            LogPrint().info("Test: Create template %s." %
                            self.dm.temp_name[self.expected_result_index])
            r = self.tempapi.createTemplate(xml_info)

            def is_temp_ok():
                return self.tempapi.getTemplateInfo(
                    temp_name=self.dm.temp_name[self.expected_result_index]
                )['result']['template']['status']['state'] == 'ok'

            if r['status_code'] == self.dm.expected_status_code:
                if wait_until(is_temp_ok, 600, 10):
                    LogPrint().info(
                        "PASS: Create Template '%s'ok." %
                        self.dm.temp_name[self.expected_result_index])
                else:
                    LogPrint().error(
                        "FAIL: Create Template '%s'overtime" %
                        self.dm.temp_name[self.expected_result_index])
                    self.flag = False
            else:
                LogPrint().error(
                    "FAIL: Create Template '%s'failed.Status-code is WRONG." %
                    self.dm.temp_name[self.expected_result_index])
                self.flag = False
            self.assertTrue(self.flag)
            self.expected_result_index += 1

        do_test()
Ejemplo n.º 18
0
 def test_CreateTemplate_DupName(self):
     '''
     @summary: 创建模板,重名
     @note: 操作失败,验证返回状态码和返回信息
     '''
     self.tempapi = TemplatesAPIs()
     LogPrint().info("Test: Create dupname template %s." %
                     self.dm.temp_name)
     r = self.tempapi.createTemplate(self.dm.temp_info)
     if r['status_code'] == self.dm.expected_status_code:
         dictCompare = DictCompare()
         d1 = xmltodict.parse(self.dm.expected_info)
         if dictCompare.isSubsetDict(d1, r['result']):
             LogPrint().info(
                 "PASS: Returned status code and messages are CORRECT when create host with dup name."
             )
         else:
             LogPrint().error("FAIL: Returned messages are incorrectly.")
             self.flag = False
     else:
         LogPrint().error("FAIL: Status-code is WRONG.")
         self.assertTrue(False)
Ejemplo n.º 19
0
class ITC0701030101_CreateTemplate(BaseTestCase):
    '''
    @summary: 07模板管理-01基本操作-03创建模板-01成功创建-01最小测试集
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        
    def test_CreateTemplate(self):
        '''
        @summary: 创建模板
        @note: 操作成功,验证返回状态码和返回信息
        '''
        self.tempapi = TemplatesAPIs()
        self.expected_result_index = 0
        @BaseTestCase.drive_data(self, self.dm.temp_info)
        def do_test(xml_info):
            self.flag=True
            LogPrint().info("Test: Create template %s."%self.dm.temp_name[self.expected_result_index])
            r = self.tempapi.createTemplate(xml_info)
            def is_temp_ok():
                return self.tempapi.getTemplateInfo(temp_name=self.dm.temp_name[self.expected_result_index])['result']['template']['status']['state']=='ok'
            if r['status_code'] == self.dm.expected_status_code:
                if wait_until(is_temp_ok, 600, 10):
                    LogPrint().info("PASS: Create Template '%s'ok."%self.dm.temp_name[self.expected_result_index])
                else:
                    LogPrint().error("FAIL: Create Template '%s'overtime"%self.dm.temp_name[self.expected_result_index])
                    self.flag=False
            else:
                LogPrint().error("FAIL: Create Template '%s'failed.Status-code is WRONG."%self.dm.temp_name[self.expected_result_index])
                self.flag=False
            self.assertTrue(self.flag)
            self.expected_result_index += 1
        do_test()
        
    def tearDown(self):
        for index in range(0,5):
            LogPrint().info("Post-Test: Delete template %s."%self.dm.temp_name[index])
            self.assertTrue(smart_delete_template(self.dm.temp_name[index]))
Ejemplo n.º 20
0
class ITC070105_DeleteTemplate(BaseTestCase):
    '''
    @summary: 07模板管理-01基本操作-05删除模板
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        LogPrint().info("Pre-Test: Create a template %s for TC." %
                        self.dm.temp_name)
        self.assertTrue(
            smart_create_template(self.dm.temp_name, self.dm.temp_info))

    def test_DeleteTemplate(self):
        '''
        @summary: 删除模板
        @note: 操作成功,验证返回状态码和返回信息
        '''
        self.flag = True
        self.tempapi = TemplatesAPIs()
        LogPrint().info("Test: Delete template %s." % self.dm.temp_name)
        r = self.tempapi.delTemplate(self.dm.temp_name)

        def temp_not_exist():
            return self.tempapi.searchTemplateByName(
                self.dm.temp_name)['result']['templates'] == None

        if r['status_code'] == self.dm.expected_status_code:
            if wait_until(temp_not_exist, 300, 5):
                LogPrint().info("PASS: Delete Template SUCCESS.")
            else:
                LogPrint().info(
                    "FAIL: Delete Template failed.The Template still exist")
                self.flag = False
        else:
            LogPrint().info(
                "FAIL: Delete Template failed.The status_code is WRONG")
            self.flag = False
        self.assertTrue(self.flag)
Ejemplo n.º 21
0
class ITC0701030102_CreateTemplate_SD(BaseTestCase):
    '''
    @summary: 07模板管理-01基本操作-03创建模板-01成功创建-02指定存储域
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()

    def test_CreateTemplate_SD(self):
        '''
        @summary: 创建模板,指定存储域
        @note: 操作成功,验证返回状态码和返回信息
        '''
        self.tempapi = TemplatesAPIs()
        LogPrint().info("Test: Create template %s." % self.dm.temp_name)
        r = self.tempapi.createTemplate(self.dm.temp_info)
        print r

        def is_temp_ok():
            return self.tempapi.getTemplateInfo(
                temp_name=self.dm.temp_name
            )['result']['template']['status']['state'] == 'ok'

        if r['status_code'] == self.dm.expected_status_code:
            if wait_until(is_temp_ok, 600, 10):
                LogPrint().info("PASS: Create Template ok.")
            else:
                LogPrint().error("FAIL: Create Template overtime")
                self.assertTrue(False)
        else:
            LogPrint().error(
                "FAIL: Create Template failed.Status-code is WRONG.")
            self.assertTrue(False)

    def tearDown(self):
        LogPrint().info("Post-Test: Delete template %s." % self.dm.temp_name)
        self.assertTrue(smart_delete_template(self.dm.temp_name))
Ejemplo n.º 22
0
 def test_CreateTemplate_DupName(self):
     '''
     @summary: 创建模板,重名
     @note: 操作失败,验证返回状态码和返回信息
     '''
     self.tempapi = TemplatesAPIs()
     LogPrint().info("Test: Create dupname template %s."%self.dm.temp_name)
     r = self.tempapi.createTemplate(self.dm.temp_info)
     if r['status_code'] == self.dm.expected_status_code:
         dictCompare = DictCompare()
         d1 = xmltodict.parse(self.dm.expected_info)
         if dictCompare.isSubsetDict(d1, r['result']):
             LogPrint().info("PASS: Returned status code and messages are CORRECT when create host with dup name.")
         else:
             LogPrint().error("FAIL: Returned messages are incorrectly.")
             self.flag = False
     else:
         LogPrint().error("FAIL: Status-code is WRONG.")
         self.assertTrue(False)
Ejemplo n.º 23
0
 def test_CreateTemplate_SD(self):
     '''
     @summary: 创建模板,指定存储域
     @note: 操作成功,验证返回状态码和返回信息
     '''
     self.tempapi = TemplatesAPIs()
     LogPrint().info("Test: Create template %s."%self.dm.temp_name)
     r = self.tempapi.createTemplate(self.dm.temp_info)
     print r
     def is_temp_ok():
         return self.tempapi.getTemplateInfo(temp_name=self.dm.temp_name)['result']['template']['status']['state']=='ok'
     if r['status_code'] == self.dm.expected_status_code:
         if wait_until(is_temp_ok, 600, 10):
             LogPrint().info("PASS: Create Template ok.")
         else:
             LogPrint().error("FAIL: Create Template overtime")
             self.assertTrue(False)
     else:
         LogPrint().error("FAIL: Create Template failed.Status-code is WRONG.")
         self.assertTrue(False)
Ejemplo n.º 24
0
 def test_DeleteTemplate(self):
     '''
     @summary: 删除模板
     @note: 操作成功,验证返回状态码和返回信息
     '''
     self.flag=True
     self.tempapi = TemplatesAPIs()
     LogPrint().info("Test: Delete template %s."%self.dm.temp_name)
     r = self.tempapi.delTemplate(self.dm.temp_name)
     def temp_not_exist():
         return self.tempapi.searchTemplateByName(self.dm.temp_name)['result']['templates'] ==None
     if r['status_code'] == self.dm.expected_status_code:
         if wait_until(temp_not_exist,300, 5):
             LogPrint().info("PASS: Delete Template SUCCESS.")
         else:
             LogPrint().info("FAIL: Delete Template failed.The Template still exist")
             self.flag=False
     else:
         LogPrint().info("FAIL: Delete Template failed.The status_code is WRONG")
         self.flag=False
     self.assertTrue(self.flag)
Ejemplo n.º 25
0
 def test(self):
     #step1:创建一个虚拟机
     self.assertTrue(smart_create_vm(self.dm.vm_name, self.dm.xml_vm_info))
     #step2:为虚拟机创建模板
     vm_id = VirtualMachineAPIs().getVmIdByName(self.dm.vm_name)
     TemplatesAPIs().createTemplate(self.dm.xml_temp_info, vm_id)
'''
---------------------------------------------------------------------------------------------------
@note: Pre-Test-Data
---------------------------------------------------------------------------------------------------
'''



'''
---------------------------------------------------------------------------------------------------
@note: Test-Data
---------------------------------------------------------------------------------------------------
'''
vm_name = 'vm-ITC05010301'
cluster_id = ClusterAPIs().getClusterIdByName(ModuleData.cluster_nfs_name)
template_id = TemplatesAPIs().getTemplateIdByName('Blank')

xml_vm_info='''
<vm>
    <name>%s</name>
    <description>Test for ITC050102</description>
    <type>server</type>
    <memory>536870912</memory>
    <cluster id="%s"/>
    <template id="%s"/>
    <cpu>
        <topology sockets="1" cores="1"/>
    </cpu>
    <os type="NKAS6x64">
        <boot dev="hd"/>
    </os>
Ejemplo n.º 27
0
from TestAPIs.HostAPIs import HostAPIs
from TestAPIs.ClusterAPIs import ClusterAPIs
from TestAPIs.TemplatesAPIs import TemplatesAPIs
from TestData.VirtualMachine.ITC05010502_DelVm_WithoutDisk import disk_alias
from TestAPIs.StorageDomainAPIs import StorageDomainAPIs
from TestAPIs.VirtualMachineAPIs import VirtualMachineAPIs
'''
---------------------------------------------------------------------------------------------------
@note: ModuleTestData
---------------------------------------------------------------------------------------------------
'''

#虚拟机信息
vm_name = 'vm-ITC1003'
cluster_id = ClusterAPIs().getClusterIdByName('Cluster-ITC05-NFS')
template_id = TemplatesAPIs().getTemplateIdByName('Blank')
#使用blank模板创建虚拟机xml
xml_vm_info = '''
<vm>
    <name>%s</name>
    <description>Test for ITC1003</description>
    <type>server</type>
    <memory>536870912</memory>
    <cluster id="%s"/>
    <template id="%s"/>
    <cpu>
        <topology sockets="1" cores="1"/>
    </cpu>
    <os type="NKAS6x64">
        <boot dev="hd"/>
    </os>
Ejemplo n.º 28
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     self.temp_api = TemplatesAPIs()
     LogPrint().info("Pre-Test: Create a template %s for TC."%self.dm.temp_name)
     self.assertTrue(smart_create_template(self.dm.temp_name, self.dm.temp_info))
Ejemplo n.º 29
0
class ITC080402_DeleteDisk_AttachtoTemp(BaseTestCase):
    '''
    @summary: ITC-08磁盘管理-04删除磁盘-02磁盘附加到模板上
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        #创建一个虚拟机
        LogPrint().info("Pre-Test-1: Create vm %s for TC."% self.dm.vm_name)
        self.assertTrue(smart_create_vm(self.dm.vm_name, self.dm.vm_info))    
        #创建一块磁盘
        '''
        @note: 创建磁盘时,磁盘的sharable属性必须为false,因为共享磁盘不作为模板的一部份
        '''
        LogPrint().info("Pre-Test-2: Create a disk for TC.")
        r= smart_create_disk(self.dm.disk_info, self.dm.disk_name)
        self.assertTrue(r[0])
        self.disk_id = r[1]    
        #将该磁盘附加到虚拟机上
        LogPrint().info("Pre-Test-3: Attach disk %s to vm %s for TC."% (self.dm.disk_name
                                                                 ,self.dm.vm_name))
        self.vmdiskapi = VmDiskAPIs()
        r=self.vmdiskapi.attachDiskToVm(self.dm.vm_name, self.disk_id)
        if r['status_code'] == 200:
            LogPrint().info("Attach Disk to vm success.")
        else:
            LogPrint().error("Attach Disk to vm fail.Status-code is wrong.")
            self.assertTrue(False)    
        #该虚拟机创建模板   
        LogPrint().info("Pre-Test-4: Create template for vm %s for TC."% self.dm.vm_name)
        self.tempapi = TemplatesAPIs()
        self.vm_id = VirtualMachineAPIs().getVmIdByName(self.dm.vm_name)
        r = self.tempapi.createTemplate(self.dm.temp_info, self.vm_id)
        def is_temp_ok():
            return self.tempapi.getTemplateInfo(temp_name=self.dm.temp_name)['result']['template']['status']['state']=='ok'
        if r['status_code'] == 202:
            if wait_until(is_temp_ok, 600, 10):
                LogPrint().info("Create Template ok.")
            else:
                LogPrint().error("Create Template overtime")
                self.assertTrue(False)
        else:
            LogPrint().error("Create Template failed.Status-code is wrong.")
            self.assertTrue(False)
        #获得模板关联的磁盘id
        r = TemplateDisksAPIs().getTemplateDiskInfo(self.dm.temp_name, self.dm.disk_name) 
        if r['status_code'] == 200:
            self.disk_id_temp = r['result']['disk']['@id']
        else:
            self.assertTrue(False)
         
    def test_DeleteDisk_AttachtoTemp(self): 
        '''
        @summary: 删除附加到模板的磁盘
        @note: 操作失败,验证返回验证码及报错信息
        '''
        self.flag = True
        LogPrint().info("Test: Delete disk attached to template.")
        r = DiskAPIs().deleteDisk(self.disk_id_temp)
        if r['status_code'] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info), r['result']):
                LogPrint().info("PASS: The returned status code and messages are CORRECT.")
            else:
                LogPrint().error("FAIL: The returned messages are INCORRECT.")
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code))
            self.flag = False
        self.assertTrue(self.flag)
         
    def tearDown(self):
        LogPrint().info("Post-Test-1: Delete template %s."% self.dm.temp_name)
        self.assertTrue(smart_delete_template(self.dm.temp_name))
        LogPrint().info("Post-Test-2: Delete vm %s."% self.dm.vm_name)
        self.assertTrue(smart_del_vm(self.dm.vm_name))