Esempio n. 1
0
 def test_update_node_instance_already_associated(self):
     node1 = utils.create_test_node(uuid=magnum_utils.generate_uuid())
     new_i_uuid = magnum_utils.generate_uuid()
     self.dbapi.update_node(node1.id, {'ironic_node_id': new_i_uuid})
     node2 = utils.create_test_node(uuid=magnum_utils.generate_uuid())
     self.assertRaises(exception.InstanceAssociated, self.dbapi.update_node,
                       node2.id, {'ironic_node_id': new_i_uuid})
Esempio n. 2
0
 def test_update_node_instance_already_associated(self):
     node1 = utils.create_test_node(uuid=magnum_utils.generate_uuid())
     new_i_uuid = magnum_utils.generate_uuid()
     self.dbapi.update_node(node1.id, {'ironic_node_id': new_i_uuid})
     node2 = utils.create_test_node(uuid=magnum_utils.generate_uuid())
     self.assertRaises(exception.InstanceAssociated,
                       self.dbapi.update_node, node2.id,
                       {'ironic_node_id': new_i_uuid})
Esempio n. 3
0
 def test_create_node_instance_already_associated(self):
     instance_uuid = magnum_utils.generate_uuid()
     utils.create_test_node(uuid=magnum_utils.generate_uuid(),
                            ironic_node_id=instance_uuid)
     self.assertRaises(exception.InstanceAssociated,
                       utils.create_test_node,
                       uuid=magnum_utils.generate_uuid(),
                       ironic_node_id=instance_uuid)
Esempio n. 4
0
 def test_create_node_instance_already_associated(self):
     instance_uuid = magnum_utils.generate_uuid()
     utils.create_test_node(uuid=magnum_utils.generate_uuid(),
                            ironic_node_id=instance_uuid)
     self.assertRaises(exception.InstanceAssociated,
                       utils.create_test_node,
                       uuid=magnum_utils.generate_uuid(),
                       ironic_node_id=instance_uuid)
Esempio n. 5
0
 def test_update_node_already_associated(self):
     node = utils.create_test_node()
     new_i_uuid_one = magnum_utils.generate_uuid()
     self.dbapi.update_node(node.id, {'ironic_node_id': new_i_uuid_one})
     new_i_uuid_two = magnum_utils.generate_uuid()
     self.assertRaises(exception.NodeAssociated, self.dbapi.update_node,
                       node.id, {'ironic_node_id': new_i_uuid_two})
Esempio n. 6
0
 def test_update_node_associate_and_disassociate(self):
     node = utils.create_test_node()
     new_i_uuid = magnum_utils.generate_uuid()
     res = self.dbapi.update_node(node.id, {'ironic_node_id': new_i_uuid})
     self.assertEqual(new_i_uuid, res.ironic_node_id)
     res = self.dbapi.update_node(node.id, {'ironic_node_id': None})
     self.assertIsNone(res.ironic_node_id)
Esempio n. 7
0
 def test_update_node_associate_and_disassociate(self):
     node = utils.create_test_node()
     new_i_uuid = magnum_utils.generate_uuid()
     res = self.dbapi.update_node(node.id, {'ironic_node_id': new_i_uuid})
     self.assertEqual(new_i_uuid, res.ironic_node_id)
     res = self.dbapi.update_node(node.id, {'ironic_node_id': None})
     self.assertIsNone(res.ironic_node_id)
Esempio n. 8
0
    def test_update_node(self):
        node = utils.create_test_node()
        old_image = node.image_id
        new_image = 'new-image'
        self.assertNotEqual(old_image, new_image)

        res = self.dbapi.update_node(node.id, {'image_id': new_image})
        self.assertEqual(new_image, res.image_id)
Esempio n. 9
0
    def test_update_node(self):
        node = utils.create_test_node()
        old_image = node.image_id
        new_image = 'new-image'
        self.assertNotEqual(old_image, new_image)

        res = self.dbapi.update_node(node.id, {'image_id': new_image})
        self.assertEqual(new_image, res.image_id)
Esempio n. 10
0
 def test_update_node_already_associated(self):
     node = utils.create_test_node()
     new_i_uuid_one = magnum_utils.generate_uuid()
     self.dbapi.update_node(node.id, {'ironic_node_id': new_i_uuid_one})
     new_i_uuid_two = magnum_utils.generate_uuid()
     self.assertRaises(exception.NodeAssociated,
                       self.dbapi.update_node, node.id,
                       {'ironic_node_id': new_i_uuid_two})
Esempio n. 11
0
 def test_get_node_list(self):
     uuids = []
     for i in range(1, 6):
         node = utils.create_test_node(uuid=magnum_utils.generate_uuid())
         uuids.append(six.text_type(node['uuid']))
     res = self.dbapi.get_node_list(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
Esempio n. 12
0
 def test_get_node_list(self):
     uuids = []
     for i in range(1, 6):
         node = utils.create_test_node(uuid=magnum_utils.generate_uuid())
         uuids.append(six.text_type(node['uuid']))
     res = self.dbapi.get_node_list(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
Esempio n. 13
0
    def test_get_node_list_with_filters(self):
        node1 = utils.create_test_node(type='virt',
            ironic_node_id=magnum_utils.generate_uuid(),
            uuid=magnum_utils.generate_uuid())
        node2 = utils.create_test_node(type='bare',
            uuid=magnum_utils.generate_uuid())

        res = self.dbapi.get_node_list(self.context, filters={'type': 'virt'})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(self.context,
                                       filters={'type': 'bad-type'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_node_list(self.context,
                                       filters={'associated': True})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(self.context,
                                       filters={'associated': False})
        self.assertEqual([node2.id], [r.id for r in res])
Esempio n. 14
0
    def test_get_node_list_with_filters(self):
        node1 = utils.create_test_node(
            type='virt',
            ironic_node_id=magnum_utils.generate_uuid(),
            uuid=magnum_utils.generate_uuid())
        node2 = utils.create_test_node(type='bare',
                                       uuid=magnum_utils.generate_uuid())

        res = self.dbapi.get_node_list(self.context, filters={'type': 'virt'})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(self.context,
                                       filters={'type': 'bad-type'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_node_list(self.context,
                                       filters={'associated': True})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(self.context,
                                       filters={'associated': False})
        self.assertEqual([node2.id], [r.id for r in res])
Esempio n. 15
0
    def test_get_node_list_sorted(self):
        uuids = []
        for _ in range(5):
            node = utils.create_test_node(uuid=magnum_utils.generate_uuid())
            uuids.append(six.text_type(node.uuid))
        res = self.dbapi.get_node_list(self.context, sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          self.dbapi.get_node_list,
                          self.context,
                          sort_key='foo')
Esempio n. 16
0
    def test_get_node_list_sorted(self):
        uuids = []
        for _ in range(5):
            node = utils.create_test_node(uuid=magnum_utils.generate_uuid())
            uuids.append(six.text_type(node.uuid))
        res = self.dbapi.get_node_list(self.context, sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          self.dbapi.get_node_list,
                          self.context,
                          sort_key='foo')
Esempio n. 17
0
 def test_destroy_node(self):
     node = utils.create_test_node()
     self.dbapi.destroy_node(node.id)
     self.assertRaises(exception.NodeNotFound,
                       self.dbapi.get_node_by_id, self.context, node.id)
Esempio n. 18
0
 def test_create_node(self):
     utils.create_test_node()
Esempio n. 19
0
 def test_update_node_uuid(self):
     node = utils.create_test_node()
     self.assertRaises(exception.InvalidParameterValue,
                       self.dbapi.update_node, node.id, {'uuid': ''})
Esempio n. 20
0
 def test_create_node_already_exists(self):
     utils.create_test_node()
     self.assertRaises(exception.NodeAlreadyExists, utils.create_test_node)
Esempio n. 21
0
 def test_get_node_by_uuid(self):
     node = utils.create_test_node()
     res = self.dbapi.get_node_by_uuid(self.context, node.uuid)
     self.assertEqual(node.id, res.id)
     self.assertEqual(node.uuid, res.uuid)
Esempio n. 22
0
 def test_create_node_already_exists(self):
     utils.create_test_node()
     self.assertRaises(exception.NodeAlreadyExists,
                       utils.create_test_node)
Esempio n. 23
0
 def test_create_node(self):
     utils.create_test_node()
Esempio n. 24
0
 def test_get_node_by_uuid(self):
     node = utils.create_test_node()
     res = self.dbapi.get_node_by_uuid(self.context, node.uuid)
     self.assertEqual(node.id, res.id)
     self.assertEqual(node.uuid, res.uuid)
Esempio n. 25
0
 def test_destroy_node_by_uuid(self):
     node = utils.create_test_node()
     self.dbapi.destroy_node(node.uuid)
     self.assertRaises(exception.NodeNotFound, self.dbapi.get_node_by_uuid,
                       self.context, node.uuid)
Esempio n. 26
0
 def test_update_node_uuid(self):
     node = utils.create_test_node()
     self.assertRaises(exception.InvalidParameterValue,
                       self.dbapi.update_node, node.id,
                       {'uuid': ''})