[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Added host.other_config.



# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1170120238 0
# Node ID 5e8da0663ff863c9de8948b72399e591f34828a2
# Parent  d794356ad7ff70144cfa025f7417e943ddbcf1ea
Added host.other_config.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 docs/xen-api/xenapi-datamodel.tex |  138 ++++++++++++++++++++++++++++++++++++++
 tools/libxen/include/xen_host.h   |   32 ++++++++
 tools/libxen/src/xen_host.c       |   71 +++++++++++++++++++
 tools/python/xen/xend/XendAPI.py  |   24 ++++++
 tools/python/xen/xend/XendNode.py |    8 +-
 5 files changed, 270 insertions(+), 3 deletions(-)

diff -r d794356ad7ff -r 5e8da0663ff8 docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Tue Jan 30 00:36:43 2007 +0000
+++ b/docs/xen-api/xenapi-datamodel.tex Tue Jan 30 01:23:58 2007 +0000
@@ -3756,6 +3756,7 @@ Quals & Field & Type & Description \\
 $\mathit{RW}$ &  {\tt name/label} & string & a human-readable name \\
 $\mathit{RW}$ &  {\tt name/description} & string & a notes field containg 
human-readable description \\
 $\mathit{RO}_\mathit{run}$ &  {\tt software\_version} & (string $\rightarrow$ 
string) Map & version strings \\
+$\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & 
additional configuration \\
 $\mathit{RO}_\mathit{run}$ &  {\tt resident\_VMs} & (VM ref) Set & list of VMs 
currently resident on host \\
 $\mathit{RO}_\mathit{run}$ &  {\tt PIFs} & (PIF ref) Set & physical network 
interfaces \\
 $\mathit{RO}_\mathit{run}$ &  {\tt PBDs} & (PBD ref) Set & physical 
blockdevices \\
@@ -4108,6 +4109,143 @@ Get the software\_version field of the g
 
 
 value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_other\_config}
+
+{\bf Overview:} 
+Get the other\_config field of the given host.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} ((string -> string) Map) get_other_config (session_id s, host 
ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt host ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+(string $\rightarrow$ string) Map
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_other\_config}
+
+{\bf Overview:} 
+Set the other\_config field of the given host.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void set_other_config (session_id s, host ref self, (string 
-> string) Map value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt host ref } & self & reference to the object \\ \hline 
+
+{\tt (string $\rightarrow$ string) Map } & value & New value to set \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~add\_to\_other\_config}
+
+{\bf Overview:} 
+Add the given key-value pair to the other\_config field of the given host.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void add_to_other_config (session_id s, host ref self, string 
key, string value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt host ref } & self & reference to the object \\ \hline 
+
+{\tt string } & key & Key to add \\ \hline 
+
+{\tt string } & value & Value to add \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~remove\_from\_other\_config}
+
+{\bf Overview:} 
+Remove the given key and its corresponding value from the other\_config
+field of the given host.  If the key is not in that Map, then do nothing.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void remove_from_other_config (session_id s, host ref self, 
string key)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt host ref } & self & reference to the object \\ \hline 
+
+{\tt string } & key & Key to remove \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
diff -r d794356ad7ff -r 5e8da0663ff8 tools/libxen/include/xen_host.h
--- a/tools/libxen/include/xen_host.h   Tue Jan 30 00:36:43 2007 +0000
+++ b/tools/libxen/include/xen_host.h   Tue Jan 30 01:23:58 2007 +0000
@@ -70,6 +70,7 @@ typedef struct xen_host_record
     char *name_label;
     char *name_description;
     xen_string_string_map *software_version;
+    xen_string_string_map *other_config;
     struct xen_vm_record_opt_set *resident_vms;
     struct xen_pif_record_opt_set *pifs;
     struct xen_pbd_record_opt_set *pbds;
