Exemplo n.º 1
0
    def test_node_list_show_deleted(self, notify):
        node = self.eng.node_create(self.ctx, 'n1', self.profile['id'])
        result = self.eng.node_list(self.ctx)
        self.assertEqual(1, len(result))
        self.assertEqual(node['id'], result[0]['id'])

        db_api.node_delete(self.ctx, node['id'])

        result = self.eng.node_list(self.ctx)
        self.assertEqual(0, len(result))

        result = self.eng.node_list(self.ctx, show_deleted=True)
        self.assertEqual(1, len(result))
        self.assertEqual(node['id'], result[0]['id'])
Exemplo n.º 2
0
    def test_node_list_show_deleted(self, notify):
        node = self.eng.node_create(self.ctx, "n1", self.profile["id"])
        result = self.eng.node_list(self.ctx)
        self.assertEqual(1, len(result))
        self.assertEqual(node["id"], result[0]["id"])

        db_api.node_delete(self.ctx, node["id"])

        result = self.eng.node_list(self.ctx)
        self.assertEqual(0, len(result))

        result = self.eng.node_list(self.ctx, show_deleted=True)
        self.assertEqual(1, len(result))
        self.assertEqual(node["id"], result[0]["id"])
Exemplo n.º 3
0
    def do_delete(self, context):
        if not self.physical_id:
            db_api.node_delete(context, self.id)
            return True

        # TODO(Qiming): check if actions are working on it and can be canceled
        # TODO(Qiming): log events
        self.set_status(context, self.DELETING, reason='Deletion in progress')
        res = profile_base.Profile.delete_object(context, self)
        if res:
            db_api.node_delete(context, self.id)
            return True
        else:
            self.set_status(context, self.ERROR, reason='Deletion failed')
            return False
Exemplo n.º 4
0
    def test_node_find_show_deleted(self, notify):
        node = self.eng.node_create(self.ctx, "n1", self.profile["id"])
        nodeid = node["id"]
        db_api.node_delete(self.ctx, nodeid)

        for identity in [nodeid, nodeid[:6], "n1"]:
            self.assertRaises(exception.NodeNotFound, self.eng.node_find, self.ctx, identity)

        # short id and name based finding does not support show_deleted
        for identity in [nodeid[:6], "n-1"]:
            self.assertRaises(exception.NodeNotFound, self.eng.node_find, self.ctx, identity)

        # ID based finding is okay with show_deleted
        result = self.eng.node_find(self.ctx, nodeid, show_deleted=True)
        self.assertIsNotNone(result)
Exemplo n.º 5
0
    def test_node_find_show_deleted(self, notify):
        node = self.eng.node_create(self.ctx, 'n1', self.profile['id'])
        nodeid = node['id']
        db_api.node_delete(self.ctx, nodeid)

        for identity in [nodeid, nodeid[:6], 'n1']:
            self.assertRaises(exception.NodeNotFound, self.eng.node_find,
                              self.ctx, identity)

        # short id and name based finding does not support show_deleted
        for identity in [nodeid[:6], 'n-1']:
            self.assertRaises(exception.NodeNotFound, self.eng.node_find,
                              self.ctx, identity)

        # ID based finding is okay with show_deleted
        result = self.eng.node_find(self.ctx, nodeid, show_deleted=True)
        self.assertIsNotNone(result)
Exemplo n.º 6
0
    def do_delete(self, context):
        if not self.physical_id:
            db_api.node_delete(context, self.id)
            return True

        # TODO(Qiming): check if actions are working on it and can be canceled
        self.set_status(context, self.DELETING, reason='Deletion in progress')
        try:
            res = profile_base.Profile.delete_object(context, self)
        except exception.ResourceStatusError as ex:
            self._handle_exception(context, 'delete', self.ERROR, ex)
            res = False

        if res:
            db_api.node_delete(context, self.id)
            return True
        else:
            self.set_status(context, self.ERROR, reason='Deletion failed')
            return False
Exemplo n.º 7
0
    def do_delete(self, context):
        if not self.physical_id:
            db_api.node_delete(context, self.id)
            return True

        # TODO(Qiming): check if actions are working on it and can be canceled
        self.set_status(context, self.DELETING, reason='Deletion in progress')
        event_mod.info(context, self, 'delete')
        try:
            res = profile_base.Profile.delete_object(context, self)
        except exception.ResourceStatusError as ex:
            self._handle_exception(context, 'delete', self.ERROR, ex)
            res = False

        if res:
            db_api.node_delete(context, self.id)
            return True
        else:
            self.set_status(context, self.ERROR, reason='Deletion failed')
            return False
Exemplo n.º 8
0
 def delete(cls, context, obj_id):
     return db_api.node_delete(context, obj_id)
Exemplo n.º 9
0
 def delete(cls, context, obj_id):
     db_api.node_delete(context, obj_id)