← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/configured-interf into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/configured-interf into lp:maas.

Commit message:
Fix the utility method find_nodegroup so that only the managed interfaces will be considered.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1085823 in MAAS: "The cluster controller detection algorithm considers all the interfaces (and not only the managed interfaces)."
  https://bugs.launchpad.net/maas/+bug/1085823

For more details, see:
https://code.launchpad.net/~rvb/maas/configured-interf/+merge/137502

= Notes =

This was pre-imp'ed with Gavin.
-- 
https://code.launchpad.net/~rvb/maas/configured-interf/+merge/137502
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/configured-interf into lp:maas.
=== modified file 'src/maasserver/utils/__init__.py'
--- src/maasserver/utils/__init__.py	2012-11-28 15:50:35 +0000
+++ src/maasserver/utils/__init__.py	2012-12-03 08:25:07 +0000
@@ -25,6 +25,7 @@
 
 from django.conf import settings
 from django.core.urlresolvers import reverse
+from maasserver.enum import NODEGROUPINTERFACE_MANAGEMENT
 from maasserver.utils.orm import get_one
 
 
@@ -127,7 +128,14 @@
                 SELECT nodegroup_id
                 FROM maasserver_nodegroupinterface
                 WHERE (inet %s & subnet_mask) = (ip & subnet_mask)
+                AND management IN %s
             )
-            """, [ip_address])
+            """, [
+                ip_address,
+                (
+                    NODEGROUPINTERFACE_MANAGEMENT.DHCP,
+                    NODEGROUPINTERFACE_MANAGEMENT.DHCP_AND_DNS,
+                )
+                ])
         return get_one(query)
     return None

=== modified file 'src/maasserver/utils/tests/test_utils.py'
--- src/maasserver/utils/tests/test_utils.py	2012-11-28 15:50:35 +0000
+++ src/maasserver/utils/tests/test_utils.py	2012-12-03 08:25:07 +0000
@@ -18,7 +18,10 @@
 from django.core.urlresolvers import reverse
 from django.http import HttpRequest
 from django.test.client import RequestFactory
-from maasserver.enum import NODE_STATUS_CHOICES
+from maasserver.enum import (
+    NODE_STATUS_CHOICES,
+    NODEGROUPINTERFACE_MANAGEMENT,
+    )
 from maasserver.models import (
     NodeGroup,
     nodegroupinterface,
@@ -211,6 +214,14 @@
             nodegroup,
             find_nodegroup(get_request(ip)))
 
+    def test_find_nodegroup_looks_up_only_configured_interfaces(self):
+        network = IPNetwork("192.168.41.0/24")
+        factory.make_node_group(
+            network=network,
+            management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED)
+        ip = factory.getRandomIPInNetwork(network)
+        self.assertIsNone(find_nodegroup(get_request(ip)))
+
     def test_find_nodegroup_accepts_any_ip_in_nodegroup_subnet(self):
         nodegroup = factory.make_node_group(
             network=IPNetwork("192.168.41.0/24"))