Beispiel #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})
Beispiel #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})
Beispiel #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)
Beispiel #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)
Beispiel #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})
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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})
Beispiel #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))
Beispiel #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))
Beispiel #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])
Beispiel #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])
Beispiel #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')
Beispiel #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')
Beispiel #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)
Beispiel #18
0
 def test_create_node(self):
     utils.create_test_node()
Beispiel #19
0
 def test_update_node_uuid(self):
     node = utils.create_test_node()
     self.assertRaises(exception.InvalidParameterValue,
                       self.dbapi.update_node, node.id, {'uuid': ''})
Beispiel #20
0
 def test_create_node_already_exists(self):
     utils.create_test_node()
     self.assertRaises(exception.NodeAlreadyExists, utils.create_test_node)
Beispiel #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)
Beispiel #22
0
 def test_create_node_already_exists(self):
     utils.create_test_node()
     self.assertRaises(exception.NodeAlreadyExists,
                       utils.create_test_node)
Beispiel #23
0
 def test_create_node(self):
     utils.create_test_node()
Beispiel #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)
Beispiel #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)
Beispiel #26
0
 def test_update_node_uuid(self):
     node = utils.create_test_node()
     self.assertRaises(exception.InvalidParameterValue,
                       self.dbapi.update_node, node.id,
                       {'uuid': ''})