Greg Padgett has uploaded a new change for review.

Change subject: lib: fix acceptance of keyword arguments for vdsm api
......................................................................

lib: fix acceptance of keyword arguments for vdsm api

A prior refactoring broke keyword argument usage in calls to the
run_vds_client_cmd() method.  This fix allows for both argument lists
and keyword arguments, and automatically converts the keyword arguments
to a dict that is accepted by the vdsm api.  Callers should be careful
to use the proper parameter form as required by the vdsm api.

Change-Id: I9931d6c87b0798152bf344ddd8b9328ce01565a8
Signed-off-by: Greg Padgett <[email protected]>
---
M ovirt_hosted_engine_ha/lib/vds_client.py
1 file changed, 8 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-ha 
refs/changes/72/19872/1

diff --git a/ovirt_hosted_engine_ha/lib/vds_client.py 
b/ovirt_hosted_engine_ha/lib/vds_client.py
index d876ad4..b7e2ba7 100644
--- a/ovirt_hosted_engine_ha/lib/vds_client.py
+++ b/ovirt_hosted_engine_ha/lib/vds_client.py
@@ -28,7 +28,7 @@
 from ..env import constants
 
 
-def run_vds_client_cmd(address, use_ssl, command, *args):
+def run_vds_client_cmd(address, use_ssl, command, *args, **kwargs):
     """
     Run the passed in command name from the vdsClient library and either
     throw an exception with the error message or return the results.
@@ -55,14 +55,19 @@
         host_port = vdscli.cannonizeHostPort(address)
         serv.do_connect(host_port)
 
-    log.debug("Connected, running %s, args %r", command, args)
+    log.debug("Connected, running %s, args %r, kwargs %r",
+              command, args, kwargs)
 
     method = getattr(serv.s, command)
     retry = 0
     response = None
+    new_args = list(args)
+    # Add keyword args to argument list as a dict for vds api compatibility
+    if len(kwargs):
+        new_args.append(kwargs)
     while retry < constants.VDS_CLIENT_MAX_RETRY:
         try:
-            response = method(*args)
+            response = method(*new_args)
             break
         except socket.error:
             log.debug("Error", exc_info=True)


-- 
To view, visit http://gerrit.ovirt.org/19872
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9931d6c87b0798152bf344ddd8b9328ce01565a8
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-ha
Gerrit-Branch: master
Gerrit-Owner: Greg Padgett <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to