From: Ewan Mellor Date: Sun, 28 Jan 2007 13:40:07 +0000 (+0000) Subject: Document existing PIF.create_VLAN, and remove PIF.create (PIFs are implicitly X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15368^2~66 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=bd16434c05c6e62b093b9957c1d9a577255d7e2f;p=xen.git 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 --- diff --git a/docs/xen-api/xenapi-datamodel.tex b/docs/xen-api/xenapi-datamodel.tex index 8b837a09ef..d650092a58 100644 --- a/docs/xen-api/xenapi-datamodel.tex +++ b/docs/xen-api/xenapi-datamodel.tex @@ -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} +\subsubsection{RPC name:~get\_device} {\bf Overview:} -Get the name field of the given PIF. +Get the device field of the given PIF. \noindent {\bf Signature:} -\begin{verbatim} string get_name (session_id s, PIF ref self)\end{verbatim} +\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} +\subsubsection{RPC name:~set\_device} {\bf Overview:} -Set the name field of the given PIF. +Set the device field of the given PIF. \noindent {\bf Signature:} -\begin{verbatim} void set_name (session_id s, PIF ref self, string value)\end{verbatim} +\begin{verbatim} void set_device (session_id s, PIF ref self, string value)\end{verbatim} \noindent{\bf Arguments:} @@ -6913,7 +6985,7 @@ void 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 @@ value of the field 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 --git a/tools/libxen/include/xen_pif.h b/tools/libxen/include/xen_pif.h index edc2b5a83b..0c0525f9a1 100644 --- a/tools/libxen/include/xen_pif.h +++ b/tools/libxen/include/xen_pif.h @@ -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; @@ -168,20 +168,6 @@ extern bool xen_pif_get_by_uuid(xen_session *session, xen_pif *result, char *uuid); -/** - * 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. */ @@ -190,10 +176,10 @@ xen_pif_get_uuid(xen_session *session, char **result, xen_pif pif); /** - * Get the name field of the given PIF. + * Get the device field of the given PIF. */ extern bool -xen_pif_get_name(xen_session *session, char **result, xen_pif pif); +xen_pif_get_device(xen_session *session, char **result, xen_pif pif); /** @@ -228,7 +214,7 @@ xen_pif_get_mtu(xen_session *session, int64_t *result, xen_pif pif); * 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 *session, double *result, xen_pif pif); /** - * Set the name field of the given PIF. + * Set the device field of the given PIF. */ extern bool -xen_pif_set_name(xen_session *session, xen_pif pif, char *name); +xen_pif_set_device(xen_session *session, xen_pif pif, char *device); /** @@ -284,7 +270,22 @@ xen_pif_set_mtu(xen_session *session, xen_pif pif, int64_t mtu); * 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 --git a/tools/libxen/src/xen_pif.c b/tools/libxen/src/xen_pif.c index b3edd91e6d..16cfe53901 100644 --- a/tools/libxen/src/xen_pif.c +++ b/tools/libxen/src/xen_pif.c @@ -41,9 +41,9 @@ static const struct_member xen_pif_record_struct_members[] = { .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_record_struct_members[] = .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 *record) } 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,38 +135,7 @@ xen_pif_get_by_uuid(xen_session *session, xen_pif *result, char *uuid) 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) +xen_pif_get_device(xen_session *session, char **result, xen_pif pif) { abstract_value param_values[] = { @@ -178,7 +146,7 @@ xen_pif_get_name(xen_session *session, char **result, xen_pif pif) abstract_type result_type = abstract_type_string; *result = NULL; - XEN_CALL_("PIF.get_name"); + XEN_CALL_("PIF.get_device"); return session->ok; } @@ -251,7 +219,7 @@ xen_pif_get_mtu(xen_session *session, int64_t *result, xen_pif pif) 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) { abstract_value param_values[] = { @@ -259,9 +227,8 @@ xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif) .u.string_val = pif } }; - abstract_type result_type = abstract_type_string; + abstract_type result_type = abstract_type_int; - *result = NULL; XEN_CALL_("PIF.get_VLAN"); return session->ok; } @@ -300,17 +267,17 @@ xen_pif_get_io_write_kbs(xen_session *session, double *result, xen_pif pif) bool -xen_pif_set_name(xen_session *session, xen_pif pif, char *name) +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 = name } + .u.string_val = device } }; - xen_call_(session, "PIF.set_name", param_values, 2, NULL, NULL); + 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, xen_pif pif, int64_t mtu) 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) { abstract_value param_values[] = { { .type = &abstract_type_string, .u.string_val = pif }, - { .type = &abstract_type_string, - .u.string_val = vlan } + { .type = &abstract_type_int, + .u.int_val = vlan } }; xen_call_(session, "PIF.set_VLAN", param_values, 2, NULL, NULL); @@ -395,6 +362,43 @@ xen_pif_set_vlan(xen_session *session, xen_pif pif, char *vlan) } +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) { diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py index b9e6dfe1c8..60f50330c4 100644 --- a/tools/python/xen/xend/XendAPI.py +++ b/tools/python/xen/xend/XendAPI.py @@ -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): - 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)) + try: + 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 --git a/tools/python/xen/xend/XendError.py b/tools/python/xen/xend/XendError.py index 439133d9a0..f1507c43dc 100644 --- a/tools/python/xen/xend/XendError.py +++ b/tools/python/xen/xend/XendError.py @@ -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 --git a/tools/python/xen/xend/XendNode.py b/tools/python/xen/xend/XendNode.py index 713dc081d4..e742477ee4 100644 --- a/tools/python/xen/xend/XendNode.py +++ b/tools/python/xen/xend/XendNode.py @@ -23,7 +23,7 @@ import xen.lowlevel.xc 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 --git a/tools/python/xen/xend/XendPIF.py b/tools/python/xen/xend/XendPIF.py index 057d1335ec..a8afde9546 100644 --- a/tools/python/xen/xend/XendPIF.py +++ b/tools/python/xen/xend/XendPIF.py @@ -90,18 +90,18 @@ def linux_set_mtu(iface, mtu): 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 --git a/tools/python/xen/xm/messages/en/xen-xm.po b/tools/python/xen/xm/messages/en/xen-xm.po index ff4b4ea75b..9778b17031 100644 --- a/tools/python/xen/xm/messages/en/xen-xm.po +++ b/tools/python/xen/xm/messages/en/xen-xm.po @@ -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 \n" "Language-Team: xen-devel \n" "MIME-Version: 1.0\n" @@ -68,5 +68,11 @@ msgstr "The VTPM handle %(1)s is invalid." 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)."