launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06854
[Merge] lp:~rvb/maas/maas-bug-961414 into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/maas-bug-961414 into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/maas-bug-961414/+merge/98850
When a node is deleted, the related mac addresses are deleted right *after* the node itself is deleted. This causes the provisioning server to blow up (http://paste.ubuntu.com/895141/) because it tries to unregister the mac address from a non-existant node. This branch overrides node.delete to manually delete the related mac addresses.
--
https://code.launchpad.net/~rvb/maas/maas-bug-961414/+merge/98850
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/maas-bug-961414 into lp:maas.
=== modified file 'src/maasserver/models.py'
--- src/maasserver/models.py 2012-03-22 14:30:46 +0000
+++ src/maasserver/models.py 2012-03-22 14:34:24 +0000
@@ -431,6 +431,11 @@
if mac:
mac.delete()
+ def delete(self):
+ # Delete the related mac addresses first.
+ self.macaddress_set.all().delete()
+ super(Node, self).delete()
+
def set_mac_based_hostname(self, mac_address):
mac_hostname = mac_address.replace(':', '').lower()
self.hostname = "node-%s" % mac_hostname
=== modified file 'src/maasserver/tests/test_models.py'
--- src/maasserver/tests/test_models.py 2012-03-22 14:30:46 +0000
+++ src/maasserver/tests/test_models.py 2012-03-22 14:34:24 +0000
@@ -95,6 +95,13 @@
node=node, mac_address='AA:BB:CC:DD:EE:FF').count()
self.assertEqual(0, macs)
+ def test_delete_node_deletes_related_mac(self):
+ node = factory.make_node()
+ mac = node.add_mac_address('AA:BB:CC:DD:EE:FF')
+ node.delete()
+ self.assertRaises(
+ MACAddress.DoesNotExist, MACAddress.objects.get, id=mac.id)
+
def test_set_mac_based_hostname(self):
node = factory.make_node()
node.set_mac_based_hostname('AA:BB:CC:DD:EE:FF')
=== modified file 'src/maasserver/views.py'
--- src/maasserver/views.py 2012-03-22 04:29:00 +0000
+++ src/maasserver/views.py 2012-03-22 14:34:24 +0000
@@ -44,7 +44,6 @@
render_to_response,
)
from django.template import RequestContext
-from django.utils.safestring import mark_safe
from django.views.generic import (
CreateView,
DeleteView,