direct-io.hg

changeset 12355:d243a33a6e51

[XEND] Add missing implementation for host_set_name_{label,description}.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Fri Nov 10 12:46:25 2006 +0000 (2006-11-10)
parents 272cd2dc7cdf
children 40a9f315b708
files tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendNode.py
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Fri Nov 10 12:44:47 2006 +0000
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Fri Nov 10 12:46:25 2006 +0000
     1.3 @@ -27,20 +27,36 @@ from xen.xend.XendLogging import log
     1.4  from xen.xend.XendAPIConstants import *
     1.5  from xen.util.xmlrpclib2 import stringify
     1.6  
     1.7 +# ------------------------------------------
     1.8 +# Utility Methods for Xen API Implementation
     1.9 +# ------------------------------------------
    1.10 +
    1.11  def xen_api_success(value):
    1.12 +    """Wraps a return value in XenAPI format."""
    1.13      return {"Status": "Success", "Value": stringify(value)}
    1.14  
    1.15  def xen_api_success_void():
    1.16      """Return success, but caller expects no return value."""
    1.17      return xen_api_success("")
    1.18 +
    1.19  def xen_api_error(error):
    1.20 +    """Wraps an error value in XenAPI format."""
    1.21      return {"Status": "Error", "ErrorDescription": error}
    1.22 +
    1.23  def xen_api_todo():
    1.24      """Temporary method to make sure we track down all the TODOs"""
    1.25      return {"Status": "Error", "ErrorDescription": XEND_ERROR_TODO}
    1.26  
    1.27 +# ---------------------------------------------------
    1.28 +# Python Method Decorators for input value validation
    1.29 +# ---------------------------------------------------
    1.30 +
    1.31  def trace(func, api_name = ''):
    1.32 -    """Decorator to trace XMLRPC Xen API methods."""
    1.33 +    """Decorator to trace XMLRPC Xen API methods.
    1.34 +
    1.35 +    @param func: function with any parameters
    1.36 +    @param api_name: name of the api call for debugging.
    1.37 +    """
    1.38      if hasattr(func, 'api'):
    1.39          api_name = func.api
    1.40      def trace_func(self, *args, **kwargs):
    1.41 @@ -225,6 +241,10 @@ def valid_sr(func):
    1.42          
    1.43      return check_sr_ref
    1.44  
    1.45 +# -----------------------------
    1.46 +# Bridge to Legacy XM API calls
    1.47 +# -----------------------------
    1.48 +
    1.49  def do_vm_func(fn_name, vm_ref, *args):
    1.50      """Helper wrapper func to abstract away from repeative code.
    1.51  
    1.52 @@ -240,6 +260,7 @@ def do_vm_func(fn_name, vm_ref, *args):
    1.53      return xen_api_success(xendom.do_legacy_api_with_uuid(
    1.54          fn, vm_ref, *args))
    1.55  
    1.56 +
    1.57  class XendAPI:
    1.58      """Implementation of the Xen-API in Xend. Expects to be
    1.59      used via XMLRPCServer.
    1.60 @@ -274,7 +295,8 @@ class XendAPI:
    1.61          # Cheat methods
    1.62          # -------------
    1.63          # Methods that have a trivial implementation for all classes.
    1.64 -        # 1. get_by_uuid == getting by ref, so just return uuid.
    1.65 +        # 1. get_by_uuid == getting by ref, so just return uuid for
    1.66 +        #    all get_by_uuid() methods.
    1.67          
    1.68          for cls in classes.keys():
    1.69              get_by_uuid = '%s_get_by_uuid' % cls.lower()
    1.70 @@ -424,12 +446,14 @@ class XendAPI:
    1.71      # attributes
    1.72      def host_get_name_label(self, session, host_ref):
    1.73          return xen_api_success(XendNode.instance().name)
    1.74 -    def host_set_name_label(self, session, host_ref):
    1.75 -        return xen_api_success(XendNode.instance().name)
    1.76 +    def host_set_name_label(self, session, host_ref, new_name):
    1.77 +        XendNode.instance().set_name(new_name)
    1.78 +        return xen_api_success_void()
    1.79      def host_get_name_description(self, session, host_ref):
    1.80 -        return xen_api_success(XendNode.instance().description)    
    1.81 +        return xen_api_success(XendNode.instance().description)
    1.82      def host_set_name_description(self, session, host_ref):
    1.83 -        return xen_api_success(XendNode.instance().description)
    1.84 +        XendNode.instance().set_description(new_description)
    1.85 +        return xen_api_success_void()
    1.86      def host_get_software_version(self, session, host_ref):
    1.87          return xen_api_success(XendNode.instance().xen_version())
    1.88      def host_get_resident_VMs(self, session, host_ref):
     2.1 --- a/tools/python/xen/xend/XendNode.py	Fri Nov 10 12:44:47 2006 +0000
     2.2 +++ b/tools/python/xen/xend/XendNode.py	Fri Nov 10 12:46:25 2006 +0000
     2.3 @@ -94,6 +94,12 @@ class XendNode:
     2.4      def set_name(self, new_name):
     2.5          self.name = new_name
     2.6  
     2.7 +    def get_description(self):
     2.8 +        return self.desc
     2.9 +
    2.10 +    def set_description(self, new_desc):
    2.11 +        self.desc = new_desc
    2.12 +
    2.13      #
    2.14      # Host CPU Functions
    2.15      #