ia64/xen-unstable

changeset 14536:678b8838d361

Add a last_updated field to every metrics class.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Fri Mar 23 13:27:29 2007 +0000 (2007-03-23)
parents 931c4b77ea7d
children 6f2f72f39872
files docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen_host_metrics.h tools/libxen/include/xen_pif_metrics.h tools/libxen/include/xen_vbd_metrics.h tools/libxen/include/xen_vif_metrics.h tools/libxen/include/xen_vm_guest_metrics.h tools/libxen/include/xen_vm_metrics.h tools/libxen/src/xen_host_metrics.c tools/libxen/src/xen_pif_metrics.c tools/libxen/src/xen_vbd_metrics.c tools/libxen/src/xen_vif_metrics.c tools/libxen/src/xen_vm_guest_metrics.c tools/libxen/src/xen_vm_metrics.c tools/libxen/test/test_bindings.c tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendPIFMetrics.py tools/python/xen/xend/XendVMMetrics.py
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Fri Mar 23 13:26:08 2007 +0000
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Fri Mar 23 13:27:29 2007 +0000
     1.3 @@ -3983,6 +3983,7 @@ Quals & Field & Type & Description \\
     1.4  $\mathit{RO}_\mathit{run}$ &  {\tt memory/actual} & int & Guest's actual memory (bytes) \\
     1.5  $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/number} & int & Current number of VCPUs \\
     1.6  $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/utilisation} & (int $\rightarrow$ float) Map & Utilisation for all of guest's current VCPUs \\
     1.7 +$\mathit{RO}_\mathit{run}$ &  {\tt last\_updated} & datetime & Time at which this information was last updated \\
     1.8  \hline
     1.9  \end{longtable}
    1.10  \subsection{RPCs associated with class: VM\_metrics}
    1.11 @@ -4135,6 +4136,38 @@ 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\_last\_updated}
    1.16 +
    1.17 +{\bf Overview:} 
    1.18 +Get the last\_updated field of the given VM\_metrics.
    1.19 +
    1.20 + \noindent {\bf Signature:} 
    1.21 +\begin{verbatim} datetime get_last_updated (session_id s, VM_metrics 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 VM\_metrics 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 +datetime
    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:~get\_by\_uuid}
    1.48  
    1.49  {\bf Overview:} 
    1.50 @@ -4219,6 +4252,7 @@ Quals & Field & Type & Description \\
    1.51  $\mathit{RO}_\mathit{run}$ &  {\tt disks} & (string $\rightarrow$ string) Map & disk configuration/free space \\
    1.52  $\mathit{RO}_\mathit{run}$ &  {\tt networks} & (string $\rightarrow$ string) Map & network configuration \\
    1.53  $\mathit{RO}_\mathit{run}$ &  {\tt other} & (string $\rightarrow$ string) Map & anything else \\
    1.54 +$\mathit{RO}_\mathit{run}$ &  {\tt last\_updated} & datetime & Time at which this information was last updated \\
    1.55  \hline
    1.56  \end{longtable}
    1.57  \subsection{RPCs associated with class: VM\_guest\_metrics}
    1.58 @@ -4467,6 +4501,38 @@ value of the field
    1.59  \vspace{0.3cm}
    1.60  \vspace{0.3cm}
    1.61  \vspace{0.3cm}
    1.62 +\subsubsection{RPC name:~get\_last\_updated}
    1.63 +
    1.64 +{\bf Overview:} 
    1.65 +Get the last\_updated field of the given VM\_guest\_metrics.
    1.66 +
    1.67 + \noindent {\bf Signature:} 
    1.68 +\begin{verbatim} datetime get_last_updated (session_id s, VM_guest_metrics ref self)\end{verbatim}
    1.69 +
    1.70 +
    1.71 +\noindent{\bf Arguments:}
    1.72 +
    1.73 + 
    1.74 +\vspace{0.3cm}
    1.75 +\begin{tabular}{|c|c|p{7cm}|}
    1.76 + \hline
    1.77 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.78 +{\tt VM\_guest\_metrics ref } & self & reference to the object \\ \hline 
    1.79 +
    1.80 +\end{tabular}
    1.81 +
    1.82 +\vspace{0.3cm}
    1.83 +
    1.84 + \noindent {\bf Return Type:} 
    1.85 +{\tt 
    1.86 +datetime
    1.87 +}
    1.88 +
    1.89 +
    1.90 +value of the field
    1.91 +\vspace{0.3cm}
    1.92 +\vspace{0.3cm}
    1.93 +\vspace{0.3cm}
    1.94  \subsubsection{RPC name:~get\_by\_uuid}
    1.95  
    1.96  {\bf Overview:} 
    1.97 @@ -5816,6 +5882,7 @@ Quals & Field & Type & Description \\
    1.98  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
    1.99  $\mathit{RO}_\mathit{run}$ &  {\tt memory/total} & int & Host's total memory (bytes) \\
   1.100  $\mathit{RO}_\mathit{run}$ &  {\tt memory/free} & int & Host's free memory (bytes) \\
   1.101 +$\mathit{RO}_\mathit{run}$ &  {\tt last\_updated} & datetime & Time at which this information was last updated \\
   1.102  \hline
   1.103  \end{longtable}
   1.104  \subsection{RPCs associated with class: host\_metrics}
   1.105 @@ -5936,6 +6003,38 @@ value of the field
   1.106  \vspace{0.3cm}
   1.107  \vspace{0.3cm}
   1.108  \vspace{0.3cm}
   1.109 +\subsubsection{RPC name:~get\_last\_updated}
   1.110 +
   1.111 +{\bf Overview:} 
   1.112 +Get the last\_updated field of the given host\_metrics.
   1.113 +
   1.114 + \noindent {\bf Signature:} 
   1.115 +\begin{verbatim} datetime get_last_updated (session_id s, host_metrics ref self)\end{verbatim}
   1.116 +
   1.117 +
   1.118 +\noindent{\bf Arguments:}
   1.119 +
   1.120 + 
   1.121 +\vspace{0.3cm}
   1.122 +\begin{tabular}{|c|c|p{7cm}|}
   1.123 + \hline
   1.124 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.125 +{\tt host\_metrics ref } & self & reference to the object \\ \hline 
   1.126 +
   1.127 +\end{tabular}
   1.128 +
   1.129 +\vspace{0.3cm}
   1.130 +
   1.131 + \noindent {\bf Return Type:} 
   1.132 +{\tt 
   1.133 +datetime
   1.134 +}
   1.135 +
   1.136 +
   1.137 +value of the field
   1.138 +\vspace{0.3cm}
   1.139 +\vspace{0.3cm}
   1.140 +\vspace{0.3cm}
   1.141  \subsubsection{RPC name:~get\_by\_uuid}
   1.142  
   1.143  {\bf Overview:} 
   1.144 @@ -7745,6 +7844,7 @@ Quals & Field & Type & Description \\
   1.145  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
   1.146  $\mathit{RO}_\mathit{run}$ &  {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\
   1.147  $\mathit{RO}_\mathit{run}$ &  {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\
   1.148 +$\mathit{RO}_\mathit{run}$ &  {\tt last\_updated} & datetime & Time at which this information was last updated \\
   1.149  \hline
   1.150  \end{longtable}
   1.151  \subsection{RPCs associated with class: VIF\_metrics}
   1.152 @@ -7865,6 +7965,38 @@ value of the field
   1.153  \vspace{0.3cm}
   1.154  \vspace{0.3cm}
   1.155  \vspace{0.3cm}
   1.156 +\subsubsection{RPC name:~get\_last\_updated}
   1.157 +
   1.158 +{\bf Overview:} 
   1.159 +Get the last\_updated field of the given VIF\_metrics.
   1.160 +
   1.161 + \noindent {\bf Signature:} 
   1.162 +\begin{verbatim} datetime get_last_updated (session_id s, VIF_metrics ref self)\end{verbatim}
   1.163 +
   1.164 +
   1.165 +\noindent{\bf Arguments:}
   1.166 +
   1.167 + 
   1.168 +\vspace{0.3cm}
   1.169 +\begin{tabular}{|c|c|p{7cm}|}
   1.170 + \hline
   1.171 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.172 +{\tt VIF\_metrics ref } & self & reference to the object \\ \hline 
   1.173 +
   1.174 +\end{tabular}
   1.175 +
   1.176 +\vspace{0.3cm}
   1.177 +
   1.178 + \noindent {\bf Return Type:} 
   1.179 +{\tt 
   1.180 +datetime
   1.181 +}
   1.182 +
   1.183 +
   1.184 +value of the field
   1.185 +\vspace{0.3cm}
   1.186 +\vspace{0.3cm}
   1.187 +\vspace{0.3cm}
   1.188  \subsubsection{RPC name:~get\_by\_uuid}
   1.189  
   1.190  {\bf Overview:} 
   1.191 @@ -8522,6 +8654,7 @@ Quals & Field & Type & Description \\
   1.192  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
   1.193  $\mathit{RO}_\mathit{run}$ &  {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\
   1.194  $\mathit{RO}_\mathit{run}$ &  {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\
   1.195 +$\mathit{RO}_\mathit{run}$ &  {\tt last\_updated} & datetime & Time at which this information was last updated \\
   1.196  \hline
   1.197  \end{longtable}
   1.198  \subsection{RPCs associated with class: PIF\_metrics}
   1.199 @@ -8642,6 +8775,38 @@ value of the field
   1.200  \vspace{0.3cm}
   1.201  \vspace{0.3cm}
   1.202  \vspace{0.3cm}
   1.203 +\subsubsection{RPC name:~get\_last\_updated}
   1.204 +
   1.205 +{\bf Overview:} 
   1.206 +Get the last\_updated field of the given PIF\_metrics.
   1.207 +
   1.208 + \noindent {\bf Signature:} 
   1.209 +\begin{verbatim} datetime get_last_updated (session_id s, PIF_metrics ref self)\end{verbatim}
   1.210 +
   1.211 +
   1.212 +\noindent{\bf Arguments:}
   1.213 +
   1.214 + 
   1.215 +\vspace{0.3cm}
   1.216 +\begin{tabular}{|c|c|p{7cm}|}
   1.217 + \hline
   1.218 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.219 +{\tt PIF\_metrics ref } & self & reference to the object \\ \hline 
   1.220 +
   1.221 +\end{tabular}
   1.222 +
   1.223 +\vspace{0.3cm}
   1.224 +
   1.225 + \noindent {\bf Return Type:} 
   1.226 +{\tt 
   1.227 +datetime
   1.228 +}
   1.229 +
   1.230 +
   1.231 +value of the field
   1.232 +\vspace{0.3cm}
   1.233 +\vspace{0.3cm}
   1.234 +\vspace{0.3cm}
   1.235  \subsubsection{RPC name:~get\_by\_uuid}
   1.236  
   1.237  {\bf Overview:} 
   1.238 @@ -11293,6 +11458,7 @@ Quals & Field & Type & Description \\
   1.239  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
   1.240  $\mathit{RO}_\mathit{run}$ &  {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\
   1.241  $\mathit{RO}_\mathit{run}$ &  {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\
   1.242 +$\mathit{RO}_\mathit{run}$ &  {\tt last\_updated} & datetime & Time at which this information was last updated \\
   1.243  \hline
   1.244  \end{longtable}
   1.245  \subsection{RPCs associated with class: VBD\_metrics}
   1.246 @@ -11413,6 +11579,38 @@ value of the field
   1.247  \vspace{0.3cm}
   1.248  \vspace{0.3cm}
   1.249  \vspace{0.3cm}
   1.250 +\subsubsection{RPC name:~get\_last\_updated}
   1.251 +
   1.252 +{\bf Overview:} 
   1.253 +Get the last\_updated field of the given VBD\_metrics.
   1.254 +
   1.255 + \noindent {\bf Signature:} 
   1.256 +\begin{verbatim} datetime get_last_updated (session_id s, VBD_metrics ref self)\end{verbatim}
   1.257 +
   1.258 +
   1.259 +\noindent{\bf Arguments:}
   1.260 +
   1.261 + 
   1.262 +\vspace{0.3cm}
   1.263 +\begin{tabular}{|c|c|p{7cm}|}
   1.264 + \hline
   1.265 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.266 +{\tt VBD\_metrics ref } & self & reference to the object \\ \hline 
   1.267 +
   1.268 +\end{tabular}
   1.269 +
   1.270 +\vspace{0.3cm}
   1.271 +
   1.272 + \noindent {\bf Return Type:} 
   1.273 +{\tt 
   1.274 +datetime
   1.275 +}
   1.276 +
   1.277 +
   1.278 +value of the field
   1.279 +\vspace{0.3cm}
   1.280 +\vspace{0.3cm}
   1.281 +\vspace{0.3cm}
   1.282  \subsubsection{RPC name:~get\_by\_uuid}
   1.283  
   1.284  {\bf Overview:} 
     2.1 --- a/tools/libxen/include/xen_host_metrics.h	Fri Mar 23 13:26:08 2007 +0000
     2.2 +++ b/tools/libxen/include/xen_host_metrics.h	Fri Mar 23 13:27:29 2007 +0000
     2.3 @@ -64,6 +64,7 @@ typedef struct xen_host_metrics_record
     2.4      char *uuid;
     2.5      int64_t memory_total;
     2.6      int64_t memory_free;
     2.7 +    time_t last_updated;
     2.8  } xen_host_metrics_record;
     2.9  
    2.10  /**
    2.11 @@ -182,6 +183,13 @@ xen_host_metrics_get_memory_free(xen_ses
    2.12  
    2.13  
    2.14  /**
    2.15 + * Get the last_updated field of the given host_metrics.
    2.16 + */
    2.17 +extern bool
    2.18 +xen_host_metrics_get_last_updated(xen_session *session, time_t *result, xen_host_metrics host_metrics);
    2.19 +
    2.20 +
    2.21 +/**
    2.22   * Return a list of all the host_metrics instances known to the system.
    2.23   */
    2.24  extern bool
     3.1 --- a/tools/libxen/include/xen_pif_metrics.h	Fri Mar 23 13:26:08 2007 +0000
     3.2 +++ b/tools/libxen/include/xen_pif_metrics.h	Fri Mar 23 13:27:29 2007 +0000
     3.3 @@ -64,6 +64,7 @@ typedef struct xen_pif_metrics_record
     3.4      char *uuid;
     3.5      double io_read_kbs;
     3.6      double io_write_kbs;
     3.7 +    time_t last_updated;
     3.8  } xen_pif_metrics_record;
     3.9  
    3.10  /**
    3.11 @@ -181,6 +182,13 @@ xen_pif_metrics_get_io_write_kbs(xen_ses
    3.12  
    3.13  
    3.14  /**
    3.15 + * Get the last_updated field of the given PIF_metrics.
    3.16 + */
    3.17 +extern bool
    3.18 +xen_pif_metrics_get_last_updated(xen_session *session, time_t *result, xen_pif_metrics pif_metrics);
    3.19 +
    3.20 +
    3.21 +/**
    3.22   * Return a list of all the PIF_metrics instances known to the system.
    3.23   */
    3.24  extern bool
     4.1 --- a/tools/libxen/include/xen_vbd_metrics.h	Fri Mar 23 13:26:08 2007 +0000
     4.2 +++ b/tools/libxen/include/xen_vbd_metrics.h	Fri Mar 23 13:27:29 2007 +0000
     4.3 @@ -64,6 +64,7 @@ typedef struct xen_vbd_metrics_record
     4.4      char *uuid;
     4.5      double io_read_kbs;
     4.6      double io_write_kbs;
     4.7 +    time_t last_updated;
     4.8  } xen_vbd_metrics_record;
     4.9  
    4.10  /**
    4.11 @@ -181,6 +182,13 @@ xen_vbd_metrics_get_io_write_kbs(xen_ses
    4.12  
    4.13  
    4.14  /**
    4.15 + * Get the last_updated field of the given VBD_metrics.
    4.16 + */
    4.17 +extern bool
    4.18 +xen_vbd_metrics_get_last_updated(xen_session *session, time_t *result, xen_vbd_metrics vbd_metrics);
    4.19 +
    4.20 +
    4.21 +/**
    4.22   * Return a list of all the VBD_metrics instances known to the system.
    4.23   */
    4.24  extern bool
     5.1 --- a/tools/libxen/include/xen_vif_metrics.h	Fri Mar 23 13:26:08 2007 +0000
     5.2 +++ b/tools/libxen/include/xen_vif_metrics.h	Fri Mar 23 13:27:29 2007 +0000
     5.3 @@ -64,6 +64,7 @@ typedef struct xen_vif_metrics_record
     5.4      char *uuid;
     5.5      double io_read_kbs;
     5.6      double io_write_kbs;
     5.7 +    time_t last_updated;
     5.8  } xen_vif_metrics_record;
     5.9  
    5.10  /**
    5.11 @@ -181,6 +182,13 @@ xen_vif_metrics_get_io_write_kbs(xen_ses
    5.12  
    5.13  
    5.14  /**
    5.15 + * Get the last_updated field of the given VIF_metrics.
    5.16 + */
    5.17 +extern bool
    5.18 +xen_vif_metrics_get_last_updated(xen_session *session, time_t *result, xen_vif_metrics vif_metrics);
    5.19 +
    5.20 +
    5.21 +/**
    5.22   * Return a list of all the VIF_metrics instances known to the system.
    5.23   */
    5.24  extern bool
     6.1 --- a/tools/libxen/include/xen_vm_guest_metrics.h	Fri Mar 23 13:26:08 2007 +0000
     6.2 +++ b/tools/libxen/include/xen_vm_guest_metrics.h	Fri Mar 23 13:27:29 2007 +0000
     6.3 @@ -69,6 +69,7 @@ typedef struct xen_vm_guest_metrics_reco
     6.4      xen_string_string_map *disks;
     6.5      xen_string_string_map *networks;
     6.6      xen_string_string_map *other;
     6.7 +    time_t last_updated;
     6.8  } xen_vm_guest_metrics_record;
     6.9  
    6.10  /**
    6.11 @@ -216,6 +217,13 @@ xen_vm_guest_metrics_get_other(xen_sessi
    6.12  
    6.13  
    6.14  /**
    6.15 + * Get the last_updated field of the given VM_guest_metrics.
    6.16 + */
    6.17 +extern bool
    6.18 +xen_vm_guest_metrics_get_last_updated(xen_session *session, time_t *result, xen_vm_guest_metrics vm_guest_metrics);
    6.19 +
    6.20 +
    6.21 +/**
    6.22   * Return a list of all the VM_guest_metrics instances known to the
    6.23   * system.
    6.24   */
     7.1 --- a/tools/libxen/include/xen_vm_metrics.h	Fri Mar 23 13:26:08 2007 +0000
     7.2 +++ b/tools/libxen/include/xen_vm_metrics.h	Fri Mar 23 13:27:29 2007 +0000
     7.3 @@ -66,6 +66,7 @@ typedef struct xen_vm_metrics_record
     7.4      int64_t memory_actual;
     7.5      int64_t vcpus_number;
     7.6      xen_int_float_map *vcpus_utilisation;
     7.7 +    time_t last_updated;
     7.8  } xen_vm_metrics_record;
     7.9  
    7.10  /**
    7.11 @@ -190,6 +191,13 @@ xen_vm_metrics_get_vcpus_utilisation(xen
    7.12  
    7.13  
    7.14  /**
    7.15 + * Get the last_updated field of the given VM_metrics.
    7.16 + */
    7.17 +extern bool
    7.18 +xen_vm_metrics_get_last_updated(xen_session *session, time_t *result, xen_vm_metrics vm_metrics);
    7.19 +
    7.20 +
    7.21 +/**
    7.22   * Return a list of all the VM_metrics instances known to the system.
    7.23   */
    7.24  extern bool
     8.1 --- a/tools/libxen/src/xen_host_metrics.c	Fri Mar 23 13:26:08 2007 +0000
     8.2 +++ b/tools/libxen/src/xen_host_metrics.c	Fri Mar 23 13:27:29 2007 +0000
     8.3 @@ -44,7 +44,10 @@ static const struct_member xen_host_metr
     8.4            .offset = offsetof(xen_host_metrics_record, memory_total) },
     8.5          { .key = "memory_free",
     8.6            .type = &abstract_type_int,
     8.7 -          .offset = offsetof(xen_host_metrics_record, memory_free) }
     8.8 +          .offset = offsetof(xen_host_metrics_record, memory_free) },
     8.9 +        { .key = "last_updated",
    8.10 +          .type = &abstract_type_datetime,
    8.11 +          .offset = offsetof(xen_host_metrics_record, last_updated) }
    8.12      };
    8.13  
    8.14  const abstract_type xen_host_metrics_record_abstract_type_ =
    8.15 @@ -143,6 +146,22 @@ xen_host_metrics_get_memory_free(xen_ses
    8.16  
    8.17  
    8.18  bool
    8.19 +xen_host_metrics_get_last_updated(xen_session *session, time_t *result, xen_host_metrics host_metrics)
    8.20 +{
    8.21 +    abstract_value param_values[] =
    8.22 +        {
    8.23 +            { .type = &abstract_type_string,
    8.24 +              .u.string_val = host_metrics }
    8.25 +        };
    8.26 +
    8.27 +    abstract_type result_type = abstract_type_datetime;
    8.28 +
    8.29 +    XEN_CALL_("host_metrics.get_last_updated");
    8.30 +    return session->ok;
    8.31 +}
    8.32 +
    8.33 +
    8.34 +bool
    8.35  xen_host_metrics_get_all(xen_session *session, struct xen_host_metrics_set **result)
    8.36  {
    8.37  
     9.1 --- a/tools/libxen/src/xen_pif_metrics.c	Fri Mar 23 13:26:08 2007 +0000
     9.2 +++ b/tools/libxen/src/xen_pif_metrics.c	Fri Mar 23 13:27:29 2007 +0000
     9.3 @@ -44,7 +44,10 @@ static const struct_member xen_pif_metri
     9.4            .offset = offsetof(xen_pif_metrics_record, io_read_kbs) },
     9.5          { .key = "io_write_kbs",
     9.6            .type = &abstract_type_float,
     9.7 -          .offset = offsetof(xen_pif_metrics_record, io_write_kbs) }
     9.8 +          .offset = offsetof(xen_pif_metrics_record, io_write_kbs) },
     9.9 +        { .key = "last_updated",
    9.10 +          .type = &abstract_type_datetime,
    9.11 +          .offset = offsetof(xen_pif_metrics_record, last_updated) }
    9.12      };
    9.13  
    9.14  const abstract_type xen_pif_metrics_record_abstract_type_ =
    9.15 @@ -143,6 +146,22 @@ xen_pif_metrics_get_io_write_kbs(xen_ses
    9.16  
    9.17  
    9.18  bool
    9.19 +xen_pif_metrics_get_last_updated(xen_session *session, time_t *result, xen_pif_metrics pif_metrics)
    9.20 +{
    9.21 +    abstract_value param_values[] =
    9.22 +        {
    9.23 +            { .type = &abstract_type_string,
    9.24 +              .u.string_val = pif_metrics }
    9.25 +        };
    9.26 +
    9.27 +    abstract_type result_type = abstract_type_datetime;
    9.28 +
    9.29 +    XEN_CALL_("PIF_metrics.get_last_updated");
    9.30 +    return session->ok;
    9.31 +}
    9.32 +
    9.33 +
    9.34 +bool
    9.35  xen_pif_metrics_get_all(xen_session *session, struct xen_pif_metrics_set **result)
    9.36  {
    9.37  
    10.1 --- a/tools/libxen/src/xen_vbd_metrics.c	Fri Mar 23 13:26:08 2007 +0000
    10.2 +++ b/tools/libxen/src/xen_vbd_metrics.c	Fri Mar 23 13:27:29 2007 +0000
    10.3 @@ -44,7 +44,10 @@ static const struct_member xen_vbd_metri
    10.4            .offset = offsetof(xen_vbd_metrics_record, io_read_kbs) },
    10.5          { .key = "io_write_kbs",
    10.6            .type = &abstract_type_float,
    10.7 -          .offset = offsetof(xen_vbd_metrics_record, io_write_kbs) }
    10.8 +          .offset = offsetof(xen_vbd_metrics_record, io_write_kbs) },
    10.9 +        { .key = "last_updated",
   10.10 +          .type = &abstract_type_datetime,
   10.11 +          .offset = offsetof(xen_vbd_metrics_record, last_updated) }
   10.12      };
   10.13  
   10.14  const abstract_type xen_vbd_metrics_record_abstract_type_ =
   10.15 @@ -143,6 +146,22 @@ xen_vbd_metrics_get_io_write_kbs(xen_ses
   10.16  
   10.17  
   10.18  bool
   10.19 +xen_vbd_metrics_get_last_updated(xen_session *session, time_t *result, xen_vbd_metrics vbd_metrics)
   10.20 +{
   10.21 +    abstract_value param_values[] =
   10.22 +        {
   10.23 +            { .type = &abstract_type_string,
   10.24 +              .u.string_val = vbd_metrics }
   10.25 +        };
   10.26 +
   10.27 +    abstract_type result_type = abstract_type_datetime;
   10.28 +
   10.29 +    XEN_CALL_("VBD_metrics.get_last_updated");
   10.30 +    return session->ok;
   10.31 +}
   10.32 +
   10.33 +
   10.34 +bool
   10.35  xen_vbd_metrics_get_all(xen_session *session, struct xen_vbd_metrics_set **result)
   10.36  {
   10.37  
    11.1 --- a/tools/libxen/src/xen_vif_metrics.c	Fri Mar 23 13:26:08 2007 +0000
    11.2 +++ b/tools/libxen/src/xen_vif_metrics.c	Fri Mar 23 13:27:29 2007 +0000
    11.3 @@ -44,7 +44,10 @@ static const struct_member xen_vif_metri
    11.4            .offset = offsetof(xen_vif_metrics_record, io_read_kbs) },
    11.5          { .key = "io_write_kbs",
    11.6            .type = &abstract_type_float,
    11.7 -          .offset = offsetof(xen_vif_metrics_record, io_write_kbs) }
    11.8 +          .offset = offsetof(xen_vif_metrics_record, io_write_kbs) },
    11.9 +        { .key = "last_updated",
   11.10 +          .type = &abstract_type_datetime,
   11.11 +          .offset = offsetof(xen_vif_metrics_record, last_updated) }
   11.12      };
   11.13  
   11.14  const abstract_type xen_vif_metrics_record_abstract_type_ =
   11.15 @@ -143,6 +146,22 @@ xen_vif_metrics_get_io_write_kbs(xen_ses
   11.16  
   11.17  
   11.18  bool
   11.19 +xen_vif_metrics_get_last_updated(xen_session *session, time_t *result, xen_vif_metrics vif_metrics)
   11.20 +{
   11.21 +    abstract_value param_values[] =
   11.22 +        {
   11.23 +            { .type = &abstract_type_string,
   11.24 +              .u.string_val = vif_metrics }
   11.25 +        };
   11.26 +
   11.27 +    abstract_type result_type = abstract_type_datetime;
   11.28 +
   11.29 +    XEN_CALL_("VIF_metrics.get_last_updated");
   11.30 +    return session->ok;
   11.31 +}
   11.32 +
   11.33 +
   11.34 +bool
   11.35  xen_vif_metrics_get_all(xen_session *session, struct xen_vif_metrics_set **result)
   11.36  {
   11.37  
    12.1 --- a/tools/libxen/src/xen_vm_guest_metrics.c	Fri Mar 23 13:26:08 2007 +0000
    12.2 +++ b/tools/libxen/src/xen_vm_guest_metrics.c	Fri Mar 23 13:27:29 2007 +0000
    12.3 @@ -57,7 +57,10 @@ static const struct_member xen_vm_guest_
    12.4            .offset = offsetof(xen_vm_guest_metrics_record, networks) },
    12.5          { .key = "other",
    12.6            .type = &abstract_type_string_string_map,
    12.7 -          .offset = offsetof(xen_vm_guest_metrics_record, other) }
    12.8 +          .offset = offsetof(xen_vm_guest_metrics_record, other) },
    12.9 +        { .key = "last_updated",
   12.10 +          .type = &abstract_type_datetime,
   12.11 +          .offset = offsetof(xen_vm_guest_metrics_record, last_updated) }
   12.12      };
   12.13  
   12.14  const abstract_type xen_vm_guest_metrics_record_abstract_type_ =
   12.15 @@ -232,6 +235,22 @@ xen_vm_guest_metrics_get_other(xen_sessi
   12.16  
   12.17  
   12.18  bool
   12.19 +xen_vm_guest_metrics_get_last_updated(xen_session *session, time_t *result, xen_vm_guest_metrics vm_guest_metrics)
   12.20 +{
   12.21 +    abstract_value param_values[] =
   12.22 +        {
   12.23 +            { .type = &abstract_type_string,
   12.24 +              .u.string_val = vm_guest_metrics }
   12.25 +        };
   12.26 +
   12.27 +    abstract_type result_type = abstract_type_datetime;
   12.28 +
   12.29 +    XEN_CALL_("VM_guest_metrics.get_last_updated");
   12.30 +    return session->ok;
   12.31 +}
   12.32 +
   12.33 +
   12.34 +bool
   12.35  xen_vm_guest_metrics_get_all(xen_session *session, struct xen_vm_guest_metrics_set **result)
   12.36  {
   12.37  
    13.1 --- a/tools/libxen/src/xen_vm_metrics.c	Fri Mar 23 13:26:08 2007 +0000
    13.2 +++ b/tools/libxen/src/xen_vm_metrics.c	Fri Mar 23 13:27:29 2007 +0000
    13.3 @@ -48,7 +48,10 @@ static const struct_member xen_vm_metric
    13.4            .offset = offsetof(xen_vm_metrics_record, vcpus_number) },
    13.5          { .key = "VCPUs_utilisation",
    13.6            .type = &abstract_type_int_float_map,
    13.7 -          .offset = offsetof(xen_vm_metrics_record, vcpus_utilisation) }
    13.8 +          .offset = offsetof(xen_vm_metrics_record, vcpus_utilisation) },
    13.9 +        { .key = "last_updated",
   13.10 +          .type = &abstract_type_datetime,
   13.11 +          .offset = offsetof(xen_vm_metrics_record, last_updated) }
   13.12      };
   13.13  
   13.14  const abstract_type xen_vm_metrics_record_abstract_type_ =
   13.15 @@ -165,6 +168,22 @@ xen_vm_metrics_get_vcpus_utilisation(xen
   13.16  
   13.17  
   13.18  bool
   13.19 +xen_vm_metrics_get_last_updated(xen_session *session, time_t *result, xen_vm_metrics vm_metrics)
   13.20 +{
   13.21 +    abstract_value param_values[] =
   13.22 +        {
   13.23 +            { .type = &abstract_type_string,
   13.24 +              .u.string_val = vm_metrics }
   13.25 +        };
   13.26 +
   13.27 +    abstract_type result_type = abstract_type_datetime;
   13.28 +
   13.29 +    XEN_CALL_("VM_metrics.get_last_updated");
   13.30 +    return session->ok;
   13.31 +}
   13.32 +
   13.33 +
   13.34 +bool
   13.35  xen_vm_metrics_get_all(xen_session *session, struct xen_vm_metrics_set **result)
   13.36  {
   13.37  
    14.1 --- a/tools/libxen/test/test_bindings.c	Fri Mar 23 13:26:08 2007 +0000
    14.2 +++ b/tools/libxen/test/test_bindings.c	Fri Mar 23 13:27:29 2007 +0000
    14.3 @@ -592,6 +592,11 @@ static void print_vm_metrics(xen_session
    14.4          return;
    14.5      }
    14.6  
    14.7 +    char time[256];
    14.8 +    struct tm *tm = localtime(&vm_metrics_record->last_updated);
    14.9 +    strftime(time, 256, "Metrics updated at %c, local time.\n", tm);
   14.10 +    printf(time);
   14.11 +
   14.12      for (size_t i = 0; i < vm_metrics_record->vcpus_utilisation->size; i++)
   14.13      {
   14.14          printf("%"PRId64" -> %lf.\n",
    15.1 --- a/tools/python/xen/xend/XendAPI.py	Fri Mar 23 13:26:08 2007 +0000
    15.2 +++ b/tools/python/xen/xend/XendAPI.py	Fri Mar 23 13:27:29 2007 +0000
    15.3 @@ -21,6 +21,8 @@ import string
    15.4  import sys
    15.5  import traceback
    15.6  import threading
    15.7 +import time
    15.8 +import xmlrpclib
    15.9  
   15.10  from xen.xend import XendDomain, XendDomainInfo, XendNode, XendDmesg
   15.11  from xen.xend import XendLogging, XendTaskManager
   15.12 @@ -77,6 +79,11 @@ def xen_api_todo():
   15.13      """Temporary method to make sure we track down all the TODOs"""
   15.14      return {"Status": "Error", "ErrorDescription": XEND_ERROR_TODO}
   15.15  
   15.16 +
   15.17 +def now():
   15.18 +    return xmlrpclib.DateTime(time.strftime("%Y%m%dT%H:%M:%S", time.gmtime()))
   15.19 +
   15.20 +
   15.21  # ---------------------------------------------------
   15.22  # Python Method Decorators for input value validation
   15.23  # ---------------------------------------------------
   15.24 @@ -850,7 +857,8 @@ class XendAPI(object):
   15.25      # ----------------------------------------------------------------
   15.26  
   15.27      host_metrics_attr_ro = ['memory_total',
   15.28 -                            'memory_free']
   15.29 +                            'memory_free',
   15.30 +                            'last_updated']
   15.31      host_metrics_attr_rw = []
   15.32      host_metrics_methods = []
   15.33  
   15.34 @@ -865,14 +873,18 @@ class XendAPI(object):
   15.35              'uuid'         : ref,
   15.36              'memory_total' : self._host_metrics_get_memory_total(),
   15.37              'memory_free'  : self._host_metrics_get_memory_free(),
   15.38 +            'last_updated' : now(),
   15.39              })
   15.40  
   15.41 -    def host_metrics_get_memory_total(self, _, ref):
   15.42 +    def host_metrics_get_memory_total(self, _1, _2):
   15.43          return xen_api_success(self._host_metrics_get_memory_total())
   15.44  
   15.45 -    def host_metrics_get_memory_free(self, _, ref):
   15.46 +    def host_metrics_get_memory_free(self, _1, _2):
   15.47          return xen_api_success(self._host_metrics_get_memory_free())
   15.48  
   15.49 +    def host_metrics_get_last_updated(self, _1, _2):
   15.50 +        return xen_api_success(now())
   15.51 +
   15.52      def _host_metrics_get_memory_total(self):
   15.53          node = XendNode.instance()
   15.54          return node.xc.physinfo()['total_memory'] * 1024
   15.55 @@ -1012,7 +1024,8 @@ class XendAPI(object):
   15.56      # ----------------------------------------------------------------
   15.57  
   15.58      PIF_metrics_attr_ro = ['io_read_kbs',
   15.59 -                           'io_write_kbs']
   15.60 +                           'io_write_kbs',
   15.61 +                           'last_updated']
   15.62      PIF_metrics_attr_rw = []
   15.63      PIF_methods = []
   15.64  
   15.65 @@ -1031,6 +1044,9 @@ class XendAPI(object):
   15.66      def PIF_metrics_get_io_write_kbs(self, _, ref):
   15.67          return xen_api_success(self._PIF_metrics_get(ref).get_io_write_kbs())
   15.68  
   15.69 +    def PIF_metrics_get_last_updated(self, _1, _2):
   15.70 +        return xen_api_success(now())
   15.71 +
   15.72  
   15.73      # Xen API: Class VM
   15.74      # ----------------------------------------------------------------        
   15.75 @@ -1609,7 +1625,8 @@ class XendAPI(object):
   15.76                            'VCPUs_flags',
   15.77                            'VCPUs_params',
   15.78                            'state',
   15.79 -                          'start_time']
   15.80 +                          'start_time',
   15.81 +                          'last_updated']
   15.82      VM_metrics_attr_rw = []
   15.83      VM_metrics_methods = []
   15.84  
   15.85 @@ -1646,6 +1663,9 @@ class XendAPI(object):
   15.86      def VM_metrics_get_state(self, _, ref):
   15.87          return xen_api_success(self._VM_metrics_get(ref).get_state())
   15.88  
   15.89 +    def VM_metrics_get_last_updated(self, _1, _2):
   15.90 +        return xen_api_success(now())
   15.91 +
   15.92  
   15.93      # Xen API: Class VBD
   15.94      # ----------------------------------------------------------------
   15.95 @@ -1800,7 +1820,8 @@ class XendAPI(object):
   15.96      # ----------------------------------------------------------------
   15.97  
   15.98      VBD_metrics_attr_ro = ['io_read_kbs',
   15.99 -                           'io_write_kbs']
  15.100 +                           'io_write_kbs',
  15.101 +                           'last_updated']
  15.102      VBD_metrics_attr_rw = []
  15.103      VBD_methods = []
  15.104  
  15.105 @@ -1810,7 +1831,9 @@ class XendAPI(object):
  15.106              return xen_api_error(['HANDLE_INVALID', 'VBD_metrics', ref])
  15.107          return xen_api_success(
  15.108              { 'io_read_kbs'  : vm.get_dev_property('vbd', ref, 'io_read_kbs'),
  15.109 -              'io_write_kbs' : vm.get_dev_property('vbd', ref, 'io_write_kbs') })
  15.110 +              'io_write_kbs' : vm.get_dev_property('vbd', ref, 'io_write_kbs'),
  15.111 +              'last_updated' : now()
  15.112 +            })
  15.113  
  15.114      def VBD_metrics_get_io_read_kbs(self, _, ref):
  15.115          return self._VBD_get(ref, 'io_read_kbs')
  15.116 @@ -1818,6 +1841,9 @@ class XendAPI(object):
  15.117      def VBD_metrics_get_io_write_kbs(self, session, ref):
  15.118          return self._VBD_get(ref, 'io_write_kbs')
  15.119  
  15.120 +    def VBD_metrics_get_last_updated(self, _1, _2):
  15.121 +        return xen_api_success(now())
  15.122 +
  15.123  
  15.124      # Xen API: Class VIF
  15.125      # ----------------------------------------------------------------
  15.126 @@ -1934,7 +1960,8 @@ class XendAPI(object):
  15.127      # ----------------------------------------------------------------
  15.128  
  15.129      VIF_metrics_attr_ro = ['io_read_kbs',
  15.130 -                           'io_write_kbs']
  15.131 +                           'io_write_kbs',
  15.132 +                           'last_updated']
  15.133      VIF_metrics_attr_rw = []
  15.134      VIF_methods = []
  15.135  
  15.136 @@ -1944,7 +1971,9 @@ class XendAPI(object):
  15.137              return xen_api_error(['HANDLE_INVALID', 'VIF_metrics', ref])
  15.138          return xen_api_success(
  15.139              { 'io_read_kbs'  : vm.get_dev_property('vif', ref, 'io_read_kbs'),
  15.140 -              'io_write_kbs' : vm.get_dev_property('vif', ref, 'io_write_kbs') })
  15.141 +              'io_write_kbs' : vm.get_dev_property('vif', ref, 'io_write_kbs'),
  15.142 +              'last_updated' : now()
  15.143 +            })
  15.144  
  15.145      def VIF_metrics_get_io_read_kbs(self, _, ref):
  15.146          return self._VIF_get(ref, 'io_read_kbs')
  15.147 @@ -1952,6 +1981,9 @@ class XendAPI(object):
  15.148      def VIF_metrics_get_io_write_kbs(self, session, ref):
  15.149          return self._VIF_get(ref, 'io_write_kbs')
  15.150  
  15.151 +    def VIF_metrics_get_last_updated(self, _1, _2):
  15.152 +        return xen_api_success(now())
  15.153 +
  15.154  
  15.155      # Xen API: Class VDI
  15.156      # ----------------------------------------------------------------
  15.157 @@ -2424,39 +2456,3 @@ class XendAPIAsyncProxy:
  15.158                                                  synchronous_method_name,
  15.159                                                  session)
  15.160          return xen_api_success(task_uuid)
  15.161 -
  15.162 -#   
  15.163 -# Auto generate some stubs based on XendAPI introspection
  15.164 -#
  15.165 -if __name__ == "__main__":
  15.166 -    def output(line):
  15.167 -        print '    ' + line
  15.168 -    
  15.169 -    classes = ['VDI', 'SR']
  15.170 -    for cls in classes:
  15.171 -        ro_attrs = getattr(XendAPI, '%s_attr_ro' % cls, [])
  15.172 -        rw_attrs = getattr(XendAPI, '%s_attr_rw' % cls, [])
  15.173 -        methods  = getattr(XendAPI, '%s_methods' % cls, [])
  15.174 -        funcs    = getattr(XendAPI, '%s_funcs' % cls, [])
  15.175 -
  15.176 -        ref = '%s_ref' % cls
  15.177 -
  15.178 -        for attr_name in ro_attrs + rw_attrs + XendAPI.Base_attr_ro:
  15.179 -            getter_name = '%s_get_%s' % (cls, attr_name)
  15.180 -            output('def %s(self, session, %s):' % (getter_name, ref))
  15.181 -            output('    return xen_api_todo()')
  15.182 -
  15.183 -        for attr_name in rw_attrs + XendAPI.Base_attr_rw:
  15.184 -            setter_name = '%s_set_%s' % (cls, attr_name)
  15.185 -            output('def %s(self, session, %s, value):' % (setter_name, ref))
  15.186 -            output('    return xen_api_todo()')
  15.187 -
  15.188 -        for method_name in methods + XendAPI.Base_methods:
  15.189 -            method_full_name = '%s_%s' % (cls,method_name)
  15.190 -            output('def %s(self, session, %s):' % (method_full_name, ref))
  15.191 -            output('    return xen_api_todo()')
  15.192 -
  15.193 -        for func_name in funcs + XendAPI.Base_funcs:
  15.194 -            func_full_name = '%s_%s' % (cls, func_name)
  15.195 -            output('def %s(self, session):' % func_full_name)
  15.196 -            output('    return xen_api_todo()')
    16.1 --- a/tools/python/xen/xend/XendPIFMetrics.py	Fri Mar 23 13:26:08 2007 +0000
    16.2 +++ b/tools/python/xen/xend/XendPIFMetrics.py	Fri Mar 23 13:27:29 2007 +0000
    16.3 @@ -40,8 +40,10 @@ class XendPIFMetrics:
    16.4          return 0.0
    16.5  
    16.6      def get_record(self):
    16.7 +        import xen.xend.XendAPI as XendAPI
    16.8          return {'uuid'         : self.uuid,
    16.9                  'PIF'          : self.pif.uuid,
   16.10                  'io_read_kbs'  : self.get_io_read_kbs(),
   16.11 -                'io_write_kbs' : self.get_io_write_kbs()
   16.12 +                'io_write_kbs' : self.get_io_write_kbs(),
   16.13 +                'last_updated' : XendAPI.now(),
   16.14                  }
    17.1 --- a/tools/python/xen/xend/XendVMMetrics.py	Fri Mar 23 13:26:08 2007 +0000
    17.2 +++ b/tools/python/xen/xend/XendVMMetrics.py	Fri Mar 23 13:27:29 2007 +0000
    17.3 @@ -141,6 +141,7 @@ class XendVMMetrics:
    17.4          return self.xend_domain_instance.info.get("start_time", -1)
    17.5      
    17.6      def get_record(self):
    17.7 +        import xen.xend.XendAPI as XendAPI
    17.8          return { 'uuid'              : self.uuid,
    17.9                   'memory_actual'     : self.get_memory_actual(),
   17.10                   'VCPUs_number'      : self.get_VCPUs_number(),
   17.11 @@ -150,4 +151,5 @@ class XendVMMetrics:
   17.12                   'VCPUs_params'      : self.get_VCPUs_params(),
   17.13                   'start_time'        : self.get_start_time(),
   17.14                   'state'             : self.get_state(),
   17.15 +                 'last_updated'      : XendAPI.now(),
   17.16                 }