ia64/xen-unstable

changeset 14572:f6c38a084bef

Convert XendPIFMetrics into an autoplug class.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Mar 27 00:54:05 2007 +0100 (2007-03-27)
parents 75c797744eb4
children d01e7ace9d2c
files tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendPIFMetrics.py
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Tue Mar 27 00:48:46 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Tue Mar 27 00:54:05 2007 +0100
     1.3 @@ -34,6 +34,7 @@ from xen.xend.XendClient import ERROR_IN
     1.4  from xen.xend.XendLogging import log
     1.5  from xen.xend.XendNetwork import XendNetwork
     1.6  from xen.xend.XendTask import XendTask
     1.7 +from xen.xend.XendPIFMetrics import XendPIFMetrics
     1.8  from xen.xend.XendVMMetrics import XendVMMetrics
     1.9  
    1.10  from xen.xend.XendAPIConstants import *
    1.11 @@ -438,8 +439,9 @@ class XendAPI(object):
    1.12          }
    1.13  
    1.14          autoplug_classes = {
    1.15 -            'network'    : XendNetwork,
    1.16 -            'VM_metrics' : XendVMMetrics,
    1.17 +            'network'     : XendNetwork,
    1.18 +            'VM_metrics'  : XendVMMetrics,
    1.19 +            'PIF_metrics' : XendPIFMetrics,
    1.20          }
    1.21  
    1.22          # Cheat methods
    1.23 @@ -1071,21 +1073,9 @@ class XendAPI(object):
    1.24      def PIF_metrics_get_all(self, _):
    1.25          return xen_api_success(XendNode.instance().pif_metrics.keys())
    1.26  
    1.27 -    def _PIF_metrics_get(self, ref):
    1.28 +    def _PIF_metrics_get(self, _, ref):
    1.29          return XendNode.instance().pif_metrics[ref]
    1.30  
    1.31 -    def PIF_metrics_get_record(self, _, ref):
    1.32 -        return xen_api_success(self._PIF_metrics_get(ref).get_record())
    1.33 -
    1.34 -    def PIF_metrics_get_io_read_kbs(self, _, ref):
    1.35 -        return xen_api_success(self._PIF_metrics_get(ref).get_io_read_kbs())
    1.36 -
    1.37 -    def PIF_metrics_get_io_write_kbs(self, _, ref):
    1.38 -        return xen_api_success(self._PIF_metrics_get(ref).get_io_write_kbs())
    1.39 -
    1.40 -    def PIF_metrics_get_last_updated(self, _1, _2):
    1.41 -        return xen_api_success(now())
    1.42 -
    1.43  
    1.44      # Xen API: Class VM
    1.45      # ----------------------------------------------------------------        
     2.1 --- a/tools/python/xen/xend/XendPIFMetrics.py	Tue Mar 27 00:48:46 2007 +0100
     2.2 +++ b/tools/python/xen/xend/XendPIFMetrics.py	Tue Mar 27 00:54:05 2007 +0100
     2.3 @@ -39,11 +39,13 @@ class XendPIFMetrics:
     2.4              return pifs_util[pifname][n]
     2.5          return 0.0
     2.6  
     2.7 -    def get_record(self):
     2.8 +    def get_last_updated(self):
     2.9          import xen.xend.XendAPI as XendAPI
    2.10 +        return XendAPI.now()
    2.11 +
    2.12 +    def get_record(self):
    2.13          return {'uuid'         : self.uuid,
    2.14 -                'PIF'          : self.pif.uuid,
    2.15                  'io_read_kbs'  : self.get_io_read_kbs(),
    2.16                  'io_write_kbs' : self.get_io_write_kbs(),
    2.17 -                'last_updated' : XendAPI.now(),
    2.18 +                'last_updated' : self.get_last_updated(),
    2.19                  }