[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Add network.destroy() to XenAPI
# HG changeset patch # User Tom Wilkie <tom.wilkie@xxxxxxxxx> # Date 1177598370 -3600 # Node ID 16e38247dee8b244b13b98cce8b96b4049b08873 # Parent 58205257517d100282783f4c192106de5bf65ef9 Add network.destroy() to XenAPI signed-off-by: Tom Wilkie <tom.wilkie@xxxxxxxxx> --- tools/python/xen/xend/XendBase.py | 3 +++ tools/python/xen/xend/XendError.py | 12 ++++++++++++ tools/python/xen/xend/XendNetwork.py | 19 ++++++++++++++++++- tools/python/xen/xm/messages/en/xen-xm.po | 5 ++++- 4 files changed, 37 insertions(+), 2 deletions(-) diff -r 58205257517d -r 16e38247dee8 tools/python/xen/xend/XendBase.py --- a/tools/python/xen/xend/XendBase.py Thu Apr 26 15:42:49 2007 +0100 +++ b/tools/python/xen/xend/XendBase.py Thu Apr 26 15:39:30 2007 +0100 @@ -90,6 +90,9 @@ class XendBase: # Finally register it XendAPIStore.register(uuid, self.getClass(), self) + def destroy(self): + XendAPIStore.deregister(self.get_uuid(), self.getClass()) + def get_uuid(self): return self.__uuid diff -r 58205257517d -r 16e38247dee8 tools/python/xen/xend/XendError.py --- a/tools/python/xen/xend/XendError.py Thu Apr 26 15:42:49 2007 +0100 +++ b/tools/python/xen/xend/XendError.py Thu Apr 26 15:39:30 2007 +0100 @@ -162,6 +162,18 @@ class VLANTagInvalid(XendAPIError): def __str__(self): return 'VLAN_TAG_INVALID: %s' % self.vlan + +class NetworkError(XendAPIError): + def __init__(self, error, network): + XendAPIError.__init__(self) + self.network = network + self.error = error + + def get_api_error(self): + return ['NETWORK_ERROR', self.error, self.network] + + def __str__(self): + return 'NETWORK_ERROR: %s %s' % (self.error, self.network) XEND_ERROR_AUTHENTICATION_FAILED = ('ELUSER', 'Authentication Failed') XEND_ERROR_SESSION_INVALID = ('EPERMDENIED', 'Session Invalid') diff -r 58205257517d -r 16e38247dee8 tools/python/xen/xend/XendNetwork.py --- a/tools/python/xen/xend/XendNetwork.py Thu Apr 26 15:42:49 2007 +0100 +++ b/tools/python/xen/xend/XendNetwork.py Thu Apr 26 15:39:30 2007 +0100 @@ -60,7 +60,8 @@ class XendNetwork(XendBase): def getMethods(self): methods = ['add_to_other_config', - 'remove_from_other_config'] + 'remove_from_other_config', + 'destroy'] return XendBase.getMethods() + methods def getFuncs(self): @@ -128,6 +129,8 @@ class XendNetwork(XendBase): # Create the bridge Brctl.bridge_create(network.name_label) + XendNode.instance().save_networks() + return uuid create_phy = classmethod(create_phy) @@ -140,6 +143,20 @@ class XendNetwork(XendBase): # # XenAPI Mehtods # + + def destroy(self): + # check no VIFs or PIFs attached + if len(self.get_VIFs()) > 0: + raise NetworkError("Cannot destroy network with VIFs attached", + self.get_name_label()) + + if len(self.get_PIFs()) > 0: + raise NetworkError("Cannot destroy network with PIFs attached", + self.get_name_label()) + + XendBase.destroy(self) + Brctl.bridge_del(self.get_name_label()) + XendNode.instance().save_networks() def get_name_label(self): return self.name_label diff -r 58205257517d -r 16e38247dee8 tools/python/xen/xm/messages/en/xen-xm.po --- a/tools/python/xen/xm/messages/en/xen-xm.po Thu Apr 26 15:42:49 2007 +0100 +++ b/tools/python/xen/xm/messages/en/xen-xm.po Thu Apr 26 15:39:30 2007 +0100 @@ -87,4 +87,7 @@ msgstr "Class %s does not implement %s" msgstr "Class %s does not implement %s" msgid "VLAN_TAG_INVALID" -msgstr "VLAN tag invalid %s" \ No newline at end of file +msgstr "VLAN tag invalid %s" + +msgid "NETWORK_ERROR" +msgstr "Network Error: %s - %s" \ No newline at end of file _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |