Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
 def tearDown(self):
     """
     @summary: 测试结束后的资源清理(恢复初始环境)
     """
     LogPrint().info("Post-Test-1: Delete host %s. " % self.dm.host_name)
     self.assertTrue(smart_del_host(self.dm.host_name, self.dm.host_del_option))
     LogPrint().info("Post-Test-2: Delete cluster %s. " % self.dm.cluster_name)
     self.assertTrue(smart_delete_cluster(self.dm.cluster_name))
Ejemplo n.º 4
0
 def tearDown(self):
     '''
     @summary: 测试结束后的资源清理(恢复初始环境)
     '''
     LogPrint().info("Post-Test-1: Delete host %s. " % self.dm.host_name)
     self.assertTrue(
         smart_del_host(self.dm.host_name, self.dm.host_del_option))
     LogPrint().info("Post-Test-2: Delete cluster %s. " %
                     self.dm.cluster_name)
     self.assertTrue(smart_delete_cluster(self.dm.cluster_name))
Ejemplo n.º 5
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)