mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
Convert XendPIFMetrics into an autoplug class.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
1 parent
4b24edbf8b
commit
4d3817aae9
2 files changed
+10
-18
No files matched your search
@@ -34,6 +34,7 @@ from xen.xend.XendClient import ERROR_INVALID_DOMAIN
|
||||
from xen.xend.XendLogging import log
|
||||
from xen.xend.XendNetwork import XendNetwork
|
||||
from xen.xend.XendTask import XendTask
|
||||
from xen.xend.XendPIFMetrics import XendPIFMetrics
|
||||
from xen.xend.XendVMMetrics import XendVMMetrics
|
||||
|
||||
from xen.xend.XendAPIConstants import *
|
||||
@@ -438,8 +439,9 @@ class XendAPI(object):
|
||||
}
|
||||
|
||||
autoplug_classes = {
|
||||
'network' : XendNetwork,
|
||||
'VM_metrics' : XendVMMetrics,
|
||||
'network' : XendNetwork,
|
||||
'VM_metrics' : XendVMMetrics,
|
||||
'PIF_metrics' : XendPIFMetrics,
|
||||
}
|
||||
|
||||
# Cheat methods
|
||||
@@ -1071,21 +1073,9 @@ class XendAPI(object):
|
||||
def PIF_metrics_get_all(self, _):
|
||||
return xen_api_success(XendNode.instance().pif_metrics.keys())
|
||||
|
||||
def _PIF_metrics_get(self, ref):
|
||||
def _PIF_metrics_get(self, _, ref):
|
||||
return XendNode.instance().pif_metrics[ref]
|
||||
|
||||
def PIF_metrics_get_record(self, _, ref):
|
||||
return xen_api_success(self._PIF_metrics_get(ref).get_record())
|
||||
|
||||
def PIF_metrics_get_io_read_kbs(self, _, ref):
|
||||
return xen_api_success(self._PIF_metrics_get(ref).get_io_read_kbs())
|
||||
|
||||
def PIF_metrics_get_io_write_kbs(self, _, ref):
|
||||
return xen_api_success(self._PIF_metrics_get(ref).get_io_write_kbs())
|
||||
|
||||
def PIF_metrics_get_last_updated(self, _1, _2):
|
||||
return xen_api_success(now())
|
||||
|
||||
|
||||
# Xen API: Class VM
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
@@ -39,11 +39,13 @@ class XendPIFMetrics:
|
||||
return pifs_util[pifname][n]
|
||||
return 0.0
|
||||
|
||||
def get_record(self):
|
||||
def get_last_updated(self):
|
||||
import xen.xend.XendAPI as XendAPI
|
||||
return XendAPI.now()
|
||||
|
||||
def get_record(self):
|
||||
return {'uuid' : self.uuid,
|
||||
'PIF' : self.pif.uuid,
|
||||
'io_read_kbs' : self.get_io_read_kbs(),
|
||||
'io_write_kbs' : self.get_io_write_kbs(),
|
||||
'last_updated' : XendAPI.now(),
|
||||
'last_updated' : self.get_last_updated(),
|
||||
}
|
||||