)]}'
{"oslo_limit/limit.py":[{"author":{"_account_id":15054,"name":"wangxiyuan","email":"wangxiyuan1007@gmail.com","username":"wangxiyuan"},"change_message_id":"486f52c95c29f007395e58890d11a02a3199d717","unresolved":false,"context_lines":[{"line_number":55,"context_line":""},{"line_number":56,"context_line":"class Enforcer(object):"},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"    def __init__(self, claim, callback\u003dNone, verify\u003dTrue):"},{"line_number":59,"context_line":"        \"\"\"Context manager for checking usage against resource claims."},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"        :param claim: An object containing information about the claim."}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_5dbcd6da","line":58,"range":{"start_line":58,"start_character":30,"end_line":58,"end_character":38},"updated":"2018-09-10 01:40:01.000000000","message":"Should this be changed as well? like the callback is a list of get_usage_func?\nIt can be done in the follow up patches, I just want to make sure how will it be like before merging this patch.","commit_id":"4a992a7c1f14dbbac7c94bb25de9613d9606b585"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"3420b2bd508e9e24ee052541811111b6080b31d8","unresolved":false,"context_lines":[{"line_number":32,"context_line":"        self.claims \u003d {}"},{"line_number":33,"context_line":"        self.project_id \u003d project_id"},{"line_number":34,"context_line":""},{"line_number":35,"context_line":"    def add_resource(self, resource_name, quantity):"},{"line_number":36,"context_line":"        \"\"\"Add a resource type and quantity to a claim."},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"        :param resource_name: A string representing the resource to claim."}],"source_content_type":"text/x-python","patch_set":6,"id":"3f79a3b5_b4ddaedf","line":35,"updated":"2018-11-02 15:47:34.000000000","message":"This totally works, but I would honestly be tempted by also allowing __init__ to take a dict of resource_name/quantity to make it easier to consume, or maybe via **kwargs?","commit_id":"7f45d2413631ebadd29a93dad10afc257e95d1bc"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"3420b2bd508e9e24ee052541811111b6080b31d8","unresolved":false,"context_lines":[{"line_number":55,"context_line":""},{"line_number":56,"context_line":"class Enforcer(object):"},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"    def __init__(self, claim, callback\u003dNone, verify\u003dTrue):"},{"line_number":59,"context_line":"        \"\"\"Context manager for checking usage against resource claims."},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"        :param claim: An object containing information about the claim."}],"source_content_type":"text/x-python","patch_set":6,"id":"3f79a3b5_34b19e92","line":58,"range":{"start_line":58,"start_character":30,"end_line":58,"end_character":38},"updated":"2018-11-02 15:47:34.000000000","message":"The expected signature of callback is sure to change due to the changes above.\n\nI think I expect a project_id and a list of resource_names to get passed into the callback, now a claim could be for multiple things.","commit_id":"7f45d2413631ebadd29a93dad10afc257e95d1bc"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"1642b5dca560bdd34f457e3840e9dc3ad7547e27","unresolved":false,"context_lines":[{"line_number":55,"context_line":""},{"line_number":56,"context_line":"class Enforcer(object):"},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"    def __init__(self, claim, callback\u003dNone, verify\u003dTrue):"},{"line_number":59,"context_line":"        \"\"\"Context manager for checking usage against resource claims."},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"        :param claim: An object containing information about the claim."}],"source_content_type":"text/x-python","patch_set":6,"id":"3f79a3b5_b18283a5","line":58,"range":{"start_line":58,"start_character":30,"end_line":58,"end_character":38},"in_reply_to":"3f79a3b5_34b19e92","updated":"2018-11-05 09:57:39.000000000","message":"I have worked through this a bit more on the Nova side. Two things I think we should consider...\n\n1) I think we actually are unlikely to use the context manager. Basically our re-check is done by a separate process (currently). Not saying we should not include a context manager, I am only saying Nova needs a more basic direct interface (ideally).\n\n2) Most important bit is there is a single callback call to get *all* usages for the various resource_names. Reason, we only want to fetch all the users instances from the DB once (well actually we are trying to use placement instead, but same thing applies with that approach).\n\nAttempted to sketch it out here:\nhttps://github.com/JohnGarbutt/oslo.limit/blob/0d6fa80ab5548af3ed5beda96ba381f0eddf8fdd/oslo_limit/limit.py#L107\n\nAnd link it back to Nova code here:\nhttps://review.openstack.org/#/c/615180","commit_id":"7f45d2413631ebadd29a93dad10afc257e95d1bc"}]}
