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)
def TearDown(self): ''' @summary: 清理环境,卷删除后应在主机上执行下列操作: setfattr -x trusted.glusterfs.volume-id /test/data1 setfattr -x trusted.gfid /test/data1 ''' #step1:删除子模板 self.assertTrue( smart_delete_template(self.dm.base_temp_name, self.dm.temp_name)) #step2:删除基础模板 self.assertTrue(smart_delete_template(self.dm.base_temp_name)) #step3:删除虚拟机 self.assertTrue(smart_del_vm(self.dm.vm_name)) #step4:停止卷 self.assertTrue(smart_stop_volume(self.dm.cluster_name, 'disrep')) #step5:删除卷 self.assertTrue(smart_delete_volume(self.dm.cluster_name, 'disrep')) #step6:维护数据域 self.assertTrue( smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.sd_name)) #step7:分离数据域 self.assertTrue( smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.sd_name)) #step8:删除数据域 self.assertTrue( smart_del_storage_domain(self.dm.sd_name, self.dm.xml_del_option))
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)
def TearDown(self): ''' @summary: 清理环境,卷删除后应在主机上执行下列操作: setfattr -x trusted.glusterfs.volume-id /test/data1 setfattr -x trusted.gfid /test/data1 ''' #step1:删除子模板 self.assertTrue(smart_delete_template(self.dm.base_temp_name,self.dm.temp_name)) #step2:删除基础模板 self.assertTrue(smart_delete_template(self.dm.base_temp_name)) #step3:删除虚拟机 self.assertTrue(smart_del_vm(self.dm.vm_name)) #step4:停止卷 self.assertTrue(smart_stop_volume(self.dm.cluster_name, 'disrep')) #step5:删除卷 self.assertTrue(smart_delete_volume(self.dm.cluster_name, 'disrep')) #step6:维护数据域 self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name,self.dm.sd_name)) #step7:分离数据域 self.assertTrue(smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.sd_name)) #step8:删除数据域 self.assertTrue(smart_del_storage_domain(self.dm.sd_name, self.dm.xml_del_option))
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)
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)