def check(self): super(zstack_kvm_volume_file_checker, self).check() volume = self.test_obj.volume volume_installPath = volume.installPath if not volume_installPath: test_util.test_logger( 'Check result: [installPath] is Null for [volume uuid: ] %s. Can not check volume file existence' % volume.uuid) return self.judge(False) ps_uuid = volume.primaryStorageUuid ps = test_lib.lib_get_primary_storage_by_uuid(ps_uuid) if test_lib.lib_is_ps_iscsi_backend(ps_uuid): self.check_iscsi(volume, volume_installPath, ps) elif ps.type == inventory.NFS_PRIMARY_STORAGE_TYPE: self.check_nfs(volume, volume_installPath) elif ps.type == inventory.LOCAL_STORAGE_TYPE: host = test_lib.lib_get_local_storage_volume_host(volume.uuid) if not host: return self.judge(False) self.check_file_exist(volume, volume_installPath, host) elif ps.type == inventory.CEPH_PRIMARY_STORAGE_TYPE: self.check_ceph(volume, volume_installPath, ps) elif ps.type == 'SharedBlock': self.check_sharedblock(volume, volume_installPath, ps)
def check(self): super(zstack_kvm_volume_file_checker, self).check() volume = self.test_obj.volume volume_installPath = volume.installPath if not volume_installPath: test_util.test_logger('Check result: [installPath] is Null for [volume uuid: ] %s. Can not check volume file existence' % volume.uuid) return self.judge(False) ps_uuid = volume.primaryStorageUuid ps = test_lib.lib_get_primary_storage_by_uuid(ps_uuid) if test_lib.lib_is_ps_iscsi_backend(ps_uuid): self.check_iscsi(volume, volume_installPath, ps) elif ps.type == inventory.NFS_PRIMARY_STORAGE_TYPE: self.check_nfs(volume, volume_installPath) elif ps.type == inventory.LOCAL_STORAGE_TYPE: host = test_lib.lib_get_local_storage_volume_host(volume.uuid) if not host: return self.judge(False) self.check_file_exist(volume, volume_installPath, host) elif ps.type == inventory.CEPH_PRIMARY_STORAGE_TYPE: self.check_ceph(volume, volume_installPath, ps) elif ps.type == 'SharedBlock': self.check_sharedblock(volume, volume_installPath, ps) elif ps.type == 'AliyunEBS': self.check_ebs(ps, volume_installPath) elif ps.type == 'MiniStorage': self.check_mini(volume, volume_installPath, ps)
def create_checker(self, test_obj): sp_checker_chain = checker_header.CheckerChain() if test_obj.get_target_volume().get_volume(): #target volume is not deleted. sp_checker_chain.add_checker(\ sp_checker.zstack_kvm_snapshot_checker(), True, test_obj) ps_uuid = test_obj.get_target_volume().get_volume().primaryStorageUuid if test_lib.lib_is_ps_iscsi_backend(ps_uuid): sp_checker_chain.add_checker(\ sp_checker.zstack_kvm_snapshot_tree_checker(), True, \ test_obj) if test_obj.get_backuped_snapshots(): sp_checker_chain.add_checker(\ sp_checker.zstack_kvm_backuped_snapshot_checker(), \ True, test_obj) return sp_checker_chain
def create_checker(self, test_obj): sp_checker_chain = checker_header.CheckerChain() if test_obj.get_target_volume().get_volume(): #target volume is not deleted. sp_checker_chain.add_checker(\ sp_checker.zstack_vcenter_snapshot_checker(), True, test_obj) ps_uuid = test_obj.get_target_volume().get_volume().primaryStorageUuid if test_lib.lib_is_ps_iscsi_backend(ps_uuid): sp_checker_chain.add_checker(\ sp_checker.zstack_vcenter_snapshot_tree_checker(), True, \ test_obj) if test_obj.get_backuped_snapshots(): sp_checker_chain.add_checker(\ sp_checker.zstack_vcenter_backuped_snapshot_checker(), \ True, test_obj) return sp_checker_chain
def check(self): super(zstack_vcenter_volume_file_checker, self).check() volume = self.test_obj.volume volume_installPath = volume.installPath if not volume_installPath: test_util.test_logger( 'Check result: [installPath] is Null for [volume uuid: ] %s. Can not check volume file existence' % volume.uuid) return self.judge(False) ps_uuid = volume.primaryStorageUuid ps = test_lib.lib_get_primary_storage_by_uuid(ps_uuid) if test_lib.lib_is_ps_iscsi_backend(ps_uuid): self.check_iscsi(volume, volume_installPath, ps) elif ps.type == inventory.VCENTER_PRIMARY_STORAGE_TYPE: cond = res_ops.gen_query_conditions('volume.uuid', '=', volume.uuid) vc_ps = res_ops.query_resource(res_ops.VCENTER_PRIMARY_STORAGE, cond) global vc_ps_volume_expunged if vc_ps: vc_ps = vc_ps[0] sign = 1 vc_ps_volume_expunged = vc_ps else: sign = 0 vc_ps = vc_ps_volume_expunged #connect vcenter, get datastore.host import ssl from pyVmomi import vim import atexit from pyVim import connect import zstackwoodpecker.zstack_test.vcenter_checker.zstack_vcenter_vm_checker as vm_checker vcenter_password = os.environ['vcenterpwd'] vcenter_server = os.environ['vcenter'] vcenter_username = os.environ['vcenteruser'] sslContext = ssl.SSLContext(ssl.PROTOCOL_SSLv23) sslContext.verify_mode = ssl.CERT_NONE SI = connect.SmartConnect(host=vcenter_server, user=vcenter_username, pwd=vcenter_password, port=443, sslContext=sslContext) if not SI: test_util.test_fail("Unable to connect to the vCenter") content = SI.RetrieveContent() datastore = vm_checker.get_obj(content, [vim.Datastore], name=vc_ps.name) test_util.test_logger(datastore) host = str(datastore.host[0].key) host_morval = host.split(':')[1][:-1] test_util.test_logger(host_morval) atexit.register(connect.Disconnect, SI) cond = res_ops.gen_query_conditions('hypervisorType', '=', 'ESX') vc_hosts = res_ops.query_resource(res_ops.HOST, cond) for vc_host in vc_hosts: if vc_host.morval == host_morval: vc_host = vc_host.managementIp break if not vc_host: return self.judge(False) if volume_installPath.startswith('[' + vc_ps.name + ']'): test_util.test_logger(vc_ps.url) if sign: vc_ps.url = vc_ps.url.split('//')[1] test_util.test_logger(vc_ps.url) volume_installPath = volume_installPath.split('[' + vc_ps.name + ']')[1].lstrip() volume_installPath = vc_ps.url + volume_installPath file_exist = "file_exist" cmd = '[ -f %s ] && echo %s' % (volume_installPath, file_exist) vchost_user = os.environ['vchostUser'] vchost_password = os.environ['vchostpwd'] #test_lib.lib_execute_ssh_cmd(vc_host, vchost_user, vchost_password, cmd, 180) result = test_lib.lib_execute_ssh_cmd(vc_host, vchost_user, vchost_password, cmd, 180) test_util.test_logger(result) result = str(result) test_util.test_logger(result) if result.rstrip('\n') == "file_exist": test_util.test_logger(result.rstrip('\n')) return self.judge(True) else: return self.judge(False)
def check(self): super(zstack_vcenter_volume_file_checker, self).check() volume = self.test_obj.volume volume_installPath = volume.installPath if not volume_installPath: test_util.test_logger('Check result: [installPath] is Null for [volume uuid: ] %s. Can not check volume file existence' % volume.uuid) return self.judge(False) ps_uuid = volume.primaryStorageUuid ps = test_lib.lib_get_primary_storage_by_uuid(ps_uuid) if test_lib.lib_is_ps_iscsi_backend(ps_uuid): self.check_iscsi(volume, volume_installPath, ps) elif ps.type == inventory.VCENTER_PRIMARY_STORAGE_TYPE: cond = res_ops.gen_query_conditions('volume.uuid', '=', volume.uuid) vc_ps = res_ops.query_resource(res_ops.VCENTER_PRIMARY_STORAGE, cond) global vc_ps_volume_expunged if vc_ps: vc_ps = vc_ps[0] sign = 1 vc_ps_volume_expunged = vc_ps else: sign = 0 vc_ps = vc_ps_volume_expunged #connect vcenter, get datastore.host import ssl from pyVmomi import vim import atexit from pyVim import connect import zstackwoodpecker.zstack_test.vcenter_checker.zstack_vcenter_vm_checker as vm_checker vcenter_password = os.environ['vcenterpwd'] vcenter_server = os.environ['vcenter'] vcenter_username = os.environ['vcenteruser'] sslContext = ssl.SSLContext(ssl.PROTOCOL_SSLv23) sslContext.verify_mode = ssl.CERT_NONE SI = connect.SmartConnect(host=vcenter_server, user=vcenter_username, pwd=vcenter_password, port=443, sslContext=sslContext) if not SI: test_util.test_fail("Unable to connect to the vCenter") content = SI.RetrieveContent() datastore = vm_checker.get_obj(content, [vim.Datastore], name=vc_ps.name) test_util.test_logger(datastore) host = str(datastore.host[0].key) host_morval = host.split(':')[1][:-1] test_util.test_logger(host_morval) atexit.register(connect.Disconnect, SI) cond = res_ops.gen_query_conditions('hypervisorType', '=', 'ESX') vc_hosts = res_ops.query_resource(res_ops.HOST, cond) for vc_host in vc_hosts: if vc_host.morval == host_morval: vc_host = vc_host.managementIp break if not vc_host: return self.judge(False) if volume_installPath.startswith('[' + vc_ps.name + ']'): test_util.test_logger(vc_ps.url) if sign: vc_ps.url = vc_ps.url.split('//')[1] test_util.test_logger(vc_ps.url) volume_installPath = volume_installPath.split('[' + vc_ps.name + ']')[1].lstrip() volume_installPath = vc_ps.url + volume_installPath file_exist = "file_exist" cmd = '[ -f %s ] && echo %s' % (volume_installPath, file_exist) vchost_user = os.environ['vchostUser'] vchost_password = os.environ['vchostpwd'] #test_lib.lib_execute_ssh_cmd(vc_host, vchost_user, vchost_password, cmd, 180) result = test_lib.lib_execute_ssh_cmd(vc_host, vchost_user, vchost_password, cmd, 180) test_util.test_logger(result) result = str(result) test_util.test_logger(result) if result.rstrip('\n') == "file_exist": test_util.test_logger(result.rstrip('\n')) return self.judge(True) else: return self.judge(False)