)]}'
{"neutron/db/ipam_non_pluggable_backend.py":[{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":60,"context_line":""},{"line_number":61,"context_line":"        ip_allocations \u003d {}"},{"line_number":62,"context_line":"        for ipallocation in allocation_qry:"},{"line_number":63,"context_line":"            subnet_ip_allocs \u003d ip_allocations.get(ipallocation.subnet_id)"},{"line_number":64,"context_line":"            if not subnet_ip_allocs:"},{"line_number":65,"context_line":"                subnet_ip_allocs \u003d netaddr.IPSet()"},{"line_number":66,"context_line":"                ip_allocations[ipallocation.subnet_id] \u003d subnet_ip_allocs"},{"line_number":67,"context_line":"            "},{"line_number":68,"context_line":"            subnet_ip_allocs.add(netaddr.IPAddress(ipallocation.ip_address))"},{"line_number":69,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_59abad1d","line":66,"range":{"start_line":63,"start_character":12,"end_line":66,"end_character":73},"updated":"2016-03-21 20:54:29.000000000","message":"nit:  A good job for a defaultdict [1].\n\n [1] https://docs.python.org/2/library/collections.html#collections.defaultdict","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":70,"context_line":"        ip_pools \u003d {}"},{"line_number":71,"context_line":"        for ip_pool in pool_qry:"},{"line_number":72,"context_line":"            subnet_ip_pools \u003d ip_pools.get(ip_pool.subnet_id)"},{"line_number":73,"context_line":"            if not subnet_ip_pools:"},{"line_number":74,"context_line":"                subnet_ip_pools \u003d netaddr.IPSet()"},{"line_number":75,"context_line":"                ip_pools[ip_pool.subnet_id] \u003d subnet_ip_pools"},{"line_number":76,"context_line":""},{"line_number":77,"context_line":"            subnet_ip_pools.add(netaddr.IPRange(ip_pool.first_ip,"},{"line_number":78,"context_line":"                                                ip_pool.last_ip))"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_b387880e","line":75,"range":{"start_line":73,"start_character":12,"end_line":75,"end_character":61},"updated":"2016-03-21 20:54:29.000000000","message":"ditto","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":77,"context_line":"            subnet_ip_pools.add(netaddr.IPRange(ip_pool.first_ip,"},{"line_number":78,"context_line":"                                                ip_pool.last_ip))"},{"line_number":79,"context_line":""},{"line_number":80,"context_line":"        for subnet in ip_pools:"},{"line_number":81,"context_line":"            subnet_ip_pools \u003d ip_pools[subnet]"},{"line_number":82,"context_line":"            subnet_ip_allocs \u003d ip_allocations.get(subnet)"},{"line_number":83,"context_line":"            if not subnet_ip_allocs:"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_b3b5c8ce","line":80,"range":{"start_line":80,"start_character":12,"end_line":80,"end_character":30},"updated":"2016-03-21 20:54:29.000000000","message":"nit:  for subnet, subnet_ip_pools in ip_pools.items():","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":80,"context_line":"        for subnet in ip_pools:"},{"line_number":81,"context_line":"            subnet_ip_pools \u003d ip_pools[subnet]"},{"line_number":82,"context_line":"            subnet_ip_allocs \u003d ip_allocations.get(subnet)"},{"line_number":83,"context_line":"            if not subnet_ip_allocs:"},{"line_number":84,"context_line":"                subnet_ip_allocs \u003d netaddr.IPSet()"},{"line_number":85,"context_line":"            av_set \u003d subnet_ip_pools.difference(subnet_ip_allocs)"},{"line_number":86,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":87,"context_line":"            window \u003d 0"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_73e210d7","line":84,"range":{"start_line":83,"start_character":12,"end_line":84,"end_character":50},"updated":"2016-03-21 20:54:29.000000000","message":"nit:  Comment on L75 eliminates this too.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":82,"context_line":"            subnet_ip_allocs \u003d ip_allocations.get(subnet)"},{"line_number":83,"context_line":"            if not subnet_ip_allocs:"},{"line_number":84,"context_line":"                subnet_ip_allocs \u003d netaddr.IPSet()"},{"line_number":85,"context_line":"            av_set \u003d subnet_ip_pools.difference(subnet_ip_allocs)"},{"line_number":86,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":87,"context_line":"            window \u003d 0"},{"line_number":88,"context_line":"            av_set_size \u003d av_set.size"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_fe48a72f","line":85,"range":{"start_line":85,"start_character":21,"end_line":85,"end_character":65},"updated":"2016-03-21 20:54:29.000000000","message":"piconit:  prefer subnet_ip_pools - subnet_ip_allocs","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":84,"context_line":"                subnet_ip_allocs \u003d netaddr.IPSet()"},{"line_number":85,"context_line":"            av_set \u003d subnet_ip_pools.difference(subnet_ip_allocs)"},{"line_number":86,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":87,"context_line":"            window \u003d 0"},{"line_number":88,"context_line":"            av_set_size \u003d av_set.size"},{"line_number":89,"context_line":"            if not av_set_size:"},{"line_number":90,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_beb90fec","line":87,"range":{"start_line":87,"start_character":12,"end_line":87,"end_character":22},"updated":"2016-03-21 20:54:29.000000000","message":"This is no reason to initialize this to 0 here.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":85,"context_line":"            av_set \u003d subnet_ip_pools.difference(subnet_ip_allocs)"},{"line_number":86,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":87,"context_line":"            window \u003d 0"},{"line_number":88,"context_line":"            av_set_size \u003d av_set.size"},{"line_number":89,"context_line":"            if not av_set_size:"},{"line_number":90,"context_line":"                continue"},{"line_number":91,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_9e2c0b4c","line":88,"range":{"start_line":88,"start_character":12,"end_line":88,"end_character":23},"updated":"2016-03-21 20:54:29.000000000","message":"nit:  Is this really necessary?  I don\u0027t see any benefit of this particular local variable.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":86,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":87,"context_line":"            window \u003d 0"},{"line_number":88,"context_line":"            av_set_size \u003d av_set.size"},{"line_number":89,"context_line":"            if not av_set_size:"},{"line_number":90,"context_line":"                continue"},{"line_number":91,"context_line":""},{"line_number":92,"context_line":"            window \u003d min(av_set_size, 10)"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_fe79c730","line":89,"range":{"start_line":89,"start_character":15,"end_line":89,"end_character":30},"updated":"2016-03-21 20:54:29.000000000","message":"femtonit:  prefer \"if av_set_size \u003d\u003d 0:\"","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":89,"context_line":"            if not av_set_size:"},{"line_number":90,"context_line":"                continue"},{"line_number":91,"context_line":""},{"line_number":92,"context_line":"            window \u003d min(av_set_size, 10)"},{"line_number":93,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":94,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":95,"context_line":"            print ip_index"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_be874f0e","line":92,"range":{"start_line":92,"start_character":12,"end_line":92,"end_character":41},"updated":"2016-03-21 20:54:29.000000000","message":"I just noticed something here.  If we have a network with multiple subnets, we could get some congestion as one available subnet\u0027s available size (av_set_size) goes to 0 because the window will shrink.  If there happens to be multiple ports competing for the last remaining addresses on the subnet, they won\u0027t spill over to the next subnet until the current one is completely used.\n\nIn that case, I guess they\u0027ll be subject to a retry and will probably succeed the next time.  Maybe it isn\u0027t much of a concern.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"aef5ae2a3c39626432bb101b46296ee66fcd6c7d","unresolved":false,"context_lines":[{"line_number":89,"context_line":"            if not av_set_size:"},{"line_number":90,"context_line":"                continue"},{"line_number":91,"context_line":""},{"line_number":92,"context_line":"            window \u003d min(av_set_size, 10)"},{"line_number":93,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":94,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":95,"context_line":"            print ip_index"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_871650a5","line":92,"range":{"start_line":92,"start_character":12,"end_line":92,"end_character":41},"in_reply_to":"fa0719c6_be874f0e","updated":"2016-03-22 15:55:00.000000000","message":"I had thought about that too. My thinking is that you might see a brief spike in retry requests while the subnet fills up, but I suspect to see this seamlessly move on to allocating from the next subnet using the retry mechanism.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":92,"context_line":"            window \u003d min(av_set_size, 10)"},{"line_number":93,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":94,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":95,"context_line":"            print ip_index"},{"line_number":96,"context_line":"            #print candidate_ips"},{"line_number":97,"context_line":"            #print av_set"},{"line_number":98,"context_line":"            if candidate_ips:"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_7e949736","line":95,"range":{"start_line":95,"start_character":12,"end_line":95,"end_character":26},"updated":"2016-03-21 20:54:29.000000000","message":"WIP!  ;)","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"aef5ae2a3c39626432bb101b46296ee66fcd6c7d","unresolved":false,"context_lines":[{"line_number":92,"context_line":"            window \u003d min(av_set_size, 10)"},{"line_number":93,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":94,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":95,"context_line":"            print ip_index"},{"line_number":96,"context_line":"            #print candidate_ips"},{"line_number":97,"context_line":"            #print av_set"},{"line_number":98,"context_line":"            if candidate_ips:"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_04f51e82","line":95,"range":{"start_line":95,"start_character":12,"end_line":95,"end_character":26},"in_reply_to":"fa0719c6_7e949736","updated":"2016-03-22 15:55:00.000000000","message":"Very much so!","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":98,"context_line":"            if candidate_ips:"},{"line_number":99,"context_line":"                allocated_ip \u003d candidate_ips[-1]"},{"line_number":100,"context_line":"                print allocated_ip.__str__()"},{"line_number":101,"context_line":"                return {\u0027ip_address\u0027: allocated_ip.__str__(),"},{"line_number":102,"context_line":"                        \u0027subnet_id\u0027: subnet}"},{"line_number":103,"context_line":"        wrapped_exc \u003d n_exc.IpAddressGenerationFailure("},{"line_number":104,"context_line":"            net_id\u003dsubnets[0][\u0027network_id\u0027])"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_b9a48957","line":101,"range":{"start_line":101,"start_character":38,"end_line":101,"end_character":61},"updated":"2016-03-21 20:54:29.000000000","message":"nit:  str(allocated_ip)","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"aef5ae2a3c39626432bb101b46296ee66fcd6c7d","unresolved":false,"context_lines":[{"line_number":98,"context_line":"            if candidate_ips:"},{"line_number":99,"context_line":"                allocated_ip \u003d candidate_ips[-1]"},{"line_number":100,"context_line":"                print allocated_ip.__str__()"},{"line_number":101,"context_line":"                return {\u0027ip_address\u0027: allocated_ip.__str__(),"},{"line_number":102,"context_line":"                        \u0027subnet_id\u0027: subnet}"},{"line_number":103,"context_line":"        wrapped_exc \u003d n_exc.IpAddressGenerationFailure("},{"line_number":104,"context_line":"            net_id\u003dsubnets[0][\u0027network_id\u0027])"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_c402066f","line":101,"range":{"start_line":101,"start_character":38,"end_line":101,"end_character":61},"in_reply_to":"fa0719c6_b9a48957","updated":"2016-03-22 15:55:00.000000000","message":"Done","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":102,"context_line":"                        \u0027subnet_id\u0027: subnet}"},{"line_number":103,"context_line":"        wrapped_exc \u003d n_exc.IpAddressGenerationFailure("},{"line_number":104,"context_line":"            net_id\u003dsubnets[0][\u0027network_id\u0027])"},{"line_number":105,"context_line":"        raise db_exc.RetryRequest(wrapped_exc)"},{"line_number":106,"context_line":""},{"line_number":107,"context_line":"    @staticmethod"},{"line_number":108,"context_line":"    def _rebuild_availability_ranges(context, subnets):"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_7e6817f6","line":105,"range":{"start_line":105,"start_character":21,"end_line":105,"end_character":33},"updated":"2016-03-21 20:54:29.000000000","message":"Is retrying going to help in this particular case?  Seems the network\u0027s IPs are completely exhausted.  \n\nThe case that we *do* want to retry is the one where we select an IP address, go to record it in the allocations table, and the DB detects a duplicate and raises an exception.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"aef5ae2a3c39626432bb101b46296ee66fcd6c7d","unresolved":false,"context_lines":[{"line_number":102,"context_line":"                        \u0027subnet_id\u0027: subnet}"},{"line_number":103,"context_line":"        wrapped_exc \u003d n_exc.IpAddressGenerationFailure("},{"line_number":104,"context_line":"            net_id\u003dsubnets[0][\u0027network_id\u0027])"},{"line_number":105,"context_line":"        raise db_exc.RetryRequest(wrapped_exc)"},{"line_number":106,"context_line":""},{"line_number":107,"context_line":"    @staticmethod"},{"line_number":108,"context_line":"    def _rebuild_availability_ranges(context, subnets):"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_a405527b","line":105,"range":{"start_line":105,"start_character":21,"end_line":105,"end_character":33},"in_reply_to":"fa0719c6_7e6817f6","updated":"2016-03-22 15:55:00.000000000","message":"I think you\u0027re right, simply raising an IpAddressGenerationFailure is the right thing to do in this case.  We\u0027re just prolonging the inevitable by raising RetryRequest.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":105,"context_line":"        raise db_exc.RetryRequest(wrapped_exc)"},{"line_number":106,"context_line":""},{"line_number":107,"context_line":"    @staticmethod"},{"line_number":108,"context_line":"    def _rebuild_availability_ranges(context, subnets):"},{"line_number":109,"context_line":"        \"\"\"Rebuild availability ranges."},{"line_number":110,"context_line":""},{"line_number":111,"context_line":"        This method is called only when there\u0027s no more IP available or by"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_be174f50","line":108,"range":{"start_line":108,"start_character":8,"end_line":108,"end_character":36},"updated":"2016-03-21 20:54:29.000000000","message":"This goes away, right?","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"aef5ae2a3c39626432bb101b46296ee66fcd6c7d","unresolved":false,"context_lines":[{"line_number":105,"context_line":"        raise db_exc.RetryRequest(wrapped_exc)"},{"line_number":106,"context_line":""},{"line_number":107,"context_line":"    @staticmethod"},{"line_number":108,"context_line":"    def _rebuild_availability_ranges(context, subnets):"},{"line_number":109,"context_line":"        \"\"\"Rebuild availability ranges."},{"line_number":110,"context_line":""},{"line_number":111,"context_line":"        This method is called only when there\u0027s no more IP available or by"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_848c8e36","line":108,"range":{"start_line":108,"start_character":8,"end_line":108,"end_character":36},"in_reply_to":"fa0719c6_be174f50","updated":"2016-03-22 15:55:00.000000000","message":"Yes it does. I suppose yanking it sooner rather than later would be useful.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"c095a7eb8b8a4821ef196a767d3d10dfd7fc6d96","unresolved":false,"context_lines":[{"line_number":94,"context_line":"            # there may be a better way to handle allocations inside this"},{"line_number":95,"context_line":"            # transaction."},{"line_number":96,"context_line":"            av_set \u003d subnet_ip_pools.difference(subnet_ip_allocs)"},{"line_number":97,"context_line":"            av_set \u003d av_set.difference(filter_set)"},{"line_number":98,"context_line":""},{"line_number":99,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":100,"context_line":"            window \u003d 0"}],"source_content_type":"text/x-python","patch_set":2,"id":"9a061dce_93bdeb6a","line":97,"updated":"2016-04-05 22:13:01.000000000","message":"During a bulk allocation, we effectively \"mark\" IP\u0027s in memory as being allocated inside the transaction. Under contention in the DB, the non-deterministic selection of IP\u0027s could open even more contention issues as this transaction goes to commit. I think bulk allocation needs more thought.","commit_id":"94f925230373d8bb1337ca2e33b77e40b95fe12d"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"c095a7eb8b8a4821ef196a767d3d10dfd7fc6d96","unresolved":false,"context_lines":[{"line_number":102,"context_line":"            if not av_set_size:"},{"line_number":103,"context_line":"                continue"},{"line_number":104,"context_line":""},{"line_number":105,"context_line":"            window \u003d min(av_set_size, 10)"},{"line_number":106,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":107,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":108,"context_line":"            if candidate_ips:"}],"source_content_type":"text/x-python","patch_set":2,"id":"9a061dce_b3874fd6","line":105,"updated":"2016-04-05 22:13:01.000000000","message":"TODO What is an appropriate bound on window size?","commit_id":"94f925230373d8bb1337ca2e33b77e40b95fe12d"},{"author":{"_account_id":1653,"name":"garyk","email":"gkotton@vmware.com","username":"garyk"},"change_message_id":"9e3e031d00f3a067efbfc3584617edaa24ac94f8","unresolved":false,"context_lines":[{"line_number":14,"context_line":"#    under the License."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"import itertools"},{"line_number":17,"context_line":"import netaddr"},{"line_number":18,"context_line":"import random"},{"line_number":19,"context_line":""},{"line_number":20,"context_line":"from oslo_db import exception as db_exc"}],"source_content_type":"text/x-python","patch_set":4,"id":"9a061dce_aaf78957","line":17,"updated":"2016-04-07 06:14:55.000000000","message":"netaddr is third party","commit_id":"dacabefd6d7bc41c7d25e4e409b4b35166d5238f"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"2948b12f236caa1b78168f61dfada3c2ec6e7a1a","unresolved":false,"context_lines":[{"line_number":14,"context_line":"#    under the License."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"import itertools"},{"line_number":17,"context_line":"import netaddr"},{"line_number":18,"context_line":"import random"},{"line_number":19,"context_line":""},{"line_number":20,"context_line":"from oslo_db import exception as db_exc"}],"source_content_type":"text/x-python","patch_set":4,"id":"9a061dce_d4051b46","line":17,"in_reply_to":"9a061dce_aaf78957","updated":"2016-04-07 16:05:49.000000000","message":"Done","commit_id":"dacabefd6d7bc41c7d25e4e409b4b35166d5238f"},{"author":{"_account_id":1653,"name":"garyk","email":"gkotton@vmware.com","username":"garyk"},"change_message_id":"9e3e031d00f3a067efbfc3584617edaa24ac94f8","unresolved":false,"context_lines":[{"line_number":51,"context_line":"        the network."},{"line_number":52,"context_line":"        \"\"\""},{"line_number":53,"context_line":"        if not filtered_ips:"},{"line_number":54,"context_line":"            filtered_ips \u003d []"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":"        subnet_id_list \u003d [subnet[\u0027id\u0027] for subnet in subnets]"},{"line_number":57,"context_line":"        pool_qry \u003d context.session.query(models_v2.IPAllocationPool)"}],"source_content_type":"text/x-python","patch_set":4,"id":"9a061dce_8a8ba5c2","line":54,"updated":"2016-04-07 06:14:55.000000000","message":"filtered_ips \u003d filtered_ips or []","commit_id":"dacabefd6d7bc41c7d25e4e409b4b35166d5238f"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"2948b12f236caa1b78168f61dfada3c2ec6e7a1a","unresolved":false,"context_lines":[{"line_number":51,"context_line":"        the network."},{"line_number":52,"context_line":"        \"\"\""},{"line_number":53,"context_line":"        if not filtered_ips:"},{"line_number":54,"context_line":"            filtered_ips \u003d []"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":"        subnet_id_list \u003d [subnet[\u0027id\u0027] for subnet in subnets]"},{"line_number":57,"context_line":"        pool_qry \u003d context.session.query(models_v2.IPAllocationPool)"}],"source_content_type":"text/x-python","patch_set":4,"id":"9a061dce_f4f65f5b","line":54,"in_reply_to":"9a061dce_8a8ba5c2","updated":"2016-04-07 16:05:49.000000000","message":"Done","commit_id":"dacabefd6d7bc41c7d25e4e409b4b35166d5238f"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"b8429c7ef119b8d90ee3ae0c36dbb18136dbe1c0","unresolved":false,"context_lines":[{"line_number":40,"context_line":""},{"line_number":41,"context_line":"    @staticmethod"},{"line_number":42,"context_line":"    def _generate_ip(context, subnets, filtered_ips\u003dNone):"},{"line_number":43,"context_line":"        return IpamNonPluggableBackend._try_generate_ip(context, subnets,"},{"line_number":44,"context_line":"                                                        filtered_ips)"},{"line_number":45,"context_line":""},{"line_number":46,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":12,"id":"5a18252c_8fd612ef","line":43,"range":{"start_line":43,"start_character":15,"end_line":43,"end_character":55},"updated":"2016-04-14 21:48:33.000000000","message":"nit:  This whole level of indirection is pretty much obsolete now, right?","commit_id":"eb87dbfbecfe4ffa9ae12930baef1f8ce401ab5c"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"dfd73404002b56388ec2e1667bf24376a765b11f","unresolved":false,"context_lines":[{"line_number":40,"context_line":""},{"line_number":41,"context_line":"    @staticmethod"},{"line_number":42,"context_line":"    def _generate_ip(context, subnets, filtered_ips\u003dNone):"},{"line_number":43,"context_line":"        return IpamNonPluggableBackend._try_generate_ip(context, subnets,"},{"line_number":44,"context_line":"                                                        filtered_ips)"},{"line_number":45,"context_line":""},{"line_number":46,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":12,"id":"5a18252c_cacd9832","line":43,"range":{"start_line":43,"start_character":15,"end_line":43,"end_character":55},"in_reply_to":"5a18252c_8fd612ef","updated":"2016-04-14 21:55:41.000000000","message":"yes, I have that change queued up. I\u0027ve been sidetracked by getting the unit tests right.","commit_id":"eb87dbfbecfe4ffa9ae12930baef1f8ce401ab5c"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"b8429c7ef119b8d90ee3ae0c36dbb18136dbe1c0","unresolved":false,"context_lines":[{"line_number":62,"context_line":"        allocation_qry \u003d allocation_qry.filter("},{"line_number":63,"context_line":"            models_v2.IPAllocation.subnet_id.in_(subnet_id_list))"},{"line_number":64,"context_line":""},{"line_number":65,"context_line":"        ip_allocations \u003d {}"},{"line_number":66,"context_line":"        for ipallocation in allocation_qry:"},{"line_number":67,"context_line":"            subnet_ip_allocs \u003d ip_allocations.get(ipallocation.subnet_id)"},{"line_number":68,"context_line":"            if not subnet_ip_allocs:"},{"line_number":69,"context_line":"                subnet_ip_allocs \u003d netaddr.IPSet()"},{"line_number":70,"context_line":"                ip_allocations[ipallocation.subnet_id] \u003d subnet_ip_allocs"},{"line_number":71,"context_line":""},{"line_number":72,"context_line":"            subnet_ip_allocs.add(netaddr.IPAddress(ipallocation.ip_address))"},{"line_number":73,"context_line":""}],"source_content_type":"text/x-python","patch_set":12,"id":"5a18252c_aa32dcef","line":70,"range":{"start_line":65,"start_character":0,"end_line":70,"end_character":73},"updated":"2016-04-14 21:48:33.000000000","message":"Still a very nice use case for defaultdict:\n\n  ip_allocations \u003d collections.defaultdict(netaddr.IPSet)\n  for ipallocation in allocation_qry:\n      subnet_ip_allocs \u003d ip_allocations[ipallocation.subnet_id]\n\nI gave this feedback on PS1 along with a bunch of other points but didn\u0027t give an example of how it would look in this case.  I marked it all as nit but I thought of a lot of the same feedback again reading over this version.  I\u0027ll try not to harp on it anymore but it takes a lot of the fat out of the code and helps readers focus on what it is doing.","commit_id":"eb87dbfbecfe4ffa9ae12930baef1f8ce401ab5c"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"dfd73404002b56388ec2e1667bf24376a765b11f","unresolved":false,"context_lines":[{"line_number":62,"context_line":"        allocation_qry \u003d allocation_qry.filter("},{"line_number":63,"context_line":"            models_v2.IPAllocation.subnet_id.in_(subnet_id_list))"},{"line_number":64,"context_line":""},{"line_number":65,"context_line":"        ip_allocations \u003d {}"},{"line_number":66,"context_line":"        for ipallocation in allocation_qry:"},{"line_number":67,"context_line":"            subnet_ip_allocs \u003d ip_allocations.get(ipallocation.subnet_id)"},{"line_number":68,"context_line":"            if not subnet_ip_allocs:"},{"line_number":69,"context_line":"                subnet_ip_allocs \u003d netaddr.IPSet()"},{"line_number":70,"context_line":"                ip_allocations[ipallocation.subnet_id] \u003d subnet_ip_allocs"},{"line_number":71,"context_line":""},{"line_number":72,"context_line":"            subnet_ip_allocs.add(netaddr.IPAddress(ipallocation.ip_address))"},{"line_number":73,"context_line":""}],"source_content_type":"text/x-python","patch_set":12,"id":"5a18252c_0aeb1079","line":70,"range":{"start_line":65,"start_character":0,"end_line":70,"end_character":73},"in_reply_to":"5a18252c_aa32dcef","updated":"2016-04-14 21:55:41.000000000","message":"Good feedback, not ignoring it :)","commit_id":"eb87dbfbecfe4ffa9ae12930baef1f8ce401ab5c"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"b8429c7ef119b8d90ee3ae0c36dbb18136dbe1c0","unresolved":false,"context_lines":[{"line_number":83,"context_line":""},{"line_number":84,"context_line":"        for subnet in ip_pools:"},{"line_number":85,"context_line":"            subnet_ip_pools \u003d ip_pools[subnet]"},{"line_number":86,"context_line":"            subnet_ip_allocs \u003d ip_allocations.get(subnet)"},{"line_number":87,"context_line":"            filter_set \u003d netaddr.IPSet()"},{"line_number":88,"context_line":"            if not subnet_ip_allocs:"},{"line_number":89,"context_line":"                subnet_ip_allocs \u003d netaddr.IPSet()"}],"source_content_type":"text/x-python","patch_set":12,"id":"5a18252c_2aa36c01","line":86,"range":{"start_line":86,"start_character":31,"end_line":86,"end_character":57},"updated":"2016-04-14 21:48:33.000000000","message":"If you used defaultdict, this would have to be: \n\n  subnet_ip_allocs \u003d ip_allocations[subnet]","commit_id":"eb87dbfbecfe4ffa9ae12930baef1f8ce401ab5c"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"dfd73404002b56388ec2e1667bf24376a765b11f","unresolved":false,"context_lines":[{"line_number":83,"context_line":""},{"line_number":84,"context_line":"        for subnet in ip_pools:"},{"line_number":85,"context_line":"            subnet_ip_pools \u003d ip_pools[subnet]"},{"line_number":86,"context_line":"            subnet_ip_allocs \u003d ip_allocations.get(subnet)"},{"line_number":87,"context_line":"            filter_set \u003d netaddr.IPSet()"},{"line_number":88,"context_line":"            if not subnet_ip_allocs:"},{"line_number":89,"context_line":"                subnet_ip_allocs \u003d netaddr.IPSet()"}],"source_content_type":"text/x-python","patch_set":12,"id":"5a18252c_aafadc40","line":86,"range":{"start_line":86,"start_character":31,"end_line":86,"end_character":57},"in_reply_to":"5a18252c_2aa36c01","updated":"2016-04-14 21:55:41.000000000","message":"Done","commit_id":"eb87dbfbecfe4ffa9ae12930baef1f8ce401ab5c"},{"author":{"_account_id":13667,"name":"ZongKai LI","email":"onionpiece@163.com","username":"lzklibj"},"change_message_id":"3cbf2d5b8d924478912eb99f8ffad09ebd9052d2","unresolved":false,"context_lines":[{"line_number":72,"context_line":"        for subnet_id in ip_pools:"},{"line_number":73,"context_line":"            subnet_ip_pools \u003d ip_pools[subnet_id]"},{"line_number":74,"context_line":"            subnet_ip_allocs \u003d ip_allocations[subnet_id]"},{"line_number":75,"context_line":"            filter_set \u003d netaddr.IPSet()"},{"line_number":76,"context_line":"            for ip in filtered_ips:"},{"line_number":77,"context_line":"                filter_set.add(netaddr.IPAddress(ip))"},{"line_number":78,"context_line":""},{"line_number":79,"context_line":"            av_set \u003d subnet_ip_pools.difference(subnet_ip_allocs)"},{"line_number":80,"context_line":"            av_set \u003d av_set.difference(filter_set)"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_511e330c","line":77,"range":{"start_line":75,"start_character":12,"end_line":77,"end_character":53},"updated":"2016-04-21 03:00:33.000000000","message":"these three lines should go before L72.","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"9a1548abd3249b163879dd0971751a22f87efcd6","unresolved":false,"context_lines":[{"line_number":72,"context_line":"        for subnet_id in ip_pools:"},{"line_number":73,"context_line":"            subnet_ip_pools \u003d ip_pools[subnet_id]"},{"line_number":74,"context_line":"            subnet_ip_allocs \u003d ip_allocations[subnet_id]"},{"line_number":75,"context_line":"            filter_set \u003d netaddr.IPSet()"},{"line_number":76,"context_line":"            for ip in filtered_ips:"},{"line_number":77,"context_line":"                filter_set.add(netaddr.IPAddress(ip))"},{"line_number":78,"context_line":""},{"line_number":79,"context_line":"            av_set \u003d subnet_ip_pools.difference(subnet_ip_allocs)"},{"line_number":80,"context_line":"            av_set \u003d av_set.difference(filter_set)"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_7a5ddb47","line":77,"range":{"start_line":75,"start_character":12,"end_line":77,"end_character":53},"in_reply_to":"1a122d0e_511e330c","updated":"2016-04-21 18:48:58.000000000","message":"Good catch, this is wasteful","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"075f3460d7960cf380735007203dab11b5e2ae2b","unresolved":false,"context_lines":[{"line_number":72,"context_line":"        for subnet_id in ip_pools:"},{"line_number":73,"context_line":"            subnet_ip_pools \u003d ip_pools[subnet_id]"},{"line_number":74,"context_line":"            subnet_ip_allocs \u003d ip_allocations[subnet_id]"},{"line_number":75,"context_line":"            filter_set \u003d netaddr.IPSet()"},{"line_number":76,"context_line":"            for ip in filtered_ips:"},{"line_number":77,"context_line":"                filter_set.add(netaddr.IPAddress(ip))"},{"line_number":78,"context_line":""},{"line_number":79,"context_line":"            av_set \u003d subnet_ip_pools.difference(subnet_ip_allocs)"},{"line_number":80,"context_line":"            av_set \u003d av_set.difference(filter_set)"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_59861adc","line":77,"range":{"start_line":75,"start_character":12,"end_line":77,"end_character":53},"in_reply_to":"1a122d0e_630c093c","updated":"2016-05-02 23:23:00.000000000","message":"Maybe, my netaddr ignorance is showing :)","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"a2b82f284d71f12c3a54627531c28feb11ec2f0b","unresolved":false,"context_lines":[{"line_number":72,"context_line":"        for subnet_id in ip_pools:"},{"line_number":73,"context_line":"            subnet_ip_pools \u003d ip_pools[subnet_id]"},{"line_number":74,"context_line":"            subnet_ip_allocs \u003d ip_allocations[subnet_id]"},{"line_number":75,"context_line":"            filter_set \u003d netaddr.IPSet()"},{"line_number":76,"context_line":"            for ip in filtered_ips:"},{"line_number":77,"context_line":"                filter_set.add(netaddr.IPAddress(ip))"},{"line_number":78,"context_line":""},{"line_number":79,"context_line":"            av_set \u003d subnet_ip_pools.difference(subnet_ip_allocs)"},{"line_number":80,"context_line":"            av_set \u003d av_set.difference(filter_set)"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_630c093c","line":77,"range":{"start_line":75,"start_character":12,"end_line":77,"end_character":53},"in_reply_to":"1a122d0e_7a5ddb47","updated":"2016-05-02 22:30:57.000000000","message":"Also, would this work?\n\n  filter_set \u003d netaddr.IPSet(iterable\u003dfiltered_ips)\n\nBut, also see comment on L300.","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":13667,"name":"ZongKai LI","email":"onionpiece@163.com","username":"lzklibj"},"change_message_id":"3cbf2d5b8d924478912eb99f8ffad09ebd9052d2","unresolved":false,"context_lines":[{"line_number":83,"context_line":"            if av_set_size \u003d\u003d 0:"},{"line_number":84,"context_line":"                continue"},{"line_number":85,"context_line":""},{"line_number":86,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":87,"context_line":"            window \u003d min(av_set_size, 10)"},{"line_number":88,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":89,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":90,"context_line":"            if candidate_ips:"},{"line_number":91,"context_line":"                allocated_ip \u003d candidate_ips[-1]"},{"line_number":92,"context_line":"                return {\u0027ip_address\u0027: str(allocated_ip),"},{"line_number":93,"context_line":"                        \u0027subnet_id\u0027: subnet_id}"},{"line_number":94,"context_line":"        raise n_exc.IpAddressGenerationFailure("}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_51f6338f","line":91,"range":{"start_line":86,"start_character":12,"end_line":91,"end_character":48},"updated":"2016-04-21 03:00:33.000000000","message":"I think these code are making things complex, indeed this method just return one IP address, so maybe the computing here is too expansive.","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"9a1548abd3249b163879dd0971751a22f87efcd6","unresolved":false,"context_lines":[{"line_number":83,"context_line":"            if av_set_size \u003d\u003d 0:"},{"line_number":84,"context_line":"                continue"},{"line_number":85,"context_line":""},{"line_number":86,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":87,"context_line":"            window \u003d min(av_set_size, 10)"},{"line_number":88,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":89,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":90,"context_line":"            if candidate_ips:"},{"line_number":91,"context_line":"                allocated_ip \u003d candidate_ips[-1]"},{"line_number":92,"context_line":"                return {\u0027ip_address\u0027: str(allocated_ip),"},{"line_number":93,"context_line":"                        \u0027subnet_id\u0027: subnet_id}"},{"line_number":94,"context_line":"        raise n_exc.IpAddressGenerationFailure("}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_fa61eb12","line":91,"range":{"start_line":86,"start_character":12,"end_line":91,"end_character":48},"in_reply_to":"1a122d0e_51f6338f","updated":"2016-04-21 18:48:58.000000000","message":"Not sure I understand the comment. The algorithm involves using a window and psuedo-randomly selecting an IP address within that window. Are you thinking this algorithm has too much overhead? I\u0027m not sure I agree, could you explain further?","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"a2b82f284d71f12c3a54627531c28feb11ec2f0b","unresolved":false,"context_lines":[{"line_number":83,"context_line":"            if av_set_size \u003d\u003d 0:"},{"line_number":84,"context_line":"                continue"},{"line_number":85,"context_line":""},{"line_number":86,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":87,"context_line":"            window \u003d min(av_set_size, 10)"},{"line_number":88,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":89,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":90,"context_line":"            if candidate_ips:"},{"line_number":91,"context_line":"                allocated_ip \u003d candidate_ips[-1]"},{"line_number":92,"context_line":"                return {\u0027ip_address\u0027: str(allocated_ip),"},{"line_number":93,"context_line":"                        \u0027subnet_id\u0027: subnet_id}"},{"line_number":94,"context_line":"        raise n_exc.IpAddressGenerationFailure("}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_a391019d","line":91,"range":{"start_line":86,"start_character":12,"end_line":91,"end_character":48},"in_reply_to":"1a122d0e_fa61eb12","updated":"2016-05-02 22:30:57.000000000","message":"@ZongKai, do you have an alternate suggestion?  I think we\u0027ve got to do something like this to avoid contention around the next IP address to be allocated.  The parameters of the algorithm might be up for discussion but I\u0027m not sure how we could do better on the algorithm itself at this point.\n\nAs for complexity, the algorithmic complexity of all of this code is O(1).  \nIn terms of lines of code, it is a bit more complex than the naive algorithm but I think it is warranted.","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"a2b82f284d71f12c3a54627531c28feb11ec2f0b","unresolved":false,"context_lines":[{"line_number":297,"context_line":"        # those IPs happen to be next in the line for allocation for ones that"},{"line_number":298,"context_line":"        # didn\u0027t ask for a specific IP"},{"line_number":299,"context_line":"        fixed_ips.sort(key\u003dlambda x: \u0027ip_address\u0027 not in x)"},{"line_number":300,"context_line":"        allocated_ips \u003d []"},{"line_number":301,"context_line":"        for fixed in fixed_ips:"},{"line_number":302,"context_line":"            subnet \u003d self._get_subnet(context, fixed[\u0027subnet_id\u0027])"},{"line_number":303,"context_line":"            is_auto_addr \u003d ipv6_utils.is_auto_address_subnet(subnet)"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_966361dd","line":300,"range":{"start_line":300,"start_character":24,"end_line":300,"end_character":26},"updated":"2016-05-02 22:30:57.000000000","message":"This probably ought to be a set at least.  Or, an IPSet would work nicely here.","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"075f3460d7960cf380735007203dab11b5e2ae2b","unresolved":false,"context_lines":[{"line_number":297,"context_line":"        # those IPs happen to be next in the line for allocation for ones that"},{"line_number":298,"context_line":"        # didn\u0027t ask for a specific IP"},{"line_number":299,"context_line":"        fixed_ips.sort(key\u003dlambda x: \u0027ip_address\u0027 not in x)"},{"line_number":300,"context_line":"        allocated_ips \u003d []"},{"line_number":301,"context_line":"        for fixed in fixed_ips:"},{"line_number":302,"context_line":"            subnet \u003d self._get_subnet(context, fixed[\u0027subnet_id\u0027])"},{"line_number":303,"context_line":"            is_auto_addr \u003d ipv6_utils.is_auto_address_subnet(subnet)"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_d9498ab9","line":300,"range":{"start_line":300,"start_character":24,"end_line":300,"end_character":26},"in_reply_to":"1a122d0e_966361dd","updated":"2016-05-02 23:23:00.000000000","message":"Done","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"a2b82f284d71f12c3a54627531c28feb11ec2f0b","unresolved":false,"context_lines":[{"line_number":321,"context_line":"                else:"},{"line_number":322,"context_line":"                    subnets \u003d [subnet]"},{"line_number":323,"context_line":"                    # IP address allocation"},{"line_number":324,"context_line":"                    result \u003d self._generate_ip(context, subnets, allocated_ips)"},{"line_number":325,"context_line":"                    allocated_ips.append(result[\u0027ip_address\u0027])"},{"line_number":326,"context_line":"                    ips.append({\u0027ip_address\u0027: result[\u0027ip_address\u0027],"},{"line_number":327,"context_line":"                                \u0027subnet_id\u0027: result[\u0027subnet_id\u0027]})"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_56cd49b6","line":324,"range":{"start_line":324,"start_character":34,"end_line":324,"end_character":46},"updated":"2016-05-02 22:30:57.000000000","message":"If I understand, you\u0027re considering the case where the fixed_ips ends of asking for multiple addresses from the same subnet.  Part of me thought that we wouldn\u0027t allow that but I\u0027m not sure.","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"cadbf3821031e6727956c5fed7c33031053ea2e1","unresolved":false,"context_lines":[{"line_number":321,"context_line":"                else:"},{"line_number":322,"context_line":"                    subnets \u003d [subnet]"},{"line_number":323,"context_line":"                    # IP address allocation"},{"line_number":324,"context_line":"                    result \u003d self._generate_ip(context, subnets, allocated_ips)"},{"line_number":325,"context_line":"                    allocated_ips.append(result[\u0027ip_address\u0027])"},{"line_number":326,"context_line":"                    ips.append({\u0027ip_address\u0027: result[\u0027ip_address\u0027],"},{"line_number":327,"context_line":"                                \u0027subnet_id\u0027: result[\u0027subnet_id\u0027]})"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_18b8fcc6","line":324,"range":{"start_line":324,"start_character":34,"end_line":324,"end_character":46},"in_reply_to":"1a122d0e_1998221b","updated":"2016-05-03 19:40:12.000000000","message":"Well, I don\u0027t think I actually finished the comment.  Sorry.  It was more like thinking out loud and I meant to revisit it before submitting.\n\nYou\u0027re passing in \"allocated_ips\" so that _generate_ip won\u0027t allocate the same ones again.  But, I didn\u0027t think we\u0027d allocate two IPs from the same subnet.  But, maybe we do.  If we do, I guess you\u0027ve got to keep track of the ones that you\u0027ve allocated already so that it doesn\u0027t give them out again.\n\nI\u0027m not sure what I\u0027d suggest to change this.  So, ignore this for now.","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"075f3460d7960cf380735007203dab11b5e2ae2b","unresolved":false,"context_lines":[{"line_number":321,"context_line":"                else:"},{"line_number":322,"context_line":"                    subnets \u003d [subnet]"},{"line_number":323,"context_line":"                    # IP address allocation"},{"line_number":324,"context_line":"                    result \u003d self._generate_ip(context, subnets, allocated_ips)"},{"line_number":325,"context_line":"                    allocated_ips.append(result[\u0027ip_address\u0027])"},{"line_number":326,"context_line":"                    ips.append({\u0027ip_address\u0027: result[\u0027ip_address\u0027],"},{"line_number":327,"context_line":"                                \u0027subnet_id\u0027: result[\u0027subnet_id\u0027]})"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_1998221b","line":324,"range":{"start_line":324,"start_character":34,"end_line":324,"end_character":46},"in_reply_to":"1a122d0e_56cd49b6","updated":"2016-05-02 23:23:00.000000000","message":"Not sure I understand the comment :) As written this will pull IP addresses from the first available subnet, then as it gets allocated completely it begins allocating from the next subnet on the network. Not sure if that is helpful at all or if it\u0027s even the right thing to do, but it seemed to be in line with what it looked like the previous implementation  did.....","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":1653,"name":"garyk","email":"gkotton@vmware.com","username":"garyk"},"change_message_id":"71f521802019cc25002465766d14b178b5ef9654","unresolved":false,"context_lines":[{"line_number":13,"context_line":"#    License for the specific language governing permissions and limitations"},{"line_number":14,"context_line":"#    under the License."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"import collections"},{"line_number":17,"context_line":"import itertools"},{"line_number":18,"context_line":"import netaddr"},{"line_number":19,"context_line":"from neutron_lib import constants"}],"source_content_type":"text/x-python","patch_set":17,"id":"1a122d0e_620ae321","line":16,"updated":"2016-05-04 23:38:51.000000000","message":"minor nit - these new imports are not third party - so they should be in their own section above","commit_id":"466260f2dea0d30b147ef391fe94fb968c1b818a"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"8957d6293d190fa3933d4a990a6c75d62798b6f3","unresolved":false,"context_lines":[{"line_number":13,"context_line":"#    License for the specific language governing permissions and limitations"},{"line_number":14,"context_line":"#    under the License."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"import collections"},{"line_number":17,"context_line":"import itertools"},{"line_number":18,"context_line":"import netaddr"},{"line_number":19,"context_line":"from neutron_lib import constants"}],"source_content_type":"text/x-python","patch_set":17,"id":"1a122d0e_422c074a","line":16,"in_reply_to":"1a122d0e_620ae321","updated":"2016-05-04 23:46:18.000000000","message":"Done","commit_id":"466260f2dea0d30b147ef391fe94fb968c1b818a"},{"author":{"_account_id":1653,"name":"garyk","email":"gkotton@vmware.com","username":"garyk"},"change_message_id":"71f521802019cc25002465766d14b178b5ef9654","unresolved":false,"context_lines":[{"line_number":45,"context_line":""},{"line_number":46,"context_line":"        The IP address will be generated from one of the subnets defined on"},{"line_number":47,"context_line":"        the network."},{"line_number":48,"context_line":"        \"\"\""},{"line_number":49,"context_line":"        if not filtered_ips:"},{"line_number":50,"context_line":"            filtered_ips \u003d []"},{"line_number":51,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"1a122d0e_821c5f67","line":48,"updated":"2016-05-04 23:38:51.000000000","message":"filtered_ips \u003d filtered_ips or []","commit_id":"466260f2dea0d30b147ef391fe94fb968c1b818a"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"e114c769f5210b29c08ca2aa75bf249fae2f926b","unresolved":false,"context_lines":[{"line_number":45,"context_line":""},{"line_number":46,"context_line":"        The IP address will be generated from one of the subnets defined on"},{"line_number":47,"context_line":"        the network."},{"line_number":48,"context_line":"        \"\"\""},{"line_number":49,"context_line":"        if not filtered_ips:"},{"line_number":50,"context_line":"            filtered_ips \u003d []"},{"line_number":51,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"dab17558_80e5e0a9","line":48,"in_reply_to":"1a122d0e_821c5f67","updated":"2016-05-05 23:17:02.000000000","message":"Done","commit_id":"466260f2dea0d30b147ef391fe94fb968c1b818a"},{"author":{"_account_id":1653,"name":"garyk","email":"gkotton@vmware.com","username":"garyk"},"change_message_id":"71f521802019cc25002465766d14b178b5ef9654","unresolved":false,"context_lines":[{"line_number":83,"context_line":"            if av_set_size \u003d\u003d 0:"},{"line_number":84,"context_line":"                continue"},{"line_number":85,"context_line":""},{"line_number":86,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":87,"context_line":"            window \u003d min(av_set_size, 10)"},{"line_number":88,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":89,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"}],"source_content_type":"text/x-python","patch_set":17,"id":"1a122d0e_8253bf15","line":86,"updated":"2016-05-04 23:38:51.000000000","message":"can you please write an explanation what you are doing here. It will make life terribly easier for those looking","commit_id":"466260f2dea0d30b147ef391fe94fb968c1b818a"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"8957d6293d190fa3933d4a990a6c75d62798b6f3","unresolved":false,"context_lines":[{"line_number":83,"context_line":"            if av_set_size \u003d\u003d 0:"},{"line_number":84,"context_line":"                continue"},{"line_number":85,"context_line":""},{"line_number":86,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":87,"context_line":"            window \u003d min(av_set_size, 10)"},{"line_number":88,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":89,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"}],"source_content_type":"text/x-python","patch_set":17,"id":"1a122d0e_02004faa","line":86,"in_reply_to":"1a122d0e_8253bf15","updated":"2016-05-04 23:46:18.000000000","message":"I\u0027ll update the comment. What we are doing here is selecting from a window of the first 10(numerically ordered) available IP\u0027s at random to avoid contention on a particular IP address. A window size of 10 was sort of pulled out of thin air, but it does give you enough breathing room to avoid contention on a specific IP while the window slides sequentially across the subnet. 10 seemed like a reasonable window size for keeping allocations from being randomly pulled from all over the subnet.","commit_id":"466260f2dea0d30b147ef391fe94fb968c1b818a"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"ff8ac7f574e4fa6bc2ab289d095980f7003eada6","unresolved":false,"context_lines":[{"line_number":20,"context_line":"import netaddr"},{"line_number":21,"context_line":"from neutron_lib import constants"},{"line_number":22,"context_line":"from neutron_lib import exceptions as n_exc"},{"line_number":23,"context_line":""},{"line_number":24,"context_line":"from oslo_db import exception as db_exc"},{"line_number":25,"context_line":"from oslo_log import log as logging"},{"line_number":26,"context_line":"from sqlalchemy import and_"}],"source_content_type":"text/x-python","patch_set":23,"id":"9abb7d3a_2e243ec3","line":23,"updated":"2016-05-31 22:48:27.000000000","message":"I\u0027m not sure why you\u0027re adding a blank line here.","commit_id":"c9f8ac35f834754235eae09d709ae2b3d9ecf77b"}],"neutron/db/ipam_pluggable_backend.py":[{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"299dc68f8a564619b76b54d2b75b15b1200f6409","unresolved":false,"context_lines":[{"line_number":304,"context_line":"                                                new_mac)"},{"line_number":305,"context_line":"        try:"},{"line_number":306,"context_line":"            # Check if the IPs need to be updated"},{"line_number":307,"context_line":"            network_id \u003d db_port[\u0027network_id\u0027]"},{"line_number":308,"context_line":"            for ip in changes.remove:"},{"line_number":309,"context_line":"                self._delete_ip_allocation(context, network_id,"},{"line_number":310,"context_line":"                                           ip[\u0027subnet_id\u0027], ip[\u0027ip_address\u0027])"}],"source_content_type":"text/x-python","patch_set":15,"id":"1a122d0e_bdec5abc","line":307,"updated":"2016-05-03 19:16:38.000000000","message":"I kicked over a rock and may have uncovered a bug. Not sure if what I did here is the best answer, but it works. If IPAM hands back an IP address you already had on a port, we need to delete the allocation before re-adding it otherwise sqlalchemy complains.\n\nI\u0027m thinking in the case where I get handed back the same IP address I already had on a port, why not just skip over the de-allocate/re-allocate step? Does it make sense to essentially treat it as a no-op? This is what has me thinking there may be some further refinement needed.","commit_id":"c0daaf06e91d9893998bce5ddfdd71296d1654b7"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"213fe778ccca9d5cfa0a31d9f86f71976af97ae6","unresolved":false,"context_lines":[{"line_number":304,"context_line":"                                                new_mac)"},{"line_number":305,"context_line":"        try:"},{"line_number":306,"context_line":"            # Check if the IPs need to be updated"},{"line_number":307,"context_line":"            network_id \u003d db_port[\u0027network_id\u0027]"},{"line_number":308,"context_line":"            for ip in changes.remove:"},{"line_number":309,"context_line":"                self._delete_ip_allocation(context, network_id,"},{"line_number":310,"context_line":"                                           ip[\u0027subnet_id\u0027], ip[\u0027ip_address\u0027])"}],"source_content_type":"text/x-python","patch_set":15,"id":"1a122d0e_108290c8","line":307,"in_reply_to":"1a122d0e_58b8b475","updated":"2016-05-03 22:23:30.000000000","message":"OK, so I\u0027ve been digging on this and actually do think this is the right answer even though it is not optimized. This gives us parity with the non-pluggable backend. Here\u0027s why I think that:\n\nIf you look around L288 in neutron/db/ipam_non_pluggable_backend.py you will see a similar construct in place. See test_update_port_add_additional_ip() in neutron/tests/unit/db/test_db_base_plugin_v2.py (around L1586). The non-pluggable backend removes the IPAllocation, then saves it again. The pluggable backend has to save both the IpamAllocation and the IPAllocation. The pluggable backend removes the IpamAllocation then re-adds it, this process needs to be mirrored when handling the IPAllocation\u0027s as well, otherwise the IPAM tables and the Neutron tables are out of sync. This change puts the management of both tables in lock-step so they don\u0027t get out of sync.\n\nThere is probably an optimization to pursue here, and that is to recognize when an \"ANY\" request has not actually changed the IP address and bypass the de-allocate/re-allocate step. I don\u0027t want to pursue that in this patch though.","commit_id":"c0daaf06e91d9893998bce5ddfdd71296d1654b7"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"68d6f53633ce1253132f25c481a69b6632e0798b","unresolved":false,"context_lines":[{"line_number":304,"context_line":"                                                new_mac)"},{"line_number":305,"context_line":"        try:"},{"line_number":306,"context_line":"            # Check if the IPs need to be updated"},{"line_number":307,"context_line":"            network_id \u003d db_port[\u0027network_id\u0027]"},{"line_number":308,"context_line":"            for ip in changes.remove:"},{"line_number":309,"context_line":"                self._delete_ip_allocation(context, network_id,"},{"line_number":310,"context_line":"                                           ip[\u0027subnet_id\u0027], ip[\u0027ip_address\u0027])"}],"source_content_type":"text/x-python","patch_set":15,"id":"1a122d0e_58b8b475","line":307,"in_reply_to":"1a122d0e_98beccfe","updated":"2016-05-03 19:47:33.000000000","message":"Not totally sure that it\u0027s the DB complaining. You get a FlushError out of sqlalchemy, not an explicit constraint violation. I wish it was that straight-forward :) Yes, we should look to see why. I\u0027ve been stumped by it, and this gets us around the issue so I pushed what I had. I just wanted to point it out so I could get more eyes on the issue since I\u0027m really perplexed and code-blind right now.","commit_id":"c0daaf06e91d9893998bce5ddfdd71296d1654b7"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"8e572e6ca869bec87b7307416c2a8c85b069b0be","unresolved":false,"context_lines":[{"line_number":304,"context_line":"                                                new_mac)"},{"line_number":305,"context_line":"        try:"},{"line_number":306,"context_line":"            # Check if the IPs need to be updated"},{"line_number":307,"context_line":"            network_id \u003d db_port[\u0027network_id\u0027]"},{"line_number":308,"context_line":"            for ip in changes.remove:"},{"line_number":309,"context_line":"                self._delete_ip_allocation(context, network_id,"},{"line_number":310,"context_line":"                                           ip[\u0027subnet_id\u0027], ip[\u0027ip_address\u0027])"}],"source_content_type":"text/x-python","patch_set":15,"id":"1a122d0e_98beccfe","line":307,"in_reply_to":"1a122d0e_bdec5abc","updated":"2016-05-03 19:40:46.000000000","message":"I think you mean that the DB complains.  It is a violated constraint.\n\nI\u0027m having a little bit of trouble figuring out what gets us in to this situation.  If the IP address didn\u0027t change, wouldn\u0027t it appear in changes.original?  If not, shouldn\u0027t we look to see why?","commit_id":"c0daaf06e91d9893998bce5ddfdd71296d1654b7"}],"neutron/ipam/drivers/neutrondb_ipam/driver.py":[{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":308,"context_line":""},{"line_number":309,"context_line":"        return self._try_generate_ip(session)"},{"line_number":310,"context_line":""},{"line_number":311,"context_line":"    def _try_generate_ip(self, session):"},{"line_number":312,"context_line":"        \"\"\"Generate an IP address from availability ranges.\"\"\""},{"line_number":313,"context_line":"        ip_allocations \u003d netaddr.IPSet()"},{"line_number":314,"context_line":"        for ipallocation in self.subnet_manager.list_allocations(session):"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_591bad1b","line":311,"range":{"start_line":311,"start_character":8,"end_line":311,"end_character":24},"updated":"2016-03-21 20:54:29.000000000","message":"It\u0027d be nice of this method could share some implementation with the method in the previous file.  At least, they should have consistent implementation.  There are many things in this one that are inexplicably different than the other one.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"aef5ae2a3c39626432bb101b46296ee66fcd6c7d","unresolved":false,"context_lines":[{"line_number":308,"context_line":""},{"line_number":309,"context_line":"        return self._try_generate_ip(session)"},{"line_number":310,"context_line":""},{"line_number":311,"context_line":"    def _try_generate_ip(self, session):"},{"line_number":312,"context_line":"        \"\"\"Generate an IP address from availability ranges.\"\"\""},{"line_number":313,"context_line":"        ip_allocations \u003d netaddr.IPSet()"},{"line_number":314,"context_line":"        for ipallocation in self.subnet_manager.list_allocations(session):"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_075b6055","line":311,"range":{"start_line":311,"start_character":8,"end_line":311,"end_character":24},"in_reply_to":"fa0719c6_591bad1b","updated":"2016-03-22 15:55:00.000000000","message":"That is the intent, I started here but thought I could make better progress by focusing on the non-pluggable backend.  I do intend to make this look like the non-pluggable implementation.  I haven\u0027t really started slogging through making changes in the pluggable backend. You can ignore these changes for the moment","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":320,"context_line":""},{"line_number":321,"context_line":"        av_set \u003d ip_pools.difference(ip_allocations)"},{"line_number":322,"context_line":"        # Compute a value for the selection window based on size of av_set"},{"line_number":323,"context_line":"        window \u003d 0"},{"line_number":324,"context_line":"        av_set_size \u003d av_set.size()"},{"line_number":325,"context_line":"        if av_set_size \u003e 10:"},{"line_number":326,"context_line":"            window \u003d 10"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_f95ba152","line":323,"range":{"start_line":323,"start_character":8,"end_line":323,"end_character":18},"updated":"2016-03-21 20:54:29.000000000","message":"No need.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":321,"context_line":"        av_set \u003d ip_pools.difference(ip_allocations)"},{"line_number":322,"context_line":"        # Compute a value for the selection window based on size of av_set"},{"line_number":323,"context_line":"        window \u003d 0"},{"line_number":324,"context_line":"        av_set_size \u003d av_set.size()"},{"line_number":325,"context_line":"        if av_set_size \u003e 10:"},{"line_number":326,"context_line":"            window \u003d 10"},{"line_number":327,"context_line":"        else:"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_79ee7123","line":324,"range":{"start_line":324,"start_character":22,"end_line":324,"end_character":35},"updated":"2016-03-21 20:54:29.000000000","message":"This should just be av_set.size, I think.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":322,"context_line":"        # Compute a value for the selection window based on size of av_set"},{"line_number":323,"context_line":"        window \u003d 0"},{"line_number":324,"context_line":"        av_set_size \u003d av_set.size()"},{"line_number":325,"context_line":"        if av_set_size \u003e 10:"},{"line_number":326,"context_line":"            window \u003d 10"},{"line_number":327,"context_line":"        else:"},{"line_number":328,"context_line":"            window \u003d av_set_size"},{"line_number":329,"context_line":""},{"line_number":330,"context_line":"        if not window:"},{"line_number":331,"context_line":"            raise ipam_exc.IpAddressGenerationFailure()"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_59e8cd10","line":328,"range":{"start_line":325,"start_character":8,"end_line":328,"end_character":32},"updated":"2016-03-21 20:54:29.000000000","message":"min?","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3c4daf5df32512c07d802e0aadf0fee0ffa3f173","unresolved":false,"context_lines":[{"line_number":357,"context_line":"            else:"},{"line_number":358,"context_line":"                ip_address, all_pool_id \u003d self._generate_ip(session)"},{"line_number":359,"context_line":"                auto_generated \u003d True"},{"line_number":360,"context_line":"            #self._allocate_specific_ip(session, ip_address, all_pool_id,"},{"line_number":361,"context_line":"            #                           auto_generated)"},{"line_number":362,"context_line":"            # Create IP allocation request object"},{"line_number":363,"context_line":"            # The only defined status at this stage is \u0027ALLOCATED\u0027."}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_7904b114","line":360,"range":{"start_line":360,"start_character":12,"end_line":360,"end_character":13},"updated":"2016-03-21 20:54:29.000000000","message":"Huh?","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"aef5ae2a3c39626432bb101b46296ee66fcd6c7d","unresolved":false,"context_lines":[{"line_number":357,"context_line":"            else:"},{"line_number":358,"context_line":"                ip_address, all_pool_id \u003d self._generate_ip(session)"},{"line_number":359,"context_line":"                auto_generated \u003d True"},{"line_number":360,"context_line":"            #self._allocate_specific_ip(session, ip_address, all_pool_id,"},{"line_number":361,"context_line":"            #                           auto_generated)"},{"line_number":362,"context_line":"            # Create IP allocation request object"},{"line_number":363,"context_line":"            # The only defined status at this stage is \u0027ALLOCATED\u0027."}],"source_content_type":"text/x-python","patch_set":1,"id":"fa0719c6_e4a62a0f","line":360,"range":{"start_line":360,"start_character":12,"end_line":360,"end_character":13},"in_reply_to":"fa0719c6_7904b114","updated":"2016-03-22 15:55:00.000000000","message":"WIP, just trying to identify which tests are affected by changes to this code.","commit_id":"e6e3576a9324f0964320e47a0b9de6f34f23ed8e"},{"author":{"_account_id":1653,"name":"garyk","email":"gkotton@vmware.com","username":"garyk"},"change_message_id":"9e3e031d00f3a067efbfc3584617edaa24ac94f8","unresolved":false,"context_lines":[{"line_number":14,"context_line":"#    under the License."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"import itertools"},{"line_number":17,"context_line":"import netaddr"},{"line_number":18,"context_line":"from oslo_db import exception as db_exc"},{"line_number":19,"context_line":"from oslo_log import log"},{"line_number":20,"context_line":"from oslo_utils import uuidutils"}],"source_content_type":"text/x-python","patch_set":4,"id":"9a061dce_ea37c1fc","line":17,"updated":"2016-04-07 06:14:55.000000000","message":"same comment as before","commit_id":"dacabefd6d7bc41c7d25e4e409b4b35166d5238f"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"2948b12f236caa1b78168f61dfada3c2ec6e7a1a","unresolved":false,"context_lines":[{"line_number":14,"context_line":"#    under the License."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"import itertools"},{"line_number":17,"context_line":"import netaddr"},{"line_number":18,"context_line":"from oslo_db import exception as db_exc"},{"line_number":19,"context_line":"from oslo_log import log"},{"line_number":20,"context_line":"from oslo_utils import uuidutils"}],"source_content_type":"text/x-python","patch_set":4,"id":"9a061dce_949e0305","line":17,"in_reply_to":"9a061dce_ea37c1fc","updated":"2016-04-07 16:05:49.000000000","message":"Done","commit_id":"dacabefd6d7bc41c7d25e4e409b4b35166d5238f"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"3f2c95f7dc5cd58764cd4a0f8c29e2cbbcca797b","unresolved":false,"context_lines":[{"line_number":188,"context_line":"        final_ranges \u003d []"},{"line_number":189,"context_line":"        ip_in_pools \u003d False"},{"line_number":190,"context_line":"        if allocation_pool_id:"},{"line_number":191,"context_line":"            av_ranges \u003d self.subnet_manager.list_ranges_by_allocation_pool("},{"line_number":192,"context_line":"                session, allocation_pool_id)"},{"line_number":193,"context_line":"        else:"},{"line_number":194,"context_line":"            av_ranges \u003d self.subnet_manager.list_ranges_by_subnet_id(session)"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_82f4cd87","line":191,"updated":"2016-04-21 20:51:18.000000000","message":"Seeing some test failures that I suspect trace back to here. I think av_ranges needs to be computed similarly to how it computed in _generate_ip()","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"075f3460d7960cf380735007203dab11b5e2ae2b","unresolved":false,"context_lines":[{"line_number":188,"context_line":"        final_ranges \u003d []"},{"line_number":189,"context_line":"        ip_in_pools \u003d False"},{"line_number":190,"context_line":"        if allocation_pool_id:"},{"line_number":191,"context_line":"            av_ranges \u003d self.subnet_manager.list_ranges_by_allocation_pool("},{"line_number":192,"context_line":"                session, allocation_pool_id)"},{"line_number":193,"context_line":"        else:"},{"line_number":194,"context_line":"            av_ranges \u003d self.subnet_manager.list_ranges_by_subnet_id(session)"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_590f3a88","line":191,"in_reply_to":"1a122d0e_01eaf273","updated":"2016-05-02 23:23:00.000000000","message":"You\u0027re right, this method is not needed. Will remove it.","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":13768,"name":"Pavel Bondar","email":"pbondar@infoblox.com","username":"pavel_bondar"},"change_message_id":"e8749a96156205112ca39019da95ab0be55010e5","unresolved":false,"context_lines":[{"line_number":188,"context_line":"        final_ranges \u003d []"},{"line_number":189,"context_line":"        ip_in_pools \u003d False"},{"line_number":190,"context_line":"        if allocation_pool_id:"},{"line_number":191,"context_line":"            av_ranges \u003d self.subnet_manager.list_ranges_by_allocation_pool("},{"line_number":192,"context_line":"                session, allocation_pool_id)"},{"line_number":193,"context_line":"        else:"},{"line_number":194,"context_line":"            av_ranges \u003d self.subnet_manager.list_ranges_by_subnet_id(session)"}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_01eaf273","line":191,"in_reply_to":"1a122d0e_82f4cd87","updated":"2016-04-27 09:55:46.000000000","message":"Yes, you don\u0027t need av_ranges (availability ranges) any more because generating ip address no longer relies on them.\nLooking deeper into it it looks like this entire method _allocate_specific_ip is not needed. Because all you need for specific ip case is just save ip in IpamAllocation and except/retry if ip is concurently allocated.\nAnd storing happends in self.subnet_manager.create_allocation.\nBut looks like create_allocation has to be reworked a bit to handle correctly concurent allocation, because now this is the point where synchronization happens.","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":13667,"name":"ZongKai LI","email":"onionpiece@163.com","username":"lzklibj"},"change_message_id":"3cbf2d5b8d924478912eb99f8ffad09ebd9052d2","unresolved":false,"context_lines":[{"line_number":316,"context_line":"                continue"},{"line_number":317,"context_line":""},{"line_number":318,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":319,"context_line":"            window \u003d min(av_set.size, 10)"},{"line_number":320,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":321,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":322,"context_line":"            allocated_ip \u003d candidate_ips[-1]"},{"line_number":323,"context_line":"            return str(allocated_ip), ip_pool.id"},{"line_number":324,"context_line":""},{"line_number":325,"context_line":"        raise ipam_exc.IpAddressGenerationFailure("}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_318297c8","line":322,"range":{"start_line":319,"start_character":12,"end_line":322,"end_character":43},"updated":"2016-04-21 03:00:33.000000000","message":"ditto","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"9a1548abd3249b163879dd0971751a22f87efcd6","unresolved":false,"context_lines":[{"line_number":316,"context_line":"                continue"},{"line_number":317,"context_line":""},{"line_number":318,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":319,"context_line":"            window \u003d min(av_set.size, 10)"},{"line_number":320,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":321,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":322,"context_line":"            allocated_ip \u003d candidate_ips[-1]"},{"line_number":323,"context_line":"            return str(allocated_ip), ip_pool.id"},{"line_number":324,"context_line":""},{"line_number":325,"context_line":"        raise ipam_exc.IpAddressGenerationFailure("}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_7a24bbc5","line":322,"range":{"start_line":319,"start_character":12,"end_line":322,"end_character":43},"in_reply_to":"1a122d0e_318297c8","updated":"2016-04-21 18:48:58.000000000","message":"Done","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"06acb0d1dc01f41d825984ee2b3c6a55832fbe35","unresolved":false,"context_lines":[{"line_number":316,"context_line":"                continue"},{"line_number":317,"context_line":""},{"line_number":318,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":319,"context_line":"            window \u003d min(av_set.size, 10)"},{"line_number":320,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":321,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":322,"context_line":"            allocated_ip \u003d candidate_ips[-1]"},{"line_number":323,"context_line":"            return str(allocated_ip), ip_pool.id"},{"line_number":324,"context_line":""},{"line_number":325,"context_line":"        raise ipam_exc.IpAddressGenerationFailure("}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_ee9e5062","line":322,"range":{"start_line":319,"start_character":12,"end_line":322,"end_character":43},"in_reply_to":"1a122d0e_7a24bbc5","updated":"2016-04-21 18:59:08.000000000","message":"Oops, misunderstood this to be a comment about something else. Can you explain further?","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"a2b82f284d71f12c3a54627531c28feb11ec2f0b","unresolved":false,"context_lines":[{"line_number":316,"context_line":"                continue"},{"line_number":317,"context_line":""},{"line_number":318,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":319,"context_line":"            window \u003d min(av_set.size, 10)"},{"line_number":320,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":321,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":322,"context_line":"            allocated_ip \u003d candidate_ips[-1]"},{"line_number":323,"context_line":"            return str(allocated_ip), ip_pool.id"},{"line_number":324,"context_line":""},{"line_number":325,"context_line":"        raise ipam_exc.IpAddressGenerationFailure("}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_f601f5b0","line":322,"range":{"start_line":319,"start_character":12,"end_line":322,"end_character":43},"in_reply_to":"1a122d0e_ee9e5062","updated":"2016-05-02 22:30:57.000000000","message":"You might consider extracting it out in to a helper method for clarify and reuse between the two drivers.","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"075f3460d7960cf380735007203dab11b5e2ae2b","unresolved":false,"context_lines":[{"line_number":316,"context_line":"                continue"},{"line_number":317,"context_line":""},{"line_number":318,"context_line":"            # Compute a value for the selection window based on size of av_set"},{"line_number":319,"context_line":"            window \u003d min(av_set.size, 10)"},{"line_number":320,"context_line":"            ip_index \u003d random.randint(1, window)"},{"line_number":321,"context_line":"            candidate_ips \u003d list(itertools.islice(av_set, ip_index))"},{"line_number":322,"context_line":"            allocated_ip \u003d candidate_ips[-1]"},{"line_number":323,"context_line":"            return str(allocated_ip), ip_pool.id"},{"line_number":324,"context_line":""},{"line_number":325,"context_line":"        raise ipam_exc.IpAddressGenerationFailure("}],"source_content_type":"text/x-python","patch_set":14,"id":"1a122d0e_d91b4ac9","line":322,"range":{"start_line":319,"start_character":12,"end_line":322,"end_character":43},"in_reply_to":"1a122d0e_f601f5b0","updated":"2016-05-02 23:23:00.000000000","message":"I\u0027ll look into this a little more","commit_id":"55d87177d08f5ac17ae469f225fe6e02cc78cef5"},{"author":{"_account_id":1653,"name":"garyk","email":"gkotton@vmware.com","username":"garyk"},"change_message_id":"71f521802019cc25002465766d14b178b5ef9654","unresolved":false,"context_lines":[{"line_number":13,"context_line":"#    License for the specific language governing permissions and limitations"},{"line_number":14,"context_line":"#    under the License."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"import itertools"},{"line_number":17,"context_line":"import netaddr"},{"line_number":18,"context_line":"from neutron_lib import exceptions as n_exc"},{"line_number":19,"context_line":"from oslo_log import log"}],"source_content_type":"text/x-python","patch_set":17,"id":"1a122d0e_e25b9320","line":16,"updated":"2016-05-04 23:38:51.000000000","message":"itertools and random should be in their own section","commit_id":"466260f2dea0d30b147ef391fe94fb968c1b818a"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"8957d6293d190fa3933d4a990a6c75d62798b6f3","unresolved":false,"context_lines":[{"line_number":13,"context_line":"#    License for the specific language governing permissions and limitations"},{"line_number":14,"context_line":"#    under the License."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"import itertools"},{"line_number":17,"context_line":"import netaddr"},{"line_number":18,"context_line":"from neutron_lib import exceptions as n_exc"},{"line_number":19,"context_line":"from oslo_log import log"}],"source_content_type":"text/x-python","patch_set":17,"id":"1a122d0e_62278363","line":16,"in_reply_to":"1a122d0e_e25b9320","updated":"2016-05-04 23:46:18.000000000","message":"Done","commit_id":"466260f2dea0d30b147ef391fe94fb968c1b818a"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"ff8ac7f574e4fa6bc2ab289d095980f7003eada6","unresolved":false,"context_lines":[{"line_number":208,"context_line":"                session.add(av_range)"},{"line_number":209,"context_line":""},{"line_number":210,"context_line":"    def _generate_ip(self, session):"},{"line_number":211,"context_line":"        \"\"\"Generate an IP address from availability ranges.\"\"\""},{"line_number":212,"context_line":"        ip_allocations \u003d netaddr.IPSet()"},{"line_number":213,"context_line":"        for ipallocation in self.subnet_manager.list_allocations(session):"},{"line_number":214,"context_line":"            ip_allocations.add(netaddr.IPAddress(ipallocation.ip_address))"}],"source_content_type":"text/x-python","patch_set":23,"id":"9abb7d3a_c92c8c04","line":211,"range":{"start_line":211,"start_character":11,"end_line":211,"end_character":58},"updated":"2016-05-31 22:48:27.000000000","message":"This comment is no longer accurate.","commit_id":"c9f8ac35f834754235eae09d709ae2b3d9ecf77b"}],"neutron/tests/functional/db/test_ipam.py":[{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"b8429c7ef119b8d90ee3ae0c36dbb18136dbe1c0","unresolved":false,"context_lines":[{"line_number":161,"context_line":"            ip_avail_ranges_expected)"},{"line_number":162,"context_line":""},{"line_number":163,"context_line":"#    NOTE(tidwellr): the name of this test seems dubious given that we want"},{"line_number":164,"context_line":"#    to make it so the IP allocation strategy is pluggable. Remove?"},{"line_number":165,"context_line":"#    def test_allocate_first_available_ip(self):"},{"line_number":166,"context_line":"#        self._create_port(self.port_id)"},{"line_number":167,"context_line":"#        ip_alloc_expected \u003d [{\u0027port_id\u0027: self.port_id,"}],"source_content_type":"text/x-python","patch_set":12,"id":"5a18252c_6afa8476","line":164,"range":{"start_line":164,"start_character":60,"end_line":164,"end_character":66},"updated":"2016-04-14 21:48:33.000000000","message":"Yes.","commit_id":"eb87dbfbecfe4ffa9ae12930baef1f8ce401ab5c"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"dfd73404002b56388ec2e1667bf24376a765b11f","unresolved":false,"context_lines":[{"line_number":161,"context_line":"            ip_avail_ranges_expected)"},{"line_number":162,"context_line":""},{"line_number":163,"context_line":"#    NOTE(tidwellr): the name of this test seems dubious given that we want"},{"line_number":164,"context_line":"#    to make it so the IP allocation strategy is pluggable. Remove?"},{"line_number":165,"context_line":"#    def test_allocate_first_available_ip(self):"},{"line_number":166,"context_line":"#        self._create_port(self.port_id)"},{"line_number":167,"context_line":"#        ip_alloc_expected \u003d [{\u0027port_id\u0027: self.port_id,"}],"source_content_type":"text/x-python","patch_set":12,"id":"5a18252c_ca9bd816","line":164,"range":{"start_line":164,"start_character":60,"end_line":164,"end_character":66},"in_reply_to":"5a18252c_6afa8476","updated":"2016-04-14 21:55:41.000000000","message":"Done","commit_id":"eb87dbfbecfe4ffa9ae12930baef1f8ce401ab5c"}],"neutron/tests/unit/db/test_ipam_non_pluggable_backend.py":[{"author":{"_account_id":1653,"name":"garyk","email":"gkotton@vmware.com","username":"garyk"},"change_message_id":"9e3e031d00f3a067efbfc3584617edaa24ac94f8","unresolved":false,"context_lines":[{"line_number":29,"context_line":"class TestIpamNonPluggableBackend(base.BaseTestCase):"},{"line_number":30,"context_line":"    \"\"\"Unit Tests for non pluggable IPAM Logic.\"\"\""},{"line_number":31,"context_line":""},{"line_number":32,"context_line":"# NOTE(tidwellr): What is the value of these 2 tests?"},{"line_number":33,"context_line":""},{"line_number":34,"context_line":"#    def test_generate_ip(self):"},{"line_number":35,"context_line":"#        with mock.patch.object(non_ipam.IpamNonPluggableBackend,"}],"source_content_type":"text/x-python","patch_set":4,"id":"9a061dce_fe75c297","line":32,"updated":"2016-04-07 06:14:55.000000000","message":"either leave them or blow them away. as far as i understand they are around to check the values passed to the method","commit_id":"dacabefd6d7bc41c7d25e4e409b4b35166d5238f"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"2948b12f236caa1b78168f61dfada3c2ec6e7a1a","unresolved":false,"context_lines":[{"line_number":29,"context_line":"class TestIpamNonPluggableBackend(base.BaseTestCase):"},{"line_number":30,"context_line":"    \"\"\"Unit Tests for non pluggable IPAM Logic.\"\"\""},{"line_number":31,"context_line":""},{"line_number":32,"context_line":"# NOTE(tidwellr): What is the value of these 2 tests?"},{"line_number":33,"context_line":""},{"line_number":34,"context_line":"#    def test_generate_ip(self):"},{"line_number":35,"context_line":"#        with mock.patch.object(non_ipam.IpamNonPluggableBackend,"}],"source_content_type":"text/x-python","patch_set":4,"id":"9a061dce_b47507cc","line":32,"in_reply_to":"9a061dce_fe75c297","updated":"2016-04-07 16:05:49.000000000","message":"I\u0027ll find a way to patch these up so they pass, there is probably some value in them.","commit_id":"dacabefd6d7bc41c7d25e4e409b4b35166d5238f"}]}
