WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [XEND][XENAPI] XendNode implementation fo

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XEND][XENAPI] XendNode implementation for Xen API Host, Host CPUs
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 02 Nov 2006 22:08:30 +0000
Delivery-date: Thu, 02 Nov 2006 21:40:11 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [XEND][XENAPI] XendNode implementation for Xen API Host, Host CPUs, Xen patchbot-unstable <=