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-api

Re: [Xen-API] Want to find out the uptime of individual VM running on Ci

To: "Sane, Abhijeet" <Abhijeet_Sane@xxxxxxx>
Subject: Re: [Xen-API] Want to find out the uptime of individual VM running on Citrix Xen
From: Alberto González Rodríguez <alberto@xxxxxxxxxxxxx>
Date: Tue, 11 May 2010 12:08:04 +0200
Cc: "xen-api@xxxxxxxxxxxxxxxxxxx" <xen-api@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Tue, 11 May 2010 03:08:17 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <CACE9D90AB02DA4F8DE4C45DB43BA34512B054383A@xxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
References: <CACE9D90AB02DA4F8DE4C45DB43BA34512B054383A@xxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
on openxencenter i use (not with xenapi.py):

self.all_vms = self.connection.VM.get_all_records\
                      (self.session_uuid)['Value']

metric = self.all_vms[ref]['metrics']
startup = 
self.humanize_time(self.get_seconds_difference(self.all_vm_metrics[metric]['start_time']))


functions are:

    def humanize_time(self, secs):
        string = ""
        mins, secs = divmod(secs, 60)
        hours, mins = divmod(mins, 60)
        days, hours = divmod(hours, 24)
        if days:
            string += "%02d days " % (days)
        if hours:
            string += "%02d hours " % (hours)
        if mins:
            string += "%02d minutes " % (mins)
        if secs:
            string += "%02d seconds " % (secs)
        return string

    def get_seconds_difference(self, toconvert):
        converted = datetime.datetime.strptime(str(toconvert),
"%Y%m%dT%H:%M:%SZ")
        totime = time.mktime(converted.timetuple())
        #FIXME
        return time.time()-totime-3600



2010/5/11 Sane, Abhijeet <Abhijeet_Sane@xxxxxxx>:
> Hi,
>
> I want to know if it is possible to get the uptime of individual VM that are
> running on the Citrix host using the Citrix Xen python API..
>
> Something on the lines of ‘xm uptime’
>
>
>
> Regards
>
> Abhijeet Sane
>
> _______________________________________________
> xen-api mailing list
> xen-api@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/mailman/listinfo/xen-api
>
>

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

<Prev in Thread] Current Thread [Next in Thread>