From 7b10acaeb04fe5bb4066ee0159498aa2c1adc78c Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Sun, 29 May 2022 21:40:52 +0300 Subject: [PATCH] examples: Show how to use client.checksum() Add simple example showing how to use client.checksum() to compute a checksum for local image. This is mainly useful for benchmarking, for example comparing to sha256sum, or blksum. Signed-off-by: Nir Soffer --- examples/checksum | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 examples/checksum diff --git a/examples/checksum b/examples/checksum new file mode 100755 index 00000000..60331c6c --- /dev/null +++ b/examples/checksum @@ -0,0 +1,18 @@ +#!/usr/bin/python3 +# ovirt-imageio +# Copyright (C) 2018 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +""" +Show how to compute disk image checksum. +""" +import sys +from ovirt_imageio import client + +path = sys.argv[1] +res = client.checksum(path, algorithm="sha256") +print(f"{res['checksum']} {path}")