def checksum(self, cloud, path): """ Get checksum of `filepath`. :return: str """ runner = _remote_runner(cloud) return files.remote_md5_sum(runner, path)
def verify(self, data): """ Verification that the file has been copied correctly. :param data: The dictionary with necessary information :return: True or False """ src_host = data['host_src'] src_path = data['path_src'] dst_host = data['host_dst'] dst_path = data['path_dst'] src_runner = self.runner(src_host, 'src') dst_runner = self.runner(dst_host, 'dst') src_size = files.remote_file_size(src_runner, src_path) dst_size = files.remote_file_size(dst_runner, dst_path) if src_size != dst_size: LOG.warning("The sizes of '%s' (%s) and '%s' (%s) are mismatch", src_path, sizeof_format.sizeof_fmt(src_size), dst_path, sizeof_format.sizeof_fmt(dst_size)) return False if CONF.migrate.copy_with_md5_verification: LOG.info("Running md5 checksum calculation on the file '%s' with " "size %s on host '%s'", src_path, sizeof_format.sizeof_fmt(src_size), src_host) src_md5 = files.remote_md5_sum(src_runner, src_path) LOG.info("Running md5 checksum calculation on the file '%s' with " "size %s on host '%s'", dst_path, sizeof_format.sizeof_fmt(dst_size), dst_host) dst_md5 = files.remote_md5_sum(dst_runner, dst_path) if src_md5 != dst_md5: LOG.warning("The md5 checksums of '%s' (%s) and '%s' (%s) are " "mismatch", src_path, src_md5, dst_path, dst_md5) return False return True