[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [XEND][XENAPI] XendNode implementation for Xen API Host, Host CPUs
# HG changeset patch # User Alastair Tse <atse@xxxxxxxxxxxxx> # Node ID 137d40894a8b8e130a4be4f29582e8ad5450b4ec # Parent a3788998952d10b2e5df05c57f1d71ccdf609857 [XEND][XENAPI] XendNode implementation for Xen API Host, Host CPUs Signed-off-by: Alastair Tse <atse@xxxxxxxxxxxxx> --- tools/python/xen/xend/XendNode.py | 110 ++++++++++++++++++++++++++++++++++---- 1 files changed, 101 insertions(+), 9 deletions(-) diff -r a3788998952d -r 137d40894a8b tools/python/xen/xend/XendNode.py --- a/tools/python/xen/xend/XendNode.py Thu Oct 05 17:29:19 2006 +0100 +++ b/tools/python/xen/xend/XendNode.py Thu Oct 05 17:29:19 2006 +0100 @@ -13,22 +13,38 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #============================================================================ # Copyright (C) 2004, 2005 Mike Wray <mike.wray@xxxxxx> -#============================================================================ - -"""Handler for node operations. - Has some persistent state: - - logs - - notification urls - -""" +# Copyright (c) 2006 Xensource Inc. +#============================================================================ import os +import socket import xen.lowlevel.xc +from xen.xend import uuid +from xen.xend.XendError import XendError class XendNode: - + """XendNode - Represents a Domain 0 Host.""" + def __init__(self): self.xc = xen.lowlevel.xc.xc() + self.uuid = uuid.createString() + self.cpus = {} + self.name = socket.gethostname() + self.desc = "" + + physinfo = self.physinfo_dict() + cpu_count = physinfo['nr_cpus'] + cpu_features = physinfo['hw_caps'] + + for i in range(cpu_count): + # construct uuid by appending extra bit on the host. + # since CPUs belong to a host. + cpu_uuid = self.uuid + '-%04d' % i + cpu_info = {'uuid': cpu_uuid, + 'host': self.uuid, + 'number': i, + 'features': cpu_features} + self.cpus[uuid] = cpu_info def shutdown(self): return 0 @@ -39,6 +55,69 @@ class XendNode: def notify(self, _): return 0 + # + # Ref validation + # + + def is_valid_host(self, host_ref): + return (host_ref == self.uuid) + + def is_valid_cpu(self, cpu_ref): + return (cpu_ref in self.cpus) + + # + # Host Functions + # + + def xen_version(self): + info = self.xc.xeninfo() + return {'Xen': '%(xen_major)d.%(xen_minor)d' % info} + + def get_name(self): + return self.name + + def set_name(self, new_name): + self.name = new_name + + # + # Host CPU Functions + # + + def get_host_cpu_by_uuid(self, host_cpu_uuid): + if host_cpu_uuid in self.cpus: + return host_cpu_uuid + raise XendError('Invalid CPU UUID') + + def get_host_cpu_refs(self): + return self.cpus.keys() + + def get_host_cpu_uuid(self, host_cpu_ref): + if host_cpu_ref in self.cpus: + return host_cpu_ref + else: + raise XendError('Invalid CPU Reference') + + def get_host_cpu_features(self, host_cpu_ref): + try: + return self.cpus[host_cpu_ref]['features'] + except KeyError: + raise XendError('Invalid CPU Reference') + + def get_host_cpu_number(self, host_cpu_ref): + try: + return self.cpus[host_cpu_ref]['number'] + except KeyError: + raise XendError('Invalid CPU Reference') + + def get_host_cpu_load(self, host_cpu_ref): + return 0.0 + + + + # + # Getting host information. + # + def info(self): return (self.nodeinfo() + self.physinfo() + self.xeninfo() + self.xendinfo()) @@ -98,6 +177,19 @@ class XendNode: def xendinfo(self): return [['xend_config_format', 2]] + # dictionary version of *info() functions to get rid of + # SXPisms. + def nodeinfo_dict(self): + return dict(self.nodeinfo()) + def xendinfo_dict(self): + return dict(self.xendinfo()) + def xeninfo_dict(self): + return dict(self.xeninfo()) + def physinfo_dict(self): + return dict(self.physinfo()) + def info_dict(self): + return dict(self.info()) + def instance(): global inst _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |