ia64/xen-unstable

changeset 14117:f3aa6e34aeb1

Added host.API_version_{major,minor,vendor,vendor_implementation} fields.

Fix missing host.other_config from the record returned by Xend.

Improve the error diagnosis when we catch TypeError.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Sun Feb 25 17:20:51 2007 +0000 (2007-02-25)
parents fd7f23e44b11
children 02f32a4df8db
files docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen_host.h tools/libxen/src/xen_host.c tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendAPIVersion.py
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Wed Feb 21 23:03:00 2007 +0000
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Sun Feb 25 17:20:51 2007 +0000
     1.3 @@ -4422,6 +4422,10 @@ Quals & Field & Type & Description \\
     1.4  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
     1.5  $\mathit{RW}$ &  {\tt name/label} & string & a human-readable name \\
     1.6  $\mathit{RW}$ &  {\tt name/description} & string & a notes field containg human-readable description \\
     1.7 +$\mathit{RO}_\mathit{run}$ &  {\tt API\_version/major} & int & major version number \\
     1.8 +$\mathit{RO}_\mathit{run}$ &  {\tt API\_version/minor} & int & minor version number \\
     1.9 +$\mathit{RO}_\mathit{run}$ &  {\tt API\_version/vendor} & string & identification of vendor \\
    1.10 +$\mathit{RO}_\mathit{run}$ &  {\tt API\_version/vendor\_implementation} & (string $\rightarrow$ string) Map & details of vendor implementation \\
    1.11  $\mathit{RO}_\mathit{run}$ &  {\tt software\_version} & (string $\rightarrow$ string) Map & version strings \\
    1.12  $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
    1.13  $\mathit{RO}_\mathit{run}$ &  {\tt supported\_bootloaders} & string Set & a list of the bootloaders installed on the machine \\
    1.14 @@ -4784,6 +4788,134 @@ void
    1.15  \vspace{0.3cm}
    1.16  \vspace{0.3cm}
    1.17  \vspace{0.3cm}
    1.18 +\subsubsection{RPC name:~get\_API\_version\_major}
    1.19 +
    1.20 +{\bf Overview:} 
    1.21 +Get the API\_version/major field of the given host.
    1.22 +
    1.23 + \noindent {\bf Signature:} 
    1.24 +\begin{verbatim} int get_API_version_major (session_id s, host ref self)\end{verbatim}
    1.25 +
    1.26 +
    1.27 +\noindent{\bf Arguments:}
    1.28 +
    1.29 + 
    1.30 +\vspace{0.3cm}
    1.31 +\begin{tabular}{|c|c|p{7cm}|}
    1.32 + \hline
    1.33 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.34 +{\tt host ref } & self & reference to the object \\ \hline 
    1.35 +
    1.36 +\end{tabular}
    1.37 +
    1.38 +\vspace{0.3cm}
    1.39 +
    1.40 + \noindent {\bf Return Type:} 
    1.41 +{\tt 
    1.42 +int
    1.43 +}
    1.44 +
    1.45 +
    1.46 +value of the field
    1.47 +\vspace{0.3cm}
    1.48 +\vspace{0.3cm}
    1.49 +\vspace{0.3cm}
    1.50 +\subsubsection{RPC name:~get\_API\_version\_minor}
    1.51 +
    1.52 +{\bf Overview:} 
    1.53 +Get the API\_version/minor field of the given host.
    1.54 +
    1.55 + \noindent {\bf Signature:} 
    1.56 +\begin{verbatim} int get_API_version_minor (session_id s, host ref self)\end{verbatim}
    1.57 +
    1.58 +
    1.59 +\noindent{\bf Arguments:}
    1.60 +
    1.61 + 
    1.62 +\vspace{0.3cm}
    1.63 +\begin{tabular}{|c|c|p{7cm}|}
    1.64 + \hline
    1.65 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.66 +{\tt host ref } & self & reference to the object \\ \hline 
    1.67 +
    1.68 +\end{tabular}
    1.69 +
    1.70 +\vspace{0.3cm}
    1.71 +
    1.72 + \noindent {\bf Return Type:} 
    1.73 +{\tt 
    1.74 +int
    1.75 +}
    1.76 +
    1.77 +
    1.78 +value of the field
    1.79 +\vspace{0.3cm}
    1.80 +\vspace{0.3cm}
    1.81 +\vspace{0.3cm}
    1.82 +\subsubsection{RPC name:~get\_API\_version\_vendor}
    1.83 +
    1.84 +{\bf Overview:} 
    1.85 +Get the API\_version/vendor field of the given host.
    1.86 +
    1.87 + \noindent {\bf Signature:} 
    1.88 +\begin{verbatim} string get_API_version_vendor (session_id s, host ref self)\end{verbatim}
    1.89 +
    1.90 +
    1.91 +\noindent{\bf Arguments:}
    1.92 +
    1.93 + 
    1.94 +\vspace{0.3cm}
    1.95 +\begin{tabular}{|c|c|p{7cm}|}
    1.96 + \hline
    1.97 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.98 +{\tt host ref } & self & reference to the object \\ \hline 
    1.99 +
   1.100 +\end{tabular}
   1.101 +
   1.102 +\vspace{0.3cm}
   1.103 +
   1.104 + \noindent {\bf Return Type:} 
   1.105 +{\tt 
   1.106 +string
   1.107 +}
   1.108 +
   1.109 +
   1.110 +value of the field
   1.111 +\vspace{0.3cm}
   1.112 +\vspace{0.3cm}
   1.113 +\vspace{0.3cm}
   1.114 +\subsubsection{RPC name:~get\_API\_version\_vendor\_implementation}
   1.115 +
   1.116 +{\bf Overview:} 
   1.117 +Get the API\_version/vendor\_implementation field of the given host.
   1.118 +
   1.119 + \noindent {\bf Signature:} 
   1.120 +\begin{verbatim} ((string -> string) Map) get_API_version_vendor_implementation (session_id s, host ref self)\end{verbatim}
   1.121 +
   1.122 +
   1.123 +\noindent{\bf Arguments:}
   1.124 +
   1.125 + 
   1.126 +\vspace{0.3cm}
   1.127 +\begin{tabular}{|c|c|p{7cm}|}
   1.128 + \hline
   1.129 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.130 +{\tt host ref } & self & reference to the object \\ \hline 
   1.131 +
   1.132 +\end{tabular}
   1.133 +
   1.134 +\vspace{0.3cm}
   1.135 +
   1.136 + \noindent {\bf Return Type:} 
   1.137 +{\tt 
   1.138 +(string $\rightarrow$ string) Map
   1.139 +}
   1.140 +
   1.141 +
   1.142 +value of the field
   1.143 +\vspace{0.3cm}
   1.144 +\vspace{0.3cm}
   1.145 +\vspace{0.3cm}
   1.146  \subsubsection{RPC name:~get\_software\_version}
   1.147  
   1.148  {\bf Overview:} 
     2.1 --- a/tools/libxen/include/xen_host.h	Wed Feb 21 23:03:00 2007 +0000
     2.2 +++ b/tools/libxen/include/xen_host.h	Sun Feb 25 17:20:51 2007 +0000
     2.3 @@ -72,6 +72,10 @@ typedef struct xen_host_record
     2.4      char *uuid;
     2.5      char *name_label;
     2.6      char *name_description;
     2.7 +    int64_t api_version_major;
     2.8 +    int64_t api_version_minor;
     2.9 +    char *api_version_vendor;
    2.10 +    xen_string_string_map *api_version_vendor_implementation;
    2.11      xen_string_string_map *software_version;
    2.12      xen_string_string_map *other_config;
    2.13      struct xen_string_set *supported_bootloaders;
    2.14 @@ -207,6 +211,34 @@ xen_host_get_name_description(xen_sessio
    2.15  
    2.16  
    2.17  /**
    2.18 + * Get the API_version/major field of the given host.
    2.19 + */
    2.20 +extern bool
    2.21 +xen_host_get_api_version_major(xen_session *session, int64_t *result, xen_host host);
    2.22 +
    2.23 +
    2.24 +/**
    2.25 + * Get the API_version/minor field of the given host.
    2.26 + */
    2.27 +extern bool
    2.28 +xen_host_get_api_version_minor(xen_session *session, int64_t *result, xen_host host);
    2.29 +
    2.30 +
    2.31 +/**
    2.32 + * Get the API_version/vendor field of the given host.
    2.33 + */
    2.34 +extern bool
    2.35 +xen_host_get_api_version_vendor(xen_session *session, char **result, xen_host host);
    2.36 +
    2.37 +
    2.38 +/**
    2.39 + * Get the API_version/vendor_implementation field of the given host.
    2.40 + */
    2.41 +extern bool
    2.42 +xen_host_get_api_version_vendor_implementation(xen_session *session, xen_string_string_map **result, xen_host host);
    2.43 +
    2.44 +
    2.45 +/**
    2.46   * Get the software_version field of the given host.
    2.47   */
    2.48  extern bool
     3.1 --- a/tools/libxen/src/xen_host.c	Wed Feb 21 23:03:00 2007 +0000
     3.2 +++ b/tools/libxen/src/xen_host.c	Sun Feb 25 17:20:51 2007 +0000
     3.3 @@ -52,6 +52,18 @@ static const struct_member xen_host_reco
     3.4          { .key = "name_description",
     3.5            .type = &abstract_type_string,
     3.6            .offset = offsetof(xen_host_record, name_description) },
     3.7 +        { .key = "API_version_major",
     3.8 +          .type = &abstract_type_int,
     3.9 +          .offset = offsetof(xen_host_record, api_version_major) },
    3.10 +        { .key = "API_version_minor",
    3.11 +          .type = &abstract_type_int,
    3.12 +          .offset = offsetof(xen_host_record, api_version_minor) },
    3.13 +        { .key = "API_version_vendor",
    3.14 +          .type = &abstract_type_string,
    3.15 +          .offset = offsetof(xen_host_record, api_version_vendor) },
    3.16 +        { .key = "API_version_vendor_implementation",
    3.17 +          .type = &abstract_type_string_string_map,
    3.18 +          .offset = offsetof(xen_host_record, api_version_vendor_implementation) },
    3.19          { .key = "software_version",
    3.20            .type = &abstract_type_string_string_map,
    3.21            .offset = offsetof(xen_host_record, software_version) },
    3.22 @@ -108,6 +120,8 @@ xen_host_record_free(xen_host_record *re
    3.23      free(record->uuid);
    3.24      free(record->name_label);
    3.25      free(record->name_description);
    3.26 +    free(record->api_version_vendor);
    3.27 +    xen_string_string_map_free(record->api_version_vendor_implementation);
    3.28      xen_string_string_map_free(record->software_version);
    3.29      xen_string_string_map_free(record->other_config);
    3.30      xen_string_set_free(record->supported_bootloaders);
    3.31 @@ -215,6 +229,72 @@ xen_host_get_name_description(xen_sessio
    3.32  
    3.33  
    3.34  bool
    3.35 +xen_host_get_api_version_major(xen_session *session, int64_t *result, xen_host host)
    3.36 +{
    3.37 +    abstract_value param_values[] =
    3.38 +        {
    3.39 +            { .type = &abstract_type_string,
    3.40 +              .u.string_val = host }
    3.41 +        };
    3.42 +
    3.43 +    abstract_type result_type = abstract_type_int;
    3.44 +
    3.45 +    XEN_CALL_("host.get_API_version_major");
    3.46 +    return session->ok;
    3.47 +}
    3.48 +
    3.49 +
    3.50 +bool
    3.51 +xen_host_get_api_version_minor(xen_session *session, int64_t *result, xen_host host)
    3.52 +{
    3.53 +    abstract_value param_values[] =
    3.54 +        {
    3.55 +            { .type = &abstract_type_string,
    3.56 +              .u.string_val = host }
    3.57 +        };
    3.58 +
    3.59 +    abstract_type result_type = abstract_type_int;
    3.60 +
    3.61 +    XEN_CALL_("host.get_API_version_minor");
    3.62 +    return session->ok;
    3.63 +}
    3.64 +
    3.65 +
    3.66 +bool
    3.67 +xen_host_get_api_version_vendor(xen_session *session, char **result, xen_host host)
    3.68 +{
    3.69 +    abstract_value param_values[] =
    3.70 +        {
    3.71 +            { .type = &abstract_type_string,
    3.72 +              .u.string_val = host }
    3.73 +        };
    3.74 +
    3.75 +    abstract_type result_type = abstract_type_string;
    3.76 +
    3.77 +    *result = NULL;
    3.78 +    XEN_CALL_("host.get_API_version_vendor");
    3.79 +    return session->ok;
    3.80 +}
    3.81 +
    3.82 +
    3.83 +bool
    3.84 +xen_host_get_api_version_vendor_implementation(xen_session *session, xen_string_string_map **result, xen_host host)
    3.85 +{
    3.86 +    abstract_value param_values[] =
    3.87 +        {
    3.88 +            { .type = &abstract_type_string,
    3.89 +              .u.string_val = host }
    3.90 +        };
    3.91 +
    3.92 +    abstract_type result_type = abstract_type_string_string_map;
    3.93 +
    3.94 +    *result = NULL;
    3.95 +    XEN_CALL_("host.get_API_version_vendor_implementation");
    3.96 +    return session->ok;
    3.97 +}
    3.98 +
    3.99 +
   3.100 +bool
   3.101  xen_host_get_software_version(xen_session *session, xen_string_string_map **result, xen_host host)
   3.102  {
   3.103      abstract_value param_values[] =
     4.1 --- a/tools/python/xen/xend/XendAPI.py	Wed Feb 21 23:03:00 2007 +0000
     4.2 +++ b/tools/python/xen/xend/XendAPI.py	Sun Feb 25 17:20:51 2007 +0000
     4.3 @@ -25,6 +25,7 @@ import threading
     4.4  from xen.xend import XendDomain, XendDomainInfo, XendNode, XendDmesg
     4.5  from xen.xend import XendLogging, XendTaskManager
     4.6  
     4.7 +from xen.xend.XendAPIVersion import *
     4.8  from xen.xend.XendAuthSessions import instance as auth_manager
     4.9  from xen.xend.XendError import *
    4.10  from xen.xend.XendClient import ERROR_INVALID_DOMAIN
    4.11 @@ -104,20 +105,22 @@ def catch_typeerror(func):
    4.12          except TypeError, exn:
    4.13              #log.exception('catch_typeerror')
    4.14              if hasattr(func, 'api') and func.api in argcounts:
    4.15 -                # Assume that if the exception was thrown inside this
    4.16 -                # file, then it is due to an invalid call from the client,
    4.17 -                # but if it was thrown elsewhere, then it's an internal
    4.18 +                # Assume that if the argument count was wrong and if the
    4.19 +                # exception was thrown inside this file, then it is due to an
    4.20 +                # invalid call from the client, otherwise it's an internal
    4.21                  # error (which will be handled further up).
    4.22 -                tb = sys.exc_info()[2]
    4.23 -                try:
    4.24 -                    sourcefile = traceback.extract_tb(tb)[-1][0]
    4.25 -                    if sourcefile == inspect.getsourcefile(XendAPI):
    4.26 -                        return xen_api_error(
    4.27 -                            ['MESSAGE_PARAMETER_COUNT_MISMATCH',
    4.28 -                             func.api, argcounts[func.api],
    4.29 -                             len(args) + len(kwargs)])
    4.30 -                finally:
    4.31 -                    del tb
    4.32 +                expected = argcounts[func.api]
    4.33 +                actual = len(args) + len(kwargs)
    4.34 +                if expected != actual:
    4.35 +                    tb = sys.exc_info()[2]
    4.36 +                    try:
    4.37 +                        sourcefile = traceback.extract_tb(tb)[-1][0]
    4.38 +                        if sourcefile == inspect.getsourcefile(XendAPI):
    4.39 +                            return xen_api_error(
    4.40 +                                ['MESSAGE_PARAMETER_COUNT_MISMATCH',
    4.41 +                                 func.api, expected, actual])
    4.42 +                    finally:
    4.43 +                        del tb
    4.44              raise
    4.45  
    4.46      return f
    4.47 @@ -627,7 +630,11 @@ class XendAPI(object):
    4.48                      'resident_VMs',
    4.49                      'host_CPUs',
    4.50                      'metrics',
    4.51 -                    'supported_bootloaders']
    4.52 +                    'supported_bootloaders',
    4.53 +                    'API_version_major',
    4.54 +                    'API_version_minor',
    4.55 +                    'API_version_vendor',
    4.56 +                    'API_version_vendor_implementation']
    4.57      
    4.58      host_attr_rw = ['name_label',
    4.59                      'name_description',
    4.60 @@ -671,6 +678,14 @@ class XendAPI(object):
    4.61          del node.other_config[key]
    4.62          node.save()
    4.63          return xen_api_success_void()
    4.64 +    def host_get_API_version_major(self, _, ref):
    4.65 +        return xen_api_success(XEN_API_VERSION_MAJOR)
    4.66 +    def host_get_API_version_minor(self, _, ref):
    4.67 +        return xen_api_success(XEN_API_VERSION_MINOR)
    4.68 +    def host_get_API_version_vendor(self, _, ref):
    4.69 +        return xen_api_success(XEN_API_VERSION_VENDOR)
    4.70 +    def host_get_API_version_vendor_implementation(self, _, ref):
    4.71 +        return xen_api_success(XEN_API_VERSION_VENDOR_IMPLEMENTATION)
    4.72      def host_get_software_version(self, session, host_ref):
    4.73          return xen_api_success(XendNode.instance().xen_version())
    4.74      def host_get_resident_VMs(self, session, host_ref):
    4.75 @@ -707,7 +722,13 @@ class XendAPI(object):
    4.76          record = {'uuid': node.uuid,
    4.77                    'name_label': node.name,
    4.78                    'name_description': '',
    4.79 +                  'API_version_major': XEN_API_VERSION_MAJOR,
    4.80 +                  'API_version_minor': XEN_API_VERSION_MINOR,
    4.81 +                  'API_version_vendor': XEN_API_VERSION_VENDOR,
    4.82 +                  'API_version_vendor_implemention':
    4.83 +                  XEN_API_VERSION_VENDOR_IMPLEMENTATION,
    4.84                    'software_version': node.xen_version(),
    4.85 +                  'other_config': node.other_config,
    4.86                    'resident_VMs': dom.get_domain_refs(),
    4.87                    'host_CPUs': node.get_host_cpu_refs(),
    4.88                    'metrics': node.host_metrics_uuid,
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/tools/python/xen/xend/XendAPIVersion.py	Sun Feb 25 17:20:51 2007 +0000
     5.3 @@ -0,0 +1,22 @@
     5.4 +#============================================================================
     5.5 +# This library is free software; you can redistribute it and/or
     5.6 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
     5.7 +# License as published by the Free Software Foundation.
     5.8 +#
     5.9 +# This library is distributed in the hope that it will be useful,
    5.10 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.11 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.12 +# Lesser General Public License for more details.
    5.13 +#
    5.14 +# You should have received a copy of the GNU Lesser General Public
    5.15 +# License along with this library; if not, write to the Free Software
    5.16 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    5.17 +#============================================================================
    5.18 +# Copyright (c) 2007 XenSource Inc.
    5.19 +#============================================================================
    5.20 +
    5.21 +
    5.22 +XEN_API_VERSION_MAJOR = 0
    5.23 +XEN_API_VERSION_MINOR = 5
    5.24 +XEN_API_VERSION_VENDOR = 'xenbits'
    5.25 +XEN_API_VERSION_VENDOR_IMPLEMENTATION = {}