コード例 #1
0
 def test_TearDown(self):
     dcapi = DataCenterAPIs()
     capi = ClusterAPIs()
     time.sleep(30)
     # Step1:将data1存储域设置为Maintenance状态
     LogPrint().info("Post-Module-Test-1: Deactivate data storage domains '%s'." % self.dm.data1_nfs_name)
     self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.data1_nfs_name))
     
     # Step2:删除数据中心dc1(非强制,之后存储域变为Unattached状态)
     if dcapi.searchDataCenterByName(self.dm.dc_nfs_name)['result']['data_centers']:
         LogPrint().info("Post-Module-Test-2: Delete DataCenter '%s'." % self.dm.dc_nfs_name)
         self.assertTrue(dcapi.delDataCenter(self.dm.dc_nfs_name)['status_code']==self.dm.expected_status_code_del_dc)
             
     # Step3:删除4个Unattached状态存储域(data1/data2/iso1/export1)
     LogPrint().info("Post-Module-Test-3: Delete all unattached storage domains.")
     dict_sd_to_host = [self.dm.data1_nfs_name, self.dm.data2_nfs_name]
     for sd in dict_sd_to_host:
         smart_del_storage_domain(sd, self.dm.xml_del_sd_option, host_name=self.dm.host1_name)
     
     # Step4:删除主机(host1)
     LogPrint().info("Post-Module-Test-6: Delete host '%s'." % self.dm.host1_name)
     self.assertTrue(smart_del_host(self.dm.host1_name, self.dm.xml_del_host_option))
     
     # Step5:删除集群cluster1
     if capi.searchClusterByName(self.dm.cluster_nfs_name)['result']['clusters']:
         LogPrint().info("Post-Module-Test-5: Delete Cluster '%s'." % self.dm.cluster_nfs_name)
         self.assertTrue(capi.delCluster(self.dm.cluster_nfs_name)['status_code']==self.dm.expected_status_code_del_dc)
コード例 #2
0
 def test_TearDown(self):
     dcapi = DataCenterAPIs()
     if dcapi.searchDataCenterByName(
             ModuleData.dc_name)['result']['data_centers']:
         LogPrint().info("Post-Module-Test: Delete DataCenter '%s'." %
                         ModuleData.dc_name)
         dcapi.delDataCenter(ModuleData.dc_name)
コード例 #3
0
    def isNetworkExist(self, nw_name, dc_name):
        """
        @summary: 检查网络是否在数据中心内存在
        @param nw_name:网络名称
        @param dc_name:数据中心名称
        @return: True or False  
        """
        nw_api = NetworkAPIs()
        dc_api = DataCenterAPIs()

        if not nw_api.searchNetworkByName(nw_name)["result"]["networks"]:
            return False
        if not dc_api.searchDataCenterByName(dc_name)["result"]["data_centers"]:
            return False
        nw_list = nw_api.searchNetworkByName(nw_name)["result"]["networks"]["network"]
        if isinstance(nw_list, dict):
            if dc_api.getDataCenterNameById(nw_list["data_center"]["@id"]) == dc_name:
                return True
            else:
                return False
        else:
            self.flag = False
            for nw in nw_list:
                dc_id = nw["data_center"]["@id"]
                dc_name = dc_api.getDataCenterNameById(dc_id)
                if dc_name == dc_name:
                    self.flag = True
            return self.flag
