Author: aconway
Date: Wed Dec 10 03:32:39 2014
New Revision: 1644326

URL: http://svn.apache.org/r1644326
Log:
NO-JIRA: Change managment name/identity prefix character from ':' to '/'

More in line with other implementations of management spec.

Modified:
    qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py
    qpid/dispatch/trunk/src/router_agent.c
    qpid/dispatch/trunk/tests/management/qdrouter.py
    qpid/dispatch/trunk/tests/system_tests_management.py
    qpid/dispatch/trunk/tests/system_tests_qdstat.py

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py?rev=1644326&r1=1644325&r2=1644326&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py Wed 
Dec 10 03:32:39 2014
@@ -93,24 +93,27 @@ class AgentEntity(SchemaEntity):
     Base class for agent entities with operations as well as attributes.
     """
 
-    def _refresh(self):
-        """Refresh self.attributes from C implementation. No-op if no C impl 
pointer"""
-        return False # Replaced by _set_pointer
-
-    def __init__(self, agent, entity_type, attributes=None, validate=True):
+    def __init__(self, agent, entity_type, attributes=None, validate=True, 
base_id=None):
         """
         @para agent: Containing L{Agent}
-        @param dispatch: Pointer to qd_dispatch C object.
         @param entity_type: L{EntityType}
         @param attributes: Attribute name:value map
