On Thu, Aug 22, 2019 at 03:39:34PM +0100, Richard W.M. Jones wrote:
This was the first version with the stable API and all the fixes
required to make the Python bindings not crash when used
asynchronously.
---
wrapper/disk_sync.py | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/wrapper/disk_sync.py b/wrapper/disk_sync.py
index e830193..e655ead 100644
--- a/wrapper/disk_sync.py
+++ b/wrapper/disk_sync.py
@@ -4,6 +4,8 @@ from pyVmomi import vim
from pyVim.connect import SmartConnect, Disconnect
from pyVim.task import WaitForTask

+from packaging import version
+

This introduces a new dependency, but it should be fine.  I added it to
requirements.txt.

import nbd

from six.moves.urllib.parse import urlparse, unquote
@@ -15,6 +17,8 @@ import ssl
import sys
import json

+NBD_MIN_VERSION = version.parse("0.9.8")
+
LOG_FORMAT_TIME = '[%(asctime)s] '
LOG_FORMAT_MSG = ': %(message)s'

@@ -582,6 +586,13 @@ def main():
    '''TODO: Add some description here '''

    args = parse_args()
+
+    nbd_version = version.parse(nbd.NBD().get_version())
+    if nbd_version < NBD_MIN_VERSION:
+        logging.error("version on libnbd is too old.  Version found = %s.  Min 
version required = %s" %
+                      (nbd_version, NBD_MIN_VERSION))
+        sys.exit(1)
+

I moved this after logging is initialized at which point it can just use
error().

Thanks.

    state = State(args).instance
    validate_state(args.sync_type)
    parse_input(args)
--
2.22.0

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Libguestfs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libguestfs

Reply via email to