コード例 #4
0
ファイル: Volume.py プロジェクト: faylau/oVirt3.3WebAPITest
    def test_TearDown(self):
        '''
        @summary: 模块级测试资源清理
        '''
        dcapi = DataCenterAPIs()
        capi = ClusterAPIs()
         
        # Step2:将export和iso存储域设置为Maintenance状态,然后从数据中心分离
        LogPrint().info("Post-Module-Test-2-1: Deactivate storage domains '%s'." % self.dm.export1_name)
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.export1_name))
        LogPrint().info("Post-Module-Test-2-2: Detach storage domains '%s'." % self.dm.export1_name)
        self.assertTrue(smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.export1_name))
        LogPrint().info("Post-Module-Test-2-3: Deactivate storage domains '%s'." % self.dm.iso1_name)
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.iso1_name))
        LogPrint().info("Post-Module-Test-2-4: Detach storage domains '%s'." % self.dm.iso1_name)
        self.assertTrue(smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.iso1_name))
        
        # Step3:将data2存储域设置为Maintenance状态,然后从数据中心分离
        LogPrint().info("Post-Module-Test-3-1: Deactivate data storage domains '%s'." % self.dm.data2_nfs_name)
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.data2_nfs_name))
        LogPrint().info("Post-Module-Test-3-2: Detach data storage domains '%s'." % self.dm.data2_nfs_name)
        self.assertTrue(smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.data2_nfs_name))
        
        # Step4:将data1存储域设置为Maintenance状态
        LogPrint().info("Post-Module-Test-4: Deactivate data storage domains '%s'." % self.dm.data1_nfs_name)
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.data1_nfs_name))
#         LogPrint().info("Post-Module-Test-3-2: Detach data storage domains '%s'." % self.dm.data1_nfs_name)
#         self.assertTrue(smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.data1_nfs_name))
                 
        # Step5:删除数据中心dc1(非强制,之后存储域变为Unattached状态)
        if dcapi.searchDataCenterByName(self.dm.dc_nfs_name)['result']['data_centers']:
            LogPrint().info("Post-Module-Test-5: Delete DataCenter '%s'." % self.dm.dc_nfs_name)
            self.assertTrue(dcapi.delDataCenter(self.dm.dc_nfs_name)['status_code']==self.dm.expected_status_code_del_dc)
                 
        # Step6:删除4个Unattached状态存储域(data1/data2/export1/iso)
        LogPrint().info("Post-Module-Test-6: Delete all unattached storage domains.")
        dict_sd_to_host = [self.dm.data1_nfs_name, self.dm.data2_nfs_name, self.dm.iso1_name, self.dm.export1_name]
        for sd in dict_sd_to_host:
            smart_del_storage_domain(sd, self.dm.xml_del_sd_option, host_name=self.dm.host1_name)
         
        # Step7:删除主机(host1)
        LogPrint().info("Post-Module-Test-7: Delete host '%s'." % self.dm.host1_name)
        self.assertTrue(smart_del_host(self.dm.host1_name, self.dm.xml_del_host_option))
        LogPrint().info("Post-Module-Test-7: Delete host '%s'." % self.dm.host2_name)
        self.assertTrue(smart_del_host(self.dm.host2_name, self.dm.xml_del_host_option)) 
        # Step8:删除集群cluster1
        if capi.searchClusterByName(self.dm.cluster_nfs_name)['result']['clusters']:
            LogPrint().info("Post-Module-Test-8: Delete Cluster '%s'." % self.dm.cluster_nfs_name)
            self.assertTrue(capi.delCluster(self.dm.cluster_nfs_name)['status_code']==self.dm.expected_status_code_del_dc)
