ia64/xen-unstable

changeset 13702:5e1c7022d4ad

Document existing PIF.create_VLAN, and remove PIF.create (PIFs are implicitly
created from the physical host configuration).

Change PIF.name to PIF.device, for consistency with other uses, and make
PIF.VLAN an int.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Sun Jan 28 13:40:07 2007 +0000 (2007-01-28)
parents ea3c75204555
children f40528773629
files docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen_pif.h tools/libxen/src/xen_pif.c tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendError.py tools/python/xen/xend/XendNode.py tools/python/xen/xend/XendPIF.py tools/python/xen/xm/messages/en/xen-xm.po
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Sat Jan 27 18:26:41 2007 +0000
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Sun Jan 28 13:40:07 2007 +0000
     1.3 @@ -6529,22 +6529,94 @@ all fields from the object
     1.4  \begin{longtable}{|lllp{0.38\textwidth}|}
     1.5  \hline
     1.6  \multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf PIF} \\
     1.7 -\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A physical network interface (note separate VLANs are represented as several PIFs)}} \\
     1.8 +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A
     1.9 +physical network interface (note separate VLANs are represented as several
    1.10 +PIFs)}} \\
    1.11  \hline
    1.12  Quals & Field & Type & Description \\
    1.13  \hline
    1.14  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
    1.15 -$\mathit{RW}$ &  {\tt name} & string & human-readable name of the interface \\
    1.16 +$\mathit{RW}$ &  {\tt device} & string & machine-readable name of the interface (e.g. eth0) \\
    1.17  $\mathit{RW}$ &  {\tt network} & network ref & virtual network to which this pif is connected \\
    1.18  $\mathit{RW}$ &  {\tt host} & host ref & physical machine to which this pif is connected \\
    1.19  $\mathit{RW}$ &  {\tt MAC} & string & ethernet MAC address of physical interface \\
    1.20  $\mathit{RW}$ &  {\tt MTU} & int & MTU in octets \\
    1.21 -$\mathit{RW}$ &  {\tt VLAN} & string & VLAN tag for all traffic passing through this interface \\
    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  \hline
    1.26  \end{longtable}
    1.27  \subsection{Additional RPCs associated with class: PIF}
    1.28 +\subsubsection{RPC name:~create\_VLAN}
    1.29 +
    1.30 +{\bf Overview:} 
    1.31 +Create a VLAN interface from an existing physical interface
    1.32 +
    1.33 + \noindent {\bf Signature:} 
    1.34 +\begin{verbatim} (PIF ref) create_VLAN (session_id s, string device, network ref network, host ref host, int VLAN)\end{verbatim}
    1.35 +
    1.36 +
    1.37 +\noindent{\bf Arguments:}
    1.38 +
    1.39 + 
    1.40 +\vspace{0.3cm}
    1.41 +\begin{tabular}{|c|c|p{7cm}|}
    1.42 + \hline
    1.43 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.44 +{\tt string } & device & physical interface on which to crate the VLAN interface \\ \hline 
    1.45 +
    1.46 +{\tt network ref } & network & network to which this interface should be connected \\ \hline 
    1.47 +
    1.48 +{\tt host ref } & host & physical machine to which this PIF is connected \\ \hline 
    1.49 +
    1.50 +{\tt int } & VLAN & VLAN tag for the new interface \\ \hline 
    1.51 +
    1.52 +\end{tabular}
    1.53 +
    1.54 +\vspace{0.3cm}
    1.55 +
    1.56 + \noindent {\bf Return Type:} 
    1.57 +{\tt 
    1.58 +PIF ref
    1.59 +}
    1.60 +
    1.61 +
    1.62 +The reference of the created PIF object
    1.63 +\vspace{0.3cm}
    1.64 +\vspace{0.3cm}
    1.65 +\vspace{0.3cm}
    1.66 +\subsubsection{RPC name:~destroy}
    1.67 +
    1.68 +{\bf Overview:} 
    1.69 +Destroy the interface (provided it is a synthetic interface like a VLAN; fail if it is a physical interface)
    1.70 +
    1.71 + \noindent {\bf Signature:} 
    1.72 +\begin{verbatim} void destroy (session_id s, PIF ref self)\end{verbatim}
    1.73 +
    1.74 +
    1.75 +\noindent{\bf Arguments:}
    1.76 +
    1.77 + 
    1.78 +\vspace{0.3cm}
    1.79 +\begin{tabular}{|c|c|p{7cm}|}
    1.80 + \hline
    1.81 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.82 +{\tt PIF ref } & self & the PIF object to destroy \\ \hline 
    1.83 +
    1.84 +\end{tabular}
    1.85 +
    1.86 +\vspace{0.3cm}
    1.87 +
    1.88 + \noindent {\bf Return Type:} 
    1.89 +{\tt 
    1.90 +void
    1.91 +}
    1.92 +
    1.93 +
    1.94 +
    1.95 +\vspace{0.3cm}
    1.96 +\vspace{0.3cm}
    1.97 +\vspace{0.3cm}
    1.98  \subsubsection{RPC name:~get\_uuid}
    1.99  
   1.100  {\bf Overview:} 
   1.101 @@ -6577,13 +6649,13 @@ value of the field
   1.102  \vspace{0.3cm}
   1.103  \vspace{0.3cm}
   1.104  \vspace{0.3cm}
   1.105 -\subsubsection{RPC name:~get\_name}
   1.106 -
   1.107 -{\bf Overview:} 
   1.108 -Get the name field of the given PIF.
   1.109 -
   1.110 - \noindent {\bf Signature:} 
   1.111 -\begin{verbatim} string get_name (session_id s, PIF ref self)\end{verbatim}
   1.112 +\subsubsection{RPC name:~get\_device}
   1.113 +
   1.114 +{\bf Overview:} 
   1.115 +Get the device field of the given PIF.
   1.116 +
   1.117 + \noindent {\bf Signature:} 
   1.118 +\begin{verbatim} string get_device (session_id s, PIF ref self)\end{verbatim}
   1.119  
   1.120  
   1.121  \noindent{\bf Arguments:}
   1.122 @@ -6609,13 +6681,13 @@ value of the field
   1.123  \vspace{0.3cm}
   1.124  \vspace{0.3cm}
   1.125  \vspace{0.3cm}
   1.126 -\subsubsection{RPC name:~set\_name}
   1.127 -
   1.128 -{\bf Overview:} 
   1.129 -Set the name field of the given PIF.
   1.130 -
   1.131 - \noindent {\bf Signature:} 
   1.132 -\begin{verbatim} void set_name (session_id s, PIF ref self, string value)\end{verbatim}
   1.133 +\subsubsection{RPC name:~set\_device}
   1.134 +
   1.135 +{\bf Overview:} 
   1.136 +Set the device field of the given PIF.
   1.137 +
   1.138 + \noindent {\bf Signature:} 
   1.139 +\begin{verbatim} void set_device (session_id s, PIF ref self, string value)\end{verbatim}
   1.140  
   1.141  
   1.142  \noindent{\bf Arguments:}
   1.143 @@ -6913,7 +6985,7 @@ void
   1.144  Get the VLAN field of the given PIF.
   1.145  
   1.146   \noindent {\bf Signature:} 
   1.147 -\begin{verbatim} string get_VLAN (session_id s, PIF ref self)\end{verbatim}
   1.148 +\begin{verbatim} int get_VLAN (session_id s, PIF ref self)\end{verbatim}
   1.149  
   1.150  
   1.151  \noindent{\bf Arguments:}
   1.152 @@ -6931,7 +7003,7 @@ Get the VLAN field of the given PIF.
   1.153  
   1.154   \noindent {\bf Return Type:} 
   1.155  {\tt 
   1.156 -string
   1.157 +int
   1.158  }
   1.159  
   1.160  
   1.161 @@ -6945,7 +7017,7 @@ value of the field
   1.162  Set the VLAN field of the given PIF.
   1.163  
   1.164   \noindent {\bf Signature:} 
   1.165 -\begin{verbatim} void set_VLAN (session_id s, PIF ref self, string value)\end{verbatim}
   1.166 +\begin{verbatim} void set_VLAN (session_id s, PIF ref self, int value)\end{verbatim}
   1.167  
   1.168  
   1.169  \noindent{\bf Arguments:}
   1.170 @@ -6957,7 +7029,7 @@ Set the VLAN field of the given PIF.
   1.171  {\bf type} & {\bf name} & {\bf description} \\ \hline
   1.172  {\tt PIF ref } & self & reference to the object \\ \hline 
   1.173  
   1.174 -{\tt string } & value & New value to set \\ \hline 
   1.175 +{\tt int } & value & New value to set \\ \hline 
   1.176  
   1.177  \end{tabular}
   1.178  
   1.179 @@ -7037,70 +7109,6 @@ value of the field
   1.180  \vspace{0.3cm}
   1.181  \vspace{0.3cm}
   1.182  \vspace{0.3cm}
   1.183 -\subsubsection{RPC name:~create}
   1.184 -
   1.185 -{\bf Overview:} 
   1.186 -Create a new PIF instance, and return its handle.
   1.187 -
   1.188 - \noindent {\bf Signature:} 
   1.189 -\begin{verbatim} (PIF ref) create (session_id s, PIF record args)\end{verbatim}
   1.190 -
   1.191 -
   1.192 -\noindent{\bf Arguments:}
   1.193 -
   1.194 - 
   1.195 -\vspace{0.3cm}
   1.196 -\begin{tabular}{|c|c|p{7cm}|}
   1.197 - \hline
   1.198 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.199 -{\tt PIF record } & args & All constructor arguments \\ \hline 
   1.200 -
   1.201 -\end{tabular}
   1.202 -
   1.203 -\vspace{0.3cm}
   1.204 -
   1.205 - \noindent {\bf Return Type:} 
   1.206 -{\tt 
   1.207 -PIF ref
   1.208 -}
   1.209 -
   1.210 -
   1.211 -reference to the newly created object
   1.212 -\vspace{0.3cm}
   1.213 -\vspace{0.3cm}
   1.214 -\vspace{0.3cm}
   1.215 -\subsubsection{RPC name:~destroy}
   1.216 -
   1.217 -{\bf Overview:} 
   1.218 -Destroy the specified PIF instance.
   1.219 -
   1.220 - \noindent {\bf Signature:} 
   1.221 -\begin{verbatim} void destroy (session_id s, PIF ref self)\end{verbatim}
   1.222 -
   1.223 -
   1.224 -\noindent{\bf Arguments:}
   1.225 -
   1.226 - 
   1.227 -\vspace{0.3cm}
   1.228 -\begin{tabular}{|c|c|p{7cm}|}
   1.229 - \hline
   1.230 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.231 -{\tt PIF ref } & self & reference to the object \\ \hline 
   1.232 -
   1.233 -\end{tabular}
   1.234 -
   1.235 -\vspace{0.3cm}
   1.236 -
   1.237 - \noindent {\bf Return Type:} 
   1.238 -{\tt 
   1.239 -void
   1.240 -}
   1.241 -
   1.242 -
   1.243 -
   1.244 -\vspace{0.3cm}
   1.245 -\vspace{0.3cm}
   1.246 -\vspace{0.3cm}
   1.247  \subsubsection{RPC name:~get\_by\_uuid}
   1.248  
   1.249  {\bf Overview:} 
     2.1 --- a/tools/libxen/include/xen_pif.h	Sat Jan 27 18:26:41 2007 +0000
     2.2 +++ b/tools/libxen/include/xen_pif.h	Sun Jan 28 13:40:07 2007 +0000
     2.3 @@ -26,8 +26,8 @@
     2.4  
     2.5  
     2.6  /*
     2.7 - * The PIF class. 
     2.8 - *  
     2.9 + * The PIF class.
    2.10 + * 
    2.11   * A physical network interface (note separate VLANs are represented as
    2.12   * several PIFs).
    2.13   */
    2.14 @@ -65,12 +65,12 @@ typedef struct xen_pif_record
    2.15  {
    2.16      xen_pif handle;
    2.17      char *uuid;
    2.18 -    char *name;
    2.19 +    char *device;
    2.20      struct xen_network_record_opt *network;
    2.21      struct xen_host_record_opt *host;
    2.22      char *mac;
    2.23      int64_t mtu;
    2.24 -    char *vlan;
    2.25 +    int64_t vlan;
    2.26      double io_read_kbs;
    2.27      double io_write_kbs;
    2.28  } xen_pif_record;
    2.29 @@ -169,20 +169,6 @@ xen_pif_get_by_uuid(xen_session *session
    2.30  
    2.31  
    2.32  /**
    2.33 - * Create a new PIF instance, and return its handle.
    2.34 - */
    2.35 -extern bool
    2.36 -xen_pif_create(xen_session *session, xen_pif *result, xen_pif_record *record);
    2.37 -
    2.38 -
    2.39 -/**
    2.40 - * Destroy the specified PIF instance.
    2.41 - */
    2.42 -extern bool
    2.43 -xen_pif_destroy(xen_session *session, xen_pif pif);
    2.44 -
    2.45 -
    2.46 -/**
    2.47   * Get the uuid field of the given PIF.
    2.48   */
    2.49  extern bool
    2.50 @@ -190,10 +176,10 @@ xen_pif_get_uuid(xen_session *session, c
    2.51  
    2.52  
    2.53  /**
    2.54 - * Get the name field of the given PIF.
    2.55 + * Get the device field of the given PIF.
    2.56   */
    2.57  extern bool
    2.58 -xen_pif_get_name(xen_session *session, char **result, xen_pif pif);
    2.59 +xen_pif_get_device(xen_session *session, char **result, xen_pif pif);
    2.60  
    2.61  
    2.62  /**
    2.63 @@ -228,7 +214,7 @@ xen_pif_get_mtu(xen_session *session, in
    2.64   * Get the VLAN field of the given PIF.
    2.65   */
    2.66  extern bool
    2.67 -xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif);
    2.68 +xen_pif_get_vlan(xen_session *session, int64_t *result, xen_pif pif);
    2.69  
    2.70  
    2.71  /**
    2.72 @@ -246,10 +232,10 @@ xen_pif_get_io_write_kbs(xen_session *se
    2.73  
    2.74  
    2.75  /**
    2.76 - * Set the name field of the given PIF.
    2.77 + * Set the device field of the given PIF.
    2.78   */
    2.79  extern bool
    2.80 -xen_pif_set_name(xen_session *session, xen_pif pif, char *name);
    2.81 +xen_pif_set_device(xen_session *session, xen_pif pif, char *device);
    2.82  
    2.83  
    2.84  /**
    2.85 @@ -284,7 +270,22 @@ xen_pif_set_mtu(xen_session *session, xe
    2.86   * Set the VLAN field of the given PIF.
    2.87   */
    2.88  extern bool
    2.89 -xen_pif_set_vlan(xen_session *session, xen_pif pif, char *vlan);
    2.90 +xen_pif_set_vlan(xen_session *session, xen_pif pif, int64_t vlan);
    2.91 +
    2.92 +
    2.93 +/**
    2.94 + * Create a VLAN interface from an existing physical interface
    2.95 + */
    2.96 +extern bool
    2.97 +xen_pif_create_vlan(xen_session *session, xen_pif *result, char *device, xen_network network, xen_host host, int64_t vlan);
    2.98 +
    2.99 +
   2.100 +/**
   2.101 + * Destroy the interface (provided it is a synthetic interface like a
   2.102 + * VLAN; fail if it is a physical interface)
   2.103 + */
   2.104 +extern bool
   2.105 +xen_pif_destroy(xen_session *session, xen_pif self);
   2.106  
   2.107  
   2.108  #endif
     3.1 --- a/tools/libxen/src/xen_pif.c	Sat Jan 27 18:26:41 2007 +0000
     3.2 +++ b/tools/libxen/src/xen_pif.c	Sun Jan 28 13:40:07 2007 +0000
     3.3 @@ -41,9 +41,9 @@ static const struct_member xen_pif_recor
     3.4          { .key = "uuid",
     3.5            .type = &abstract_type_string,
     3.6            .offset = offsetof(xen_pif_record, uuid) },
     3.7 -        { .key = "name",
     3.8 +        { .key = "device",
     3.9            .type = &abstract_type_string,
    3.10 -          .offset = offsetof(xen_pif_record, name) },
    3.11 +          .offset = offsetof(xen_pif_record, device) },
    3.12          { .key = "network",
    3.13            .type = &abstract_type_ref,
    3.14            .offset = offsetof(xen_pif_record, network) },
    3.15 @@ -57,7 +57,7 @@ static const struct_member xen_pif_recor
    3.16            .type = &abstract_type_int,
    3.17            .offset = offsetof(xen_pif_record, mtu) },
    3.18          { .key = "VLAN",
    3.19 -          .type = &abstract_type_string,
    3.20 +          .type = &abstract_type_int,
    3.21            .offset = offsetof(xen_pif_record, vlan) },
    3.22          { .key = "io_read_kbs",
    3.23            .type = &abstract_type_float,
    3.24 @@ -86,11 +86,10 @@ xen_pif_record_free(xen_pif_record *reco
    3.25      }
    3.26      free(record->handle);
    3.27      free(record->uuid);
    3.28 -    free(record->name);
    3.29 +    free(record->device);
    3.30      xen_network_record_opt_free(record->network);
    3.31      xen_host_record_opt_free(record->host);
    3.32      free(record->mac);
    3.33 -    free(record->vlan);
    3.34      free(record);
    3.35  }
    3.36  
    3.37 @@ -136,38 +135,7 @@ xen_pif_get_by_uuid(xen_session *session
    3.38  
    3.39  
    3.40  bool
    3.41 -xen_pif_create(xen_session *session, xen_pif *result, xen_pif_record *record)
    3.42 -{
    3.43 -    abstract_value param_values[] =
    3.44 -        {
    3.45 -            { .type = &xen_pif_record_abstract_type_,
    3.46 -              .u.struct_val = record }
    3.47 -        };
    3.48 -
    3.49 -    abstract_type result_type = abstract_type_string;
    3.50 -
    3.51 -    *result = NULL;
    3.52 -    XEN_CALL_("PIF.create");
    3.53 -    return session->ok;
    3.54 -}
    3.55 -
    3.56 -
    3.57 -bool
    3.58 -xen_pif_destroy(xen_session *session, xen_pif pif)
    3.59 -{
    3.60 -    abstract_value param_values[] =
    3.61 -        {
    3.62 -            { .type = &abstract_type_string,
    3.63 -              .u.string_val = pif }
    3.64 -        };
    3.65 -
    3.66 -    xen_call_(session, "PIF.destroy", param_values, 1, NULL, NULL);
    3.67 -    return session->ok;
    3.68 -}
    3.69 -
    3.70 -
    3.71 -bool
    3.72 -xen_pif_get_name(xen_session *session, char **result, xen_pif pif)
    3.73 +xen_pif_get_device(xen_session *session, char **result, xen_pif pif)
    3.74  {
    3.75      abstract_value param_values[] =
    3.76          {
    3.77 @@ -178,7 +146,7 @@ xen_pif_get_name(xen_session *session, c
    3.78      abstract_type result_type = abstract_type_string;
    3.79  
    3.80      *result = NULL;
    3.81 -    XEN_CALL_("PIF.get_name");
    3.82 +    XEN_CALL_("PIF.get_device");
    3.83      return session->ok;
    3.84  }
    3.85  
    3.86 @@ -251,7 +219,7 @@ xen_pif_get_mtu(xen_session *session, in
    3.87  
    3.88  
    3.89  bool
    3.90 -xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif)
    3.91 +xen_pif_get_vlan(xen_session *session, int64_t *result, xen_pif pif)
    3.92  {
    3.93      abstract_value param_values[] =
    3.94          {
    3.95 @@ -259,9 +227,8 @@ xen_pif_get_vlan(xen_session *session, c
    3.96                .u.string_val = pif }
    3.97          };
    3.98  
    3.99 -    abstract_type result_type = abstract_type_string;
   3.100 +    abstract_type result_type = abstract_type_int;
   3.101  
   3.102 -    *result = NULL;
   3.103      XEN_CALL_("PIF.get_VLAN");
   3.104      return session->ok;
   3.105  }
   3.106 @@ -300,17 +267,17 @@ xen_pif_get_io_write_kbs(xen_session *se
   3.107  
   3.108  
   3.109  bool
   3.110 -xen_pif_set_name(xen_session *session, xen_pif pif, char *name)
   3.111 +xen_pif_set_device(xen_session *session, xen_pif pif, char *device)
   3.112  {
   3.113      abstract_value param_values[] =
   3.114          {
   3.115              { .type = &abstract_type_string,
   3.116                .u.string_val = pif },
   3.117              { .type = &abstract_type_string,
   3.118 -              .u.string_val = name }
   3.119 +              .u.string_val = device }
   3.120          };
   3.121  
   3.122 -    xen_call_(session, "PIF.set_name", param_values, 2, NULL, NULL);
   3.123 +    xen_call_(session, "PIF.set_device", param_values, 2, NULL, NULL);
   3.124      return session->ok;
   3.125  }
   3.126  
   3.127 @@ -380,14 +347,14 @@ xen_pif_set_mtu(xen_session *session, xe
   3.128  
   3.129  
   3.130  bool
   3.131 -xen_pif_set_vlan(xen_session *session, xen_pif pif, char *vlan)
   3.132 +xen_pif_set_vlan(xen_session *session, xen_pif pif, int64_t vlan)
   3.133  {
   3.134      abstract_value param_values[] =
   3.135          {
   3.136              { .type = &abstract_type_string,
   3.137                .u.string_val = pif },
   3.138 -            { .type = &abstract_type_string,
   3.139 -              .u.string_val = vlan }
   3.140 +            { .type = &abstract_type_int,
   3.141 +              .u.int_val = vlan }
   3.142          };
   3.143  
   3.144      xen_call_(session, "PIF.set_VLAN", param_values, 2, NULL, NULL);
   3.145 @@ -396,6 +363,43 @@ xen_pif_set_vlan(xen_session *session, x
   3.146  
   3.147  
   3.148  bool
   3.149 +xen_pif_create_vlan(xen_session *session, xen_pif *result, char *device, xen_network network, xen_host host, int64_t vlan)
   3.150 +{
   3.151 +    abstract_value param_values[] =
   3.152 +        {
   3.153 +            { .type = &abstract_type_string,
   3.154 +              .u.string_val = device },
   3.155 +            { .type = &abstract_type_string,
   3.156 +              .u.string_val = network },
   3.157 +            { .type = &abstract_type_string,
   3.158 +              .u.string_val = host },
   3.159 +            { .type = &abstract_type_int,
   3.160 +              .u.int_val = vlan }
   3.161 +        };
   3.162 +
   3.163 +    abstract_type result_type = abstract_type_string;
   3.164 +
   3.165 +    *result = NULL;
   3.166 +    XEN_CALL_("PIF.create_VLAN");
   3.167 +    return session->ok;
   3.168 +}
   3.169 +
   3.170 +
   3.171 +bool
   3.172 +xen_pif_destroy(xen_session *session, xen_pif self)
   3.173 +{
   3.174 +    abstract_value param_values[] =
   3.175 +        {
   3.176 +            { .type = &abstract_type_string,
   3.177 +              .u.string_val = self }
   3.178 +        };
   3.179 +
   3.180 +    xen_call_(session, "PIF.destroy", param_values, 1, NULL, NULL);
   3.181 +    return session->ok;
   3.182 +}
   3.183 +
   3.184 +
   3.185 +bool
   3.186  xen_pif_get_uuid(xen_session *session, char **result, xen_pif pif)
   3.187  {
   3.188      *result = session->ok ? xen_strdup_((char *)pif) : NULL;
     4.1 --- a/tools/python/xen/xend/XendAPI.py	Sat Jan 27 18:26:41 2007 +0000
     4.2 +++ b/tools/python/xen/xend/XendAPI.py	Sun Jan 28 13:40:07 2007 +0000
     4.3 @@ -752,7 +752,7 @@ class XendAPI(object):
     4.4  
     4.5      PIF_attr_ro = ['io_read_kbs',
     4.6                     'io_write_kbs']
     4.7 -    PIF_attr_rw = ['name',
     4.8 +    PIF_attr_rw = ['device',
     4.9                     'network',
    4.10                     'host',
    4.11                     'MAC',
    4.12 @@ -766,24 +766,11 @@ class XendAPI(object):
    4.13      def _get_PIF(self, ref):
    4.14          return XendNode.instance().pifs[ref]
    4.15  
    4.16 -    def PIF_create(self, _, name, network_uuid, host_uuid, mac, mtu, vlan):
    4.17 +    def PIF_destroy(self, _, ref):
    4.18          try:
    4.19 -            node = XendNode.instance()
    4.20 -            if host_uuid != node.uuid:
    4.21 -                return xen_api_error(['HOST_HANDLE_INVALID', host_uuid])
    4.22 -
    4.23 -            elif _is_valid_ref(network_uuid, node.is_valid_network):
    4.24 -                network = node.get_network(network_uuid)
    4.25 -                return xen_api_success(node.PIF_create(name, mtu, vlan, mac,
    4.26 -                                                       network))
    4.27 -            else:
    4.28 -                return xen_api_error(['NETWORK_HANDLE_INVALID', network_uuid])
    4.29 -        except NetworkAlreadyConnected, exn:
    4.30 -            return xen_api_error(['NETWORK_ALREADY_CONNECTED',
    4.31 -                                  network_uuid, exn.pif_uuid])
    4.32 -
    4.33 -    def PIF_destroy(self, _, ref):
    4.34 -        return xen_api_success(XendNode.instance().PIF_destroy(ref))
    4.35 +            return xen_api_success(XendNode.instance().PIF_destroy(ref))
    4.36 +        except PIFIsPhysical, exn:
    4.37 +            return xen_api_error(['PIF_IS_PHYSICAL', ref])
    4.38  
    4.39      # object methods
    4.40      def PIF_get_record(self, _, ref):
    4.41 @@ -792,8 +779,8 @@ class XendAPI(object):
    4.42      def PIF_get_all(self, _):
    4.43          return xen_api_success(XendNode.instance().pifs.keys())
    4.44  
    4.45 -    def PIF_get_name(self, _, ref):
    4.46 -        return xen_api_success(self._get_PIF(ref).name)
    4.47 +    def PIF_get_device(self, _, ref):
    4.48 +        return xen_api_success(self._get_PIF(ref).device)
    4.49  
    4.50      def PIF_get_network(self, _, ref):
    4.51          return xen_api_success(self._get_PIF(ref).network.uuid)
    4.52 @@ -816,8 +803,8 @@ class XendAPI(object):
    4.53      def PIF_get_io_write_kbs(self, _, ref):
    4.54          return xen_api_success(self._get_PIF(ref).get_io_write_kbs())
    4.55      
    4.56 -    def PIF_set_name(self, _, ref, name):
    4.57 -        return xen_api_success(self._get_PIF(ref).set_name(name))
    4.58 +    def PIF_set_device(self, _, ref, device):
    4.59 +        return xen_api_success(self._get_PIF(ref).set_device(device))
    4.60  
    4.61      def PIF_set_MAC(self, _, ref, mac):
    4.62          return xen_api_success(self._get_PIF(ref).set_mac(mac))
    4.63 @@ -827,14 +814,23 @@ class XendAPI(object):
    4.64  
    4.65      def PIF_create_VLAN(self, _, ref, network, vlan):
    4.66          try:
    4.67 -            if _is_valid_ref(network, XendNode.instance().is_valid_network):
    4.68 -                return xen_api_success(XendNode.instance().PIF_create_VLAN(
    4.69 -                    ref, network, vlan))
    4.70 +            vlan = int(vlan)
    4.71 +        except:
    4.72 +            return xen_api_error(['VLAN_TAG_INVALID', vlan])
    4.73 +
    4.74 +        try:
    4.75 +            node = XendNode.instance()
    4.76 +            
    4.77 +            if _is_valid_ref(network, node.is_valid_network):
    4.78 +                return xen_api_success(
    4.79 +                    node.PIF_create_VLAN(ref, network, vlan))
    4.80              else:
    4.81                  return xen_api_error(['NETWORK_HANDLE_INVALID', network])
    4.82          except NetworkAlreadyConnected, exn:
    4.83              return xen_api_error(['NETWORK_ALREADY_CONNECTED',
    4.84                                    network, exn.pif_uuid])
    4.85 +        except VLANTagInvalid:
    4.86 +            return xen_api_error(['VLAN_TAG_INVALID', vlan])
    4.87  
    4.88  
    4.89      # Xen API: Class VM
     5.1 --- a/tools/python/xen/xend/XendError.py	Sat Jan 27 18:26:41 2007 +0000
     5.2 +++ b/tools/python/xen/xend/XendError.py	Sun Jan 28 13:40:07 2007 +0000
     5.3 @@ -43,6 +43,14 @@ class NetworkAlreadyConnected(XendError)
     5.4          XendError.__init__(self, 'Network already connected')
     5.5          self.pif_uuid = pif_uuid
     5.6  
     5.7 +class PIFIsPhysical(XendError):
     5.8 +    def __init__(self):
     5.9 +        XendError.__init__(self, 'PIF is physical')
    5.10 +
    5.11 +class VLANTagInvalid(XendError):
    5.12 +    def __init__(self):
    5.13 +        XendError.__init__(self, 'VLAN tag invalid')
    5.14 +
    5.15  class VmError(XendError):
    5.16      """Vm construction error."""
    5.17      pass
     6.1 --- a/tools/python/xen/xend/XendNode.py	Sat Jan 27 18:26:41 2007 +0000
     6.2 +++ b/tools/python/xen/xend/XendNode.py	Sun Jan 28 13:40:07 2007 +0000
     6.3 @@ -23,7 +23,7 @@ import xen.lowlevel.xc
     6.4  from xen.util import Brctl
     6.5  
     6.6  from xen.xend import uuid
     6.7 -from xen.xend.XendError import XendError, NetworkAlreadyConnected
     6.8 +from xen.xend.XendError import *
     6.9  from xen.xend.XendOptions import instance as xendoptions
    6.10  from xen.xend.XendQCoWStorageRepo import XendQCoWStorageRepo
    6.11  from xen.xend.XendLocalStorageRepo import XendLocalStorageRepo
    6.12 @@ -111,8 +111,13 @@ class XendNode:
    6.13                  if pif.get('network') in self.networks:
    6.14                      network = self.networks[pif['network']]
    6.15                      try:
    6.16 -                        self.PIF_create(pif['name'], pif['MTU'], pif['VLAN'],
    6.17 -                                        pif['MAC'], network, False, pif_uuid)
    6.18 +                        if 'device' not in pif and 'name' in pif:
    6.19 +                            # Compatibility hack, can go pretty soon.
    6.20 +                            pif['device'] = pif['name']
    6.21 +                        
    6.22 +                        self._PIF_create(pif['device'], pif['MTU'],
    6.23 +                                         int(pif['VLAN']),
    6.24 +                                         pif['MAC'], network, False, pif_uuid)
    6.25                      except NetworkAlreadyConnected, exn:
    6.26                          log.error('Cannot load saved PIF %s, as network %s ' +
    6.27                                    'is already connected to PIF %s',
    6.28 @@ -120,7 +125,7 @@ class XendNode:
    6.29          else:
    6.30              for name, mtu, mac in linux_get_phy_ifaces():
    6.31                  network = self.networks.values()[0]
    6.32 -                self.PIF_create(name, mtu, '', mac, network, False)
    6.33 +                self._PIF_create(name, mtu, -1, mac, network, False)
    6.34  
    6.35          # initialise storage
    6.36          saved_srs = self.state_store.load_state('sr')
    6.37 @@ -161,8 +166,8 @@ class XendNode:
    6.38          self.save_networks()
    6.39  
    6.40  
    6.41 -    def PIF_create(self, name, mtu, vlan, mac, network, persist = True,
    6.42 -                   pif_uuid = None):
    6.43 +    def _PIF_create(self, name, mtu, vlan, mac, network, persist = True,
    6.44 +                    pif_uuid = None):
    6.45          for pif in self.pifs.values():
    6.46              if pif.network == network:
    6.47                  raise NetworkAlreadyConnected(pif.uuid)
    6.48 @@ -178,12 +183,20 @@ class XendNode:
    6.49  
    6.50  
    6.51      def PIF_create_VLAN(self, pif_uuid, network_uuid, vlan):
    6.52 +        if vlan < 0 or vlan >= 4096:
    6.53 +            raise VLANTagInvalid()
    6.54 +            
    6.55          pif = self.pifs[pif_uuid]
    6.56          network = self.networks[network_uuid]
    6.57 -        return self.PIF_create(pif.name, pif.mtu, vlan, pif.mac, network)
    6.58 +        return self._PIF_create(pif.device, pif.mtu, vlan, pif.mac, network)
    6.59  
    6.60  
    6.61      def PIF_destroy(self, pif_uuid):
    6.62 +        pif = self.pifs[pif_uuid]
    6.63 +
    6.64 +        if pif.vlan == -1:
    6.65 +            raise PIFIsPhysical()
    6.66 +
    6.67          del self.pifs[pif_uuid]
    6.68          self.save_PIFs()
    6.69  
     7.1 --- a/tools/python/xen/xend/XendPIF.py	Sat Jan 27 18:26:41 2007 +0000
     7.2 +++ b/tools/python/xen/xend/XendPIF.py	Sun Jan 28 13:40:07 2007 +0000
     7.3 @@ -90,18 +90,18 @@ def linux_set_mtu(iface, mtu):
     7.4  class XendPIF:
     7.5      """Representation of a Physical Network Interface."""
     7.6      
     7.7 -    def __init__(self, uuid, name, mtu, vlan, mac, network, host):
     7.8 +    def __init__(self, uuid, device, mtu, vlan, mac, network, host):
     7.9          self.uuid = uuid
    7.10 -        self.name = name
    7.11 +        self.device = device
    7.12          self.mac = mac
    7.13          self.mtu = mtu
    7.14          self.vlan = vlan
    7.15          self.network = network
    7.16          self.host = host
    7.17  
    7.18 -    def set_name(self, new_name):
    7.19 -        self.name = new_name
    7.20 -            
    7.21 +    def set_device(self, new_device):
    7.22 +        self.device = new_device
    7.23 +
    7.24      def set_mac(self, new_mac):
    7.25          success = linux_set_mac(new_mac)
    7.26          if success:
    7.27 @@ -116,14 +116,14 @@ class XendPIF:
    7.28  
    7.29      def get_io_read_kbs(self):
    7.30          from xen.xend.XendNode import instance as xennode
    7.31 -        return xennode().get_pif_util(self.name)[0]
    7.32 +        return xennode().get_pif_util(self.device)[0]
    7.33  
    7.34      def get_io_write_kbs(self):
    7.35          from xen.xend.XendNode import instance as xennode
    7.36 -        return xennode().get_pif_util(self.name)[1]      
    7.37 +        return xennode().get_pif_util(self.device)[1]      
    7.38  
    7.39      def get_record(self, transient = True):
    7.40 -        result = {'name': self.name,
    7.41 +        result = {'device': self.device,
    7.42                    'MAC': self.mac,
    7.43                    'MTU': self.mtu,
    7.44                    'VLAN': self.vlan,
    7.45 @@ -143,10 +143,10 @@ class XendPIF:
    7.46              # there's nothing we can do -- this should have been set up with
    7.47              # the network script.  Otherwise, we can use vconfig to derive
    7.48              # a subinterface.
    7.49 -            if not self.vlan:
    7.50 +            if self.vlan == -1:
    7.51                  return
    7.52              
    7.53 -            rc, _ = _cmd('vconfig add %s %s', self.name, self.vlan)
    7.54 +            rc, _ = _cmd('vconfig add %s %d', self.device, self.vlan)
    7.55              if rc != 0:
    7.56                  log.error('Could not refresh %s', ifname)
    7.57                  return
    7.58 @@ -176,9 +176,9 @@ class XendPIF:
    7.59  
    7.60      def interface_name(self):
    7.61          if self.vlan:
    7.62 -            return '%s.%s' % (self.name, self.vlan)
    7.63 +            return '%s.%d' % (self.device, self.vlan)
    7.64          else:
    7.65 -            return self.name
    7.66 +            return self.device
    7.67  
    7.68  
    7.69  def _cmd(cmd, *args):
     8.1 --- a/tools/python/xen/xm/messages/en/xen-xm.po	Sat Jan 27 18:26:41 2007 +0000
     8.2 +++ b/tools/python/xen/xm/messages/en/xen-xm.po	Sun Jan 28 13:40:07 2007 +0000
     8.3 @@ -12,14 +12,14 @@
     8.4  # License along with this library; if not, write to the Free Software
     8.5  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     8.6  # ============================================================================
     8.7 -# Copyright (c) 2006 XenSource Inc.
     8.8 +# Copyright (c) 2006-2007 XenSource Inc.
     8.9  # ============================================================================
    8.10  # 
    8.11  #
    8.12  msgid ""
    8.13  msgstr ""
    8.14  "Project-Id-Version: Xen-xm 3.0\n"
    8.15 -"PO-Revision-Date: 2006-12-28 15:43+0000\n"
    8.16 +"PO-Revision-Date: 2007-01-28 12:59+0000\n"
    8.17  "Last-Translator: Ewan Mellor <ewan@xensource.com>\n"
    8.18  "Language-Team: xen-devel <xen-devel@lists.xensource.com>\n"
    8.19  "MIME-Version: 1.0\n"
    8.20 @@ -68,5 +68,11 @@ msgstr "The VTPM handle %(1)s is invalid
    8.21  msgid "NETWORK_ALREADY_CONNECTED"
    8.22  msgstr "The network you specified already has a PIF attached to it, and so another one may not be attached."
    8.23  
    8.24 +msgid "PIF_IS_PHYSICAL"
    8.25 +msgstr "The PIF %(1)s corresponds to a physical interface, and so may not be destroyed."
    8.26 +
    8.27 +msgid "VLAN_TAG_INVALID"
    8.28 +msgstr "The VLAN tag you gave (%(1)s) is invalid -- it must be between 0 and 4095."
    8.29 +
    8.30  msgid "VM_BAD_POWER_STATE"
    8.31  msgstr "The VM must be %(2)s to perform the requested operation (it is currently %(3)s)."