You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ch...@apache.org on 2016/01/18 17:52:00 UTC

[1/2] qpid-dispatch git commit: Add controls specify pure json config file; skips conf file processing.

Repository: qpid-dispatch
Updated Branches:
  refs/heads/crolke-DISPATCH-202-1 [created] b0e4b77e1


Add controls specify pure json config file; skips conf file processing.


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

Branch: refs/heads/crolke-DISPATCH-202-1
Commit: fe69669eb7a693fbb8b38fe6e4dcd4ebcea29c4b
Parents: e8b516b
Author: Chuck Rolke <cr...@redhat.com>
Authored: Mon Jan 18 11:21:33 2016 -0500
Committer: Chuck Rolke <cr...@redhat.com>
Committed: Mon Jan 18 11:21:33 2016 -0500

----------------------------------------------------------------------
 .../qpid_dispatch_internal/management/config.py | 23 +++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/fe69669e/python/qpid_dispatch_internal/management/config.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/config.py b/python/qpid_dispatch_internal/management/config.py
index 73725c1..e083372 100644
--- a/python/qpid_dispatch_internal/management/config.py
+++ b/python/qpid_dispatch_internal/management/config.py
@@ -30,13 +30,13 @@ from .qdrouter import QdSchema
 class Config(object):
     """Load config entities from qdrouterd.conf and validated against L{QdSchema}."""
 
-    def __init__(self, filename=None, schema=QdSchema()):
+    def __init__(self, filename=None, schema=QdSchema(), raw_json=False):
         self.schema = schema
         self.config_types = [et for et in schema.entity_types.itervalues()
                              if schema.is_configuration(et)]
         if filename:
             try:
-                self.load(filename)
+                self.load(filename, raw_json)
             except Exception, e:
                 raise Exception, "Cannot load configuration file %s: %s" % (filename, e), sys.exc_info()[2]
         else:
@@ -67,6 +67,17 @@ class Config(object):
             s[1] = dict((camelcase(k), v) for k, v in s[1].iteritems())
         return sections
 
+    @staticmethod
+    def _parserawjson(lines):
+        """Parse raw json config file format into a section list"""
+        def sub(line):
+            """Do substitutions to make line json-friendly"""
+            line = line.split('#')[0].strip() # Strip comments
+            return line
+        js_text = "%s"%("".join([sub(l) for l in lines]))
+        sections = json.loads(js_text)
+        return sections
+
 
     def _expand(self, content):
         """
@@ -90,16 +101,18 @@ class Config(object):
         return [_expand_section(s, annotations) for s in content
                 if self.schema.is_configuration(self.schema.entity_type(s[0], False))]
 
-    def load(self, source):
+    def load(self, source, raw_json=False):
         """
         Load a configuration file.
         @param source: A file name, open file object or iterable list of lines
+        @param raw_json: Source is pure json not needing conf-style substitutions
         """
         if isinstance(source, basestring):
+            raw_json |= source.endswith(".json")
             with open(source) as f:
-                self.load(f)
+                self.load(f, raw_json)
         else:
-            sections = self._parse(source)
+            sections = self._parserawjson(source) if raw_json else self._parse(source)
             # Add missing singleton sections
             for et in self.config_types:
                 if et.singleton and not [s for s in sections if s[0] == et.short_name]:


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


[2/2] qpid-dispatch git commit: add a map type to dummy mgmt object

Posted by ch...@apache.org.
add a map type to dummy mgmt object


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

Branch: refs/heads/crolke-DISPATCH-202-1
Commit: b0e4b77e1940fe30a53d7a1209a3396d28570eb3
Parents: fe69669
Author: Chuck Rolke <cr...@redhat.com>
Authored: Mon Jan 18 11:48:52 2016 -0500
Committer: Chuck Rolke <cr...@redhat.com>
Committed: Mon Jan 18 11:48:52 2016 -0500

----------------------------------------------------------------------
 python/qpid_dispatch/management/qdrouter.json | 3 ++-
 tests/system_tests_management.py              | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b0e4b77e/python/qpid_dispatch/management/qdrouter.json
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch/management/qdrouter.json b/python/qpid_dispatch/management/qdrouter.json
index 3c342ad..054e776 100644
--- a/python/qpid_dispatch/management/qdrouter.json
+++ b/python/qpid_dispatch/management/qdrouter.json
@@ -1012,7 +1012,8 @@
                 "arg1": {"type": "string", "create": true, "update": true},
                 "arg2": {"type": "string", "create": true, "update": true},
                 "num1": {"type": "integer", "create": true, "update": true},
-                "num2": {"type": "integer", "create": true, "update": true}
+                "num2": {"type": "integer", "create": true, "update": true},
+                "map": {"type": "map", "create": true, "update": true}
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b0e4b77e/tests/system_tests_management.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_management.py b/tests/system_tests_management.py
index 1fb512f..14c0dfe 100644
--- a/tests/system_tests_management.py
+++ b/tests/system_tests_management.py
@@ -463,7 +463,7 @@ class ManagementTest(system_test.TestCase):
 
     def test_get_attributes(self):
         result = self.node.get_attributes(type=DUMMY)
-        self.assertEqual(set([u'arg1', u'arg2', u'num1', u'num2', u'name', u'identity', u'type']),
+        self.assertEqual(set([u'arg1', u'arg2', u'num1', u'num2', u'name', u'identity', u'type', u'map']),
                          set(result[DUMMY]))
         result = self.node.get_attributes()
         for type in LISTENER, WAYPOINT, LINK: self.assertIn(type, result)


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