)]}'
{"nova/api/openstack/compute/contrib/cells.py":[{"author":{"_account_id":6167,"name":"Ken\u0027ichi Ohmichi","email":"ken1ohmichi@gmail.com","username":"oomichi"},"change_message_id":"67589e4b9c5d36053a7045ad71c13b43bb29ae6d","unresolved":false,"context_lines":[{"line_number":105,"context_line":"        items \u003d [_scrub_cell(item, detail\u003ddetail) for item in items]"},{"line_number":106,"context_line":"        return dict(cells\u003ditems)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"    @common.check_cells_enabled"},{"line_number":109,"context_line":"    def index(self, req):"},{"line_number":110,"context_line":"        \"\"\"Return all cells in brief.\"\"\""},{"line_number":111,"context_line":"        ctxt \u003d req.environ[\u0027nova.context\u0027]"}],"source_content_type":"text/x-python","patch_set":10,"id":"9a80dd14_6fd1f3fa","line":108,"updated":"2015-03-05 05:13:40.000000000","message":"This patch removes require_admin_context() from cell_get() and cell_get_all() also at compute API layer, so I feel we need to add require_admin_context() to index(), detail() and show() also.","commit_id":"9cb0db78fafdbdd52138f820517e6ec6e1447de2"},{"author":{"_account_id":6167,"name":"Ken\u0027ichi Ohmichi","email":"ken1ohmichi@gmail.com","username":"oomichi"},"change_message_id":"7076b9bd217759920bbb3c8f26de6c96d784e15b","unresolved":false,"context_lines":[{"line_number":105,"context_line":"        items \u003d [_scrub_cell(item, detail\u003ddetail) for item in items]"},{"line_number":106,"context_line":"        return dict(cells\u003ditems)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"    @common.check_cells_enabled"},{"line_number":109,"context_line":"    def index(self, req):"},{"line_number":110,"context_line":"        \"\"\"Return all cells in brief.\"\"\""},{"line_number":111,"context_line":"        ctxt \u003d req.environ[\u0027nova.context\u0027]"}],"source_content_type":"text/x-python","patch_set":10,"id":"9a80dd14_4e4b715f","line":108,"in_reply_to":"9a80dd14_0ec38bed","updated":"2015-03-17 02:29:43.000000000","message":"I cannot understand the above comment.\nAS you said, cells_rpcapi.cell_get is *set* in __init__(), but it is called in each show() API operation.","commit_id":"9cb0db78fafdbdd52138f820517e6ec6e1447de2"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"1979575657aaf8220381ac0eabea469e653e270d","unresolved":false,"context_lines":[{"line_number":105,"context_line":"        items \u003d [_scrub_cell(item, detail\u003ddetail) for item in items]"},{"line_number":106,"context_line":"        return dict(cells\u003ditems)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"    @common.check_cells_enabled"},{"line_number":109,"context_line":"    def index(self, req):"},{"line_number":110,"context_line":"        \"\"\"Return all cells in brief.\"\"\""},{"line_number":111,"context_line":"        ctxt \u003d req.environ[\u0027nova.context\u0027]"}],"source_content_type":"text/x-python","patch_set":10,"id":"9a80dd14_9649c034","line":108,"in_reply_to":"9a80dd14_2572c9e3","updated":"2015-03-18 06:11:22.000000000","message":"yea, I think the reason is _cell_data_sync use elevated context, so the show method needn\u0027t admin permission checks.","commit_id":"9cb0db78fafdbdd52138f820517e6ec6e1447de2"},{"author":{"_account_id":12175,"name":"Eli Qiao","email":"qiaoliyong@gmail.com","username":"Eli"},"change_message_id":"6a2323d3ce37a01f59a220221c28f28d4aa18962","unresolved":false,"context_lines":[{"line_number":105,"context_line":"        items \u003d [_scrub_cell(item, detail\u003ddetail) for item in items]"},{"line_number":106,"context_line":"        return dict(cells\u003ditems)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"    @common.check_cells_enabled"},{"line_number":109,"context_line":"    def index(self, req):"},{"line_number":110,"context_line":"        \"\"\"Return all cells in brief.\"\"\""},{"line_number":111,"context_line":"        ctxt \u003d req.environ[\u0027nova.context\u0027]"}],"source_content_type":"text/x-python","patch_set":10,"id":"9a80dd14_e25d197b","line":108,"in_reply_to":"9a80dd14_4e4b715f","updated":"2015-03-17 03:45:07.000000000","message":"for show() api , the call sequence is :\n\n\n 1) rpcapi.cell_get()  link [1]\n 2) self.state_manager.cell_get() link[2] \n 3) link [3]\n    @sync_before\n    def cell_get(self, ctxt, cell_name):\n        for cells_dict in (self.parent_cells, self.child_cells):\n            if cell_name in cells_dict:\n                return cells_dict[cell_name]\n\n4) in sync_before\ndef sync_before(f):\n    \"\"\"Use as a decorator to wrap methods that use cell information to\n    make sure they sync the latest information from the DB periodically.\n    \"\"\"\n    @functools.wraps(f)\n    def wrapper(self, *args, **kwargs):\n        self._cell_data_sync()\n        return f(self, *args, **kwargs)\n    return wrapper\n\n\n5) in _cell_data_sync\n    def _cell_data_sync(self, force\u003dFalse):\n        \"\"\"Update cell status for all cells from the backing data store\n        when necessary.\n\n        :param force: If True, cell status will be updated regardless\n                      of whether it\u0027s time to do so.\n        \"\"\"\n        if force or self._time_to_sync():\n            LOG.debug(\"Updating cell cache from db.\")\n            self.last_cell_db_check \u003d timeutils.utcnow()\n            ctxt \u003d context.get_admin_context()\n            db_cells \u003d self.db.cell_get_all(ctxt)\n            db_cells_dict \u003d {cell[\u0027name\u0027]: cell for cell in db_cells}\n            self._refresh_cells_from_dict(db_cells_dict)\n            self._update_our_capacity(ctxt)\n\n\n[1]https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/contrib/cells.py#L164\n\n[2] https://github.com/openstack/nova/blob/master/nova/cells/manager.py#L496\n\n[3]https://github.com/openstack/nova/blob/master/nova/cells/state.py#L425\n\neven in db api we have these:\n\n@require_admin_context\ndef cell_get(context, cell_name):\n    result \u003d _cell_get_by_name_query(context, cell_name).first()\n    if not result:\n        raise exception.CellNotFound(cell_name\u003dcell_name)\n    return result\n\nbut we never called it in our code.","commit_id":"9cb0db78fafdbdd52138f820517e6ec6e1447de2"},{"author":{"_account_id":12175,"name":"Eli Qiao","email":"qiaoliyong@gmail.com","username":"Eli"},"change_message_id":"39834f6a52e1a7734bdbbfc00fa914147025c587","unresolved":false,"context_lines":[{"line_number":105,"context_line":"        items \u003d [_scrub_cell(item, detail\u003ddetail) for item in items]"},{"line_number":106,"context_line":"        return dict(cells\u003ditems)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"    @common.check_cells_enabled"},{"line_number":109,"context_line":"    def index(self, req):"},{"line_number":110,"context_line":"        \"\"\"Return all cells in brief.\"\"\""},{"line_number":111,"context_line":"        ctxt \u003d req.environ[\u0027nova.context\u0027]"}],"source_content_type":"text/x-python","patch_set":10,"id":"9a80dd14_8ad8d5f0","line":108,"in_reply_to":"9a80dd14_6fd1f3fa","updated":"2015-03-05 05:51:07.000000000","message":"hi Ken\u0027ichi, thanks for your comments.\nbut this patch, don\u0027t remove anything in compute API layer, and actually, this REST API don\u0027t call compute_api at all, see \nhttps://review.openstack.org/#/c/160281/\n\nand for index/detail/show, I read the code,it doesn\u0027t call cell_get/cell_get_all directly from db layer, it call\u0027s a cell rpc api method, cells_rpcapi.get_cell_info_for_neighbors(...)\n\nthis method will query cell infor which has been loaded by cell state manager when the state manager initialing.\ncheck\nhttps://github.com/openstack/nova/blob/master/nova/cells/state.py#L174\n\nand in _cell_data_sync, it uses a admin context to query db.\ncheck https://github.com/openstack/nova/blob/master/nova/cells/state.py#L447\n\nso I think we don\u0027t need to add require_admin_context() to index(), detail() and show() also.\n\nEli.","commit_id":"9cb0db78fafdbdd52138f820517e6ec6e1447de2"},{"author":{"_account_id":6167,"name":"Ken\u0027ichi Ohmichi","email":"ken1ohmichi@gmail.com","username":"oomichi"},"change_message_id":"26646bdecc6f2bbc1a3f1b1e2c10649d5911810c","unresolved":false,"context_lines":[{"line_number":105,"context_line":"        items \u003d [_scrub_cell(item, detail\u003ddetail) for item in items]"},{"line_number":106,"context_line":"        return dict(cells\u003ditems)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"    @common.check_cells_enabled"},{"line_number":109,"context_line":"    def index(self, req):"},{"line_number":110,"context_line":"        \"\"\"Return all cells in brief.\"\"\""},{"line_number":111,"context_line":"        ctxt \u003d req.environ[\u0027nova.context\u0027]"}],"source_content_type":"text/x-python","patch_set":10,"id":"9a80dd14_e2b01545","line":108,"in_reply_to":"9a80dd14_8ad8d5f0","updated":"2015-03-09 05:14:12.000000000","message":"Thanks for your response.\n\nI am still thinking require_admin_context is necessary for show() because show() calls self.cells_rpcapi.cell_get().","commit_id":"9cb0db78fafdbdd52138f820517e6ec6e1447de2"},{"author":{"_account_id":5441,"name":"Andrew Laski","email":"andrew@lascii.com","username":"alaski"},"change_message_id":"a4dbeec567cdd84de00bf2ae20d815fe7e89d593","unresolved":false,"context_lines":[{"line_number":105,"context_line":"        items \u003d [_scrub_cell(item, detail\u003ddetail) for item in items]"},{"line_number":106,"context_line":"        return dict(cells\u003ditems)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"    @common.check_cells_enabled"},{"line_number":109,"context_line":"    def index(self, req):"},{"line_number":110,"context_line":"        \"\"\"Return all cells in brief.\"\"\""},{"line_number":111,"context_line":"        ctxt \u003d req.environ[\u0027nova.context\u0027]"}],"source_content_type":"text/x-python","patch_set":10,"id":"9a80dd14_2572c9e3","line":108,"in_reply_to":"9a80dd14_e25d197b","updated":"2015-03-17 12:56:46.000000000","message":"Looking at step 5 in your code flow, db.cell_get_all is called with an elevated context.  My guess is that the reason it is elevated is because of the @require_admin_context that you\u0027re removing from cell_get_all.  So you should be able to remove that now.\n\nAs far as adding an admin check here, it seems to me that due to the context elevation that is present it was not required to have an admin context when making this call.  This is a read operation which may explain why it didn\u0027t require an admin context while the calls below do.","commit_id":"9cb0db78fafdbdd52138f820517e6ec6e1447de2"},{"author":{"_account_id":12175,"name":"Eli Qiao","email":"qiaoliyong@gmail.com","username":"Eli"},"change_message_id":"753b6fb584f56faf36a4b98172248dec4eda1c23","unresolved":false,"context_lines":[{"line_number":105,"context_line":"        items \u003d [_scrub_cell(item, detail\u003ddetail) for item in items]"},{"line_number":106,"context_line":"        return dict(cells\u003ditems)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"    @common.check_cells_enabled"},{"line_number":109,"context_line":"    def index(self, req):"},{"line_number":110,"context_line":"        \"\"\"Return all cells in brief.\"\"\""},{"line_number":111,"context_line":"        ctxt \u003d req.environ[\u0027nova.context\u0027]"}],"source_content_type":"text/x-python","patch_set":10,"id":"9a80dd14_0ec38bed","line":108,"in_reply_to":"9a80dd14_e2b01545","updated":"2015-03-09 11:21:20.000000000","message":"Hi ken\u0027ichi , thanks ,but cells_rpcapi.cell_get does not access do at all, it reads the data loaded in memory which is loaded at init","commit_id":"9cb0db78fafdbdd52138f820517e6ec6e1447de2"}]}
