From ee87fff0d75d2ac7bb42d9581d669dfc75678989 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Thu, 12 May 2011 18:15:09 +0200 Subject: [PATCH] dom0: implement QubesVm.get_start_time() (#231) Needed to check if VM was just started again --- dom0/qvm-core/qubes.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 4c4ecca4..885988a8 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -499,6 +499,20 @@ class QubesVm(object): else: return False + def get_start_time(self): + if not self.is_running(): + return 0 + + try: + start_time = xend_session.session.xenapi.VM_metrics.get_record (self.session_metrics)['start_time'] + except XenAPI.Failure: + self.refresh_xend_session() + if self.session_uuid is None: + return "NA" + start_time = xend_session.session.xenapi.VM_metrics.get_record (self.session_metrics)['start_time'] + + return start_time + def is_outdated(self): # Makes sense only on VM based on template if self.template_vm is None: