~maas-committers/maas/1.8

« back to all changes in this revision

Viewing changes to src/maasserver/models/tests/test_macaddress.py

  • Committer: MAAS Lander
  • Author(s): Mike Pontillo
  • Date: 2015-11-25 02:12:41 UTC
  • mfrom: (4055.1.3 fix-1519177-1.8)
  • Revision ID: maas_lander-20151125021241-pnm351t1p1prur3t
[r=blake-rouse][bug=1519177][author=mpontillo] Allow nodes to boot from unmanaged cluster interfaces using an off-link network (fixes MAAS with external DHCP in some scenarios).

Show diffs side-by-side

added added

removed removed

Lines of Context:
219
219
            find_cluster_interface_responsible_for_ip(
220
220
                interfaces, IPAddress('10.3.3.100')))
221
221
 
 
222
    def test__finds_interface_using_static_range(self):
 
223
        nodegroup = factory.make_NodeGroup()
 
224
        factory.make_NodeGroupInterface(nodegroup, network=IPNetwork(
 
225
            '192.168.2.0/24'))
 
226
        ngi = factory.make_NodeGroupInterface(
 
227
            nodegroup, management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED,
 
228
            ip='192.168.0.1', subnet_mask='', ip_range_low='',
 
229
            ip_range_high='', static_ip_range_low='192.168.1.10',
 
230
            static_ip_range_high='192.168.1.20')
 
231
        factory.make_NodeGroupInterface(nodegroup, network=IPNetwork(
 
232
            '192.168.3.0/24'))
 
233
        self.assertEqual(ngi, find_cluster_interface_responsible_for_ip(
 
234
            NodeGroupInterface.objects.all(), IPAddress('192.168.1.15')))
 
235
 
 
236
    def test__finds_interface_using_dynamic_range(self):
 
237
        nodegroup = factory.make_NodeGroup()
 
238
        factory.make_NodeGroupInterface(nodegroup, network=IPNetwork(
 
239
            '192.168.2.0/24'))
 
240
        ngi = factory.make_NodeGroupInterface(
 
241
            nodegroup, management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED,
 
242
            ip='192.168.0.1', subnet_mask='', static_ip_range_low='',
 
243
            static_ip_range_high='', ip_range_low='192.168.1.10',
 
244
            ip_range_high='192.168.1.20')
 
245
        factory.make_NodeGroupInterface(nodegroup, network=IPNetwork(
 
246
            '192.168.3.0/24'))
 
247
        self.assertEqual(ngi, find_cluster_interface_responsible_for_ip(
 
248
            NodeGroupInterface.objects.all(), IPAddress('192.168.1.15')))
 
249
 
222
250
 
223
251
def find_cluster_interface(cluster, ip_version):
224
252
    """Find cluster interface for `cluster` with the given IP version.