Michael Pasternak has uploaded a new change for review.

Change subject: cli: validate args in /connect command
......................................................................

cli: validate args in /connect command

Change-Id: I785672abf85b317379604e9b30db0687b8a9653d
Signed-off-by: Michael pasternak <mpast...@redhat.com>
---
M src/ovirtcli/command/connect.py
1 file changed, 14 insertions(+), 8 deletions(-)


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

diff --git a/src/ovirtcli/command/connect.py b/src/ovirtcli/command/connect.py
index f73535d..85cdd80 100644
--- a/src/ovirtcli/command/connect.py
+++ b/src/ovirtcli/command/connect.py
@@ -24,12 +24,18 @@
     ConnectionError
 from cli.messages import Messages
 from urlparse import urlparse
+from ovirtcli.shell.connectcmdshell import ConnectCmdShell
 
 class ConnectCommand(OvirtCommand):
 
     name = 'connect'
     description = 'connect to a oVirt manager'
-    args_check = (0, 3)
+    args_check = (0, len(ConnectCmdShell.OPTIONS))
+    valid_options = [ (
+          '--' + item, str
+         )
+         for item in ConnectCmdShell.OPTIONS
+    ]
 
     helptext = """\
         == Usage ==
@@ -152,13 +158,13 @@
         if url is None:
             return False;
         regex = re.compile(
-            r'^(?:http)s?://' # http:// or https://
-            
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'
 # domain...
-            r'localhost|' # localhost...
-            r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|' # ...or ipv4
-            r'\[?[A-F0-9]*:[A-F0-9:]+\]?)' # ...or ipv6
-            r'(?::\d+)?' # optional port
-            r'(/api)' # /api
+            r'^(?:http)s?://'  # http:// or https://
+            
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'
  # domain...
+            r'localhost|'  # localhost...
+            r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|'  # ...or ipv4
+            r'\[?[A-F0-9]*:[A-F0-9:]+\]?)'  # ...or ipv6
+            r'(?::\d+)?'  # optional port
+            r'(/api)'  # /api
            , re.IGNORECASE)
         if not regex.search(url):
             return False


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I785672abf85b317379604e9b30db0687b8a9653d
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