Browse Source

[2922] Provide the members of group/MsgQ

Michal 'vorner' Vaner 12 years ago
parent
commit
e567e51a23
2 changed files with 15 additions and 3 deletions
  1. 13 1
      src/bin/msgq/msgq.py.in
  2. 2 2
      src/bin/msgq/tests/msgq_test.py

+ 13 - 1
src/bin/msgq/msgq.py.in

@@ -807,7 +807,19 @@ class MsgQ:
             if not self.running:
                 return
 
-            # TODO: Any commands go here
+            # TODO: Who does validation? The ModuleCCSession or must we?
+
+            if command == 'members':
+                # List all members of MsgQ or of a group.
+                if args is None:
+                    args = {}
+                group = args.get('group')
+                if group:
+                    return isc.config.create_answer(0,
+                        list(map(lambda sock: self.fd_to_lname[sock.fileno()],
+                                 self.subs.find(group, ''))))
+                else:
+                    return isc.config.create_answer(0, self.lnames.keys())
 
             config_logger.error(MSGQ_COMMAND_UNKNOWN, command)
             return isc.config.create_answer(1, 'unknown command: ' + command)

+ 2 - 2
src/bin/msgq/tests/msgq_test.py

@@ -218,8 +218,8 @@ class MsgQTest(unittest.TestCase):
             any order).
             """
             array = result['result'][1]
-            self.assertEqual(set(['first', 'second']), array)
-            self.assertEqual({'result': [0, array]}, array)
+            self.assertEqual(set(['first', 'second']), set(array))
+            self.assertEqual({'result': [0, array]}, result)
         # Members of the G1 and G2
         self.assertEqual({'result': [0, ["second"]]},
                          self.__msgq.command_handler('members',