Compute uptime on the server so time drift doesn't cause problems sipb-xen-remctl-auto/1.0.15
authorQuentin Smith <quentin@mit.edu>
Fri, 16 May 2008 00:58:19 +0000 (20:58 -0400)
committerQuentin Smith <quentin@mit.edu>
Fri, 16 May 2008 00:58:19 +0000 (20:58 -0400)
svn path=/trunk/packages/sipb-xen-remctl-auto/; revision=533

debian/changelog
files/usr/sbin/sipb-xen-listvms

index c3439d7..82f6cec 100644 (file)
@@ -1,3 +1,9 @@
+sipb-xen-remctl-auto (1.0.15) unstable; urgency=low
+
+  * Compute time differences on server to avoid drift
+
+ -- Quentin Smith <quentin@mit.edu>  Thu, 15 May 2008 20:58:04 -0400
+
 sipb-xen-remctl-auto (1.0.14) unstable; urgency=low
 
   * Use more efficient python API to get VM information, and return it
index 7884d87..427a586 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys
+import time
 sys.path.insert(0, '/usr/lib/xen-3.1-1/lib/python')
 from xen.lowlevel.xs import xs
 
@@ -8,7 +9,7 @@ trans = xs()
 
 def live_vms():
     domids = set(trans.ls('', '/local/domain'))
-    domids.remove('0')
+    domids.discard('0')
 
     vms = dict()
 
@@ -28,6 +29,7 @@ def get_dom(domid):
     # uptime
     data['vm'] = trans.read('', '/local/domain/%d/vm' % domid)
     data['start_time'] = float(trans.read('', '%s/start_time' % data['vm']))
+    data['uptime'] = time.time()-data['start_time']
     
     return name, data
 
@@ -35,6 +37,6 @@ if __name__ == '__main__':
     vms = live_vms()
     if '--pickle' in sys.argv[1:]:
         import cPickle
-        cPickle.dump(vms, sys.stdout)
+        cPickle.dump(vms, sys.stdout, cPickle.HIGHEST_PROTOCOL)
     else:
         print vms