# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1169991607 0
# Node ID 5e1c7022d4ad69d59b661f73302d8f9a135db714
# Parent ea3c752045555180c2de41913e5efeabd424d0cf
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@xxxxxxxxxxxxx>
---
docs/xen-api/xenapi-datamodel.tex | 178 +++++++++++++++---------------
tools/libxen/include/xen_pif.h | 57 ++++-----
tools/libxen/src/xen_pif.c | 160 +++++++++++++-------------
tools/python/xen/xend/XendAPI.py | 46 +++----
tools/python/xen/xend/XendError.py | 8 +
tools/python/xen/xend/XendNode.py | 27 +++-
tools/python/xen/xend/XendPIF.py | 24 ++--
tools/python/xen/xm/messages/en/xen-xm.po | 10 +
8 files changed, 273 insertions(+), 237 deletions(-)
diff -r ea3c75204555 -r 5e1c7022d4ad docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Sat Jan 27 18:26:41 2007 +0000
+++ b/docs/xen-api/xenapi-datamodel.tex Sun Jan 28 13:40:07 2007 +0000
@@ -6529,22 +6529,94 @@ all fields from the object
\begin{longtable}{|lllp{0.38\textwidth}|}
\hline
\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf PIF} \\
-\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A
physical network interface (note separate VLANs are represented as several
PIFs)}} \\
+\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A
+physical network interface (note separate VLANs are represented as several
+PIFs)}} \\
\hline
Quals & Field & Type & Description \\
\hline
$\mathit{RO}_\mathit{run}$ & {\tt uuid} & string & unique identifier/object
reference \\
-$\mathit{RW}$ & {\tt name} & string & human-readable name of the interface \\
+$\mathit{RW}$ & {\tt device} & string & machine-readable name of the
interface (e.g. eth0) \\
$\mathit{RW}$ & {\tt network} & network ref & virtual network to which this
pif is connected \\
$\mathit{RW}$ & {\tt host} & host ref & physical machine to which this pif is
connected \\
$\mathit{RW}$ & {\tt MAC} & string & ethernet MAC address of physical
interface \\
$\mathit{RW}$ & {\tt MTU} & int & MTU in octets \\
-$\mathit{RW}$ & {\tt VLAN} & string & VLAN tag for all traffic passing
through this interface \\
+$\mathit{RW}$ & {\tt VLAN} & int & VLAN tag for all traffic passing through
this interface \\
$\mathit{RO}_\mathit{run}$ & {\tt io/read\_kbs} & float & Read bandwidth
(KiB/s) \\
$\mathit{RO}_\mathit{run}$ & {\tt io/write\_kbs} & float & Write bandwidth
(KiB/s) \\
\hline
\end{longtable}
\subsection{Additional RPCs associated with class: PIF}
+\subsubsection{RPC name:~create\_VLAN}
+
+{\bf Overview:}
+Create a VLAN interface from an existing physical interface
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (PIF ref) create_VLAN (session_id s, string device, network
ref network, host ref host, int VLAN)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt string } & device & physical interface on which to crate the VLAN
interface \\ \hline
+
+{\tt network ref } & network & network to which this interface should be
connected \\ \hline
+
+{\tt host ref } & host & physical machine to which this PIF is connected \\
\hline
+
+{\tt int } & VLAN & VLAN tag for the new interface \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+PIF ref
+}
+
+
+The reference of the created PIF object
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~destroy}
+
+{\bf Overview:}
+Destroy the interface (provided it is a synthetic interface like a VLAN; fail
if it is a physical interface)
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void destroy (session_id s, PIF ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt PIF ref } & self & the PIF object to destroy \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
\subsubsection{RPC name:~get\_uuid}
{\bf Overview:}
@@ -6577,13 +6649,13 @@ value of the field
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~get\_name}
-
-{\bf Overview:}
-Get the name field of the given PIF.
-
- \noindent {\bf Signature:}
-\begin{verbatim} string get_name (session_id s, PIF ref self)\end{verbatim}
+\subsubsection{RPC name:~get\_device}
+
+{\bf Overview:}
+Get the device field of the given PIF.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_device (session_id s, PIF ref self)\end{verbatim}
\noindent{\bf Arguments:}
@@ -6609,13 +6681,13 @@ value of the field
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~set\_name}
-
-{\bf Overview:}
-Set the name field of the given PIF.
-
- \noindent {\bf Signature:}
-\begin{verbatim} void set_name (session_id s, PIF ref self, string
value)\end{verbatim}
+\subsubsection{RPC name:~set\_device}
+
+{\bf Overview:}
+Set the device field of the given PIF.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void set_device (session_id s, PIF ref self, string
value)\end{verbatim}
\noindent{\bf Arguments:}
@@ -6913,7 +6985,7 @@ Get the VLAN field of the given PIF.
Get the VLAN field of the given PIF.
\noindent {\bf Signature:}
-\begin{verbatim} string get_VLAN (session_id s, PIF ref self)\end{verbatim}
+\begin{verbatim} int get_VLAN (session_id s, PIF ref self)\end{verbatim}
\noindent{\bf Arguments:}
@@ -6931,7 +7003,7 @@ Get the VLAN field of the given PIF.
\noindent {\bf Return Type:}
{\tt
-string
+int
}
@@ -6945,7 +7017,7 @@ Set the VLAN field of the given PIF.
Set the VLAN field of the given PIF.
\noindent {\bf Signature:}
-\begin{verbatim} void set_VLAN (session_id s, PIF ref self, string
value)\end{verbatim}
+\begin{verbatim} void set_VLAN (session_id s, PIF ref self, int
value)\end{verbatim}
\noindent{\bf Arguments:}
@@ -6957,7 +7029,7 @@ Set the VLAN field of the given PIF.
{\bf type} & {\bf name} & {\bf description} \\ \hline
{\tt PIF ref } & self & reference to the object \\ \hline
-{\tt string } & value & New value to set \\ \hline
+{\tt int } & value & New value to set \\ \hline
\end{tabular}
@@ -7034,70 +7106,6 @@ float
value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~create}
-
-{\bf Overview:}
-Create a new PIF instance, and return its handle.
-
- \noindent {\bf Signature:}
-\begin{verbatim} (PIF ref) create (session_id s, PIF record args)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
-
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt PIF record } & args & All constructor arguments \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-PIF ref
-}
-
-
-reference to the newly created object
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~destroy}
-
-{\bf Overview:}
-Destroy the specified PIF instance.
-
- \noindent {\bf Signature:}
-\begin{verbatim} void destroy (session_id s, PIF ref self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
-
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt PIF ref } & self & reference to the object \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-void
-}
-
-
-
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
diff -r ea3c75204555 -r 5e1c7022d4ad tools/libxen/include/xen_pif.h
--- a/tools/libxen/include/xen_pif.h Sat Jan 27 18:26:41 2007 +0000
+++ b/tools/libxen/include/xen_pif.h Sun Jan 28 13:40:07 2007 +0000
@@ -26,8 +26,8 @@
/*
- * The PIF class.
- *
+ * The PIF class.
+ *
* A physical network interface (note separate VLANs are represented as
* several PIFs).
*/
@@ -65,12 +65,12 @@ typedef struct xen_pif_record
{
xen_pif handle;
char *uuid;
- char *name;
+ char *device;
struct xen_network_record_opt *network;
struct xen_host_record_opt *host;
char *mac;
int64_t mtu;
- char *vlan;
+ int64_t vlan;
double io_read_kbs;
double io_write_kbs;
} xen_pif_record;
@@ -169,20 +169,6 @@ xen_pif_get_by_uuid(xen_session *session
/**
- * Create a new PIF instance, and return its handle.
- */
-extern bool
-xen_pif_create(xen_session *session, xen_pif *result, xen_pif_record *record);
-
-
-/**
- * Destroy the specified PIF instance.
- */
-extern bool
-xen_pif_destroy(xen_session *session, xen_pif pif);
-
-
-/**
* Get the uuid field of the given PIF.
*/
extern bool
@@ -190,10 +176,10 @@ xen_pif_get_uuid(xen_session *session, c
/**
- * Get the name field of the given PIF.
- */
-extern bool
-xen_pif_get_name(xen_session *session, char **result, xen_pif pif);
+ * Get the device field of the given PIF.
+ */
+extern bool
+xen_pif_get_device(xen_session *session, char **result, xen_pif pif);
/**
@@ -228,7 +214,7 @@ xen_pif_get_mtu(xen_session *session, in
* Get the VLAN field of the given PIF.
*/
extern bool
-xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif);
+xen_pif_get_vlan(xen_session *session, int64_t *result, xen_pif pif);
/**
@@ -246,10 +232,10 @@ xen_pif_get_io_write_kbs(xen_session *se
/**
- * Set the name field of the given PIF.
- */
-extern bool
-xen_pif_set_name(xen_session *session, xen_pif pif, char *name);
+ * Set the device field of the given PIF.
+ */
+extern bool
+xen_pif_set_device(xen_session *session, xen_pif pif, char *device);
/**
@@ -284,7 +270,22 @@ xen_pif_set_mtu(xen_session *session, xe
* Set the VLAN field of the given PIF.
*/
extern bool
-xen_pif_set_vlan(xen_session *session, xen_pif pif, char *vlan);
+xen_pif_set_vlan(xen_session *session, xen_pif pif, int64_t vlan);
+
+
+/**
+ * Create a VLAN interface from an existing physical interface
+ */
+extern bool
+xen_pif_create_vlan(xen_session *session, xen_pif *result, char *device,
xen_network network, xen_host host, int64_t vlan);
+
+
+/**
+ * Destroy the interface (provided it is a synthetic interface like a
+ * VLAN; fail if it is a physical interface)
+ */
+extern bool
+xen_pif_destroy(xen_session *session, xen_pif self);
#endif
diff -r ea3c75204555 -r 5e1c7022d4ad tools/libxen/src/xen_pif.c
--- a/tools/libxen/src/xen_pif.c Sat Jan 27 18:26:41 2007 +0000
+++ b/tools/libxen/src/xen_pif.c Sun Jan 28 13:40:07 2007 +0000
@@ -41,9 +41,9 @@ static const struct_member xen_pif_recor
{ .key = "uuid",
.type = &abstract_type_string,
.offset = offsetof(xen_pif_record, uuid) },
- { .key = "name",
+ { .key = "device",
.type = &abstract_type_string,
- .offset = offsetof(xen_pif_record, name) },
+ .offset = offsetof(xen_pif_record, device) },
{ .key = "network",
.type = &abstract_type_ref,
.offset = offsetof(xen_pif_record, network) },
@@ -57,7 +57,7 @@ static const struct_member xen_pif_recor
.type = &abstract_type_int,
.offset = offsetof(xen_pif_record, mtu) },
{ .key = "VLAN",
- .type = &abstract_type_string,
+ .type = &abstract_type_int,
.offset = offsetof(xen_pif_record, vlan) },
{ .key = "io_read_kbs",
.type = &abstract_type_float,
@@ -86,11 +86,10 @@ xen_pif_record_free(xen_pif_record *reco
}
free(record->handle);
free(record->uuid);
- free(record->name);
+ free(record->device);
xen_network_record_opt_free(record->network);
xen_host_record_opt_free(record->host);
free(record->mac);
- free(record->vlan);
free(record);
}
@@ -136,49 +135,18 @@ xen_pif_get_by_uuid(xen_session *session
bool
-xen_pif_create(xen_session *session, xen_pif *result, xen_pif_record *record)
-{
- abstract_value param_values[] =
- {
- { .type = &xen_pif_record_abstract_type_,
- .u.struct_val = record }
- };
-
- abstract_type result_type = abstract_type_string;
-
- *result = NULL;
- XEN_CALL_("PIF.create");
- return session->ok;
-}
-
-
-bool
-xen_pif_destroy(xen_session *session, xen_pif pif)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = pif }
- };
-
- xen_call_(session, "PIF.destroy", param_values, 1, NULL, NULL);
- return session->ok;
-}
-
-
-bool
-xen_pif_get_name(xen_session *session, char **result, xen_pif pif)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = pif }
- };
-
- abstract_type result_type = abstract_type_string;
-
- *result = NULL;
- XEN_CALL_("PIF.get_name");
+xen_pif_get_device(xen_session *session, char **result, xen_pif pif)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pif }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("PIF.get_device");
return session->ok;
}
@@ -251,17 +219,16 @@ xen_pif_get_mtu(xen_session *session, in
bool
-xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = pif }
- };
-
- abstract_type result_type = abstract_type_string;
-
- *result = NULL;
+xen_pif_get_vlan(xen_session *session, int64_t *result, xen_pif pif)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pif }
+ };
+
+ abstract_type result_type = abstract_type_int;
+
XEN_CALL_("PIF.get_VLAN");
return session->ok;
}
@@ -300,17 +267,17 @@ xen_pif_get_io_write_kbs(xen_session *se
bool
-xen_pif_set_name(xen_session *session, xen_pif pif, char *name)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = pif },
- { .type = &abstract_type_string,
- .u.string_val = name }
- };
-
- xen_call_(session, "PIF.set_name", param_values, 2, NULL, NULL);
+xen_pif_set_device(xen_session *session, xen_pif pif, char *device)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pif },
+ { .type = &abstract_type_string,
+ .u.string_val = device }
+ };
+
+ xen_call_(session, "PIF.set_device", param_values, 2, NULL, NULL);
return session->ok;
}
@@ -380,14 +347,14 @@ xen_pif_set_mtu(xen_session *session, xe
bool
-xen_pif_set_vlan(xen_session *session, xen_pif pif, char *vlan)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = pif },
- { .type = &abstract_type_string,
- .u.string_val = vlan }
+xen_pif_set_vlan(xen_session *session, xen_pif pif, int64_t vlan)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pif },
+ { .type = &abstract_type_int,
+ .u.int_val = vlan }
};
xen_call_(session, "PIF.set_VLAN", param_values, 2, NULL, NULL);
@@ -396,6 +363,43 @@ xen_pif_set_vlan(xen_session *session, x
bool
+xen_pif_create_vlan(xen_session *session, xen_pif *result, char *device,
xen_network network, xen_host host, int64_t vlan)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = device },
+ { .type = &abstract_type_string,
+ .u.string_val = network },
+ { .type = &abstract_type_string,
+ .u.string_val = host },
+ { .type = &abstract_type_int,
+ .u.int_val = vlan }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("PIF.create_VLAN");
+ return session->ok;
+}
+
+
+bool
+xen_pif_destroy(xen_session *session, xen_pif self)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = self }
+ };
+
+ xen_call_(session, "PIF.destroy", param_values, 1, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
xen_pif_get_uuid(xen_session *session, char **result, xen_pif pif)
{
*result = session->ok ? xen_strdup_((char *)pif) : NULL;
diff -r ea3c75204555 -r 5e1c7022d4ad tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py Sat Jan 27 18:26:41 2007 +0000
+++ b/tools/python/xen/xend/XendAPI.py Sun Jan 28 13:40:07 2007 +0000
@@ -752,7 +752,7 @@ class XendAPI(object):
PIF_attr_ro = ['io_read_kbs',
'io_write_kbs']
- PIF_attr_rw = ['name',
+ PIF_attr_rw = ['device',
'network',
'host',
'MAC',
@@ -766,24 +766,11 @@ class XendAPI(object):
def _get_PIF(self, ref):
return XendNode.instance().pifs[ref]
- def PIF_create(self, _, name, network_uuid, host_uuid, mac, mtu, vlan):
+ def PIF_destroy(self, _, ref):
try:
- node = XendNode.instance()
- if host_uuid != node.uuid:
- return xen_api_error(['HOST_HANDLE_INVALID', host_uuid])
-
- elif _is_valid_ref(network_uuid, node.is_valid_network):
- network = node.get_network(network_uuid)
- return xen_api_success(node.PIF_create(name, mtu, vlan, mac,
- network))
- else:
- return xen_api_error(['NETWORK_HANDLE_INVALID', network_uuid])
- except NetworkAlreadyConnected, exn:
- return xen_api_error(['NETWORK_ALREADY_CONNECTED',
- network_uuid, exn.pif_uuid])
-
- def PIF_destroy(self, _, ref):
- return xen_api_success(XendNode.instance().PIF_destroy(ref))
+ return xen_api_success(XendNode.instance().PIF_destroy(ref))
+ except PIFIsPhysical, exn:
+ return xen_api_error(['PIF_IS_PHYSICAL', ref])
# object methods
def PIF_get_record(self, _, ref):
@@ -792,8 +779,8 @@ class XendAPI(object):
def PIF_get_all(self, _):
return xen_api_success(XendNode.instance().pifs.keys())
- def PIF_get_name(self, _, ref):
- return xen_api_success(self._get_PIF(ref).name)
+ def PIF_get_device(self, _, ref):
+ return xen_api_success(self._get_PIF(ref).device)
def PIF_get_network(self, _, ref):
return xen_api_success(self._get_PIF(ref).network.uuid)
@@ -816,8 +803,8 @@ class XendAPI(object):
def PIF_get_io_write_kbs(self, _, ref):
return xen_api_success(self._get_PIF(ref).get_io_write_kbs())
- def PIF_set_name(self, _, ref, name):
- return xen_api_success(self._get_PIF(ref).set_name(name))
+ def PIF_set_device(self, _, ref, device):
+ return xen_api_success(self._get_PIF(ref).set_device(device))
def PIF_set_MAC(self, _, ref, mac):
return xen_api_success(self._get_PIF(ref).set_mac(mac))
@@ -827,14 +814,23 @@ class XendAPI(object):
def PIF_create_VLAN(self, _, ref, network, vlan):
try:
- if _is_valid_ref(network, XendNode.instance().is_valid_network):
- return xen_api_success(XendNode.instance().PIF_create_VLAN(
- ref, network, vlan))
+ vlan = int(vlan)
+ except:
+ return xen_api_error(['VLAN_TAG_INVALID', vlan])
+
+ try:
+ node = XendNode.instance()
+
+ if _is_valid_ref(network, node.is_valid_network):
+ return xen_api_success(
+ node.PIF_create_VLAN(ref, network, vlan))
else:
return xen_api_error(['NETWORK_HANDLE_INVALID', network])
except NetworkAlreadyConnected, exn:
return xen_api_error(['NETWORK_ALREADY_CONNECTED',
network, exn.pif_uuid])
+ except VLANTagInvalid:
+ return xen_api_error(['VLAN_TAG_INVALID', vlan])
# Xen API: Class VM
diff -r ea3c75204555 -r 5e1c7022d4ad tools/python/xen/xend/XendError.py
--- a/tools/python/xen/xend/XendError.py Sat Jan 27 18:26:41 2007 +0000
+++ b/tools/python/xen/xend/XendError.py Sun Jan 28 13:40:07 2007 +0000
@@ -43,6 +43,14 @@ class NetworkAlreadyConnected(XendError)
XendError.__init__(self, 'Network already connected')
self.pif_uuid = pif_uuid
+class PIFIsPhysical(XendError):
+ def __init__(self):
+ XendError.__init__(self, 'PIF is physical')
+
+class VLANTagInvalid(XendError):
+ def __init__(self):
+ XendError.__init__(self, 'VLAN tag invalid')
+
class VmError(XendError):
"""Vm construction error."""
pass
diff -r ea3c75204555 -r 5e1c7022d4ad tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Sat Jan 27 18:26:41 2007 +0000
+++ b/tools/python/xen/xend/XendNode.py Sun Jan 28 13:40:07 2007 +0000
@@ -23,7 +23,7 @@ from xen.util import Brctl
from xen.util import Brctl
from xen.xend import uuid
-from xen.xend.XendError import XendError, NetworkAlreadyConnected
+from xen.xend.XendError import *
from xen.xend.XendOptions import instance as xendoptions
from xen.xend.XendQCoWStorageRepo import XendQCoWStorageRepo
from xen.xend.XendLocalStorageRepo import XendLocalStorageRepo
@@ -111,8 +111,13 @@ class XendNode:
if pif.get('network') in self.networks:
network = self.networks[pif['network']]
try:
- self.PIF_create(pif['name'], pif['MTU'], pif['VLAN'],
- pif['MAC'], network, False, pif_uuid)
+ if 'device' not in pif and 'name' in pif:
+ # Compatibility hack, can go pretty soon.
+ pif['device'] = pif['name']
+
+ self._PIF_create(pif['device'], pif['MTU'],
+ int(pif['VLAN']),
+ pif['MAC'], network, False, pif_uuid)
except NetworkAlreadyConnected, exn:
log.error('Cannot load saved PIF %s, as network %s ' +
'is already connected to PIF %s',
@@ -120,7 +125,7 @@ class XendNode:
else:
for name, mtu, mac in linux_get_phy_ifaces():
network = self.networks.values()[0]
- self.PIF_create(name, mtu, '', mac, network, False)
+ self._PIF_create(name, mtu, -1, mac, network, False)
# initialise storage
saved_srs = self.state_store.load_state('sr')
@@ -161,8 +166,8 @@ class XendNode:
self.save_networks()
- def PIF_create(self, name, mtu, vlan, mac, network, persist = True,
- pif_uuid = None):
+ def _PIF_create(self, name, mtu, vlan, mac, network, persist = True,
+ pif_uuid = None):
for pif in self.pifs.values():
if pif.network == network:
raise NetworkAlreadyConnected(pif.uuid)
@@ -178,12 +183,20 @@ class XendNode:
def PIF_create_VLAN(self, pif_uuid, network_uuid, vlan):
+ if vlan < 0 or vlan >= 4096:
+ raise VLANTagInvalid()
+
pif = self.pifs[pif_uuid]
network = self.networks[network_uuid]
- return self.PIF_create(pif.name, pif.mtu, vlan, pif.mac, network)
+ return self._PIF_create(pif.device, pif.mtu, vlan, pif.mac, network)
def PIF_destroy(self, pif_uuid):
+ pif = self.pifs[pif_uuid]
+
+ if pif.vlan == -1:
+ raise PIFIsPhysical()
+
del self.pifs[pif_uuid]
self.save_PIFs()
diff -r ea3c75204555 -r 5e1c7022d4ad tools/python/xen/xend/XendPIF.py
--- a/tools/python/xen/xend/XendPIF.py Sat Jan 27 18:26:41 2007 +0000
+++ b/tools/python/xen/xend/XendPIF.py Sun Jan 28 13:40:07 2007 +0000
@@ -90,18 +90,18 @@ class XendPIF:
class XendPIF:
"""Representation of a Physical Network Interface."""
- def __init__(self, uuid, name, mtu, vlan, mac, network, host):
+ def __init__(self, uuid, device, mtu, vlan, mac, network, host):
self.uuid = uuid
- self.name = name
+ self.device = device
self.mac = mac
self.mtu = mtu
self.vlan = vlan
self.network = network
self.host = host
- def set_name(self, new_name):
- self.name = new_name
-
+ def set_device(self, new_device):
+ self.device = new_device
+
def set_mac(self, new_mac):
success = linux_set_mac(new_mac)
if success:
@@ -116,14 +116,14 @@ class XendPIF:
def get_io_read_kbs(self):
from xen.xend.XendNode import instance as xennode
- return xennode().get_pif_util(self.name)[0]
+ return xennode().get_pif_util(self.device)[0]
def get_io_write_kbs(self):
from xen.xend.XendNode import instance as xennode
- return xennode().get_pif_util(self.name)[1]
+ return xennode().get_pif_util(self.device)[1]
def get_record(self, transient = True):
- result = {'name': self.name,
+ result = {'device': self.device,
'MAC': self.mac,
'MTU': self.mtu,
'VLAN': self.vlan,
@@ -143,10 +143,10 @@ class XendPIF:
# there's nothing we can do -- this should have been set up with
# the network script. Otherwise, we can use vconfig to derive
# a subinterface.
- if not self.vlan:
+ if self.vlan == -1:
return
- rc, _ = _cmd('vconfig add %s %s', self.name, self.vlan)
+ rc, _ = _cmd('vconfig add %s %d', self.device, self.vlan)
if rc != 0:
log.error('Could not refresh %s', ifname)
return
@@ -176,9 +176,9 @@ class XendPIF:
def interface_name(self):
if self.vlan:
- return '%s.%s' % (self.name, self.vlan)
+ return '%s.%d' % (self.device, self.vlan)
else:
- return self.name
+ return self.device
def _cmd(cmd, *args):
diff -r ea3c75204555 -r 5e1c7022d4ad tools/python/xen/xm/messages/en/xen-xm.po
--- a/tools/python/xen/xm/messages/en/xen-xm.po Sat Jan 27 18:26:41 2007 +0000
+++ b/tools/python/xen/xm/messages/en/xen-xm.po Sun Jan 28 13:40:07 2007 +0000
@@ -12,14 +12,14 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# ============================================================================
-# Copyright (c) 2006 XenSource Inc.
+# Copyright (c) 2006-2007 XenSource Inc.
# ============================================================================
#
#
msgid ""
msgstr ""
"Project-Id-Version: Xen-xm 3.0\n"
-"PO-Revision-Date: 2006-12-28 15:43+0000\n"
+"PO-Revision-Date: 2007-01-28 12:59+0000\n"
"Last-Translator: Ewan Mellor <ewan@xxxxxxxxxxxxx>\n"
"Language-Team: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>\n"
"MIME-Version: 1.0\n"
@@ -68,5 +68,11 @@ msgid "NETWORK_ALREADY_CONNECTED"
msgid "NETWORK_ALREADY_CONNECTED"
msgstr "The network you specified already has a PIF attached to it, and so
another one may not be attached."
+msgid "PIF_IS_PHYSICAL"
+msgstr "The PIF %(1)s corresponds to a physical interface, and so may not be
destroyed."
+
+msgid "VLAN_TAG_INVALID"
+msgstr "The VLAN tag you gave (%(1)s) is invalid -- it must be between 0 and
4095."
+
msgid "VM_BAD_POWER_STATE"
msgstr "The VM must be %(2)s to perform the requested operation (it is
currently %(3)s)."
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|