Michael Pasternak has uploaded a new change for review.

Change subject: cli: wrong error when passing empty kwargs #891080
......................................................................

cli: wrong error when passing empty kwargs #891080

https://bugzilla.redhat.com/show_bug.cgi?id=891080

Change-Id: I155a898afa8cd36f14fb0a6c725f76753be22e0f
Signed-off-by: Michael Pasternak <mpast...@redhat.com>
---
M src/cli/messages.py
M src/ovirtcli/command/command.py
2 files changed, 13 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/20/10620/1

diff --git a/src/cli/messages.py b/src/cli/messages.py
index 78eddac..6d6a573 100644
--- a/src/cli/messages.py
+++ b/src/cli/messages.py
@@ -46,6 +46,8 @@
         INVALID_COLLECTION_BASED_OPTION_SYNTAX = 'invalid syntax at "--%s", 
see help on collection based arguments for more details.'
         INVALID_ARGUMENT_SEGMENT = '"%s" is invalid argument segment.'
         INVALID_OPTION_SEGMENT = '"%s" is invalid segment at option "--%s".'
+        INVALID_KWARGS_FORMAT = '"%s" is invalid --kwargs argument, valid 
format is "x=y;z=q;...".'
+        INVALID_KWARGS_CONTENT = '--kwargs constraint cannot be empty.'
         MISSING_CONFIGURATION_VARIABLE = 'missing configuration variable: %s.'
     class Warning():
         CANNOT_FETCH_HOST_CERT_SUBJECT = 'could not fetch host certificate 
info.'
diff --git a/src/ovirtcli/command/command.py b/src/ovirtcli/command/command.py
index 84f348a..e9a7da8 100644
--- a/src/ovirtcli/command/command.py
+++ b/src/ovirtcli/command/command.py
@@ -215,10 +215,18 @@
         """INTERNAL: retrieves query and kwargs from attribute options"""
         query = opts[query_arg] if opts.has_key(query_arg) else None
         kw = {}
+        empty = True
         if opts.has_key(kwargs_arg):
-            for item in opts[kwargs_arg].split(';'):
-                k, v = item.split('=')
-                kw[k.replace('-', '.')] = v
+            if opts[kwargs_arg]:
+                for item in opts[kwargs_arg].split(';'):
+                    if item.find("=") != -1:
+                        k, v = item.split('=')
+                        kw[k.replace('-', '.')] = v
+                        empty = False
+                    elif empty:
+                        self.error(Messages.Error.INVALID_KWARGS_FORMAT % item)
+            else:
+                self.error(Messages.Error.INVALID_KWARGS_CONTENT)
         mopts = {}
         for k, v in opts.iteritems():
             if k != query_arg and k != kwargs_arg and not 
k.endswith('-identifier'):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I155a898afa8cd36f14fb0a6c725f76753be22e0f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-cli
Gerrit-Branch: master
Gerrit-Owner: Michael Pasternak <mpast...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to