You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gm...@apache.org on 2018/01/16 14:25:20 UTC

qpid-dispatch git commit: DISPATCH-907 - Added code to qdmanage to handle integer types

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master eed8bb654 -> 791592a93


DISPATCH-907 - Added code to qdmanage to handle integer types


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/791592a9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/791592a9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/791592a9

Branch: refs/heads/master
Commit: 791592a935fd2d9998fbf42fe4442d92cb999568
Parents: eed8bb6
Author: Ganesh Murthy <gm...@redhat.com>
Authored: Mon Jan 15 14:09:49 2018 -0500
Committer: Ganesh Murthy <gm...@redhat.com>
Committed: Tue Jan 16 09:21:46 2018 -0500

----------------------------------------------------------------------
 tests/system_tests_qdmanage.py | 13 +++++++++++++
 tools/qdmanage                 | 25 ++++++++++++++++++-------
 2 files changed, 31 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/791592a9/tests/system_tests_qdmanage.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_qdmanage.py b/tests/system_tests_qdmanage.py
index d2ac364..9c73db6 100644
--- a/tests/system_tests_qdmanage.py
+++ b/tests/system_tests_qdmanage.py
@@ -250,6 +250,13 @@ class QdmanageTest(TestCase):
         self.assertEqual(output[1]['pattern'], "a/*/b/#/c")
         self.assertTrue('prefix' not in output[1])
 
+    def test_create_address(self):
+        long_type = 'org.apache.qpid.dispatch.router.config.address'
+        create_command = 'CREATE --type=' + long_type + ' pattern="a.b.#" ingressPhase=5 egressPhase=6'
+        output = json.loads(self.run_qdmanage(create_command))
+        self.assertEqual(output['egressPhase'], 6)
+        self.assertEqual(output['ingressPhase'], 5)
+
     def test_check_link_route_name(self):
         long_type = 'org.apache.qpid.dispatch.router.config.linkRoute'
         query_command = 'QUERY --type=' + long_type
@@ -272,6 +279,12 @@ class QdmanageTest(TestCase):
         self.assertEqual(output[0]['dir'], "out")
         self.assertEqual(output[0]['addr'], "mnop")
 
+    def test_create_auto_link_with_phase(self):
+        long_type = 'org.apache.qpid.dispatch.router.config.autoLink'
+        create_command = 'CREATE --type=' + long_type + ' addr=xyz containerId=id1 dir=out phase=2'
+        output = json.loads(self.run_qdmanage(create_command))
+        self.assertEqual(output['phase'], 2)
+
     def test_specify_container_id_connection_auto_link(self):
         long_type = 'org.apache.qpid.dispatch.router.config.autoLink'
         create_command = 'CREATE --type=' + long_type + ' addr=abc containerId=id1 connection=conn1 dir=out'

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/791592a9/tools/qdmanage
----------------------------------------------------------------------
diff --git a/tools/qdmanage b/tools/qdmanage
index a534eb6..33c1756 100755
--- a/tools/qdmanage
+++ b/tools/qdmanage
@@ -26,18 +26,29 @@ from collections import Mapping, Sequence
 from optparse import OptionGroup
 from qpid_dispatch_internal.tools.command import OptionParser, Option, UsageError, connection_options, check_args, \
     main, opts_ssl_domain, opts_url, opts_sasl
+from qpid_dispatch_internal.management.qdrouter import QdSchema
 
-def attr_split(attrstr):
+INTEGER_TYPE = "integer"
+
+def attr_split(attrstr, qd_schema, type):
     """Split an attribute string of the form name=value or name to indicate None"""
     nv = attrstr.split("=", 1)
-    if len(nv) == 1: return [nv[0], None]
+    if len(nv) == 1:
+        return [nv[0], None]
     else:
-        if nv[1] == "true": nv[1] = True
-        if nv[1] == "false": nv[1] = False
+        if nv[1] == "true":
+            nv[1] = True
+        elif nv[1] == "false":
+            nv[1] = False
+        elif type and qd_schema.entity_type(type) and qd_schema.entity_type(type).attribute(nv[0]).type == INTEGER_TYPE:
+            nv[1] = int(nv[1])
+
         return nv
 
+
 class QdManage():
     def __init__(self):
+        self.qd_schema = QdSchema()
         self.prefix = 'org.apache.qpid.dispatch.'
         self.operations = ['QUERY', 'CREATE', 'READ', 'UPDATE', 'DELETE',
                            'GET-TYPES', 'GET-OPERATIONS', 'GET-ATTRIBUTES', 'GET-ANNOTATIONS',
@@ -149,7 +160,7 @@ class QdManage():
     def create(self):
         """create [ATTR=VALUE...]   Create a new entity."""
         if self.args:
-            self.opts.attributes = dict(attr_split(arg) for arg in self.args)
+            self.opts.attributes = dict(attr_split(arg, self.qd_schema, self.opts.type) for arg in self.args)
         self.call_bulk(lambda attrs: self.call_node('create', 'type', 'name', attributes=attrs))
 
     def read(self):
@@ -160,7 +171,7 @@ class QdManage():
     def update(self):
         """update [ATTR=VALUE...]   Update an entity."""
         if self.args:
-            self.opts.attributes = dict(attr_split(arg) for arg in self.args)
+            self.opts.attributes = dict(attr_split(arg, self.qd_schema, self.opts.type) for arg in self.args)
         self.call_bulk(
             lambda attrs: self.call_node('update', 'type', 'name', 'identity', attributes=attrs))
 
@@ -204,7 +215,7 @@ class QdManage():
 
     def operation(self, operation):
         """operation [ATTR=VALUE...]   Call custom operation with ATTR=VALUE as request properties. Use --body and --properties if specified."""
-        properties = dict(attr_split(arg) for arg in self.args or [])
+        properties = dict(attr_split(arg, self.qd_schema, self.opts.type) for arg in self.args or [])
         if self.opts.properties:
             properties.update(self.json_arg(self.opts.properties))
         body = None


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org