direct-io.hg

changeset 13703:5e8da0663ff8

Added host.other_config.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Jan 30 01:23:58 2007 +0000 (2007-01-30)
parents d794356ad7ff
children fe02bdd43ac1
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/XendNode.py
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Tue Jan 30 00:36:43 2007 +0000
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Tue Jan 30 01:23:58 2007 +0000
     1.3 @@ -3756,6 +3756,7 @@ Quals & Field & Type & Description \\
     1.4  $\mathit{RW}$ &  {\tt name/label} & string & a human-readable name \\
     1.5  $\mathit{RW}$ &  {\tt name/description} & string & a notes field containg human-readable description \\
     1.6  $\mathit{RO}_\mathit{run}$ &  {\tt software\_version} & (string $\rightarrow$ string) Map & version strings \\
     1.7 +$\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
     1.8  $\mathit{RO}_\mathit{run}$ &  {\tt resident\_VMs} & (VM ref) Set & list of VMs currently resident on host \\
     1.9  $\mathit{RO}_\mathit{run}$ &  {\tt PIFs} & (PIF ref) Set & physical network interfaces \\
    1.10  $\mathit{RO}_\mathit{run}$ &  {\tt PBDs} & (PBD ref) Set & physical blockdevices \\
    1.11 @@ -4111,6 +4112,143 @@ value of the field
    1.12  \vspace{0.3cm}
    1.13  \vspace{0.3cm}
    1.14  \vspace{0.3cm}
    1.15 +\subsubsection{RPC name:~get\_other\_config}
    1.16 +
    1.17 +{\bf Overview:} 
    1.18 +Get the other\_config field of the given host.
    1.19 +
    1.20 + \noindent {\bf Signature:} 
    1.21 +\begin{verbatim} ((string -> string) Map) get_other_config (session_id s, host ref self)\end{verbatim}
    1.22 +
    1.23 +
    1.24 +\noindent{\bf Arguments:}
    1.25 +
    1.26 + 
    1.27 +\vspace{0.3cm}
    1.28 +\begin{tabular}{|c|c|p{7cm}|}
    1.29 + \hline
    1.30 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.31 +{\tt host ref } & self & reference to the object \\ \hline 
    1.32 +
    1.33 +\end{tabular}
    1.34 +
    1.35 +\vspace{0.3cm}
    1.36 +
    1.37 + \noindent {\bf Return Type:} 
    1.38 +{\tt 
    1.39 +(string $\rightarrow$ string) Map
    1.40 +}
    1.41 +
    1.42 +
    1.43 +value of the field
    1.44 +\vspace{0.3cm}
    1.45 +\vspace{0.3cm}
    1.46 +\vspace{0.3cm}
    1.47 +\subsubsection{RPC name:~set\_other\_config}
    1.48 +
    1.49 +{\bf Overview:} 
    1.50 +Set the other\_config field of the given host.
    1.51 +
    1.52 + \noindent {\bf Signature:} 
    1.53 +\begin{verbatim} void set_other_config (session_id s, host ref self, (string -> string) Map value)\end{verbatim}
    1.54 +
    1.55 +
    1.56 +\noindent{\bf Arguments:}
    1.57 +
    1.58 + 
    1.59 +\vspace{0.3cm}
    1.60 +\begin{tabular}{|c|c|p{7cm}|}
    1.61 + \hline
    1.62 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.63 +{\tt host ref } & self & reference to the object \\ \hline 
    1.64 +
    1.65 +{\tt (string $\rightarrow$ string) Map } & value & New value to set \\ \hline 
    1.66 +
    1.67 +\end{tabular}
    1.68 +
    1.69 +\vspace{0.3cm}
    1.70 +
    1.71 + \noindent {\bf Return Type:} 
    1.72 +{\tt 
    1.73 +void
    1.74 +}
    1.75 +
    1.76 +
    1.77 +
    1.78 +\vspace{0.3cm}
    1.79 +\vspace{0.3cm}
    1.80 +\vspace{0.3cm}
    1.81 +\subsubsection{RPC name:~add\_to\_other\_config}
    1.82 +
    1.83 +{\bf Overview:} 
    1.84 +Add the given key-value pair to the other\_config field of the given host.
    1.85 +
    1.86 + \noindent {\bf Signature:} 
    1.87 +\begin{verbatim} void add_to_other_config (session_id s, host ref self, string key, string value)\end{verbatim}
    1.88 +
    1.89 +
    1.90 +\noindent{\bf Arguments:}
    1.91 +
    1.92 + 
    1.93 +\vspace{0.3cm}
    1.94 +\begin{tabular}{|c|c|p{7cm}|}
    1.95 + \hline
    1.96 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.97 +{\tt host ref } & self & reference to the object \\ \hline 
    1.98 +
    1.99 +{\tt string } & key & Key to add \\ \hline 
   1.100 +
   1.101 +{\tt string } & value & Value to add \\ \hline 
   1.102 +
   1.103 +\end{tabular}
   1.104 +
   1.105 +\vspace{0.3cm}
   1.106 +
   1.107 + \noindent {\bf Return Type:} 
   1.108 +{\tt 
   1.109 +void
   1.110 +}
   1.111 +
   1.112 +
   1.113 +
   1.114 +\vspace{0.3cm}
   1.115 +\vspace{0.3cm}
   1.116 +\vspace{0.3cm}
   1.117 +\subsubsection{RPC name:~remove\_from\_other\_config}
   1.118 +
   1.119 +{\bf Overview:} 
   1.120 +Remove the given key and its corresponding value from the other\_config
   1.121 +field of the given host.  If the key is not in that Map, then do nothing.
   1.122 +
   1.123 + \noindent {\bf Signature:} 
   1.124 +\begin{verbatim} void remove_from_other_config (session_id s, host ref self, string key)\end{verbatim}
   1.125 +
   1.126 +
   1.127 +\noindent{\bf Arguments:}
   1.128 +
   1.129 + 
   1.130 +\vspace{0.3cm}
   1.131 +\begin{tabular}{|c|c|p{7cm}|}
   1.132 + \hline
   1.133 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.134 +{\tt host ref } & self & reference to the object \\ \hline 
   1.135 +
   1.136 +{\tt string } & key & Key to remove \\ \hline 
   1.137 +
   1.138 +\end{tabular}
   1.139 +
   1.140 +\vspace{0.3cm}
   1.141 +
   1.142 + \noindent {\bf Return Type:} 
   1.143 +{\tt 
   1.144 +void
   1.145 +}
   1.146 +
   1.147 +
   1.148 +
   1.149 +\vspace{0.3cm}
   1.150 +\vspace{0.3cm}
   1.151 +\vspace{0.3cm}
   1.152  \subsubsection{RPC name:~get\_resident\_VMs}
   1.153  
   1.154  {\bf Overview:} 
     2.1 --- a/tools/libxen/include/xen_host.h	Tue Jan 30 00:36:43 2007 +0000
     2.2 +++ b/tools/libxen/include/xen_host.h	Tue Jan 30 01:23:58 2007 +0000
     2.3 @@ -70,6 +70,7 @@ typedef struct xen_host_record
     2.4      char *name_label;
     2.5      char *name_description;
     2.6      xen_string_string_map *software_version;
     2.7 +    xen_string_string_map *other_config;
     2.8      struct xen_vm_record_opt_set *resident_vms;
     2.9      struct xen_pif_record_opt_set *pifs;
    2.10      struct xen_pbd_record_opt_set *pbds;
    2.11 @@ -219,6 +220,13 @@ xen_host_get_software_version(xen_sessio
    2.12  
    2.13  
    2.14  /**
    2.15 + * Get the other_config field of the given host.
    2.16 + */
    2.17 +extern bool
    2.18 +xen_host_get_other_config(xen_session *session, xen_string_string_map **result, xen_host host);
    2.19 +
    2.20 +
    2.21 +/**
    2.22   * Get the resident_VMs field of the given host.
    2.23   */
    2.24  extern bool
    2.25 @@ -261,6 +269,30 @@ xen_host_set_name_description(xen_sessio
    2.26  
    2.27  
    2.28  /**
    2.29 + * Set the other_config field of the given host.
    2.30 + */
    2.31 +extern bool
    2.32 +xen_host_set_other_config(xen_session *session, xen_host host, xen_string_string_map *other_config);
    2.33 +
    2.34 +
    2.35 +/**
    2.36 + * Add the given key-value pair to the other_config field of the given
    2.37 + * host.
    2.38 + */
    2.39 +extern bool
    2.40 +xen_host_add_to_other_config(xen_session *session, xen_host host, char *key, char *value);
    2.41 +
    2.42 +
    2.43 +/**
    2.44 + * Remove the given key and its corresponding value from the
    2.45 + * other_config field of the given host.  If the key is not in that Map, then
    2.46 + * do nothing.
    2.47 + */
    2.48 +extern bool
    2.49 +xen_host_remove_from_other_config(xen_session *session, xen_host host, char *key);
    2.50 +
    2.51 +
    2.52 +/**
    2.53   * Puts the host into a state in which no new VMs can be started.
    2.54   * Currently active VMs on the host continue to execute.
    2.55   */
     3.1 --- a/tools/libxen/src/xen_host.c	Tue Jan 30 00:36:43 2007 +0000
     3.2 +++ b/tools/libxen/src/xen_host.c	Tue Jan 30 01:23:58 2007 +0000
     3.3 @@ -53,6 +53,9 @@ static const struct_member xen_host_reco
     3.4          { .key = "software_version",
     3.5            .type = &abstract_type_string_string_map,
     3.6            .offset = offsetof(xen_host_record, software_version) },
     3.7 +        { .key = "other_config",
     3.8 +          .type = &abstract_type_string_string_map,
     3.9 +          .offset = offsetof(xen_host_record, other_config) },
    3.10          { .key = "resident_VMs",
    3.11            .type = &abstract_type_ref_set,
    3.12            .offset = offsetof(xen_host_record, resident_vms) },
    3.13 @@ -89,6 +92,7 @@ xen_host_record_free(xen_host_record *re
    3.14      free(record->name_label);
    3.15      free(record->name_description);
    3.16      xen_string_string_map_free(record->software_version);
    3.17 +    xen_string_string_map_free(record->other_config);
    3.18      xen_vm_record_opt_set_free(record->resident_vms);
    3.19      xen_pif_record_opt_set_free(record->pifs);
    3.20      xen_pbd_record_opt_set_free(record->pbds);
    3.21 @@ -237,6 +241,23 @@ xen_host_get_software_version(xen_sessio
    3.22  
    3.23  
    3.24  bool
    3.25 +xen_host_get_other_config(xen_session *session, xen_string_string_map **result, xen_host host)
    3.26 +{
    3.27 +    abstract_value param_values[] =
    3.28 +        {
    3.29 +            { .type = &abstract_type_string,
    3.30 +              .u.string_val = host }
    3.31 +        };
    3.32 +
    3.33 +    abstract_type result_type = abstract_type_string_string_map;
    3.34 +
    3.35 +    *result = NULL;
    3.36 +    XEN_CALL_("host.get_other_config");
    3.37 +    return session->ok;
    3.38 +}
    3.39 +
    3.40 +
    3.41 +bool
    3.42  xen_host_get_resident_vms(xen_session *session, struct xen_vm_set **result, xen_host host)
    3.43  {
    3.44      abstract_value param_values[] =
    3.45 @@ -337,6 +358,56 @@ xen_host_set_name_description(xen_sessio
    3.46  
    3.47  
    3.48  bool
    3.49 +xen_host_set_other_config(xen_session *session, xen_host host, xen_string_string_map *other_config)
    3.50 +{
    3.51 +    abstract_value param_values[] =
    3.52 +        {
    3.53 +            { .type = &abstract_type_string,
    3.54 +              .u.string_val = host },
    3.55 +            { .type = &abstract_type_string_string_map,
    3.56 +              .u.set_val = (arbitrary_set *)other_config }
    3.57 +        };
    3.58 +
    3.59 +    xen_call_(session, "host.set_other_config", param_values, 2, NULL, NULL);
    3.60 +    return session->ok;
    3.61 +}
    3.62 +
    3.63 +
    3.64 +bool
    3.65 +xen_host_add_to_other_config(xen_session *session, xen_host host, char *key, char *value)
    3.66 +{
    3.67 +    abstract_value param_values[] =
    3.68 +        {
    3.69 +            { .type = &abstract_type_string,
    3.70 +              .u.string_val = host },
    3.71 +            { .type = &abstract_type_string,
    3.72 +              .u.string_val = key },
    3.73 +            { .type = &abstract_type_string,
    3.74 +              .u.string_val = value }
    3.75 +        };
    3.76 +
    3.77 +    xen_call_(session, "host.add_to_other_config", param_values, 3, NULL, NULL);
    3.78 +    return session->ok;
    3.79 +}
    3.80 +
    3.81 +
    3.82 +bool
    3.83 +xen_host_remove_from_other_config(xen_session *session, xen_host host, char *key)
    3.84 +{
    3.85 +    abstract_value param_values[] =
    3.86 +        {
    3.87 +            { .type = &abstract_type_string,
    3.88 +              .u.string_val = host },
    3.89 +            { .type = &abstract_type_string,
    3.90 +              .u.string_val = key }
    3.91 +        };
    3.92 +
    3.93 +    xen_call_(session, "host.remove_from_other_config", param_values, 2, NULL, NULL);
    3.94 +    return session->ok;
    3.95 +}
    3.96 +
    3.97 +
    3.98 +bool
    3.99  xen_host_disable(xen_session *session, xen_host host)
   3.100  {
   3.101      abstract_value param_values[] =
     4.1 --- a/tools/python/xen/xend/XendAPI.py	Tue Jan 30 00:36:43 2007 +0000
     4.2 +++ b/tools/python/xen/xend/XendAPI.py	Tue Jan 30 01:23:58 2007 +0000
     4.3 @@ -581,12 +581,15 @@ class XendAPI(object):
     4.4                      'host_CPUs']
     4.5      
     4.6      host_attr_rw = ['name_label',
     4.7 -                    'name_description']
     4.8 +                    'name_description',
     4.9 +                    'other_config']
    4.10  
    4.11      host_methods = [('disable', None),
    4.12                      ('enable', None),
    4.13                      ('reboot', None),
    4.14 -                    ('shutdown', None)]
    4.15 +                    ('shutdown', None),
    4.16 +                    ('add_to_other_config', None),
    4.17 +                    ('remove_from_other_config', None)]
    4.18      
    4.19      host_funcs = [('get_by_name_label', 'Set(host)')]
    4.20  
    4.21 @@ -601,6 +604,23 @@ class XendAPI(object):
    4.22      def host_set_name_description(self, session, host_ref, new_desc):
    4.23          XendNode.instance().set_description(new_desc)
    4.24          return xen_api_success_void()
    4.25 +    def host_get_other_config(self, session, host_ref):
    4.26 +        return xen_api_success(XendNode.instance().other_config)
    4.27 +    def host_set_other_config(self, session, host_ref, other_config):
    4.28 +        node = XendNode.instance()
    4.29 +        node.other_config = dict(other_config)
    4.30 +        node.save()
    4.31 +        return xen_api_success_void()
    4.32 +    def host_add_to_other_config(self, session, host_ref, key, value):
    4.33 +        node = XendNode.instance()
    4.34 +        node.other_config[key] = value
    4.35 +        node.save()
    4.36 +        return xen_api_success_void()
    4.37 +    def host_remove_from_other_config(self, session, host_ref, key):
    4.38 +        node = XendNode.instance()
    4.39 +        del node.other_config[key]
    4.40 +        node.save()
    4.41 +        return xen_api_success_void()
    4.42      def host_get_software_version(self, session, host_ref):
    4.43          return xen_api_success(XendNode.instance().xen_version())
    4.44      def host_get_resident_VMs(self, session, host_ref):
     5.1 --- a/tools/python/xen/xend/XendNode.py	Tue Jan 30 00:36:43 2007 +0000
     5.2 +++ b/tools/python/xen/xend/XendNode.py	Tue Jan 30 01:23:58 2007 +0000
     5.3 @@ -59,11 +59,16 @@ class XendNode:
     5.4              host = saved_host[self.uuid]
     5.5              self.name = host.get('name_label', socket.gethostname())
     5.6              self.desc = host.get('name_description', '')
     5.7 +            try:
     5.8 +                self.other_config = eval(host['other_config'])
     5.9 +            except:
    5.10 +                self.other_config = {}
    5.11              self.cpus = {}
    5.12          else:
    5.13              self.uuid = uuid.createString()
    5.14              self.name = socket.gethostname()
    5.15              self.desc = ''
    5.16 +            self.other_config = {}
    5.17              self.cpus = {}
    5.18              
    5.19          # load CPU UUIDs
    5.20 @@ -218,7 +223,8 @@ class XendNode:
    5.21      def save(self):
    5.22          # save state
    5.23          host_record = {self.uuid: {'name_label':self.name,
    5.24 -                                   'name_description':self.desc}}
    5.25 +                                   'name_description':self.desc,
    5.26 +                                   'other_config': repr(self.other_config)}}
    5.27          self.state_store.save_state('host',host_record)
    5.28          self.state_store.save_state('cpu', self.cpus)
    5.29          self.save_PIFs()