Exemplo n.º 1
0
 def test_UpdateTemplateNic(self):
     '''
     @summary: 为模板编辑网络接口
     @note: 操作成功,验证返回状态码和返回信息
     '''
     self.flag = True
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info("Test: Update nic %s for this template." %
                     self.dm.nic_name)
     r = tempnic_api.updateTemplateNic(self.dm.temp_name, self.dm.nic_name,
                                       self.dm.update_info, self.proid)
     if r['status_code'] == self.dm.expected_status_code:
         dictCompare = DictCompare()
         expected_result = xmltodict.parse(
             (self.dm.update_info % self.proid))
         actual_result = r['result']
         if dictCompare.isSubsetDict(expected_result, actual_result):
             LogPrint().info("PASS: UpdateTemplateNic SUCCESS.")
         else:
             LogPrint().error(
                 "FAIL: UpdateTemplateNic fail.The nic_info is WRONG")
             self.flag = False
     else:
         LogPrint().error(
             "FAIL: UpdateTemplateNic fail.The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)
Exemplo n.º 2
0
 def test_CreateTemplateNic_proid(self):
     '''
     @summary: 为模板创建网络接口,指定配置集
     @note: 操作成功,验证返回状态码和返回信息
     '''
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info(
         "Test-: Create a nic %s with profile %s for template %s." %
         (self.dm.nic_name, self.dm.profile_name, self.dm.temp_name))
     r = tempnic_api.createTemplateNic(self.dm.temp_name, self.dm.nic_data,
                                       self.proid)
     if r['status_code'] == self.dm.expected_status_code:
         dictCompare = DictCompare()
         expected_result = xmltodict.parse((self.dm.nic_data % self.proid))
         actual_result = r['result']
         if dictCompare.isSubsetDict(expected_result, actual_result):
             LogPrint().info(
                 "PASS: Create a nic %s with profile %s for template %s SUCCESS."
                 % (self.dm.nic_name, self.dm.profile_name,
                    self.dm.temp_name))
         else:
             LogPrint().error("FAIL: The nic_info is WRONG")
             self.flag = False
     else:
         LogPrint().error("FAIL: The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)
Exemplo n.º 3
0
 def test_GetTemplateNicList(self):
     '''
     @summary: 获取模板的网络接口列表
     @note: 操作成功,验证返回状态码
     '''
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info("Test: Get nic list of template %s."%self.dm.temp_name)
     r=tempnic_api.getTemplateNicList(self.dm.temp_name)
     if r['status_code'] == self.dm.expected_status_code:
         LogPrint().info("PASS: GetTemplateNicList SUCCESS.")
     else:
         LogPrint().error("FAIL: GetTemplateNicList fail.The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)
Exemplo n.º 4
0
    def test_CreateTemplateNic(self):
        '''
        @summary: 创建模板的网络接口
        @note: 操作成功,验证返回状态码和返回信息
        '''
        tempnic_api = TemplateNicsAPIs()
        self.expected_result_index = 0

        @BaseTestCase.drive_data(self, self.dm.nic_data)
        def do_test(xml_info):
            LogPrint().info("Test: Create nic %s for template %s." %
                            (self.dm.nic_name[self.expected_result_index],
                             self.dm.temp_name))
            r = tempnic_api.createTemplateNic(self.dm.temp_name, xml_info)
            if r['status_code'] == self.dm.expected_status_code:
                dictCompare = DictCompare()
                print xml_info
                expected_result = xmltodict.parse(xml_info)
                actual_result = r['result']
                if dictCompare.isSubsetDict(expected_result, actual_result):
                    LogPrint().info(
                        "PASS: Create Nic %s SUCCESS." %
                        self.dm.nic_name[self.expected_result_index])
                else:
                    LogPrint().error(
                        "FAIL: The nic %s info is WRONG" %
                        self.dm.nic_name[self.expected_result_index])
                    self.flag = False
            else:
                LogPrint().error("FAIL: The status_code is WRONG")
                self.flag = False
            self.assertTrue(self.flag)
            self.expected_result_index += 1

        do_test()
Exemplo n.º 5
0
 def test_GetTemplateNicList(self):
     '''
     @summary: 获取模板的网络接口列表
     @note: 操作成功,验证返回状态码
     '''
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info("Test: Get nic list of template %s." %
                     self.dm.temp_name)
     r = tempnic_api.getTemplateNicList(self.dm.temp_name)
     if r['status_code'] == self.dm.expected_status_code:
         LogPrint().info("PASS: GetTemplateNicList SUCCESS.")
     else:
         LogPrint().error(
             "FAIL: GetTemplateNicList fail.The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)
Exemplo n.º 6
0
 def test_DeleteTemplateNic(self):  
     '''
     @summary: 删除模板网络接口
     @note: 操作成功,验证返回状态码,检查接口是否存在
     '''    
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info("Test: Delete nic %s for this template %s."%(self.dm.nic_name, self.dm.temp_name))
     r =  tempnic_api.deleteTemplateNic(self.dm.temp_name, self.dm.nic_name)
     if r['status_code'] == self.dm.expected_status_code:
         if not tempnic_api.getNicIdByName(self.dm.temp_name, self.dm.nic_name):
             LogPrint().info("PASS: Delete nic %s for this template %s SUCCESS."%(self.dm.nic_name, self.dm.temp_name))
         else:
             LogPrint().error("FAIL: The nic %s is still exist."%self.dm.nic_name)
             self.flag = False
     else:
         LogPrint().error("FAIL: The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)
Exemplo n.º 7
0
 def test_CreateTemplateNic_NoRequired(self):  
     '''
     @summary: 为模板创建网络接口,缺少必填项
     @note: 操作失败,验证返回状态码和返回信息
     '''    
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info("Test: Create nic for this template.")
     r =  tempnic_api.createTemplateNic(self.dm.temp_name, self.dm.nic_data)
     if r['status_code'] == self.dm.expected_status_code:
         dictCompare = DictCompare()
         expected_result = xmltodict.parse(self.dm.expected_info)
         actual_result = r['result']
         if dictCompare.isSubsetDict(expected_result,actual_result):
             LogPrint().info("PASS: The returned status code and messages are CORRECT.")
         else:
             LogPrint().error("FAIL: Returned messages are incorrectly.")
             self.flag = False
     else:
         LogPrint().error("FAIL: The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)
Exemplo n.º 8
0
 def test_CreateTemplateNic_proid(self): 
     '''
     @summary: 为模板创建网络接口,指定配置集
     @note: 操作成功,验证返回状态码和返回信息
     ''' 
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info("Test-: Create a nic %s with profile %s for template %s."%(self.dm.nic_name, self.dm.profile_name, self.dm.temp_name))
     r =  tempnic_api.createTemplateNic(self.dm.temp_name, self.dm.nic_data,self.proid)
     if r['status_code'] == self.dm.expected_status_code:
         dictCompare = DictCompare()
         expected_result = xmltodict.parse((self.dm.nic_data %self.proid))
         actual_result = r['result']
         if dictCompare.isSubsetDict(expected_result,actual_result):
             LogPrint().info("PASS: Create a nic %s with profile %s for template %s SUCCESS."%(self.dm.nic_name, self.dm.profile_name, self.dm.temp_name))
         else:
             LogPrint().error("FAIL: The nic_info is WRONG")
             self.flag = False
     else:
         LogPrint().error("FAIL: The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)   
Exemplo n.º 9
0
 def test_GetTemplateNicInfo(self):
     '''
     @summary: 获取模板的网络接口详情
     @note: 操作成功,验证返回状态码和返回信息
     '''
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info("Test: Get nic %s info of template %s."%(self.dm.nic_name, self.dm.temp_name))
     r =  tempnic_api.getTemplateNicInfo(self.dm.temp_name, self.dm.nic_name)
     if r['status_code'] == self.dm.expected_status_code:
         dictCompare = DictCompare()
         expected_result = xmltodict.parse(self.dm.nic_data)
         actual_result = r['result']
         if dictCompare.isSubsetDict(expected_result,actual_result):
             LogPrint().info("PASS: Get nic %s info of template %s SUCCESS."%(self.dm.nic_name, self.dm.temp_name))
         else:
             LogPrint().error("FAIL: Returned nic info is WRONG")
             self.flag = False
     else:
         LogPrint().error("FAIL: The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)
Exemplo n.º 10
0
 def test_CreateTemplateNic_NoRequired(self):
     '''
     @summary: 为模板创建网络接口,缺少必填项
     @note: 操作失败,验证返回状态码和返回信息
     '''
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info("Test: Create nic for this template.")
     r = tempnic_api.createTemplateNic(self.dm.temp_name, self.dm.nic_data)
     if r['status_code'] == self.dm.expected_status_code:
         dictCompare = DictCompare()
         expected_result = xmltodict.parse(self.dm.expected_info)
         actual_result = r['result']
         if dictCompare.isSubsetDict(expected_result, actual_result):
             LogPrint().info(
                 "PASS: The returned status code and messages are CORRECT.")
         else:
             LogPrint().error("FAIL: Returned messages are incorrectly.")
             self.flag = False
     else:
         LogPrint().error("FAIL: The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)
Exemplo n.º 11
0
 def test_UpdateTemplateNic(self):
     '''
     @summary: 为模板编辑网络接口
     @note: 操作成功,验证返回状态码和返回信息
     '''    
     self.flag = True  
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info("Test: Update nic %s for this template."%self.dm.nic_name)
     r =  tempnic_api.updateTemplateNic(self.dm.temp_name, self.dm.nic_name,self.dm.update_info,self.proid)
     if r['status_code'] == self.dm.expected_status_code:
         dictCompare = DictCompare()
         expected_result = xmltodict.parse((self.dm.update_info %self.proid))
         actual_result = r['result']
         if dictCompare.isSubsetDict(expected_result,actual_result):
             LogPrint().info("PASS: UpdateTemplateNic SUCCESS.")
         else:
             LogPrint().error("FAIL: UpdateTemplateNic fail.The nic_info is WRONG")
             self.flag = False
     else:
         LogPrint().error("FAIL: UpdateTemplateNic fail.The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)
Exemplo n.º 12
0
 def test_DeleteTemplateNic(self):
     '''
     @summary: 删除模板网络接口
     @note: 操作成功,验证返回状态码,检查接口是否存在
     '''
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info("Test: Delete nic %s for this template %s." %
                     (self.dm.nic_name, self.dm.temp_name))
     r = tempnic_api.deleteTemplateNic(self.dm.temp_name, self.dm.nic_name)
     if r['status_code'] == self.dm.expected_status_code:
         if not tempnic_api.getNicIdByName(self.dm.temp_name,
                                           self.dm.nic_name):
             LogPrint().info(
                 "PASS: Delete nic %s for this template %s SUCCESS." %
                 (self.dm.nic_name, self.dm.temp_name))
         else:
             LogPrint().error("FAIL: The nic %s is still exist." %
                              self.dm.nic_name)
             self.flag = False
     else:
         LogPrint().error("FAIL: The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)
Exemplo n.º 13
0
 def test_GetTemplateNicInfo(self):
     '''
     @summary: 获取模板的网络接口详情
     @note: 操作成功,验证返回状态码和返回信息
     '''
     tempnic_api = TemplateNicsAPIs()
     LogPrint().info("Test: Get nic %s info of template %s." %
                     (self.dm.nic_name, self.dm.temp_name))
     r = tempnic_api.getTemplateNicInfo(self.dm.temp_name, self.dm.nic_name)
     if r['status_code'] == self.dm.expected_status_code:
         dictCompare = DictCompare()
         expected_result = xmltodict.parse(self.dm.nic_data)
         actual_result = r['result']
         if dictCompare.isSubsetDict(expected_result, actual_result):
             LogPrint().info(
                 "PASS: Get nic %s info of template %s SUCCESS." %
                 (self.dm.nic_name, self.dm.temp_name))
         else:
             LogPrint().error("FAIL: Returned nic info is WRONG")
             self.flag = False
     else:
         LogPrint().error("FAIL: The status_code is WRONG")
         self.flag = False
     self.assertTrue(self.flag)