ia64/xen-unstable

changeset 13724:7261e0d4b7df

Move the io bandwidth fields from PIF onto a new PIF_metrics class.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Mon Jan 29 19:00:48 2007 +0000 (2007-01-29)
parents 0a422c8c3144
children eb7b2a9ce40c
files docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen_pif.h tools/libxen/include/xen_pif_metrics.h tools/libxen/include/xen_pif_metrics_decl.h tools/libxen/src/xen_pif.c tools/libxen/src/xen_pif_metrics.c tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendNode.py tools/python/xen/xend/XendPIF.py tools/python/xen/xend/XendPIFMetrics.py tools/python/xen/xm/messages/en/xen-xm.po
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Mon Jan 29 14:52:27 2007 +0000
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Mon Jan 29 19:00:48 2007 +0000
     1.3 @@ -30,6 +30,7 @@ Name & Description \\
     1.4  {\tt network} & A virtual network \\
     1.5  {\tt VIF} & A virtual network interface \\
     1.6  {\tt PIF} & A physical network interface (note separate VLANs are represented as several PIFs) \\
     1.7 +{\tt PIF\_metrics} & The metrics associated with a physical network interface \\
     1.8  {\tt SR} & A storage repository \\
     1.9  {\tt VDI} & A virtual disk image \\
    1.10  {\tt VBD} & A virtual block device \\
    1.11 @@ -53,6 +54,7 @@ VDI.VBDs & VBD.VDI & many-to-one\\
    1.12  VBD.VM & VM.VBDs & one-to-many\\
    1.13  VIF.VM & VM.VIFs & one-to-many\\
    1.14  VIF.network & network.VIFs & one-to-many\\
    1.15 +PIF.metrics & PIF\_metrics.PIF & one-to-one\\
    1.16  PIF.host & host.PIFs & one-to-many\\
    1.17  PIF.network & network.PIFs & one-to-many\\
    1.18  SR.VDIs & VDI.SR & many-to-one\\
    1.19 @@ -6378,8 +6380,7 @@ Quals & Field & Type & Description \\
    1.20  $\mathit{RW}$ &  {\tt MAC} & string & ethernet MAC address of physical interface \\
    1.21  $\mathit{RW}$ &  {\tt MTU} & int & MTU in octets \\
    1.22  $\mathit{RW}$ &  {\tt VLAN} & int & VLAN tag for all traffic passing through this interface \\
    1.23 -$\mathit{RO}_\mathit{run}$ &  {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\
    1.24 -$\mathit{RO}_\mathit{run}$ &  {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\
    1.25 +$\mathit{RO}_\mathit{ins}$ &  {\tt metrics} & PIF\_metrics ref & metrics associated with this PIF. \\
    1.26  \hline
    1.27  \end{longtable}
    1.28  \subsection{Additional RPCs associated with class: PIF}
    1.29 @@ -6818,13 +6819,13 @@ void
    1.30  \vspace{0.3cm}
    1.31  \vspace{0.3cm}
    1.32  \vspace{0.3cm}
    1.33 -\subsubsection{RPC name:~get\_io\_read\_kbs}
    1.34 -
    1.35 -{\bf Overview:} 
    1.36 -Get the io/read\_kbs field of the given PIF.
    1.37 -
    1.38 - \noindent {\bf Signature:} 
    1.39 -\begin{verbatim} float get_io_read_kbs (session_id s, PIF ref self)\end{verbatim}
    1.40 +\subsubsection{RPC name:~get\_metrics}
    1.41 +
    1.42 +{\bf Overview:} 
    1.43 +Get the metrics field of the given PIF.
    1.44 +
    1.45 + \noindent {\bf Signature:} 
    1.46 +\begin{verbatim} (PIF_metrics ref) get_metrics (session_id s, PIF ref self)\end{verbatim}
    1.47  
    1.48  
    1.49  \noindent{\bf Arguments:}
    1.50 @@ -6842,39 +6843,7 @@ Get the io/read\_kbs field of the given 
    1.51  
    1.52   \noindent {\bf Return Type:} 
    1.53  {\tt 
    1.54 -float
    1.55 -}
    1.56 -
    1.57 -
    1.58 -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\_io\_write\_kbs}
    1.63 -
    1.64 -{\bf Overview:} 
    1.65 -Get the io/write\_kbs field of the given PIF.
    1.66 -
    1.67 - \noindent {\bf Signature:} 
    1.68 -\begin{verbatim} float get_io_write_kbs (session_id s, PIF 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 PIF 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 -float
    1.87 +PIF\_metrics ref
    1.88  }
    1.89  
    1.90  
    1.91 @@ -6949,6 +6918,218 @@ all fields from the object
    1.92  
    1.93  \vspace{1cm}
    1.94  \newpage
    1.95 +\section{Class: PIF\_metrics}
    1.96 +\subsection{Fields for class: PIF\_metrics}
    1.97 +\begin{longtable}{|lllp{0.38\textwidth}|}
    1.98 +\hline
    1.99 +\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf PIF\_metrics} \\
   1.100 +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em
   1.101 +The metrics associated with a physical network interface.}} \\
   1.102 +\hline
   1.103 +Quals & Field & Type & Description \\
   1.104 +\hline
   1.105 +$\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
   1.106 +$\mathit{RO}_\mathit{ins}$ &  {\tt PIF} & PIF ref & PIF to which these metrics apply \\
   1.107 +$\mathit{RO}_\mathit{run}$ &  {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\
   1.108 +$\mathit{RO}_\mathit{run}$ &  {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\
   1.109 +\hline
   1.110 +\end{longtable}
   1.111 +\subsection{Additional RPCs associated with class: PIF\_metrics}
   1.112 +\subsubsection{RPC name:~get\_uuid}
   1.113 +
   1.114 +{\bf Overview:} 
   1.115 +Get the uuid field of the given PIF\_metrics.
   1.116 +
   1.117 + \noindent {\bf Signature:} 
   1.118 +\begin{verbatim} string get_uuid (session_id s, PIF_metrics ref self)\end{verbatim}
   1.119 +
   1.120 +
   1.121 +\noindent{\bf Arguments:}
   1.122 +
   1.123 + 
   1.124 +\vspace{0.3cm}
   1.125 +\begin{tabular}{|c|c|p{7cm}|}
   1.126 + \hline
   1.127 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.128 +{\tt PIF\_metrics ref } & self & reference to the object \\ \hline 
   1.129 +
   1.130 +\end{tabular}
   1.131 +
   1.132 +\vspace{0.3cm}
   1.133 +
   1.134 + \noindent {\bf Return Type:} 
   1.135 +{\tt 
   1.136 +string
   1.137 +}
   1.138 +
   1.139 +
   1.140 +value of the field
   1.141 +\vspace{0.3cm}
   1.142 +\vspace{0.3cm}
   1.143 +\vspace{0.3cm}
   1.144 +\subsubsection{RPC name:~get\_PIF}
   1.145 +
   1.146 +{\bf Overview:} 
   1.147 +Get the PIF field of the given PIF\_metrics.
   1.148 +
   1.149 + \noindent {\bf Signature:} 
   1.150 +\begin{verbatim} (PIF ref) get_PIF (session_id s, PIF_metrics ref self)\end{verbatim}
   1.151 +
   1.152 +
   1.153 +\noindent{\bf Arguments:}
   1.154 +
   1.155 + 
   1.156 +\vspace{0.3cm}
   1.157 +\begin{tabular}{|c|c|p{7cm}|}
   1.158 + \hline
   1.159 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.160 +{\tt PIF\_metrics ref } & self & reference to the object \\ \hline 
   1.161 +
   1.162 +\end{tabular}
   1.163 +
   1.164 +\vspace{0.3cm}
   1.165 +
   1.166 + \noindent {\bf Return Type:} 
   1.167 +{\tt 
   1.168 +PIF ref
   1.169 +}
   1.170 +
   1.171 +
   1.172 +value of the field
   1.173 +\vspace{0.3cm}
   1.174 +\vspace{0.3cm}
   1.175 +\vspace{0.3cm}
   1.176 +\subsubsection{RPC name:~get\_io\_read\_kbs}
   1.177 +
   1.178 +{\bf Overview:} 
   1.179 +Get the io/read\_kbs field of the given PIF\_metrics.
   1.180 +
   1.181 + \noindent {\bf Signature:} 
   1.182 +\begin{verbatim} float get_io_read_kbs (session_id s, PIF_metrics ref self)\end{verbatim}
   1.183 +
   1.184 +
   1.185 +\noindent{\bf Arguments:}
   1.186 +
   1.187 + 
   1.188 +\vspace{0.3cm}
   1.189 +\begin{tabular}{|c|c|p{7cm}|}
   1.190 + \hline
   1.191 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.192 +{\tt PIF\_metrics ref } & self & reference to the object \\ \hline 
   1.193 +
   1.194 +\end{tabular}
   1.195 +
   1.196 +\vspace{0.3cm}
   1.197 +
   1.198 + \noindent {\bf Return Type:} 
   1.199 +{\tt 
   1.200 +float
   1.201 +}
   1.202 +
   1.203 +
   1.204 +value of the field
   1.205 +\vspace{0.3cm}
   1.206 +\vspace{0.3cm}
   1.207 +\vspace{0.3cm}
   1.208 +\subsubsection{RPC name:~get\_io\_write\_kbs}
   1.209 +
   1.210 +{\bf Overview:} 
   1.211 +Get the io/write\_kbs field of the given PIF\_metrics.
   1.212 +
   1.213 + \noindent {\bf Signature:} 
   1.214 +\begin{verbatim} float get_io_write_kbs (session_id s, PIF_metrics ref self)\end{verbatim}
   1.215 +
   1.216 +
   1.217 +\noindent{\bf Arguments:}
   1.218 +
   1.219 + 
   1.220 +\vspace{0.3cm}
   1.221 +\begin{tabular}{|c|c|p{7cm}|}
   1.222 + \hline
   1.223 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.224 +{\tt PIF\_metrics ref } & self & reference to the object \\ \hline 
   1.225 +
   1.226 +\end{tabular}
   1.227 +
   1.228 +\vspace{0.3cm}
   1.229 +
   1.230 + \noindent {\bf Return Type:} 
   1.231 +{\tt 
   1.232 +float
   1.233 +}
   1.234 +
   1.235 +
   1.236 +value of the field
   1.237 +\vspace{0.3cm}
   1.238 +\vspace{0.3cm}
   1.239 +\vspace{0.3cm}
   1.240 +\subsubsection{RPC name:~get\_by\_uuid}
   1.241 +
   1.242 +{\bf Overview:} 
   1.243 +Get a reference to the PIF\_metrics instance with the specified UUID.
   1.244 +
   1.245 + \noindent {\bf Signature:} 
   1.246 +\begin{verbatim} (PIF_metrics ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
   1.247 +
   1.248 +
   1.249 +\noindent{\bf Arguments:}
   1.250 +
   1.251 + 
   1.252 +\vspace{0.3cm}
   1.253 +\begin{tabular}{|c|c|p{7cm}|}
   1.254 + \hline
   1.255 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.256 +{\tt string } & uuid & UUID of object to return \\ \hline 
   1.257 +
   1.258 +\end{tabular}
   1.259 +
   1.260 +\vspace{0.3cm}
   1.261 +
   1.262 + \noindent {\bf Return Type:} 
   1.263 +{\tt 
   1.264 +PIF\_metrics ref
   1.265 +}
   1.266 +
   1.267 +
   1.268 +reference to the object
   1.269 +\vspace{0.3cm}
   1.270 +\vspace{0.3cm}
   1.271 +\vspace{0.3cm}
   1.272 +\subsubsection{RPC name:~get\_record}
   1.273 +
   1.274 +{\bf Overview:} 
   1.275 +Get a record containing the current state of the given PIF\_metrics.
   1.276 +
   1.277 + \noindent {\bf Signature:} 
   1.278 +\begin{verbatim} (PIF_metrics record) get_record (session_id s, PIF_metrics ref self)\end{verbatim}
   1.279 +
   1.280 +
   1.281 +\noindent{\bf Arguments:}
   1.282 +
   1.283 + 
   1.284 +\vspace{0.3cm}
   1.285 +\begin{tabular}{|c|c|p{7cm}|}
   1.286 + \hline
   1.287 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.288 +{\tt PIF\_metrics ref } & self & reference to the object \\ \hline 
   1.289 +
   1.290 +\end{tabular}
   1.291 +
   1.292 +\vspace{0.3cm}
   1.293 +
   1.294 + \noindent {\bf Return Type:} 
   1.295 +{\tt 
   1.296 +PIF\_metrics record
   1.297 +}
   1.298 +
   1.299 +
   1.300 +all fields from the object
   1.301 +\vspace{0.3cm}
   1.302 +\vspace{0.3cm}
   1.303 +\vspace{0.3cm}
   1.304 +
   1.305 +\vspace{1cm}
   1.306 +\newpage
   1.307  \section{Class: SR}
   1.308  \subsection{Fields for class: SR}
   1.309  \begin{longtable}{|lllp{0.38\textwidth}|}
     2.1 --- a/tools/libxen/include/xen_pif.h	Mon Jan 29 14:52:27 2007 +0000
     2.2 +++ b/tools/libxen/include/xen_pif.h	Mon Jan 29 19:00:48 2007 +0000
     2.3 @@ -23,6 +23,7 @@
     2.4  #include "xen_host_decl.h"
     2.5  #include "xen_network_decl.h"
     2.6  #include "xen_pif_decl.h"
     2.7 +#include "xen_pif_metrics_decl.h"
     2.8  
     2.9  
    2.10  /*
    2.11 @@ -71,8 +72,7 @@ typedef struct xen_pif_record
    2.12      char *mac;
    2.13      int64_t mtu;
    2.14      int64_t vlan;
    2.15 -    double io_read_kbs;
    2.16 -    double io_write_kbs;
    2.17 +    struct xen_pif_metrics_record_opt *metrics;
    2.18  } xen_pif_record;
    2.19  
    2.20  /**
    2.21 @@ -218,17 +218,10 @@ xen_pif_get_vlan(xen_session *session, i
    2.22  
    2.23  
    2.24  /**
    2.25 - * Get the io/read_kbs field of the given PIF.
    2.26 + * Get the metrics field of the given PIF.
    2.27   */
    2.28  extern bool
    2.29 -xen_pif_get_io_read_kbs(xen_session *session, double *result, xen_pif pif);
    2.30 -
    2.31 -
    2.32 -/**
    2.33 - * Get the io/write_kbs field of the given PIF.
    2.34 - */
    2.35 -extern bool
    2.36 -xen_pif_get_io_write_kbs(xen_session *session, double *result, xen_pif pif);
    2.37 +xen_pif_get_metrics(xen_session *session, xen_pif_metrics *result, xen_pif pif);
    2.38  
    2.39  
    2.40  /**
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/libxen/include/xen_pif_metrics.h	Mon Jan 29 19:00:48 2007 +0000
     3.3 @@ -0,0 +1,192 @@
     3.4 +/*
     3.5 + * Copyright (c) 2006, XenSource Inc.
     3.6 + *
     3.7 + * This library is free software; you can redistribute it and/or
     3.8 + * modify it under the terms of the GNU Lesser General Public
     3.9 + * License as published by the Free Software Foundation; either
    3.10 + * version 2.1 of the License, or (at your option) any later version.
    3.11 + *
    3.12 + * This library is distributed in the hope that it will be useful,
    3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.15 + * Lesser General Public License for more details.
    3.16 + *
    3.17 + * You should have received a copy of the GNU Lesser General Public
    3.18 + * License along with this library; if not, write to the Free Software
    3.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    3.20 + */
    3.21 +
    3.22 +#ifndef XEN_PIF_METRICS_H
    3.23 +#define XEN_PIF_METRICS_H
    3.24 +
    3.25 +#include "xen_common.h"
    3.26 +#include "xen_pif_decl.h"
    3.27 +#include "xen_pif_metrics_decl.h"
    3.28 +
    3.29 +
    3.30 +/*
    3.31 + * The PIF_metrics class.
    3.32 + * 
    3.33 + * The metrics associated with a physical network interface.
    3.34 + */
    3.35 +
    3.36 +
    3.37 +/**
    3.38 + * Free the given xen_pif_metrics.  The given handle must have been
    3.39 + * allocated by this library.
    3.40 + */
    3.41 +extern void
    3.42 +xen_pif_metrics_free(xen_pif_metrics pif_metrics);
    3.43 +
    3.44 +
    3.45 +typedef struct xen_pif_metrics_set
    3.46 +{
    3.47 +    size_t size;
    3.48 +    xen_pif_metrics *contents[];
    3.49 +} xen_pif_metrics_set;
    3.50 +
    3.51 +/**
    3.52 + * Allocate a xen_pif_metrics_set of the given size.
    3.53 + */
    3.54 +extern xen_pif_metrics_set *
    3.55 +xen_pif_metrics_set_alloc(size_t size);
    3.56 +
    3.57 +/**
    3.58 + * Free the given xen_pif_metrics_set.  The given set must have been
    3.59 + * allocated by this library.
    3.60 + */
    3.61 +extern void
    3.62 +xen_pif_metrics_set_free(xen_pif_metrics_set *set);
    3.63 +
    3.64 +
    3.65 +typedef struct xen_pif_metrics_record
    3.66 +{
    3.67 +    xen_pif_metrics handle;
    3.68 +    char *uuid;
    3.69 +    struct xen_pif_record_opt *pif;
    3.70 +    double io_read_kbs;
    3.71 +    double io_write_kbs;
    3.72 +} xen_pif_metrics_record;
    3.73 +
    3.74 +/**
    3.75 + * Allocate a xen_pif_metrics_record.
    3.76 + */
    3.77 +extern xen_pif_metrics_record *
    3.78 +xen_pif_metrics_record_alloc(void);
    3.79 +
    3.80 +/**
    3.81 + * Free the given xen_pif_metrics_record, and all referenced values. 
    3.82 + * The given record must have been allocated by this library.
    3.83 + */
    3.84 +extern void
    3.85 +xen_pif_metrics_record_free(xen_pif_metrics_record *record);
    3.86 +
    3.87 +
    3.88 +typedef struct xen_pif_metrics_record_opt
    3.89 +{
    3.90 +    bool is_record;
    3.91 +    union
    3.92 +    {
    3.93 +        xen_pif_metrics handle;
    3.94 +        xen_pif_metrics_record *record;
    3.95 +    } u;
    3.96 +} xen_pif_metrics_record_opt;
    3.97 +
    3.98 +/**
    3.99 + * Allocate a xen_pif_metrics_record_opt.
   3.100 + */
   3.101 +extern xen_pif_metrics_record_opt *
   3.102 +xen_pif_metrics_record_opt_alloc(void);
   3.103 +
   3.104 +/**
   3.105 + * Free the given xen_pif_metrics_record_opt, and all referenced
   3.106 + * values.  The given record_opt must have been allocated by this library.
   3.107 + */
   3.108 +extern void
   3.109 +xen_pif_metrics_record_opt_free(xen_pif_metrics_record_opt *record_opt);
   3.110 +
   3.111 +
   3.112 +typedef struct xen_pif_metrics_record_set
   3.113 +{
   3.114 +    size_t size;
   3.115 +    xen_pif_metrics_record *contents[];
   3.116 +} xen_pif_metrics_record_set;
   3.117 +
   3.118 +/**
   3.119 + * Allocate a xen_pif_metrics_record_set of the given size.
   3.120 + */
   3.121 +extern xen_pif_metrics_record_set *
   3.122 +xen_pif_metrics_record_set_alloc(size_t size);
   3.123 +
   3.124 +/**
   3.125 + * Free the given xen_pif_metrics_record_set, and all referenced
   3.126 + * values.  The given set must have been allocated by this library.
   3.127 + */
   3.128 +extern void
   3.129 +xen_pif_metrics_record_set_free(xen_pif_metrics_record_set *set);
   3.130 +
   3.131 +
   3.132 +
   3.133 +typedef struct xen_pif_metrics_record_opt_set
   3.134 +{
   3.135 +    size_t size;
   3.136 +    xen_pif_metrics_record_opt *contents[];
   3.137 +} xen_pif_metrics_record_opt_set;
   3.138 +
   3.139 +/**
   3.140 + * Allocate a xen_pif_metrics_record_opt_set of the given size.
   3.141 + */
   3.142 +extern xen_pif_metrics_record_opt_set *
   3.143 +xen_pif_metrics_record_opt_set_alloc(size_t size);
   3.144 +
   3.145 +/**
   3.146 + * Free the given xen_pif_metrics_record_opt_set, and all referenced
   3.147 + * values.  The given set must have been allocated by this library.
   3.148 + */
   3.149 +extern void
   3.150 +xen_pif_metrics_record_opt_set_free(xen_pif_metrics_record_opt_set *set);
   3.151 +
   3.152 +
   3.153 +/**
   3.154 + * Get a record containing the current state of the given PIF_metrics.
   3.155 + */
   3.156 +extern bool
   3.157 +xen_pif_metrics_get_record(xen_session *session, xen_pif_metrics_record **result, xen_pif_metrics pif_metrics);
   3.158 +
   3.159 +
   3.160 +/**
   3.161 + * Get a reference to the PIF_metrics instance with the specified UUID.
   3.162 + */
   3.163 +extern bool
   3.164 +xen_pif_metrics_get_by_uuid(xen_session *session, xen_pif_metrics *result, char *uuid);
   3.165 +
   3.166 +
   3.167 +/**
   3.168 + * Get the uuid field of the given PIF_metrics.
   3.169 + */
   3.170 +extern bool
   3.171 +xen_pif_metrics_get_uuid(xen_session *session, char **result, xen_pif_metrics pif_metrics);
   3.172 +
   3.173 +
   3.174 +/**
   3.175 + * Get the PIF field of the given PIF_metrics.
   3.176 + */
   3.177 +extern bool
   3.178 +xen_pif_metrics_get_pif(xen_session *session, xen_pif *result, xen_pif_metrics pif_metrics);
   3.179 +
   3.180 +
   3.181 +/**
   3.182 + * Get the io/read_kbs field of the given PIF_metrics.
   3.183 + */
   3.184 +extern bool
   3.185 +xen_pif_metrics_get_io_read_kbs(xen_session *session, double *result, xen_pif_metrics pif_metrics);
   3.186 +
   3.187 +
   3.188 +/**
   3.189 + * Get the io/write_kbs field of the given PIF_metrics.
   3.190 + */
   3.191 +extern bool
   3.192 +xen_pif_metrics_get_io_write_kbs(xen_session *session, double *result, xen_pif_metrics pif_metrics);
   3.193 +
   3.194 +
   3.195 +#endif
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tools/libxen/include/xen_pif_metrics_decl.h	Mon Jan 29 19:00:48 2007 +0000
     4.3 @@ -0,0 +1,30 @@
     4.4 +/*
     4.5 + * Copyright (c) 2006, XenSource Inc.
     4.6 + *
     4.7 + * This library is free software; you can redistribute it and/or
     4.8 + * modify it under the terms of the GNU Lesser General Public
     4.9 + * License as published by the Free Software Foundation; either
    4.10 + * version 2.1 of the License, or (at your option) any later version.
    4.11 + *
    4.12 + * This library is distributed in the hope that it will be useful,
    4.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.15 + * Lesser General Public License for more details.
    4.16 + *
    4.17 + * You should have received a copy of the GNU Lesser General Public
    4.18 + * License along with this library; if not, write to the Free Software
    4.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    4.20 + */
    4.21 +
    4.22 +#ifndef XEN_PIF_METRICS_DECL_H
    4.23 +#define XEN_PIF_METRICS_DECL_H
    4.24 +
    4.25 +typedef void *xen_pif_metrics;
    4.26 +
    4.27 +struct xen_pif_metrics_set;
    4.28 +struct xen_pif_metrics_record;
    4.29 +struct xen_pif_metrics_record_set;
    4.30 +struct xen_pif_metrics_record_opt;
    4.31 +struct xen_pif_metrics_record_opt_set;
    4.32 +
    4.33 +#endif
     5.1 --- a/tools/libxen/src/xen_pif.c	Mon Jan 29 14:52:27 2007 +0000
     5.2 +++ b/tools/libxen/src/xen_pif.c	Mon Jan 29 19:00:48 2007 +0000
     5.3 @@ -25,6 +25,7 @@
     5.4  #include "xen_internal.h"
     5.5  #include "xen_network.h"
     5.6  #include "xen_pif.h"
     5.7 +#include "xen_pif_metrics.h"
     5.8  
     5.9  
    5.10  XEN_FREE(xen_pif)
    5.11 @@ -59,12 +60,9 @@ static const struct_member xen_pif_recor
    5.12          { .key = "VLAN",
    5.13            .type = &abstract_type_int,
    5.14            .offset = offsetof(xen_pif_record, vlan) },
    5.15 -        { .key = "io_read_kbs",
    5.16 -          .type = &abstract_type_float,
    5.17 -          .offset = offsetof(xen_pif_record, io_read_kbs) },
    5.18 -        { .key = "io_write_kbs",
    5.19 -          .type = &abstract_type_float,
    5.20 -          .offset = offsetof(xen_pif_record, io_write_kbs) }
    5.21 +        { .key = "metrics",
    5.22 +          .type = &abstract_type_ref,
    5.23 +          .offset = offsetof(xen_pif_record, metrics) }
    5.24      };
    5.25  
    5.26  const abstract_type xen_pif_record_abstract_type_ =
    5.27 @@ -90,6 +88,7 @@ xen_pif_record_free(xen_pif_record *reco
    5.28      xen_network_record_opt_free(record->network);
    5.29      xen_host_record_opt_free(record->host);
    5.30      free(record->mac);
    5.31 +    xen_pif_metrics_record_opt_free(record->metrics);
    5.32      free(record);
    5.33  }
    5.34  
    5.35 @@ -235,7 +234,7 @@ xen_pif_get_vlan(xen_session *session, i
    5.36  
    5.37  
    5.38  bool
    5.39 -xen_pif_get_io_read_kbs(xen_session *session, double *result, xen_pif pif)
    5.40 +xen_pif_get_metrics(xen_session *session, xen_pif_metrics *result, xen_pif pif)
    5.41  {
    5.42      abstract_value param_values[] =
    5.43          {
    5.44 @@ -243,25 +242,10 @@ xen_pif_get_io_read_kbs(xen_session *ses
    5.45                .u.string_val = pif }
    5.46          };
    5.47  
    5.48 -    abstract_type result_type = abstract_type_float;
    5.49 -
    5.50 -    XEN_CALL_("PIF.get_io_read_kbs");
    5.51 -    return session->ok;
    5.52 -}
    5.53 -
    5.54 +    abstract_type result_type = abstract_type_string;
    5.55  
    5.56 -bool
    5.57 -xen_pif_get_io_write_kbs(xen_session *session, double *result, xen_pif pif)
    5.58 -{
    5.59 -    abstract_value param_values[] =
    5.60 -        {
    5.61 -            { .type = &abstract_type_string,
    5.62 -              .u.string_val = pif }
    5.63 -        };
    5.64 -
    5.65 -    abstract_type result_type = abstract_type_float;
    5.66 -
    5.67 -    XEN_CALL_("PIF.get_io_write_kbs");
    5.68 +    *result = NULL;
    5.69 +    XEN_CALL_("PIF.get_metrics");
    5.70      return session->ok;
    5.71  }
    5.72  
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/tools/libxen/src/xen_pif_metrics.c	Mon Jan 29 19:00:48 2007 +0000
     6.3 @@ -0,0 +1,172 @@
     6.4 +/*
     6.5 + * Copyright (c) 2006, XenSource Inc.
     6.6 + *
     6.7 + * This library is free software; you can redistribute it and/or
     6.8 + * modify it under the terms of the GNU Lesser General Public
     6.9 + * License as published by the Free Software Foundation; either
    6.10 + * version 2.1 of the License, or (at your option) any later version.
    6.11 + *
    6.12 + * This library is distributed in the hope that it will be useful,
    6.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.15 + * Lesser General Public License for more details.
    6.16 + *
    6.17 + * You should have received a copy of the GNU Lesser General Public
    6.18 + * License along with this library; if not, write to the Free Software
    6.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    6.20 + */
    6.21 +
    6.22 +
    6.23 +#include <stddef.h>
    6.24 +#include <stdlib.h>
    6.25 +
    6.26 +#include "xen_common.h"
    6.27 +#include "xen_internal.h"
    6.28 +#include "xen_pif.h"
    6.29 +#include "xen_pif_metrics.h"
    6.30 +
    6.31 +
    6.32 +XEN_FREE(xen_pif_metrics)
    6.33 +XEN_SET_ALLOC_FREE(xen_pif_metrics)
    6.34 +XEN_ALLOC(xen_pif_metrics_record)
    6.35 +XEN_SET_ALLOC_FREE(xen_pif_metrics_record)
    6.36 +XEN_ALLOC(xen_pif_metrics_record_opt)
    6.37 +XEN_RECORD_OPT_FREE(xen_pif_metrics)
    6.38 +XEN_SET_ALLOC_FREE(xen_pif_metrics_record_opt)
    6.39 +
    6.40 +
    6.41 +static const struct_member xen_pif_metrics_record_struct_members[] =
    6.42 +    {
    6.43 +        { .key = "uuid",
    6.44 +          .type = &abstract_type_string,
    6.45 +          .offset = offsetof(xen_pif_metrics_record, uuid) },
    6.46 +        { .key = "PIF",
    6.47 +          .type = &abstract_type_ref,
    6.48 +          .offset = offsetof(xen_pif_metrics_record, pif) },
    6.49 +        { .key = "io_read_kbs",
    6.50 +          .type = &abstract_type_float,
    6.51 +          .offset = offsetof(xen_pif_metrics_record, io_read_kbs) },
    6.52 +        { .key = "io_write_kbs",
    6.53 +          .type = &abstract_type_float,
    6.54 +          .offset = offsetof(xen_pif_metrics_record, io_write_kbs) }
    6.55 +    };
    6.56 +
    6.57 +const abstract_type xen_pif_metrics_record_abstract_type_ =
    6.58 +    {
    6.59 +       .typename = STRUCT,
    6.60 +       .struct_size = sizeof(xen_pif_metrics_record),
    6.61 +       .member_count =
    6.62 +           sizeof(xen_pif_metrics_record_struct_members) / sizeof(struct_member),
    6.63 +       .members = xen_pif_metrics_record_struct_members
    6.64 +    };
    6.65 +
    6.66 +
    6.67 +void
    6.68 +xen_pif_metrics_record_free(xen_pif_metrics_record *record)
    6.69 +{
    6.70 +    if (record == NULL)
    6.71 +    {
    6.72 +        return;
    6.73 +    }
    6.74 +    free(record->handle);
    6.75 +    free(record->uuid);
    6.76 +    xen_pif_record_opt_free(record->pif);
    6.77 +    free(record);
    6.78 +}
    6.79 +
    6.80 +
    6.81 +bool
    6.82 +xen_pif_metrics_get_record(xen_session *session, xen_pif_metrics_record **result, xen_pif_metrics pif_metrics)
    6.83 +{
    6.84 +    abstract_value param_values[] =
    6.85 +        {
    6.86 +            { .type = &abstract_type_string,
    6.87 +              .u.string_val = pif_metrics }
    6.88 +        };
    6.89 +
    6.90 +    abstract_type result_type = xen_pif_metrics_record_abstract_type_;
    6.91 +
    6.92 +    *result = NULL;
    6.93 +    XEN_CALL_("PIF_metrics.get_record");
    6.94 +
    6.95 +    if (session->ok)
    6.96 +    {
    6.97 +       (*result)->handle = xen_strdup_((*result)->uuid);
    6.98 +    }
    6.99 +
   6.100 +    return session->ok;
   6.101 +}
   6.102 +
   6.103 +
   6.104 +bool
   6.105 +xen_pif_metrics_get_by_uuid(xen_session *session, xen_pif_metrics *result, char *uuid)
   6.106 +{
   6.107 +    abstract_value param_values[] =
   6.108 +        {
   6.109 +            { .type = &abstract_type_string,
   6.110 +              .u.string_val = uuid }
   6.111 +        };
   6.112 +
   6.113 +    abstract_type result_type = abstract_type_string;
   6.114 +
   6.115 +    *result = NULL;
   6.116 +    XEN_CALL_("PIF_metrics.get_by_uuid");
   6.117 +    return session->ok;
   6.118 +}
   6.119 +
   6.120 +
   6.121 +bool
   6.122 +xen_pif_metrics_get_pif(xen_session *session, xen_pif *result, xen_pif_metrics pif_metrics)
   6.123 +{
   6.124 +    abstract_value param_values[] =
   6.125 +        {
   6.126 +            { .type = &abstract_type_string,
   6.127 +              .u.string_val = pif_metrics }
   6.128 +        };
   6.129 +
   6.130 +    abstract_type result_type = abstract_type_string;
   6.131 +
   6.132 +    *result = NULL;
   6.133 +    XEN_CALL_("PIF_metrics.get_PIF");
   6.134 +    return session->ok;
   6.135 +}
   6.136 +
   6.137 +
   6.138 +bool
   6.139 +xen_pif_metrics_get_io_read_kbs(xen_session *session, double *result, xen_pif_metrics pif_metrics)
   6.140 +{
   6.141 +    abstract_value param_values[] =
   6.142 +        {
   6.143 +            { .type = &abstract_type_string,
   6.144 +              .u.string_val = pif_metrics }
   6.145 +        };
   6.146 +
   6.147 +    abstract_type result_type = abstract_type_float;
   6.148 +
   6.149 +    XEN_CALL_("PIF_metrics.get_io_read_kbs");
   6.150 +    return session->ok;
   6.151 +}
   6.152 +
   6.153 +
   6.154 +bool
   6.155 +xen_pif_metrics_get_io_write_kbs(xen_session *session, double *result, xen_pif_metrics pif_metrics)
   6.156 +{
   6.157 +    abstract_value param_values[] =
   6.158 +        {
   6.159 +            { .type = &abstract_type_string,
   6.160 +              .u.string_val = pif_metrics }
   6.161 +        };
   6.162 +
   6.163 +    abstract_type result_type = abstract_type_float;
   6.164 +
   6.165 +    XEN_CALL_("PIF_metrics.get_io_write_kbs");
   6.166 +    return session->ok;
   6.167 +}
   6.168 +
   6.169 +
   6.170 +bool
   6.171 +xen_pif_metrics_get_uuid(xen_session *session, char **result, xen_pif_metrics pif_metrics)
   6.172 +{
   6.173 +    *result = session->ok ? xen_strdup_((char *)pif_metrics) : NULL;
   6.174 +    return session->ok;
   6.175 +}
     7.1 --- a/tools/python/xen/xend/XendAPI.py	Mon Jan 29 14:52:27 2007 +0000
     7.2 +++ b/tools/python/xen/xend/XendAPI.py	Mon Jan 29 19:00:48 2007 +0000
     7.3 @@ -12,7 +12,7 @@
     7.4  # License along with this library; if not, write to the Free Software
     7.5  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     7.6  #============================================================================
     7.7 -# Copyright (C) 2006 XenSource Ltd.
     7.8 +# Copyright (C) 2006-2007 XenSource Ltd.
     7.9  #============================================================================
    7.10  
    7.11  import inspect
    7.12 @@ -261,6 +261,17 @@ def valid_pif(func):
    7.13             _check_ref(lambda r: r in XendNode.instance().pifs,
    7.14                        'PIF_HANDLE_INVALID', func, *args, **kwargs)
    7.15  
    7.16 +def valid_pif_metrics(func):
    7.17 +    """Decorator to verify if pif_metrics_ref is valid before calling
    7.18 +    method.
    7.19 +
    7.20 +    @param func: function with params: (self, session, pif_metrics_ref)
    7.21 +    @rtype: callable object
    7.22 +    """
    7.23 +    return lambda *args, **kwargs: \
    7.24 +           _check_ref(lambda r: r in XendNode.instance().pif_metrics,
    7.25 +                      'PIF_METRICS_HANDLE_INVALID', func, *args, **kwargs)
    7.26 +
    7.27  def valid_task(func):
    7.28      """Decorator to verify if task_ref is valid before calling
    7.29      method.
    7.30 @@ -361,6 +372,7 @@ class XendAPI(object):
    7.31              'console' : valid_console,
    7.32              'SR'      : valid_sr,
    7.33              'PIF'     : valid_pif,
    7.34 +            'PIF_metrics': valid_pif_metrics,
    7.35              'task'    : valid_task,
    7.36              'debug'   : valid_debug,
    7.37          }
    7.38 @@ -738,8 +750,7 @@ class XendAPI(object):
    7.39      # Xen API: Class PIF
    7.40      # ----------------------------------------------------------------
    7.41  
    7.42 -    PIF_attr_ro = ['io_read_kbs',
    7.43 -                   'io_write_kbs']
    7.44 +    PIF_attr_ro = ['metrics']
    7.45      PIF_attr_rw = ['device',
    7.46                     'network',
    7.47                     'host',
    7.48 @@ -767,6 +778,9 @@ class XendAPI(object):
    7.49      def PIF_get_all(self, _):
    7.50          return xen_api_success(XendNode.instance().pifs.keys())
    7.51  
    7.52 +    def PIF_get_metrics(self, _, ref):
    7.53 +        return xen_api_success(self._get_PIF(ref).metrics.uuid)
    7.54 +
    7.55      def PIF_get_device(self, _, ref):
    7.56          return xen_api_success(self._get_PIF(ref).device)
    7.57  
    7.58 @@ -785,12 +799,6 @@ class XendAPI(object):
    7.59      def PIF_get_VLAN(self, _, ref):
    7.60          return xen_api_success(self._get_PIF(ref).vlan)
    7.61  
    7.62 -    def PIF_get_io_read_kbs(self, _, ref):
    7.63 -        return xen_api_success(self._get_PIF(ref).get_io_read_kbs())
    7.64 -
    7.65 -    def PIF_get_io_write_kbs(self, _, ref):
    7.66 -        return xen_api_success(self._get_PIF(ref).get_io_write_kbs())
    7.67 -    
    7.68      def PIF_set_device(self, _, ref, device):
    7.69          return xen_api_success(self._get_PIF(ref).set_device(device))
    7.70  
    7.71 @@ -821,6 +829,27 @@ class XendAPI(object):
    7.72              return xen_api_error(['VLAN_TAG_INVALID', vlan])
    7.73  
    7.74  
    7.75 +    # Xen API: Class PIF_metrics
    7.76 +    # ----------------------------------------------------------------
    7.77 +
    7.78 +    PIF_metrics_attr_ro = ['io_read_kbs',
    7.79 +                           'io_write_kbs']
    7.80 +    PIF_metrics_attr_rw = []
    7.81 +    PIF_methods = []
    7.82 +
    7.83 +    def _PIF_metrics_get(self, ref):
    7.84 +        return XendNode.instance().pif_metrics[ref]
    7.85 +
    7.86 +    def PIF_metrics_get_record(self, _, ref):
    7.87 +        return xen_api_success(self._PIF_metrics_get(ref).get_record())
    7.88 +
    7.89 +    def PIF_metrics_get_io_read_kbs(self, _, ref):
    7.90 +        return xen_api_success(self._PIF_metrics_get(ref).get_io_read_kbs())
    7.91 +
    7.92 +    def PIF_metrics_get_io_write_kbs(self, _, ref):
    7.93 +        return xen_api_success(self._PIF_metrics_get(ref).get_io_write_kbs())
    7.94 +
    7.95 +
    7.96      # Xen API: Class VM
    7.97      # ----------------------------------------------------------------        
    7.98  
     8.1 --- a/tools/python/xen/xend/XendNode.py	Mon Jan 29 14:52:27 2007 +0000
     8.2 +++ b/tools/python/xen/xend/XendNode.py	Mon Jan 29 19:00:48 2007 +0000
     8.3 @@ -13,7 +13,7 @@
     8.4  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     8.5  #============================================================================
     8.6  # Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
     8.7 -# Copyright (c) 2006 Xensource Inc.
     8.8 +# Copyright (c) 2006, 2007 Xensource Inc.
     8.9  #============================================================================
    8.10  
    8.11  import os
    8.12 @@ -29,6 +29,7 @@ from xen.xend.XendQCoWStorageRepo import
    8.13  from xen.xend.XendLocalStorageRepo import XendLocalStorageRepo
    8.14  from xen.xend.XendLogging import log
    8.15  from xen.xend.XendPIF import *
    8.16 +from xen.xend.XendPIFMetrics import XendPIFMetrics
    8.17  from xen.xend.XendNetwork import *
    8.18  from xen.xend.XendStateStore import XendStateStore
    8.19  from xen.xend.XendMonitor import XendMonitor
    8.20 @@ -88,6 +89,7 @@ class XendNode:
    8.21                  self.cpus[cpu_uuid] = cpu_info
    8.22  
    8.23          self.pifs = {}
    8.24 +        self.pif_metrics = {}
    8.25          self.networks = {}
    8.26          self.srs = {}
    8.27          
    8.28 @@ -114,10 +116,14 @@ class XendNode:
    8.29                          if 'device' not in pif and 'name' in pif:
    8.30                              # Compatibility hack, can go pretty soon.
    8.31                              pif['device'] = pif['name']
    8.32 -                        
    8.33 +                        if 'metrics' not in pif:
    8.34 +                            # Compatibility hack, can go pretty soon.
    8.35 +                            pif['metrics'] = uuid.createString()
    8.36 +
    8.37                          self._PIF_create(pif['device'], pif['MTU'],
    8.38                                           int(pif['VLAN']),
    8.39 -                                         pif['MAC'], network, False, pif_uuid)
    8.40 +                                         pif['MAC'], network, False, pif_uuid,
    8.41 +                                         pif['metrics'])
    8.42                      except NetworkAlreadyConnected, exn:
    8.43                          log.error('Cannot load saved PIF %s, as network %s ' +
    8.44                                    'is already connected to PIF %s',
    8.45 @@ -167,15 +173,23 @@ class XendNode:
    8.46  
    8.47  
    8.48      def _PIF_create(self, name, mtu, vlan, mac, network, persist = True,
    8.49 -                    pif_uuid = None):
    8.50 +                    pif_uuid = None, metrics_uuid = None):
    8.51          for pif in self.pifs.values():
    8.52              if pif.network == network:
    8.53                  raise NetworkAlreadyConnected(pif.uuid)
    8.54  
    8.55          if pif_uuid is None:
    8.56              pif_uuid = uuid.createString()
    8.57 -        self.pifs[pif_uuid] = XendPIF(pif_uuid, name, mtu, vlan, mac, network,
    8.58 -                                      self)
    8.59 +        if metrics_uuid is None:
    8.60 +            metrics_uuid = uuid.createString()
    8.61 +
    8.62 +        metrics = XendPIFMetrics(metrics_uuid)
    8.63 +        pif = XendPIF(pif_uuid, metrics, name, mtu, vlan, mac, network, self)
    8.64 +        metrics.set_PIF(pif)
    8.65 +
    8.66 +        self.pif_metrics[metrics_uuid] = metrics
    8.67 +        self.pifs[pif_uuid] = pif
    8.68 +
    8.69          if persist:
    8.70              self.save_PIFs()
    8.71              self.refreshBridges()
    8.72 @@ -212,7 +226,7 @@ class XendNode:
    8.73          self.save_SRs()
    8.74  
    8.75      def save_PIFs(self):
    8.76 -        pif_records = dict([(k, v.get_record(transient = False))
    8.77 +        pif_records = dict([(k, v.get_record())
    8.78                              for k, v in self.pifs.items()])
    8.79          self.state_store.save_state('pif', pif_records)
    8.80  
    8.81 @@ -495,12 +509,6 @@ class XendNode:
    8.82              return vbd_loads[domid].get(vbdid, (0.0, 0.0))
    8.83          return (0.0, 0.0)
    8.84  
    8.85 -    def get_pif_util(self, pifname):
    8.86 -        pifs_util = self.monitor.get_pifs_util()
    8.87 -        if pifname in pifs_util:
    8.88 -            return pifs_util[pifname]
    8.89 -        return (0.0, 0.0)
    8.90 -
    8.91      # dictionary version of *info() functions to get rid of
    8.92      # SXPisms.
    8.93      def nodeinfo_dict(self):
     9.1 --- a/tools/python/xen/xend/XendPIF.py	Mon Jan 29 14:52:27 2007 +0000
     9.2 +++ b/tools/python/xen/xend/XendPIF.py	Mon Jan 29 19:00:48 2007 +0000
     9.3 @@ -90,8 +90,10 @@ def linux_set_mtu(iface, mtu):
     9.4  class XendPIF:
     9.5      """Representation of a Physical Network Interface."""
     9.6      
     9.7 -    def __init__(self, uuid, device, mtu, vlan, mac, network, host):
     9.8 +    def __init__(self, uuid, metrics, device, mtu, vlan, mac, network,
     9.9 +                 host):
    9.10          self.uuid = uuid
    9.11 +        self.metrics = metrics
    9.12          self.device = device
    9.13          self.mac = mac
    9.14          self.mtu = mtu
    9.15 @@ -114,26 +116,14 @@ class XendPIF:
    9.16              self.mtu = new_mtu
    9.17          return success
    9.18  
    9.19 -    def get_io_read_kbs(self):
    9.20 -        from xen.xend.XendNode import instance as xennode
    9.21 -        return xennode().get_pif_util(self.device)[0]
    9.22 -
    9.23 -    def get_io_write_kbs(self):
    9.24 -        from xen.xend.XendNode import instance as xennode
    9.25 -        return xennode().get_pif_util(self.device)[1]      
    9.26 -
    9.27 -    def get_record(self, transient = True):
    9.28 -        result = {'device': self.device,
    9.29 -                  'MAC': self.mac,
    9.30 -                  'MTU': self.mtu,
    9.31 -                  'VLAN': self.vlan,
    9.32 -                  'host': self.host.uuid,
    9.33 -                  'network': self.network.uuid}
    9.34 -        if transient:
    9.35 -            result['io_read_kbs'] = self.get_io_read_kbs()
    9.36 -            result['io_write_kbs'] = self.get_io_write_kbs()
    9.37 -        return result
    9.38 -
    9.39 +    def get_record(self):
    9.40 +        return {'device': self.device,
    9.41 +                'MAC': self.mac,
    9.42 +                'MTU': self.mtu,
    9.43 +                'VLAN': self.vlan,
    9.44 +                'host': self.host.uuid,
    9.45 +                'network': self.network.uuid,
    9.46 +                'metrics': self.metrics.uuid}
    9.47  
    9.48      def refresh(self, bridges):
    9.49          ifname = self.interface_name()
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/tools/python/xen/xend/XendPIFMetrics.py	Mon Jan 29 19:00:48 2007 +0000
    10.3 @@ -0,0 +1,46 @@
    10.4 +#============================================================================
    10.5 +# This library is free software; you can redistribute it and/or
    10.6 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
    10.7 +# License as published by the Free Software Foundation.
    10.8 +#
    10.9 +# This library is distributed in the hope that it will be useful,
   10.10 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.11 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   10.12 +# Lesser General Public License for more details.
   10.13 +#
   10.14 +# You should have received a copy of the GNU Lesser General Public
   10.15 +# License along with this library; if not, write to the Free Software
   10.16 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   10.17 +#============================================================================
   10.18 +# Copyright (c) 2006-2007 Xensource Inc.
   10.19 +#============================================================================
   10.20 +
   10.21 +
   10.22 +class XendPIFMetrics:
   10.23 +    """PIF Metrics."""
   10.24 +    
   10.25 +    def __init__(self, uuid):
   10.26 +        self.uuid = uuid
   10.27 +
   10.28 +    def set_PIF(self, pif):
   10.29 +        self.pif = pif
   10.30 +
   10.31 +    def get_io_read_kbs(self):
   10.32 +        return self._get_stat(0)
   10.33 +    
   10.34 +    def get_io_write_kbs(self):
   10.35 +        return self._get_stat(1)
   10.36 +
   10.37 +    def _get_stat(self, n):
   10.38 +        from xen.xend.XendNode import instance as xennode
   10.39 +        pifname = self.pif.device
   10.40 +        pifs_util = xennode().monitor.get_pifs_util()
   10.41 +        if pifname in pifs_util:
   10.42 +            return pifs_util[pifname][n]
   10.43 +        return 0.0
   10.44 +
   10.45 +    def get_record(self):
   10.46 +        return {'PIF'          : self.pif.uuid,
   10.47 +                'io_read_kbs'  : self.get_io_read_kbs(),
   10.48 +                'io_write_kbs' : self.get_io_write_kbs()
   10.49 +                }
    11.1 --- a/tools/python/xen/xm/messages/en/xen-xm.po	Mon Jan 29 14:52:27 2007 +0000
    11.2 +++ b/tools/python/xen/xm/messages/en/xen-xm.po	Mon Jan 29 19:00:48 2007 +0000
    11.3 @@ -19,7 +19,7 @@
    11.4  msgid ""
    11.5  msgstr ""
    11.6  "Project-Id-Version: Xen-xm 3.0\n"
    11.7 -"PO-Revision-Date: 2007-01-28 21:58+0000\n"
    11.8 +"PO-Revision-Date: 2007-01-29 18:50+0000\n"
    11.9  "Last-Translator: Ewan Mellor <ewan@xensource.com>\n"
   11.10  "Language-Team: xen-devel <xen-devel@lists.xensource.com>\n"
   11.11  "MIME-Version: 1.0\n"
   11.12 @@ -47,6 +47,12 @@ msgstr "The host_cpu handle %(1)s is inv
   11.13  msgid "HOST_HANDLE_INVALID"
   11.14  msgstr "The host handle %(1)s is invalid."
   11.15  
   11.16 +msgid "PIF_HANDLE_INVALID"
   11.17 +msgstr "The PIF handle %(1)s is invalid."
   11.18 +
   11.19 +msgid "PIF_METRICS_HANDLE_INVALID"
   11.20 +msgstr "The PIF_METRICS handle %(1)s is invalid."
   11.21 +
   11.22  msgid "SR_HANDLE_INVALID"
   11.23  msgstr "The SR handle %(1)s is invalid."
   11.24