Browse Source

Added sendcmd.py, which sends a specified command to a specified channel

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/f2f200910@268 e5f2f494-b856-4b98-b285-d166d9295462
Evan Hunt 15 years ago
parent
commit
d7827f2289
3 changed files with 30 additions and 3 deletions
  1. 1 1
      src/bin/parkinglot/main.cc
  2. 8 2
      src/bin/parkinglot/zoneset.h
  3. 21 0
      src/lib/cc/python/sendcmd.py

+ 1 - 1
src/bin/parkinglot/main.cc

@@ -87,7 +87,7 @@ main(int argc, char* argv[]) {
         int n = select(nfds, &fds, NULL, NULL, NULL);
         if (n < 0)
             throw FatalError("select error");
-        
+
         if (FD_ISSET(ps, &fds))
             plot.processMessage();
 

+ 8 - 2
src/bin/parkinglot/zoneset.h

@@ -21,8 +21,14 @@
 
 class ZoneSet : std::set<std::string> {
     public:
-        void serve(std::string s) { this->insert(s); }
-        void forget(std::string s) { this->erase(s); }
+        void serve(std::string s) {
+            std::cout << "now serving: " << s << std::endl;
+            this->insert(s);
+        }
+        void forget(std::string s) {
+            std::cout << "no longer serving: " << s << std::endl;
+            this->erase(s);
+        }
         bool contains(std::string s) {
             return (this->find(s) != this->end());
         }

+ 21 - 0
src/lib/cc/python/sendcmd.py

@@ -0,0 +1,21 @@
+#!/usr/bin/python3
+import ISC, sys
+
+cc = ISC.CC.Session()
+if len(sys.argv) < 3:
+    sys.stderr.write('Usage: ' + sys.argv[0] + ' <channel> <command> [arg]\n')
+    sys.exit(1)
+
+channel = sys.argv[1]
+command = sys.argv[2]
+if len(sys.argv) >= 4:
+    argument = sys.argv[3]
+else:
+    argument = ""
+
+cmd = { "command": [ command, argument ] }
+
+cc.group_subscribe(channel)
+print("Sending:")
+print(cmd)
+cc.group_sendmsg(cmd, channel)