WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [XM] Fix xm uptime TypeError exception.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XM] Fix xm uptime TypeError exception.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 08 Dec 2006 13:20:25 +0000
Delivery-date: Fri, 08 Dec 2006 05:21:32 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Alastair Tse <atse@xxxxxxxxxxxxx>
# Node ID 9de4597e1269a27719802cbc60c2e943b1ae5930
# Parent  8e035701b9ffa91caf95e01cd89579ebb1f6bd98
[XM] Fix xm uptime TypeError exception.

Signed-off-by: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
---
 tools/python/xen/xm/main.py |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff -r 8e035701b9ff -r 9de4597e1269 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Thu Dec 07 11:45:00 2006 +0000
+++ b/tools/python/xen/xm/main.py       Thu Dec 07 11:50:11 2006 +0000
@@ -30,6 +30,7 @@ import traceback
 import traceback
 import xmlrpclib
 import traceback
+import time
 import datetime
 from select import select
 import xml.dom.minidom
@@ -626,7 +627,13 @@ def parse_doms_info(info):
 
     def get_status(n, t, d):
         return DOM_STATES[t(sxp.child_value(info, n, d))]
-    
+
+    start_time = get_info('start_time', float, -1)
+    if start_time == -1:
+        up_time = float(-1)
+    else:
+        up_time = time.time() - start_time
+
     return {
         'domid'    : get_info('domid',        str,   ''),
         'name'     : get_info('name',         str,   '??'),
@@ -634,7 +641,7 @@ def parse_doms_info(info):
         'vcpus'    : get_info('vcpus',        int,   0),
         'state'    : get_info('state',        str,    ''),
         'cpu_time' : get_info('cpu_time',     float, 0),
-        'up_time'  : get_info('up_time',      float, -1),
+        'up_time'  : up_time,
         'seclabel' : security.get_security_printlabel(info),
         }
 
@@ -1209,7 +1216,7 @@ def xm_uptime(args):
 
     for dom in doms:
         d = parse_doms_info(dom)
-        if d['domid'] > 0:
+        if int(d['domid']) > 0:
             uptime = int(round(d['up_time']))
         else:
             f=open('/proc/uptime', 'r')
@@ -1236,10 +1243,10 @@ def xm_uptime(args):
         if short_mode:
             now = datetime.datetime.now()
             upstring = now.strftime(" %H:%M:%S") + " up " + upstring
-            upstring += ", " + d['name'] + " (" + str(d['domid']) + ")"
+            upstring += ", " + d['name'] + " (" + d['domid'] + ")"
         else:
             upstring += ':%(seconds)02d' % vars()
-            upstring = ("%(name)-32s %(domid)3d " % d) + upstring
+            upstring = ("%(name)-32s %(domid)3s " % d) + upstring
 
         print upstring
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [XM] Fix xm uptime TypeError exception., Xen patchbot-unstable <=