Esempio n. 1
0
    def test_POST_create_returns_machine_with_matching_mac(self):
        hostname = factory.make_name('hostname')
        machine = factory.make_Machine(hostname=hostname,
                                       status=NODE_STATUS.NEW,
                                       architecture='')
        macs = [
            str(factory.make_Interface(node=machine).mac_address)
            for _ in range(3)
        ]
        architecture = make_usable_architecture(self)
        response = self.client.post(
            reverse('machines_handler'),
            {
                'hostname':
                'maas-enlistment',
                'architecture':
                architecture,
                'mac_addresses': [
                    # Machine only has to match one MAC address.
                    random.choice(macs),
                    # A MAC address unknown to MAAS shouldn't effect finding
                    # the machine.
                    factory.make_MAC(),
                ],
            })

        self.assertEqual(http.client.OK, response.status_code)
        machine = reload_object(machine)
        self.assertEqual(hostname, machine.hostname)
        self.assertEqual(architecture, machine.architecture)
        self.assertEqual(machine.system_id,
                         json_load_bytes(response.content)['system_id'])
Esempio n. 2
0
    def test_POST_acquire_allocates_node_connected_to_routers(self):
        macs = [factory.make_MAC() for counter in range(3)]
        node = factory.make_node(routers=macs, status=NODE_STATUS.READY)
        factory.make_node(routers=[])

        response = self.client.post(reverse('nodes_handler'), {
            'op': 'acquire',
            'connected_to': [macs[2].get_raw(), macs[0].get_raw()],
        })

        self.assertResponseCode(httplib.OK, response)
        response_json = json.loads(response.content)
        self.assertEqual(node.system_id, response_json['system_id'])
Esempio n. 3
0
    def test_POST_acquire_allocates_node_connected_to_routers(self):
        macs = [factory.make_MAC() for counter in range(3)]
        node = factory.make_node(routers=macs, status=NODE_STATUS.READY)
        factory.make_node(routers=[])

        response = self.client.post(
            reverse('nodes_handler'), {
                'op': 'acquire',
                'connected_to': [macs[2].get_raw(), macs[0].get_raw()],
            })

        self.assertResponseCode(httplib.OK, response)
        response_json = json.loads(response.content)
        self.assertEqual(node.system_id, response_json['system_id'])
Esempio n. 4
0
 def test_ne_punches_through_double_double_wrapping(self):
     mac = factory.make_MAC()
     self.assertFalse(MAC(mac) != MAC(mac))
Esempio n. 5
0
 def test_mac_address_does_not_equal_none(self):
     self.assertIsNotNone(factory.make_MAC())
Esempio n. 6
0
 def test_mac_does_not_differ_from_self(self):
     mac = factory.make_MAC()
     self.assertFalse(mac != mac)
Esempio n. 7
0
 def test_mac_differs_from_other(self):
     self.assertTrue(factory.make_MAC() != factory.make_MAC())
Esempio n. 8
0
 def test_mac_does_not_equal_other(self):
     self.assertFalse(factory.make_MAC() == factory.make_MAC())
Esempio n. 9
0
 def test_eq_punches_through_double_double_wrappings(self):
     mac = factory.make_MAC()
     self.assertTrue(MAC(mac) == MAC(mac))
Esempio n. 10
0
 def test_mac_does_not_equal_other(self):
     self.assertFalse(factory.make_MAC() == factory.make_MAC())
Esempio n. 11
0
 def test_mac_equals_self(self):
     mac = factory.make_MAC()
     self.assertTrue(mac == mac)
Esempio n. 12
0
 def test_ne_punches_through_double_double_wrapping(self):
     mac = factory.make_MAC()
     self.assertFalse(MAC(mac) != MAC(mac))
Esempio n. 13
0
 def test_different_macs_hash_differently(self):
     mac1 = factory.make_MAC()
     mac2 = factory.make_MAC()
     self.assertItemsEqual(set([mac1, mac2]), [mac1, mac2])
Esempio n. 14
0
 def test_mac_address_does_not_equal_none(self):
     self.assertIsNotNone(factory.make_MAC())
Esempio n. 15
0
 def test_mac_does_not_differ_from_self(self):
     mac = factory.make_MAC()
     self.assertFalse(mac != mac)
Esempio n. 16
0
 def test_mac_differs_from_other(self):
     self.assertTrue(factory.make_MAC() != factory.make_MAC())
Esempio n. 17
0
 def test_different_macs_hash_differently(self):
     mac1 = factory.make_MAC()
     mac2 = factory.make_MAC()
     self.assertItemsEqual(set([mac1, mac2]), [mac1, mac2])
Esempio n. 18
0
 def test_mac_equals_self(self):
     mac = factory.make_MAC()
     self.assertTrue(mac == mac)
Esempio n. 19
0
 def test_true(self):
     self.assertTrue(is_mac(factory.make_MAC()))
Esempio n. 20
0
 def test_eq_punches_through_double_double_wrappings(self):
     mac = factory.make_MAC()
     self.assertTrue(MAC(mac) == MAC(mac))