# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1174952926 -3600
# Node ID 75c797744eb4d216cdfbf0510a341f88e44e3aed
# Parent 03d0dda70a8f0bc592af99b43b10e8dde77c7a85
Convert XendVMMetrics into an autoplug class. Tidy up our destroy methods
on the way -- metrics classes cannot be destroyed.
Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
tools/python/xen/xend/XendAPI.py | 56 ++++++++-------------------------
tools/python/xen/xend/XendVMMetrics.py | 7 ++--
2 files changed, 20 insertions(+), 43 deletions(-)
diff -r 03d0dda70a8f -r 75c797744eb4 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py Tue Mar 27 00:19:20 2007 +0100
+++ b/tools/python/xen/xend/XendAPI.py Tue Mar 27 00:48:46 2007 +0100
@@ -438,7 +438,8 @@ class XendAPI(object):
}
autoplug_classes = {
- 'network' : XendNetwork
+ 'network' : XendNetwork,
+ 'VM_metrics' : XendVMMetrics,
}
# Cheat methods
@@ -469,9 +470,8 @@ class XendAPI(object):
# class, and wrapped up to be compatible with the Xen-API.
for api_cls, impl_cls in autoplug_classes.items():
- getter = getattr(cls, '_%s_get' % api_cls)
-
def doit(n):
+ getter = getattr(cls, '_%s_get' % api_cls)
dot_n = '%s.%s' % (api_cls, n)
full_n = '%s_%s' % (api_cls, n)
if not hasattr(cls, full_n):
@@ -557,7 +557,7 @@ class XendAPI(object):
Base_attr_ro = ['uuid']
Base_attr_rw = []
- Base_methods = [('destroy', None), ('get_record', 'Struct')]
+ Base_methods = [('get_record', 'Struct')]
Base_funcs = [('get_all', 'Set'), ('get_by_uuid', None)]
# Xen API: Class Session
@@ -960,7 +960,8 @@ class XendAPI(object):
'name_description',
'other_config']
network_methods = [('add_to_other_config', None),
- ('remove_from_other_config', None)]
+ ('remove_from_other_config', None),
+ ('destroy', None)]
network_funcs = [('create', None)]
def _network_get(self, _, ref):
@@ -989,7 +990,7 @@ class XendAPI(object):
PIF_attr_inst = PIF_attr_rw
- PIF_methods = [('create_VLAN', 'int')]
+ PIF_methods = [('create_VLAN', 'int'), ('destroy', None)]
def _get_PIF(self, ref):
return XendNode.instance().pifs[ref]
@@ -1152,7 +1153,8 @@ class XendAPI(object):
('save', None),
('set_memory_dynamic_max_live', None),
('set_memory_dynamic_min_live', None),
- ('send_trigger', None)]
+ ('send_trigger', None),
+ ('destroy', None)]
VM_funcs = [('create', 'VM'),
('restore', None),
@@ -1696,41 +1698,11 @@ class XendAPI(object):
VM_metrics_attr_rw = []
VM_metrics_methods = []
- def _VM_metrics_get(self, ref):
+ def _VM_metrics_get(self, _, ref):
return XendVMMetrics.get_by_uuid(ref)
def VM_metrics_get_all(self, _):
return xen_api_success(XendVMMetrics.get_all())
-
- def VM_metrics_get_record(self, _, ref):
- return xen_api_success(self._VM_metrics_get(ref).get_record())
-
- def VM_metrics_get_memory_actual(self, _, ref):
- return xen_api_success(self._VM_metrics_get(ref).get_memory_actual())
-
- def VM_metrics_get_VCPUs_number(self, _, ref):
- return xen_api_success(self._VM_metrics_get(ref).get_VCPUs_number())
-
- def VM_metrics_get_VCPUs_utilisation(self, _, ref):
- return
xen_api_success(self._VM_metrics_get(ref).get_VCPUs_utilisation())
-
- def VM_metrics_get_VCPUs_CPU(self, _, ref):
- return xen_api_success(self._VM_metrics_get(ref).get_VCPUs_CPU())
-
- def VM_metrics_get_VCPUs_flags(self, _, ref):
- return xen_api_success(self._VM_metrics_get(ref).get_VCPUs_flags())
-
- def VM_metrics_get_VCPUs_params(self, _, ref):
- return xen_api_success(self._VM_metrics_get(ref).get_VCPUs_params())
-
- def VM_metrics_get_start_time(self, _, ref):
- return xen_api_success(self._VM_metrics_get(ref).get_start_time())
-
- def VM_metrics_get_state(self, _, ref):
- return xen_api_success(self._VM_metrics_get(ref).get_state())
-
- def VM_metrics_get_last_updated(self, _1, _2):
- return xen_api_success(now())
# Xen API: Class VBD
@@ -1747,7 +1719,7 @@ class XendAPI(object):
VBD_attr_inst = VBD_attr_rw
- VBD_methods = [('media_change', None)]
+ VBD_methods = [('media_change', None), ('destroy', None)]
VBD_funcs = [('create', 'VBD')]
# object methods
@@ -1924,6 +1896,7 @@ class XendAPI(object):
VIF_attr_inst = VIF_attr_rw
+ VIF_methods = [('destroy', None)]
VIF_funcs = [('create', 'VIF')]
@@ -2065,7 +2038,7 @@ class XendAPI(object):
'other_config']
VDI_attr_inst = VDI_attr_ro + VDI_attr_rw
- VDI_methods = [('snapshot', 'VDI')]
+ VDI_methods = [('snapshot', 'VDI'), ('destroy', None)]
VDI_funcs = [('create', 'VDI'),
('get_by_name_label', 'Set(VDI)')]
@@ -2182,6 +2155,7 @@ class XendAPI(object):
VTPM_attr_inst = VTPM_attr_rw
+ VTPM_methods = [('destroy', None)]
VTPM_funcs = [('create', 'VTPM')]
# object methods
@@ -2340,7 +2314,7 @@ class XendAPI(object):
'name_label',
'name_description']
- SR_methods = [('clone', 'SR')]
+ SR_methods = [('clone', 'SR'), ('destroy', None)]
SR_funcs = [('get_by_name_label', 'Set(SR)'),
('get_by_uuid', 'SR')]
diff -r 03d0dda70a8f -r 75c797744eb4 tools/python/xen/xend/XendVMMetrics.py
--- a/tools/python/xen/xend/XendVMMetrics.py Tue Mar 27 00:19:20 2007 +0100
+++ b/tools/python/xen/xend/XendVMMetrics.py Tue Mar 27 00:48:46 2007 +0100
@@ -140,8 +140,11 @@ class XendVMMetrics:
def get_start_time(self):
return self.xend_domain_instance.info.get("start_time", -1)
+ def get_last_updated(self):
+ import xen.xend.XendAPI as XendAPI
+ return XendAPI.now()
+
def get_record(self):
- import xen.xend.XendAPI as XendAPI
return { 'uuid' : self.uuid,
'memory_actual' : self.get_memory_actual(),
'VCPUs_number' : self.get_VCPUs_number(),
@@ -151,5 +154,5 @@ class XendVMMetrics:
'VCPUs_params' : self.get_VCPUs_params(),
'start_time' : self.get_start_time(),
'state' : self.get_state(),
- 'last_updated' : XendAPI.now(),
+ 'last_updated' : self.get_last_updated(),
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|