)]}'
{"keystone/role_swapper_3000.py":[{"author":{"_account_id":6794,"name":"Simon Pasquier","email":"pasquier.simon@gmail.com","username":"simon-pasquier"},"change_message_id":"e2d0ce3062f28f1a864ca5762cc117156d6adb3a","unresolved":false,"context_lines":[{"line_number":1,"context_line":"#!/usr/bin/python"},{"line_number":2,"context_line":""},{"line_number":3,"context_line":"__author__      \u003d \u0027Matt Fischer \u003cmatt.fischer@twcable.com\u003e\u0027"},{"line_number":4,"context_line":"__copyright__   \u003d \u0027Copyright 2015, Matt Fischer\u0027"}],"source_content_type":"text/x-python","patch_set":2,"id":"fa80f949_6d13205c","line":1,"updated":"2015-11-06 12:59:04.000000000","message":"I don\u0027t know where we stand regarding licensing conventions. I assume that this script is licensed under Apache v2 so it would be neat to have the Apache header as described in [0].\n\n[0] http://www.apache.org/licenses/LICENSE-2.0#apply","commit_id":"b04f9373e026592c09efaa1d1722688d0d7ffc71"},{"author":{"_account_id":12323,"name":"JJ Asghar","email":"jjasghar@gmail.com","username":"jj"},"change_message_id":"ce4d538fbb0f94e2cf38dc5030345f25e532077d","unresolved":false,"context_lines":[{"line_number":1,"context_line":"#!/usr/bin/python"},{"line_number":2,"context_line":""},{"line_number":3,"context_line":"__author__      \u003d \u0027Matt Fischer \u003cmatt.fischer@twcable.com\u003e\u0027"},{"line_number":4,"context_line":"__copyright__   \u003d \u0027Copyright 2015, Matt Fischer\u0027"}],"source_content_type":"text/x-python","patch_set":2,"id":"da85f559_40198a78","line":1,"in_reply_to":"da85f559_ceb94030","updated":"2015-11-09 23:56:42.000000000","message":"Yep, my goal is to get the contrib directory created this week.","commit_id":"b04f9373e026592c09efaa1d1722688d0d7ffc71"},{"author":{"_account_id":9060,"name":"Mike Dorman","email":"dorm@dorm.org","username":"gd-mdorman"},"change_message_id":"36fd293b2ce320e42504770d7555a96cc9974690","unresolved":false,"context_lines":[{"line_number":1,"context_line":"#!/usr/bin/python"},{"line_number":2,"context_line":""},{"line_number":3,"context_line":"__author__      \u003d \u0027Matt Fischer \u003cmatt.fischer@twcable.com\u003e\u0027"},{"line_number":4,"context_line":"__copyright__   \u003d \u0027Copyright 2015, Matt Fischer\u0027"}],"source_content_type":"text/x-python","patch_set":2,"id":"da85f559_ceb94030","line":1,"in_reply_to":"fa80f949_6d13205c","updated":"2015-11-09 16:30:00.000000000","message":"We had talked about needing a license for anything here, so it would need to be added eventually.  We\u0027re going to set up a \"contrib\" directory in which people can add stuff just to get it out there without meeting any of the requirements, but I don\u0027t think it\u0027s set up yet.  So if you don\u0027t mind dropping it in, Matt, that would be helpful for this specific case.","commit_id":"b04f9373e026592c09efaa1d1722688d0d7ffc71"},{"author":{"_account_id":9060,"name":"Mike Dorman","email":"dorm@dorm.org","username":"gd-mdorman"},"change_message_id":"36fd293b2ce320e42504770d7555a96cc9974690","unresolved":false,"context_lines":[{"line_number":14,"context_line":"# To see who is still holding the old role:"},{"line_number":15,"context_line":"# ./role_swapper_3000.py --old_role \u003cold\u003e --new_role \u003cnew\u003e"},{"line_number":16,"context_line":"#"},{"line_number":17,"context_line":"# To remove the old role from anyone who has it (dangerous)"},{"line_number":18,"context_line":"# ./role_swapper_3000.py --remove --old_role \u003cold\u003e --new_role \u003cnew\u003e"},{"line_number":19,"context_line":"# (this is dangerous because now you lack any record of the role"},{"line_number":20,"context_line":"# that you intended to swap)"}],"source_content_type":"text/x-python","patch_set":2,"id":"da85f559_ee1764eb","line":17,"updated":"2015-11-09 16:30:00.000000000","message":"Maybe change \u0027remove\u0027 to \u0027revoke\u0027 and \u0027add\u0027 to \u0027grant\u0027 in these comments?  It\u0027s a little confusing since you say above that the script does not actually add the new role or remove the old one.  I understand what you\u0027re saying, but I think it would be more clear if the nomenclature was more precise.","commit_id":"b04f9373e026592c09efaa1d1722688d0d7ffc71"},{"author":{"_account_id":9060,"name":"Mike Dorman","email":"dorm@dorm.org","username":"gd-mdorman"},"change_message_id":"36fd293b2ce320e42504770d7555a96cc9974690","unresolved":false,"context_lines":[{"line_number":25,"context_line":"# To add the new role only. This can be used when you\u0027ve got"},{"line_number":26,"context_line":"# services and tools that may refer to either the old or"},{"line_number":27,"context_line":"# new role."},{"line_number":28,"context_line":"# ./role_swapper_3000.py --add --remove --old_role \u003cold\u003e --new_role \u003cnew\u003e"},{"line_number":29,"context_line":"#"},{"line_number":30,"context_line":"# Warning:"},{"line_number":31,"context_line":"#"}],"source_content_type":"text/x-python","patch_set":2,"id":"da85f559_eebbe40c","line":28,"updated":"2015-11-09 16:30:00.000000000","message":"I think you have these example command lines swapped.  The first one should have --remove, and the second one shouldn\u0027t, right?","commit_id":"b04f9373e026592c09efaa1d1722688d0d7ffc71"},{"author":{"_account_id":6794,"name":"Simon Pasquier","email":"pasquier.simon@gmail.com","username":"simon-pasquier"},"change_message_id":"e2d0ce3062f28f1a864ca5762cc117156d6adb3a","unresolved":false,"context_lines":[{"line_number":30,"context_line":"# Warning:"},{"line_number":31,"context_line":"#"},{"line_number":32,"context_line":"# If you modify the roles for the user running the script their token"},{"line_number":33,"context_line":"# gets invalidated and the script will abort. It\u0027s ideimpotent so you"},{"line_number":34,"context_line":"# should be able to just run it again."},{"line_number":35,"context_line":""},{"line_number":36,"context_line":"from keystoneclient.v2_0 import client"}],"source_content_type":"text/x-python","patch_set":2,"id":"fa80f949_9ae6bcae","line":33,"range":{"start_line":33,"start_character":51,"end_line":33,"end_character":62},"updated":"2015-11-06 12:59:04.000000000","message":"(nit) idempotent","commit_id":"b04f9373e026592c09efaa1d1722688d0d7ffc71"},{"author":{"_account_id":6794,"name":"Simon Pasquier","email":"pasquier.simon@gmail.com","username":"simon-pasquier"},"change_message_id":"e2d0ce3062f28f1a864ca5762cc117156d6adb3a","unresolved":false,"context_lines":[{"line_number":52,"context_line":"    role_ids \u003d keystone.roles.findall(name\u003drole_name)"},{"line_number":53,"context_line":"    if len(role_ids) !\u003d 1:"},{"line_number":54,"context_line":"        print \"Found %d matches for %s in role list, fatal.\" % (len(role_ids), role_name)"},{"line_number":55,"context_line":"        return \u0027-1\u0027"},{"line_number":56,"context_line":"    return role_ids[0].id"},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"def user_already_has_role(keystone, role_id, user, tenant):"}],"source_content_type":"text/x-python","patch_set":2,"id":"fa80f949_1a808c8a","line":55,"updated":"2015-11-06 12:59:04.000000000","message":"Like Balaji has noted below, it would be better to raise an exception here. IIUC there\u0027s nothing that can be done if the old/new role can\u0027t be found.","commit_id":"b04f9373e026592c09efaa1d1722688d0d7ffc71"},{"author":{"_account_id":9060,"name":"Mike Dorman","email":"dorm@dorm.org","username":"gd-mdorman"},"change_message_id":"36fd293b2ce320e42504770d7555a96cc9974690","unresolved":false,"context_lines":[{"line_number":52,"context_line":"    role_ids \u003d keystone.roles.findall(name\u003drole_name)"},{"line_number":53,"context_line":"    if len(role_ids) !\u003d 1:"},{"line_number":54,"context_line":"        print \"Found %d matches for %s in role list, fatal.\" % (len(role_ids), role_name)"},{"line_number":55,"context_line":"        return \u0027-1\u0027"},{"line_number":56,"context_line":"    return role_ids[0].id"},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"def user_already_has_role(keystone, role_id, user, tenant):"}],"source_content_type":"text/x-python","patch_set":2,"id":"da85f559_8edd7816","line":55,"in_reply_to":"fa80f949_1a808c8a","updated":"2015-11-09 16:30:00.000000000","message":"It does say \u0027assumes no typos on role-name.\u0027  I agree this could be cleaner, but I don\u0027t think this should prevent us from merging.","commit_id":"b04f9373e026592c09efaa1d1722688d0d7ffc71"},{"author":{"_account_id":14927,"name":"Balaji Narayanan","email":"lists@balajin.net","username":"balajijegan"},"change_message_id":"dad504d9870fe4a916fc51fef423377de4068d29","unresolved":false,"context_lines":[{"line_number":82,"context_line":"                            print \"\\t\\tSkipping %s. Already has %s\" % (user.name, new_role)"},{"line_number":83,"context_line":"                        else:"},{"line_number":84,"context_line":"                            print \"\\t\\tAdding %s to %s who already has %s\" % (new_role, user.name, old_role)"},{"line_number":85,"context_line":"                            keystone.tenants.role_manager.add_user_role(user\u003duser, role\u003dnew_role_id, tenant\u003dtenant)"},{"line_number":86,"context_line":"                    if remove:"},{"line_number":87,"context_line":"                        print \"\\t\\tRemoving %s\" % (old_role)"},{"line_number":88,"context_line":"                        keystone.tenants.role_manager.remove_user_role(user\u003duser,"}],"source_content_type":"text/x-python","patch_set":2,"id":"fa80f949_581e2a60","line":85,"updated":"2015-11-06 07:55:47.000000000","message":"What happens here if the new_role_id is -1. Would this throw an error?\nWould it be better for lookup_role_id to abort rather than return -1?","commit_id":"b04f9373e026592c09efaa1d1722688d0d7ffc71"},{"author":{"_account_id":9060,"name":"Mike Dorman","email":"dorm@dorm.org","username":"gd-mdorman"},"change_message_id":"36fd293b2ce320e42504770d7555a96cc9974690","unresolved":false,"context_lines":[{"line_number":82,"context_line":"                            print \"\\t\\tSkipping %s. Already has %s\" % (user.name, new_role)"},{"line_number":83,"context_line":"                        else:"},{"line_number":84,"context_line":"                            print \"\\t\\tAdding %s to %s who already has %s\" % (new_role, user.name, old_role)"},{"line_number":85,"context_line":"                            keystone.tenants.role_manager.add_user_role(user\u003duser, role\u003dnew_role_id, tenant\u003dtenant)"},{"line_number":86,"context_line":"                    if remove:"},{"line_number":87,"context_line":"                        print \"\\t\\tRemoving %s\" % (old_role)"},{"line_number":88,"context_line":"                        keystone.tenants.role_manager.remove_user_role(user\u003duser,"}],"source_content_type":"text/x-python","patch_set":2,"id":"da85f559_ee1d24be","line":85,"in_reply_to":"fa80f949_581e2a60","updated":"2015-11-09 16:30:00.000000000","message":"Agreed this should validate the role first.  But I think that\u0027s a feature that can be iterated on later.  Worst case, if the new role is invalid, this will just spew a bunch of errors and not actually break anything.  I think that\u0027s acceptable for an basic operators\u0027 script like this.","commit_id":"b04f9373e026592c09efaa1d1722688d0d7ffc71"},{"author":{"_account_id":9060,"name":"Mike Dorman","email":"dorm@dorm.org","username":"gd-mdorman"},"change_message_id":"36fd293b2ce320e42504770d7555a96cc9974690","unresolved":false,"context_lines":[{"line_number":93,"context_line":"    parser.add_argument(\"--old_role\", required\u003dTrue)"},{"line_number":94,"context_line":"    parser.add_argument(\"--new_role\", required\u003dTrue)"},{"line_number":95,"context_line":"    parser.add_argument(\"--add\", action\u003d\u0027store_true\u0027, help\u003d\u0027Set this if you really want the new role added\u0027)"},{"line_number":96,"context_line":"    parser.add_argument(\"--remove\", action\u003d\u0027store_true\u0027, help\u003d\u0027Set this if you really want the old role removed\u0027)"},{"line_number":97,"context_line":"    args \u003d parser.parse_args()"},{"line_number":98,"context_line":"    main(args.old_role, args.new_role, args.add, args.remove)"}],"source_content_type":"text/x-python","patch_set":2,"id":"da85f559_6eb934e9","line":96,"updated":"2015-11-09 16:30:00.000000000","message":"s/remove/revoke/\ns/add/grant/","commit_id":"b04f9373e026592c09efaa1d1722688d0d7ffc71"}]}
