)]}'
{"shade/_utils.py":[{"author":{"_account_id":986,"name":"Rosario Di Somma","email":"rosario.disomma@gmail.com","username":"mr-rods"},"change_message_id":"c1722265de832a3c9b39a7f3b25b1b55e7eee0fd","unresolved":false,"context_lines":[{"line_number":223,"context_line":""},{"line_number":224,"context_line":"    # If a uuid is passed short-circuit it calling the"},{"line_number":225,"context_line":"    # get_\u003cresorce_name\u003e_by_id method"},{"line_number":226,"context_line":"    if getattr(cloud, \u0027use_direct_get\u0027, False) and _is_uuid_like(name_or_id):"},{"line_number":227,"context_line":"        if resource.endswith(\u0027s\u0027):"},{"line_number":228,"context_line":"            resource \u003d resource.rstrip(\u0027s\u0027)"},{"line_number":229,"context_line":"        get_resource \u003d getattr(cloud, \u0027get_%s_by_id\u0027 % resource, None)"}],"source_content_type":"text/x-python","patch_set":1,"id":"9f436f4f_72bc566c","line":226,"range":{"start_line":226,"start_character":7,"end_line":226,"end_character":46},"updated":"2017-08-17 13:29:36.000000000","message":"_get_entity is called even by get_host in https://github.com/openstack-infra/shade/blob/master/shade/inventory.py#L85. We are not defining use_direct_get on OpenStackInventory so we need this check. Should we add the flag there too?","commit_id":"02ae7262f35393f3ee7081d4305198201c1b8dbe"},{"author":{"_account_id":2,"name":"Monty Taylor","email":"mordred@inaugust.com","username":"mordred"},"change_message_id":"a146f8e461683a067c82980233238849c337bba5","unresolved":false,"context_lines":[{"line_number":223,"context_line":""},{"line_number":224,"context_line":"    # If a uuid is passed short-circuit it calling the"},{"line_number":225,"context_line":"    # get_\u003cresorce_name\u003e_by_id method"},{"line_number":226,"context_line":"    if getattr(cloud, \u0027use_direct_get\u0027, False) and _is_uuid_like(name_or_id):"},{"line_number":227,"context_line":"        if resource.endswith(\u0027s\u0027):"},{"line_number":228,"context_line":"            resource \u003d resource.rstrip(\u0027s\u0027)"},{"line_number":229,"context_line":"        get_resource \u003d getattr(cloud, \u0027get_%s_by_id\u0027 % resource, None)"}],"source_content_type":"text/x-python","patch_set":1,"id":"9f436f4f_95ee84b2","line":226,"range":{"start_line":226,"start_character":7,"end_line":226,"end_character":46},"in_reply_to":"9f436f4f_72bc566c","updated":"2017-08-17 13:59:47.000000000","message":"Yah- let\u0027s add it there too.","commit_id":"02ae7262f35393f3ee7081d4305198201c1b8dbe"},{"author":{"_account_id":986,"name":"Rosario Di Somma","email":"rosario.disomma@gmail.com","username":"mr-rods"},"change_message_id":"c1722265de832a3c9b39a7f3b25b1b55e7eee0fd","unresolved":false,"context_lines":[{"line_number":224,"context_line":"    # If a uuid is passed short-circuit it calling the"},{"line_number":225,"context_line":"    # get_\u003cresorce_name\u003e_by_id method"},{"line_number":226,"context_line":"    if getattr(cloud, \u0027use_direct_get\u0027, False) and _is_uuid_like(name_or_id):"},{"line_number":227,"context_line":"        if resource.endswith(\u0027s\u0027):"},{"line_number":228,"context_line":"            resource \u003d resource.rstrip(\u0027s\u0027)"},{"line_number":229,"context_line":"        get_resource \u003d getattr(cloud, \u0027get_%s_by_id\u0027 % resource, None)"},{"line_number":230,"context_line":"        if get_resource:"},{"line_number":231,"context_line":"            return get_resource(name_or_id)"}],"source_content_type":"text/x-python","patch_set":1,"id":"9f436f4f_b2d87e1e","line":228,"range":{"start_line":227,"start_character":8,"end_line":228,"end_character":43},"updated":"2017-08-17 13:29:36.000000000","message":"The idea is to dinamically make calls to get_\u003cresource\u003e_by_id or to search_\u003cresource\u003e based on the `resource` param(string) we are passing. The problem is that get_network_by_id uses the `resource`(network) in the single form while search_networks uses it in the plurale form. I\u0027m doing a terrible stripping here but not really proud of it. Anyway method lookup like this seems a little weak.","commit_id":"02ae7262f35393f3ee7081d4305198201c1b8dbe"},{"author":{"_account_id":2,"name":"Monty Taylor","email":"mordred@inaugust.com","username":"mordred"},"change_message_id":"a146f8e461683a067c82980233238849c337bba5","unresolved":false,"context_lines":[{"line_number":224,"context_line":"    # If a uuid is passed short-circuit it calling the"},{"line_number":225,"context_line":"    # get_\u003cresorce_name\u003e_by_id method"},{"line_number":226,"context_line":"    if getattr(cloud, \u0027use_direct_get\u0027, False) and _is_uuid_like(name_or_id):"},{"line_number":227,"context_line":"        if resource.endswith(\u0027s\u0027):"},{"line_number":228,"context_line":"            resource \u003d resource.rstrip(\u0027s\u0027)"},{"line_number":229,"context_line":"        get_resource \u003d getattr(cloud, \u0027get_%s_by_id\u0027 % resource, None)"},{"line_number":230,"context_line":"        if get_resource:"},{"line_number":231,"context_line":"            return get_resource(name_or_id)"}],"source_content_type":"text/x-python","patch_set":1,"id":"9f436f4f_15a2944c","line":228,"range":{"start_line":227,"start_character":8,"end_line":228,"end_character":43},"in_reply_to":"9f436f4f_b2d87e1e","updated":"2017-08-17 13:59:47.000000000","message":"WELL - we could also pass singular resource and add an \u0027s\u0027. :)\n\nI think this is ok - we have a strict naming policy across shade. We _could_ add a unittest that grabs a list of all list_{resource}s methods and makes sure there are corresponding get_{resource} get_{resource)_by_id and search_{resource}s methods.\n\nALSO - we COULD go one step further and generate both get_{service} and get_{service}_by_id from the list of search_{service}s methods at constructor time. They\u0027re both mechanical functions - and even their docstrings are mechanical. (I think this is actually a job for a metaclass) it would cut down on a bunch of copy-pasta.","commit_id":"02ae7262f35393f3ee7081d4305198201c1b8dbe"},{"author":{"_account_id":986,"name":"Rosario Di Somma","email":"rosario.disomma@gmail.com","username":"mr-rods"},"change_message_id":"c1722265de832a3c9b39a7f3b25b1b55e7eee0fd","unresolved":false,"context_lines":[{"line_number":230,"context_line":"        if get_resource:"},{"line_number":231,"context_line":"            return get_resource(name_or_id)"},{"line_number":232,"context_line":""},{"line_number":233,"context_line":"    search \u003d resource if callable(resource) else getattr("},{"line_number":234,"context_line":"        cloud, \u0027search_%s\u0027 % resource, None)"},{"line_number":235,"context_line":"    if search:"},{"line_number":236,"context_line":"        entities \u003d search(name_or_id, filters, **kwargs)"}],"source_content_type":"text/x-python","patch_set":1,"id":"9f436f4f_d2678251","line":233,"range":{"start_line":233,"start_character":25,"end_line":233,"end_character":43},"updated":"2017-08-17 13:29:36.000000000","message":"We still need to support function passing because a couple of methods are using functools.partial to set specific params https://github.com/openstack-infra/shade/blob/master/shade/openstackcloud.py#L2842","commit_id":"02ae7262f35393f3ee7081d4305198201c1b8dbe"},{"author":{"_account_id":2,"name":"Monty Taylor","email":"mordred@inaugust.com","username":"mordred"},"change_message_id":"a146f8e461683a067c82980233238849c337bba5","unresolved":false,"context_lines":[{"line_number":230,"context_line":"        if get_resource:"},{"line_number":231,"context_line":"            return get_resource(name_or_id)"},{"line_number":232,"context_line":""},{"line_number":233,"context_line":"    search \u003d resource if callable(resource) else getattr("},{"line_number":234,"context_line":"        cloud, \u0027search_%s\u0027 % resource, None)"},{"line_number":235,"context_line":"    if search:"},{"line_number":236,"context_line":"        entities \u003d search(name_or_id, filters, **kwargs)"}],"source_content_type":"text/x-python","patch_set":1,"id":"9f436f4f_b57e28ad","line":233,"range":{"start_line":233,"start_character":25,"end_line":233,"end_character":43},"in_reply_to":"9f436f4f_d2678251","updated":"2017-08-17 13:59:47.000000000","message":"Ah. Interesting. That might make my earlier metaclass idea bong. Although I suppose that actually we could  have the metaclass check to see if there is already a get_{service} method on the class and leave it if it is.\n\nFeel free to tell me I\u0027m insane and to go away, btw.","commit_id":"02ae7262f35393f3ee7081d4305198201c1b8dbe"}]}