コード例 #5
0
    def test_TearDown(self):
        dcapi = DataCenterAPIs()
        capi = ClusterAPIs()

        # Step1:将ISO域和Export域设置为Maintenance状态
        LogPrint().info("Post-Module-Test-1: Deactivate ISO and Export storage domains.")
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_name, self.dm.iso1_name))
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_name, self.dm.export1_name))

        # Step2:将ISO域和Export域从对应的数据中心分离(detach)
        LogPrint().info("Post-Module-Test-2: Deattch ISO and Export storage domains.")
        self.assertTrue(smart_detach_storage_domain(self.dm.dc_name, self.dm.iso1_name))
        self.assertTrue(smart_detach_storage_domain(self.dm.dc_name, self.dm.export1_name))

        # Step3:将Data存储域设置为Maintenance状态
        LogPrint().info("Post-Module-Test-3: Deactivate all data storage domains.")
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_name, self.dm.data1_nfs_name))
        # self.assertTrue(smart_deactive_storage_domain(self.dm.dc_name, self.dm.data1_iscsi_name))

        # 删除3个数据中心(非强制,之后存储域变为Unattached状态)
        if dcapi.searchDataCenterByName(self.dm.dc_name):
            LogPrint().info("Post-Module-Test-4: Delete DataCenter '%s'." % self.dm.dc_name)
            self.assertTrue(dcapi.delDataCenter(self.dm.dc_name)["status_code"] == self.dm.expected_status_code_del_dc)

        # 删除3个Unattached状态的Data存储域和ISO/Export域(如果没有配置FC,则删除2个)
        LogPrint().info("Post-Module-Test-5: Delete all storage domains.")
        dict_sd_to_host = {
            self.dm.data1_nfs_name: self.dm.host1_name,
            self.dm.iso1_name: self.dm.host1_name,
            self.dm.export1_name: self.dm.host1_name,
        }
        for sd in dict_sd_to_host:
            smart_del_storage_domain(sd, self.dm.xml_del_sd_option, host_name=dict_sd_to_host[sd])

        # 删除主机(host1和host4)
        LogPrint().info("Post-Module-Test-6: Delete all hosts.")
        for host_name in [self.dm.host1_name, self.dm.host4_name]:
            self.assertTrue(smart_del_host(host_name, self.dm.xml_del_host_option))

        # 删除集群

        if capi.searchClusterByName(self.dm.cluster_name):
            LogPrint().info("Post-Module-Test-7: Delete Cluster '%s'." % self.dm.cluster_name)
            self.assertTrue(capi.delCluster(self.dm.cluster_name)["status_code"] == self.dm.expected_status_code_del_dc)
コード例 #6
0
    def test_TearDown(self):
        vmapi = VirtualMachineAPIs()
        #Step1:删除虚拟机
        vmapi.delVm(self.dm.vm_name)
        dcapi = DataCenterAPIs()
        capi = ClusterAPIs()
        # Step2:将export存储域和data2存储域设置为Maintenance状态,然后从数据中心分离
        #         LogPrint().info("Post-Module-Test-1: Deactivate storage domains '%s'." % self.dm.export1_name)
        #         self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.export1_name))
        #         LogPrint().info("Post-Module-Test-2: Detach storage domains '%s'." % self.dm.export1_name)
        #         self.assertTrue(smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.export1_name))

        LogPrint().info(
            "Post-Module-Test-3: Deactivate data storage domains '%s'." %
            self.dm.data2_nfs_name)
        self.assertTrue(
            smart_deactive_storage_domain(self.dm.dc_nfs_name,
                                          self.dm.data2_nfs_name))
        LogPrint().info(
            "Post-Module-Test-4: Detach data storage domains '%s'." %
            self.dm.data2_nfs_name)
        self.assertTrue(
            smart_detach_storage_domain(self.dm.dc_nfs_name,
                                        self.dm.data2_nfs_name))
        # Step3:将data1存储域设置为Maintenance状态
        LogPrint().info(
            "Post-Module-Test-5: Deactivate data storage domains '%s'." %
            self.dm.data1_nfs_name)
        self.assertTrue(
            smart_deactive_storage_domain(self.dm.dc_nfs_name,
                                          self.dm.data1_nfs_name))

        # Step4:删除数据中心dc1(非强制,之后存储域变为Unattached状态)
        if dcapi.searchDataCenterByName(
                self.dm.dc_nfs_name)['result']['data_centers']:
            LogPrint().info("Post-Module-Test-6: Delete DataCenter '%s'." %
                            self.dm.dc_nfs_name)
            self.assertTrue(
                dcapi.delDataCenter(self.dm.dc_nfs_name)['status_code'] ==
                self.dm.expected_status_code_del_dc)

        # Step5:删除3个Unattached状态存储域(data1/data2/export1)
        LogPrint().info(
            "Post-Module-Test-7: Delete all unattached storage domains.")
        dict_sd_to_host = [self.dm.data1_nfs_name, self.dm.data2_nfs_name]
        for sd in dict_sd_to_host:
            smart_del_storage_domain(sd,
                                     self.dm.xml_del_sd_option,
                                     host_name=self.dm.host1_name)

        # Step6:删除主机(host1)
        LogPrint().info("Post-Module-Test-8: Delete host '%s'." %
                        self.dm.host1_name)
        self.assertTrue(
            smart_del_host(self.dm.host1_name, self.dm.xml_del_host_option))

        # Step7:删除集群cluster1
        if capi.searchClusterByName(
                self.dm.cluster_nfs_name)['result']['clusters']:
            LogPrint().info("Post-Module-Test-9: Delete Cluster '%s'." %
                            self.dm.cluster_nfs_name)
            self.assertTrue(
                capi.delCluster(self.dm.cluster_nfs_name)['status_code'] ==
                self.dm.expected_status_code_del_dc)