-        @param pointer: Pointer to C object that can be used to refresh 
attributes.
+        @param validate: If true, validate the entity.
+        @param base_id: Use as base identifier for name and identifier.
         """
+        if base_id:
+            full_id = "%s/%s" % (entity_type.short_name, base_id)
+            attributes['name'] = attributes['identity'] = full_id
         super(AgentEntity, self).__init__(entity_type, attributes, 
validate=validate)
         # Direct __dict__ access to avoid validation as schema attributes
         self.__dict__['_agent'] = agent
         self.__dict__['_qd'] = agent.qd
         self.__dict__['_dispatch'] = agent.dispatch
 
+    def _refresh(self):
+        """Refresh self.attributes from C implementation. No-op if no C impl 
pointer"""
+        return False # Replaced by _set_pointer
+
     def _set_pointer(self, pointer):
         fname = "qd_entity_refresh_" + 
self.entity_type.short_name.replace('.', '_')
         refreshfn = self._qd.function(fname, c_long, [py_object, c_void_p])
@@ -157,17 +160,13 @@ class ContainerEntity(AgentEntity): pass
 
 
 class RouterEntity(AgentEntity):
-    def __init__(self, *args, **kwargs):
-        kwargs['validate'] = False
-        super(RouterEntity, self).__init__(*args, **kwargs)
+    def __init__(self, agent, entity_type, attributes=None):
+        super(RouterEntity, self).__init__(agent, entity_type, attributes, 
validate=False, base_id=attributes.get('routerId'))
         self._set_pointer(self._dispatch)
 
 class LogEntity(AgentEntity):
     def __init__(self, agent, entity_type, attributes=None, validate=True):
-        module = attributes.get('module')
-        if module:
-            attributes['identity'] = attributes['name'] = "%s:%s" % 
(entity_type.short_name, module)
-        super(LogEntity, self).__init__(agent, entity_type, attributes, 
validate)
+        super(LogEntity, self).__init__(agent, entity_type, attributes, 
validate, base_id=attributes.get('module'))
 
     def create(self, request):
         self._qd.qd_log_entity(self)
@@ -221,7 +220,7 @@ class CEntity(AgentEntity):
     def __init__(self, agent, entity_type, pointer):
         def prefix(prefix, name):
             if not str(name).startswith(prefix):
-                name = "%s:%s" % (prefix, name)
+                name = "%s/%s" % (prefix, name)
             return name
 
         super(CEntity, self).__init__(agent, entity_type, validate=False)

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py?rev=1644326&r1=1644325&r2=1644326&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py Wed 
Dec 10 03:32:39 2014
@@ -107,7 +107,7 @@ class Config(object):
             elif 'identity' in attrs:
                 attrs['name'] = attrs['identity']
             else:
-                identity = "%s:%d"%(section_name, count)
+                identity = "%s/%d"%(section_name, count)
                 attrs['name'] = attrs['identity'] = identity
         return content
 

Modified: qpid/dispatch/trunk/src/router_agent.c
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/router_agent.c?rev=1644326&r1=1644325&r2=1644326&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/router_agent.c (original)
+++ qpid/dispatch/trunk/src/router_agent.c Wed Dec 10 03:32:39 2014
@@ -41,8 +41,8 @@ ENUM_DEFINE(qd_router_mode, qd_router_mo
 qd_error_t qd_entity_refresh_router(qd_entity_t* entity, void *impl) {
     qd_dispatch_t *qd = (qd_dispatch_t*) impl;
     qd_router_t *router = qd->router;
-    if (qd_entity_set_stringf(entity, "name", "%s:%s", QD_ROUTER_TYPE, 
router->router_id) == 0 &&
-        qd_entity_set_stringf(entity, "identity", "%s:%s", QD_ROUTER_TYPE, 
router->router_id) == 0 &&
+    if (qd_entity_set_stringf(entity, "name", "%s/%s", QD_ROUTER_TYPE, 
router->router_id) == 0 &&
+        qd_entity_set_stringf(entity, "identity", "%s/%s", QD_ROUTER_TYPE, 
router->router_id) == 0 &&
         
         qd_entity_set_string(entity, "area", router->router_area) == 0 &&
         qd_entity_set_string(entity, "mode", 
qd_router_mode_name(router->router_mode)) == 0 &&

Modified: qpid/dispatch/trunk/tests/management/qdrouter.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/management/qdrouter.py?rev=1644326&r1=1644325&r2=1644326&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/management/qdrouter.py (original)
+++ qpid/dispatch/trunk/tests/management/qdrouter.py Wed Dec 10 03:32:39 2014
@@ -102,21 +102,21 @@ class QdrouterTest(unittest.TestCase):
 
         content = conf._default_ids(content)
         self.assertEqual(content, [
-            [u"router", {u"mode":u"standalone", u"name":u"router:0", 
u"identity":u"router:0"}],
+            [u"router", {u"mode":u"standalone", u"name":u"router/0", 
u"identity":u"router/0"}],
             [u"listener", {u"name":u"l0", u"identity":u"l0", 
u"saslMechanisms":u"ANONYMOUS", u"password":u"secret"}],
             [u"listener", {u"name":u"l1", u"identity":u"l1", 
u"saslMechanisms":u"ANONYMOUS", u"port":u"1234"}],
-            [u"listener", {u"name":u"listener:2", u"identity":u"listener:2", 
u"saslMechanisms":u"ANONYMOUS", u"port":u"4567"}]
+            [u"listener", {u"name":u"listener/2", u"identity":u"listener/2", 
u"saslMechanisms":u"ANONYMOUS", u"port":u"4567"}]
         ])
 
         conf.load(text.split(u"\n"))
         router = conf.by_type('router').next()
-        self.assertEqual(router['name'], 'router:0')
-        self.assertEqual(router['identity'], 'router:0')
+        self.assertEqual(router['name'], 'router/0')
+        self.assertEqual(router['identity'], 'router/0')
         listeners = list(conf.by_type('listener'))
         self.assertEqual(len(listeners), 3)
         self.assertEqual(listeners[0]['name'], 'l0')
-        self.assertEqual(listeners[2]['name'], 'listener:2')
-        self.assertEqual(listeners[2]['identity'], 'listener:2')
+        self.assertEqual(listeners[2]['name'], 'listener/2')
+        self.assertEqual(listeners[2]['identity'], 'listener/2')
 
     def test_qdrouter_parse_dash(self):
         self.do_test_qdrouter_parse(conf_text)

Modified: qpid/dispatch/trunk/tests/system_tests_management.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_tests_management.py?rev=1644326&r1=1644325&r2=1644326&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_tests_management.py (original)
+++ qpid/dispatch/trunk/tests/system_tests_management.py Wed Dec 10 03:32:39 
2014
@@ -96,7 +96,7 @@ class ManagementTest(system_test.TestCas
         expect = [[LISTENER, 'l%s' % i, str(self.router.ports[i])] for i in 
xrange(3)]
         for r in expect: # We might have extras in results due to create tests
             self.assertTrue(r in response.results)
-        for name in ['router:' + self.router.name, 'log:DEFAULT']:
+        for name in ['router/' + self.router.name, 'log/DEFAULT']:
             self.assertTrue([r for r in response.get_dicts() if r['name'] == 
name],
                             msg="Can't find result with name '%s'" % name)
 
@@ -130,12 +130,12 @@ class ManagementTest(system_test.TestCas
 
         self.assertRaises(NotFoundStatus, self.node.read, 
identity='log:AGENT') # Not configured
 
-        default = self.node.read(identity='log:DEFAULT')
+        default = self.node.read(identity='log/DEFAULT')
         self.assertEqual(default.attributes,
-                         {u'identity': u'log:DEFAULT',
+                         {u'identity': u'log/DEFAULT',
                           u'level': u'trace',
                           u'module': u'DEFAULT',
-                          u'name': u'log:DEFAULT',
+                          u'name': u'log/DEFAULT',
                           u'output': u'ManagementTest.log',
                           u'source': True,
                           u'timestamp': True,
@@ -152,20 +152,20 @@ class ManagementTest(system_test.TestCas
 
         # Create a log entity, verify logging is as expected
         log = os.path.abspath("test_log.log")
-        agent_log = self.assert_create_ok('log', 'log:AGENT', 
dict(module='AGENT', level="error", output=log))
+        agent_log = self.assert_create_ok('log', 'log/AGENT', 
dict(module='AGENT', level="error", output=log))
         check_log(log)
 
         # Update the log entity to output to a different file
         log = os.path.abspath("test_log2.log")
-        self.node.update(dict(module='AGENT', level="error", output=log), 
identity='log:AGENT')
+        self.node.update(dict(module='AGENT', level="error", output=log), 
identity='log/AGENT')
         check_log(log)
 
         # Delete the log entity - return to default state.
-        self.node.delete(identity='log:AGENT')
+        self.node.delete(identity='log/AGENT')
         self.assertRaises(AssertionError, check_log, log, 'nosuch2')
 
         # Verify that debug logging shows up if enabled for a module
-        self.node.create(dict(module='AGENT', level="debug", output=log), 
type='log', name="log:AGENT")
+        self.node.create(dict(module='AGENT', level="debug", output=log), 
type='log', name="log/AGENT")
         logstr = self.cleanup(open(log)).read()
         self.assertTrue(re.search(r'AGENT \(debug\)', logstr),
                         msg="Can't find 'AGENT (debug)' messages in '%s'" % 
(logstr))

Modified: qpid/dispatch/trunk/tests/system_tests_qdstat.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_tests_qdstat.py?rev=1644326&r1=1644325&r2=1644326&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_tests_qdstat.py (original)
+++ qpid/dispatch/trunk/tests/system_tests_qdstat.py Wed Dec 10 03:32:39 2014
@@ -63,7 +63,7 @@ class QdstatTest(system_test.TestCase):
         self.run_qdstat(['--address'], r'\$management')
 
     def test_memory(self):
-        self.run_qdstat(['--memory'], r' qd_address_t\s+[0-9]+')
+        self.run_qdstat(['--memory'], r'qd_address_t\s+[0-9]+')
 
 if __name__ == '__main__':
     unittest.main(system_test.main_module())



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to