@@ -219,6 +220,13 @@ xen_host_get_software_version(xen_sessio
 
 
 /**
+ * Get the other_config field of the given host.
+ */
+extern bool
+xen_host_get_other_config(xen_session *session, xen_string_string_map 
**result, xen_host host);
+
+
+/**
  * Get the resident_VMs field of the given host.
  */
 extern bool
@@ -258,6 +266,30 @@ xen_host_set_name_label(xen_session *ses
  */
 extern bool
 xen_host_set_name_description(xen_session *session, xen_host host, char 
*description);
+
+
+/**
+ * Set the other_config field of the given host.
+ */
+extern bool
+xen_host_set_other_config(xen_session *session, xen_host host, 
xen_string_string_map *other_config);
+
+
+/**
+ * Add the given key-value pair to the other_config field of the given
+ * host.
+ */
+extern bool
+xen_host_add_to_other_config(xen_session *session, xen_host host, char *key, 
char *value);
+
+
+/**
+ * Remove the given key and its corresponding value from the
+ * other_config field of the given host.  If the key is not in that Map, then
+ * do nothing.
+ */
+extern bool
+xen_host_remove_from_other_config(xen_session *session, xen_host host, char 
*key);
 
 
 /**
diff -r d794356ad7ff -r 5e8da0663ff8 tools/libxen/src/xen_host.c
--- a/tools/libxen/src/xen_host.c       Tue Jan 30 00:36:43 2007 +0000
+++ b/tools/libxen/src/xen_host.c       Tue Jan 30 01:23:58 2007 +0000
@@ -53,6 +53,9 @@ static const struct_member xen_host_reco
         { .key = "software_version",
           .type = &abstract_type_string_string_map,
           .offset = offsetof(xen_host_record, software_version) },
+        { .key = "other_config",
+          .type = &abstract_type_string_string_map,
+          .offset = offsetof(xen_host_record, other_config) },
         { .key = "resident_VMs",
           .type = &abstract_type_ref_set,
           .offset = offsetof(xen_host_record, resident_vms) },
@@ -89,6 +92,7 @@ xen_host_record_free(xen_host_record *re
     free(record->name_label);
     free(record->name_description);
     xen_string_string_map_free(record->software_version);
+    xen_string_string_map_free(record->other_config);
     xen_vm_record_opt_set_free(record->resident_vms);
     xen_pif_record_opt_set_free(record->pifs);
     xen_pbd_record_opt_set_free(record->pbds);
@@ -237,6 +241,23 @@ xen_host_get_software_version(xen_sessio
 
 
 bool
+xen_host_get_other_config(xen_session *session, xen_string_string_map 
**result, xen_host host)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = host }
+        };
+
+    abstract_type result_type = abstract_type_string_string_map;
+
+    *result = NULL;
+    XEN_CALL_("host.get_other_config");
+    return session->ok;
+}
+
+
+bool
 xen_host_get_resident_vms(xen_session *session, struct xen_vm_set **result, 
xen_host host)
 {
     abstract_value param_values[] =
@@ -337,6 +358,56 @@ xen_host_set_name_description(xen_sessio
 
 
 bool
+xen_host_set_other_config(xen_session *session, xen_host host, 
xen_string_string_map *other_config)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = host },
+            { .type = &abstract_type_string_string_map,
+              .u.set_val = (arbitrary_set *)other_config }
+        };
+
+    xen_call_(session, "host.set_other_config", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
+xen_host_add_to_other_config(xen_session *session, xen_host host, char *key, 
char *value)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = host },
+            { .type = &abstract_type_string,
+              .u.string_val = key },
+            { .type = &abstract_type_string,
+              .u.string_val = value }
+        };
+
+    xen_call_(session, "host.add_to_other_config", param_values, 3, NULL, 
NULL);
+    return session->ok;
+}
+
+
+bool
+xen_host_remove_from_other_config(xen_session *session, xen_host host, char 
*key)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = host },
+            { .type = &abstract_type_string,
+              .u.string_val = key }
+        };
+
+    xen_call_(session, "host.remove_from_other_config", param_values, 2, NULL, 
NULL);
+    return session->ok;
+}
+
+
+bool
 xen_host_disable(xen_session *session, xen_host host)
 {
     abstract_value param_values[] =
diff -r d794356ad7ff -r 5e8da0663ff8 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Tue Jan 30 00:36:43 2007 +0000
+++ b/tools/python/xen/xend/XendAPI.py  Tue Jan 30 01:23:58 2007 +0000
@@ -581,12 +581,15 @@ class XendAPI(object):
                     'host_CPUs']
     
     host_attr_rw = ['name_label',
-                    'name_description']
+                    'name_description',
+                    'other_config']
 
     host_methods = [('disable', None),
                     ('enable', None),
                     ('reboot', None),
-                    ('shutdown', None)]
+                    ('shutdown', None),
+                    ('add_to_other_config', None),
+                    ('remove_from_other_config', None)]
     
     host_funcs = [('get_by_name_label', 'Set(host)')]
 
@@ -600,6 +603,23 @@ class XendAPI(object):
         return xen_api_success(XendNode.instance().description)
     def host_set_name_description(self, session, host_ref, new_desc):
         XendNode.instance().set_description(new_desc)
+        return xen_api_success_void()
+    def host_get_other_config(self, session, host_ref):
+        return xen_api_success(XendNode.instance().other_config)
+    def host_set_other_config(self, session, host_ref, other_config):
+        node = XendNode.instance()
+        node.other_config = dict(other_config)
+        node.save()
+        return xen_api_success_void()
+    def host_add_to_other_config(self, session, host_ref, key, value):
+        node = XendNode.instance()
+        node.other_config[key] = value
+        node.save()
+        return xen_api_success_void()
+    def host_remove_from_other_config(self, session, host_ref, key):
+        node = XendNode.instance()
+        del node.other_config[key]
+        node.save()
         return xen_api_success_void()
     def host_get_software_version(self, session, host_ref):
         return xen_api_success(XendNode.instance().xen_version())
diff -r d794356ad7ff -r 5e8da0663ff8 tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Tue Jan 30 00:36:43 2007 +0000
+++ b/tools/python/xen/xend/XendNode.py Tue Jan 30 01:23:58 2007 +0000
@@ -59,11 +59,16 @@ class XendNode:
             host = saved_host[self.uuid]
             self.name = host.get('name_label', socket.gethostname())
             self.desc = host.get('name_description', '')
+            try:
+                self.other_config = eval(host['other_config'])
+            except:
+                self.other_config = {}
             self.cpus = {}
         else:
             self.uuid = uuid.createString()
             self.name = socket.gethostname()
             self.desc = ''
+            self.other_config = {}
             self.cpus = {}
             
         # load CPU UUIDs
@@ -218,7 +223,8 @@ class XendNode:
     def save(self):
         # save state
         host_record = {self.uuid: {'name_label':self.name,
-                                   'name_description':self.desc}}
+                                   'name_description':self.desc,
+                                   'other_config': repr(self.other_config)}}
         self.state_store.save_state('host',host_record)
         self.state_store.save_state('cpu', self.cpus)
         self.save_PIFs()

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.