コード例 #7
0
ファイル: Cluster.py プロジェクト: FineFan/oVirt3.3WebAPITest
 def test_TearDown(self):
     dcapi = DataCenterAPIs()
     if dcapi.searchDataCenterByName(ModuleData.dc_name)["result"]["data_centers"]:
         LogPrint().info("Post-Module-Test: Delete DataCenter '%s'." % ModuleData.dc_name)
         dcapi.delDataCenter(ModuleData.dc_name)
コード例 #8
0
    def test_TearDown(self):
        dcapi = DataCenterAPIs()
        capi = ClusterAPIs()

        # Step1:将ISO域和Export域设置为Maintenance状态
        LogPrint().info(
            "Post-Module-Test-1: Deactivate ISO and Export storage domains.")
        self.assertTrue(
            smart_deactive_storage_domain(self.dm.dc_name, self.dm.iso1_name))
        self.assertTrue(
            smart_deactive_storage_domain(self.dm.dc_name,
                                          self.dm.export1_name))

        # Step2:将ISO域和Export域从对应的数据中心分离(detach)
        LogPrint().info(
            "Post-Module-Test-2: Deattch ISO and Export storage domains.")
        self.assertTrue(
            smart_detach_storage_domain(self.dm.dc_name, self.dm.iso1_name))
        self.assertTrue(
            smart_detach_storage_domain(self.dm.dc_name, self.dm.export1_name))

        # Step3:将Data存储域设置为Maintenance状态
        LogPrint().info(
            "Post-Module-Test-3: Deactivate all data storage domains.")
        self.assertTrue(
            smart_deactive_storage_domain(self.dm.dc_name,
                                          self.dm.data1_nfs_name))
        #self.assertTrue(smart_deactive_storage_domain(self.dm.dc_name, self.dm.data1_iscsi_name))

        # 删除3个数据中心(非强制,之后存储域变为Unattached状态)
        if dcapi.searchDataCenterByName(self.dm.dc_name):
            LogPrint().info("Post-Module-Test-4: Delete DataCenter '%s'." %
                            self.dm.dc_name)
            self.assertTrue(
                dcapi.delDataCenter(self.dm.dc_name)['status_code'] ==
                self.dm.expected_status_code_del_dc)

        # 删除3个Unattached状态的Data存储域和ISO/Export域(如果没有配置FC,则删除2个)
        LogPrint().info("Post-Module-Test-5: Delete all storage domains.")
        dict_sd_to_host = {
            self.dm.data1_nfs_name: self.dm.host1_name,
            self.dm.iso1_name: self.dm.host1_name,
            self.dm.export1_name: self.dm.host1_name
        }
        for sd in dict_sd_to_host:
            smart_del_storage_domain(sd,
                                     self.dm.xml_del_sd_option,
                                     host_name=dict_sd_to_host[sd])

        # 删除主机(host1和host4)
        LogPrint().info("Post-Module-Test-6: Delete all hosts.")
        for host_name in [self.dm.host1_name, self.dm.host4_name]:
            self.assertTrue(
                smart_del_host(host_name, self.dm.xml_del_host_option))

        # 删除集群

        if capi.searchClusterByName(self.dm.cluster_name):
            LogPrint().info("Post-Module-Test-7: Delete Cluster '%s'." %
                            self.dm.cluster_name)
            self.assertTrue(
                capi.delCluster(self.dm.cluster_name)['status_code'] ==
                self.dm.expected_status_code_del_dc)