Add perform_daemon_query() helper function

Change-Id: I289456c0043938c70a77249aff93cd9aa3b7186b
diff --git a/util.py b/util.py
index ad0b184..f9b19e2 100644
--- a/util.py
+++ b/util.py
@@ -1,5 +1,6 @@
 import logging
 import os
+import time
 from db.db import VlanDB
 from errors import CriticalError, InputError, ConfigError, SocketError
 
@@ -63,3 +64,27 @@
 
         return ret
 
+    # Simple helper wrapper for all the read-only daemon state queries
+    def perform_daemon_query(self, state, command, data):
+        print 'perform_daemon_query'
+        print command
+        print data
+        ret = {}
+        try:
+            if command == 'daemon.status':
+                # data ignored
+                ret['running'] = 'ok'
+            elif command == 'daemon.version':
+                # data ignored
+                ret['version'] = state.version
+            elif command == 'daemon.statistics':
+                ret['uptime'] = time.time() - state.starttime
+            else:
+                raise InputError("Unknown query command \"%s\"" % command)
+
+        except:
+            raise InputError("Invalid input in query")
+
+        return ret
+
+