)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"620730bdca9c9b4fb1ad23ccaf86792e2744e733","unresolved":false,"context_lines":[{"line_number":27,"context_line":"code which leverages the cache to instead use the refresh_vif_id"},{"line_number":28,"context_line":"kwarg so that we do targeted cache updates when we do things like"},{"line_number":29,"context_line":"attach and detach ports, but that\u0027s a change for another day."},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"Change-Id: I629415236b2447128ae9a980d4ebe730a082c461"},{"line_number":32,"context_line":"Closes-Bug: #1751923"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"3f79a3b5_6b3ebee3","line":30,"updated":"2018-10-29 13:54:20.000000000","message":"@Maciej: you should mention the port order changes in the commit message as well, and add yourself as co-author using the Co-Authored-By tag.","commit_id":"3689c675df4f5ee7eb1dd297a5a579545a5b974e"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"a09247c6adeff1067ca9d68b72a188bd62bec71e","unresolved":false,"context_lines":[{"line_number":27,"context_line":"code which leverages the cache to instead use the refresh_vif_id"},{"line_number":28,"context_line":"kwarg so that we do targeted cache updates when we do things like"},{"line_number":29,"context_line":"attach and detach ports, but that\u0027s a change for another day."},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"Change-Id: I629415236b2447128ae9a980d4ebe730a082c461"},{"line_number":32,"context_line":"Closes-Bug: #1751923"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"3f79a3b5_eb516e32","line":30,"in_reply_to":"3f79a3b5_6b3ebee3","updated":"2018-10-29 13:55:05.000000000","message":"Yep, I\u0027ll update this.","commit_id":"3689c675df4f5ee7eb1dd297a5a579545a5b974e"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"3e57e00b8ab5780870f24eeab32e616836967acb","unresolved":false,"context_lines":[{"line_number":35,"context_line":"kwarg so that we do targeted cache updates when we do things like"},{"line_number":36,"context_line":"attach and detach ports, but that\u0027s a change for another day."},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"[1] https://review.openstack.org/#/c/614167"},{"line_number":39,"context_line":""},{"line_number":40,"context_line":"Co-Authored-By: Maciej Jozefczyk \u003cmaciej.jozefczyk@corp.ovh.com\u003e"},{"line_number":41,"context_line":"Change-Id: I629415236b2447128ae9a980d4ebe730a082c461"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":13,"id":"1f769fc5_9ae0e4fc","line":38,"updated":"2019-01-02 18:44:57.000000000","message":"see comment on other patch. I agree with Melanie that the order these patches are in is reversed.","commit_id":"35505c09dee5a3490411a37f9790d96e3a3acbbf"}],"nova/network/neutronv2/api.py":[{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"88dd1cfe0d30737d9ce3dccf697aa7416d18094f","unresolved":false,"context_lines":[{"line_number":1634,"context_line":"        # Otherwise multiple requests could collide and cause cache"},{"line_number":1635,"context_line":"        # corruption."},{"line_number":1636,"context_line":"        compute_utils.refresh_info_cache_for_instance(context, instance)"},{"line_number":1637,"context_line":"        force_refresh \u003d kwargs.get(\u0027force_refresh\u0027, False)"},{"line_number":1638,"context_line":"        nw_info \u003d self._build_network_info_model(context, instance, networks,"},{"line_number":1639,"context_line":"                                                 port_ids, admin_client,"},{"line_number":1640,"context_line":"                                                 preexisting_port_ids,"}],"source_content_type":"text/x-python","patch_set":3,"id":"3f79a3b5_5d3aebe5","line":1637,"updated":"2018-09-18 13:12:15.000000000","message":"Nit: not sure why this isn\u0027t a top level kwarg here, like the other params, but not going to block on it.","commit_id":"9c1d265fea2063b17df8032cf47c5a0f34829082"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"ec611c55a7a3c01dd7dff838ee77e58579bee80f","unresolved":false,"context_lines":[{"line_number":2850,"context_line":"        # TODO(mriedem); we should leverage refresh_vif_id in the latter case"},{"line_number":2851,"context_line":"        # since we are unnecessarily rebuilding the entire cache for one port"},{"line_number":2852,"context_line":"        nw_info_refresh \u003d networks is None and port_ids is None"},{"line_number":2853,"context_line":"        if nw_info_refresh and force_refresh:"},{"line_number":2854,"context_line":"            # Use the current set of ports from neutron rather than the cache."},{"line_number":2855,"context_line":"            port_ids \u003d []"},{"line_number":2856,"context_line":"            net_ids \u003d []"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_7a044a13","line":2853,"updated":"2018-10-29 09:54:34.000000000","message":"I would add second `if` here to check if num(virtual_interfaces) \u003d\u003d num(neutron_ports). Then we could base on that. Without it, maybe log WARNING and do not touch / rollback to previous workflow?","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"291025977f1b7ed5b4d187abcef8c6ddba960641","unresolved":false,"context_lines":[{"line_number":2855,"context_line":"            port_ids \u003d []"},{"line_number":2856,"context_line":"            net_ids \u003d []"},{"line_number":2857,"context_line":""},{"line_number":2858,"context_line":"            port_order_map \u003d self._get_port_order_map(context, instance,"},{"line_number":2859,"context_line":"                                                      current_neutron_ports)"},{"line_number":2860,"context_line":"            port_ids \u003d [port[0] for port in port_order_map]"},{"line_number":2861,"context_line":"            net_ids \u003d [current_neutron_port_map.get(port[0]).get(\u0027network_id\u0027)"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_8f0b5bd2","line":2858,"range":{"start_line":2858,"start_character":12,"end_line":2858,"end_character":26},"updated":"2018-10-25 14:51:55.000000000","message":"As I see you use only first element of each tuple. Why not to return list of those first elements, not list of tuples?","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"70c344c8113b4d4306782f739b76b54be75d95c9","unresolved":false,"context_lines":[{"line_number":2855,"context_line":"            port_ids \u003d []"},{"line_number":2856,"context_line":"            net_ids \u003d []"},{"line_number":2857,"context_line":""},{"line_number":2858,"context_line":"            port_order_map \u003d self._get_port_order_map(context, instance,"},{"line_number":2859,"context_line":"                                                      current_neutron_ports)"},{"line_number":2860,"context_line":"            port_ids \u003d [port[0] for port in port_order_map]"},{"line_number":2861,"context_line":"            net_ids \u003d [current_neutron_port_map.get(port[0]).get(\u0027network_id\u0027)"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_9bbe88cc","line":2858,"range":{"start_line":2858,"start_character":12,"end_line":2858,"end_character":26},"in_reply_to":"3f79a3b5_8f0b5bd2","updated":"2018-11-05 08:19:03.000000000","message":"In PS7 it seems to be fixed, awesome :)","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"291025977f1b7ed5b4d187abcef8c6ddba960641","unresolved":false,"context_lines":[{"line_number":2859,"context_line":"                                                      current_neutron_ports)"},{"line_number":2860,"context_line":"            port_ids \u003d [port[0] for port in port_order_map]"},{"line_number":2861,"context_line":"            net_ids \u003d [current_neutron_port_map.get(port[0]).get(\u0027network_id\u0027)"},{"line_number":2862,"context_line":"                       for port in port_order_map]"},{"line_number":2863,"context_line":""},{"line_number":2864,"context_line":"            # This is copied from _gather_port_ids_and_networks."},{"line_number":2865,"context_line":"            networks \u003d self._get_available_networks("}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_0f62eba7","line":2862,"range":{"start_line":2862,"start_character":23,"end_line":2862,"end_character":49},"updated":"2018-10-25 14:51:55.000000000","message":"You may use here for port_id in port_ids.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"361079664631222e88639db212c48c4a41b1306c","unresolved":false,"context_lines":[{"line_number":2859,"context_line":"                                                      current_neutron_ports)"},{"line_number":2860,"context_line":"            port_ids \u003d [port[0] for port in port_order_map]"},{"line_number":2861,"context_line":"            net_ids \u003d [current_neutron_port_map.get(port[0]).get(\u0027network_id\u0027)"},{"line_number":2862,"context_line":"                       for port in port_order_map]"},{"line_number":2863,"context_line":""},{"line_number":2864,"context_line":"            # This is copied from _gather_port_ids_and_networks."},{"line_number":2865,"context_line":"            networks \u003d self._get_available_networks("}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_25f1d864","line":2862,"range":{"start_line":2862,"start_character":23,"end_line":2862,"end_character":49},"in_reply_to":"3f79a3b5_0f62eba7","updated":"2018-10-29 08:41:22.000000000","message":"yep, right","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"291025977f1b7ed5b4d187abcef8c6ddba960641","unresolved":false,"context_lines":[{"line_number":2889,"context_line":"    def _get_port_order_map(self, context, instance, current_neutron_ports):"},{"line_number":2890,"context_line":"        \"\"\"Returns ordered port list from nova historical data.\"\"\""},{"line_number":2891,"context_line":""},{"line_number":2892,"context_line":"        port_order_map \u003d {}"},{"line_number":2893,"context_line":"        # Get set of ports from nova vifs"},{"line_number":2894,"context_line":"        vifs \u003d self.get_vifs_by_instance(context, instance)"},{"line_number":2895,"context_line":"        for port in current_neutron_ports:"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_efaf6fde","line":2892,"range":{"start_line":2892,"start_character":8,"end_line":2892,"end_character":27},"updated":"2018-10-25 14:51:55.000000000","message":"I am wondering if it would be better to use list/array here and put into list/array with valid index. As a result sort-in-place will happen.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"ae2f3651358666a6a4e208aee4dca564c4388066","unresolved":false,"context_lines":[{"line_number":2889,"context_line":"    def _get_port_order_map(self, context, instance, current_neutron_ports):"},{"line_number":2890,"context_line":"        \"\"\"Returns ordered port list from nova historical data.\"\"\""},{"line_number":2891,"context_line":""},{"line_number":2892,"context_line":"        port_order_map \u003d {}"},{"line_number":2893,"context_line":"        # Get set of ports from nova vifs"},{"line_number":2894,"context_line":"        vifs \u003d self.get_vifs_by_instance(context, instance)"},{"line_number":2895,"context_line":"        for port in current_neutron_ports:"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_d751b732","line":2892,"range":{"start_line":2892,"start_character":8,"end_line":2892,"end_character":27},"in_reply_to":"3f79a3b5_4573b4e8","updated":"2018-10-29 09:47:57.000000000","message":"Or we can add second list with elements without indexes and merge those after sorting.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"70c344c8113b4d4306782f739b76b54be75d95c9","unresolved":false,"context_lines":[{"line_number":2889,"context_line":"    def _get_port_order_map(self, context, instance, current_neutron_ports):"},{"line_number":2890,"context_line":"        \"\"\"Returns ordered port list from nova historical data.\"\"\""},{"line_number":2891,"context_line":""},{"line_number":2892,"context_line":"        port_order_map \u003d {}"},{"line_number":2893,"context_line":"        # Get set of ports from nova vifs"},{"line_number":2894,"context_line":"        vifs \u003d self.get_vifs_by_instance(context, instance)"},{"line_number":2895,"context_line":"        for port in current_neutron_ports:"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_bb1b441b","line":2892,"range":{"start_line":2892,"start_character":8,"end_line":2892,"end_character":27},"in_reply_to":"3f79a3b5_d751b732","updated":"2018-11-05 08:19:03.000000000","message":"Let stay with dict.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"361079664631222e88639db212c48c4a41b1306c","unresolved":false,"context_lines":[{"line_number":2889,"context_line":"    def _get_port_order_map(self, context, instance, current_neutron_ports):"},{"line_number":2890,"context_line":"        \"\"\"Returns ordered port list from nova historical data.\"\"\""},{"line_number":2891,"context_line":""},{"line_number":2892,"context_line":"        port_order_map \u003d {}"},{"line_number":2893,"context_line":"        # Get set of ports from nova vifs"},{"line_number":2894,"context_line":"        vifs \u003d self.get_vifs_by_instance(context, instance)"},{"line_number":2895,"context_line":"        for port in current_neutron_ports:"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_4573b4e8","line":2892,"range":{"start_line":2892,"start_character":8,"end_line":2892,"end_character":27},"in_reply_to":"3f79a3b5_efaf6fde","updated":"2018-10-29 08:41:22.000000000","message":"Sort-in-place with valid index? I\u0027ll need to create a list with None elements. So I used dict instead.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"25f7592129a59606d02781382b88b100ebed8dba","unresolved":false,"context_lines":[{"line_number":2894,"context_line":"        vifs \u003d self.get_vifs_by_instance(context, instance)"},{"line_number":2895,"context_line":"        for port in current_neutron_ports:"},{"line_number":2896,"context_line":"            # NOTE(mjozefcz): For each port check if we have its index from"},{"line_number":2897,"context_line":"            # nova virtual_interfaces objects. If not - it seems"},{"line_number":2898,"context_line":"            # to be a new port - add it at the end of list."},{"line_number":2899,"context_line":""},{"line_number":2900,"context_line":"            # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2901,"context_line":"            port_order_map[port.get(\u0027id\u0027)] \u003d 9999"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_84efbd1a","line":2898,"range":{"start_line":2897,"start_character":47,"end_line":2898,"end_character":31},"updated":"2018-10-25 15:46:15.000000000","message":"It could also be a server created before newton and change I8367f740d6d4ebaeb81bc74c6a82a8faf5cd8308 which started creating virtual_interfaces table entries for ports.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":9373,"name":"Vlad Gusev","email":"vlad.esten@gmail.com","username":"s10"},"change_message_id":"8f94e1ef1887fbce8a6454aed275538d91a050b4","unresolved":false,"context_lines":[{"line_number":2894,"context_line":"        vifs \u003d self.get_vifs_by_instance(context, instance)"},{"line_number":2895,"context_line":"        for port in current_neutron_ports:"},{"line_number":2896,"context_line":"            # NOTE(mjozefcz): For each port check if we have its index from"},{"line_number":2897,"context_line":"            # nova virtual_interfaces objects. If not - it seems"},{"line_number":2898,"context_line":"            # to be a new port - add it at the end of list."},{"line_number":2899,"context_line":""},{"line_number":2900,"context_line":"            # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2901,"context_line":"            port_order_map[port.get(\u0027id\u0027)] \u003d 9999"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_f785d3ab","line":2898,"range":{"start_line":2897,"start_character":47,"end_line":2898,"end_character":31},"in_reply_to":"3f79a3b5_05529c36","updated":"2018-10-29 09:43:18.000000000","message":"Can this migration script use information from current instance_info_caches? If instance_info_caches is not damaged, it could be a reliable source of the information about an interface order.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"1354a456ad16d80b7f26e14f11c7813eae67d9e7","unresolved":false,"context_lines":[{"line_number":2894,"context_line":"        vifs \u003d self.get_vifs_by_instance(context, instance)"},{"line_number":2895,"context_line":"        for port in current_neutron_ports:"},{"line_number":2896,"context_line":"            # NOTE(mjozefcz): For each port check if we have its index from"},{"line_number":2897,"context_line":"            # nova virtual_interfaces objects. If not - it seems"},{"line_number":2898,"context_line":"            # to be a new port - add it at the end of list."},{"line_number":2899,"context_line":""},{"line_number":2900,"context_line":"            # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2901,"context_line":"            port_order_map[port.get(\u0027id\u0027)] \u003d 9999"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_8b579a59","line":2898,"range":{"start_line":2897,"start_character":47,"end_line":2898,"end_character":31},"in_reply_to":"3f79a3b5_170acf25","updated":"2018-10-29 13:47:30.000000000","message":"\u003e This order based on `id` sequence could not be consistent. We should first check if every port from instance_info_caches is inside virtual_interfaces, and if not - mark every instance virtual_interface as deleted and add again every virtual_interface object with proper order.\n\nThe problem you\u0027d have with this is the vif tag is not stored in the info_cache, so if you delete virtual interface records which had user-requested tags on them, and then rebuild from the info cache, you lose the user requested tags.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"361079664631222e88639db212c48c4a41b1306c","unresolved":false,"context_lines":[{"line_number":2894,"context_line":"        vifs \u003d self.get_vifs_by_instance(context, instance)"},{"line_number":2895,"context_line":"        for port in current_neutron_ports:"},{"line_number":2896,"context_line":"            # NOTE(mjozefcz): For each port check if we have its index from"},{"line_number":2897,"context_line":"            # nova virtual_interfaces objects. If not - it seems"},{"line_number":2898,"context_line":"            # to be a new port - add it at the end of list."},{"line_number":2899,"context_line":""},{"line_number":2900,"context_line":"            # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2901,"context_line":"            port_order_map[port.get(\u0027id\u0027)] \u003d 9999"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_05529c36","line":2898,"range":{"start_line":2897,"start_character":47,"end_line":2898,"end_character":31},"in_reply_to":"3f79a3b5_84efbd1a","updated":"2018-10-29 08:41:22.000000000","message":"And thats the real issue.\nWe could create a migration script that will fill that table, but we couldn\u0027t rely on `id` sequence then...\n\nMaybe we could check how many ports we have in virtual_interfaces and compare it from number of neutron ports? But while adding new ones it could ends bad.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"9d908ebcad2ef52d1de777d2f79e8ebf96f1b191","unresolved":false,"context_lines":[{"line_number":2894,"context_line":"        vifs \u003d self.get_vifs_by_instance(context, instance)"},{"line_number":2895,"context_line":"        for port in current_neutron_ports:"},{"line_number":2896,"context_line":"            # NOTE(mjozefcz): For each port check if we have its index from"},{"line_number":2897,"context_line":"            # nova virtual_interfaces objects. If not - it seems"},{"line_number":2898,"context_line":"            # to be a new port - add it at the end of list."},{"line_number":2899,"context_line":""},{"line_number":2900,"context_line":"            # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2901,"context_line":"            port_order_map[port.get(\u0027id\u0027)] \u003d 9999"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_cbefd283","line":2898,"range":{"start_line":2897,"start_character":47,"end_line":2898,"end_character":31},"in_reply_to":"3f79a3b5_8b579a59","updated":"2018-10-29 13:48:54.000000000","message":"\u003e The problem you\u0027d have with this is the vif tag is not stored in the info_cache, so if you delete virtual interface records which had user-requested tags on them, and then rebuild from the info cache, you lose the user requested tags.\n\nI guess you could keep track of which vifs had tags and if you recreate those records then just re-apply the tags.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"5602d8c50c49d7090c0b5e55924f089c84b8aa58","unresolved":false,"context_lines":[{"line_number":2894,"context_line":"        vifs \u003d self.get_vifs_by_instance(context, instance)"},{"line_number":2895,"context_line":"        for port in current_neutron_ports:"},{"line_number":2896,"context_line":"            # NOTE(mjozefcz): For each port check if we have its index from"},{"line_number":2897,"context_line":"            # nova virtual_interfaces objects. If not - it seems"},{"line_number":2898,"context_line":"            # to be a new port - add it at the end of list."},{"line_number":2899,"context_line":""},{"line_number":2900,"context_line":"            # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2901,"context_line":"            port_order_map[port.get(\u0027id\u0027)] \u003d 9999"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_8b9a3a0f","line":2898,"range":{"start_line":2897,"start_character":47,"end_line":2898,"end_character":31},"in_reply_to":"3f79a3b5_cbefd283","updated":"2018-10-29 13:50:57.000000000","message":"Yes, I\u0027ll keep that and re-apply tags after.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"ec611c55a7a3c01dd7dff838ee77e58579bee80f","unresolved":false,"context_lines":[{"line_number":2894,"context_line":"        vifs \u003d self.get_vifs_by_instance(context, instance)"},{"line_number":2895,"context_line":"        for port in current_neutron_ports:"},{"line_number":2896,"context_line":"            # NOTE(mjozefcz): For each port check if we have its index from"},{"line_number":2897,"context_line":"            # nova virtual_interfaces objects. If not - it seems"},{"line_number":2898,"context_line":"            # to be a new port - add it at the end of list."},{"line_number":2899,"context_line":""},{"line_number":2900,"context_line":"            # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2901,"context_line":"            port_order_map[port.get(\u0027id\u0027)] \u003d 9999"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_170acf25","line":2898,"range":{"start_line":2897,"start_character":47,"end_line":2898,"end_character":31},"in_reply_to":"3f79a3b5_f785d3ab","updated":"2018-10-29 09:54:34.000000000","message":"Yes It can. The only thing is what we gonna do with instances that don\u0027t have every port saved in virtual_interfaces (instances older than Newton and port-attached after Newton upgrade). \n\nThis order based on `id` sequence could not be consistent. We should first check if every port from instance_info_caches is inside virtual_interfaces, and if not - mark every instance virtual_interface as deleted and add again every virtual_interface object with proper order.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"291025977f1b7ed5b4d187abcef8c6ddba960641","unresolved":false,"context_lines":[{"line_number":2898,"context_line":"            # to be a new port - add it at the end of list."},{"line_number":2899,"context_line":""},{"line_number":2900,"context_line":"            # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2901,"context_line":"            port_order_map[port.get(\u0027id\u0027)] \u003d 9999"},{"line_number":2902,"context_line":""},{"line_number":2903,"context_line":"            # Find port index if it was attached before."},{"line_number":2904,"context_line":"            for vif in vifs:"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_2f46c723","line":2901,"range":{"start_line":2901,"start_character":45,"end_line":2901,"end_character":49},"updated":"2018-10-25 14:51:55.000000000","message":"I would not rely on big enough numbers. How about using list and putting into list in correct places (sort-in-place)?\n\nAlso what will happen if two ports with different IDs will have 9999?","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"70c344c8113b4d4306782f739b76b54be75d95c9","unresolved":false,"context_lines":[{"line_number":2898,"context_line":"            # to be a new port - add it at the end of list."},{"line_number":2899,"context_line":""},{"line_number":2900,"context_line":"            # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2901,"context_line":"            port_order_map[port.get(\u0027id\u0027)] \u003d 9999"},{"line_number":2902,"context_line":""},{"line_number":2903,"context_line":"            # Find port index if it was attached before."},{"line_number":2904,"context_line":"            for vif in vifs:"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_9b10c8f6","line":2901,"range":{"start_line":2901,"start_character":45,"end_line":2901,"end_character":49},"in_reply_to":"3f79a3b5_252238b8","updated":"2018-11-05 08:19:03.000000000","message":"I could see that you fixed it with port_order_list and ports_without_order. Perfect!","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"361079664631222e88639db212c48c4a41b1306c","unresolved":false,"context_lines":[{"line_number":2898,"context_line":"            # to be a new port - add it at the end of list."},{"line_number":2899,"context_line":""},{"line_number":2900,"context_line":"            # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2901,"context_line":"            port_order_map[port.get(\u0027id\u0027)] \u003d 9999"},{"line_number":2902,"context_line":""},{"line_number":2903,"context_line":"            # Find port index if it was attached before."},{"line_number":2904,"context_line":"            for vif in vifs:"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_252238b8","line":2901,"range":{"start_line":2901,"start_character":45,"end_line":2901,"end_character":49},"in_reply_to":"3f79a3b5_2f46c723","updated":"2018-10-29 08:41:22.000000000","message":"Yes, thats the issue. How we could prevent this? The `id` sequence could be even more than 9999. I was thinking about setting `-1` for each missing port and after sorting the dict move it to the end. But we could miss the order of those ports that comes from neutron-api (maybe its needed?).\n\nUsing spare-list could be an option for that.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"291025977f1b7ed5b4d187abcef8c6ddba960641","unresolved":false,"context_lines":[{"line_number":2902,"context_line":""},{"line_number":2903,"context_line":"            # Find port index if it was attached before."},{"line_number":2904,"context_line":"            for vif in vifs:"},{"line_number":2905,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2906,"context_line":"                    port_order_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2907,"context_line":""},{"line_number":2908,"context_line":"        # Lets sort created port order_map by given index."}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_efdd2f6e","line":2905,"range":{"start_line":2905,"start_character":16,"end_line":2905,"end_character":45},"updated":"2018-10-25 14:51:55.000000000","message":"That could used as lambda condition for filter().","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"361079664631222e88639db212c48c4a41b1306c","unresolved":false,"context_lines":[{"line_number":2902,"context_line":""},{"line_number":2903,"context_line":"            # Find port index if it was attached before."},{"line_number":2904,"context_line":"            for vif in vifs:"},{"line_number":2905,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2906,"context_line":"                    port_order_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2907,"context_line":""},{"line_number":2908,"context_line":"        # Lets sort created port order_map by given index."}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_65a91023","line":2905,"range":{"start_line":2905,"start_character":16,"end_line":2905,"end_character":45},"in_reply_to":"3f79a3b5_efdd2f6e","updated":"2018-10-29 08:41:22.000000000","message":"Yes, also","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"291025977f1b7ed5b4d187abcef8c6ddba960641","unresolved":false,"context_lines":[{"line_number":2903,"context_line":"            # Find port index if it was attached before."},{"line_number":2904,"context_line":"            for vif in vifs:"},{"line_number":2905,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2906,"context_line":"                    port_order_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2907,"context_line":""},{"line_number":2908,"context_line":"        # Lets sort created port order_map by given index."},{"line_number":2909,"context_line":"        port_order_map \u003d sorted(port_order_map.items(),"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_cf6073a7","line":2906,"range":{"start_line":2906,"start_character":53,"end_line":2906,"end_character":59},"updated":"2018-10-25 14:51:55.000000000","message":"That seems to be index for putting into sorted list of ports. The only question is how to normalize those indexes to have not-sparse-list. That\u0027s why dict seems to be a good option.","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"70c344c8113b4d4306782f739b76b54be75d95c9","unresolved":false,"context_lines":[{"line_number":2903,"context_line":"            # Find port index if it was attached before."},{"line_number":2904,"context_line":"            for vif in vifs:"},{"line_number":2905,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2906,"context_line":"                    port_order_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2907,"context_line":""},{"line_number":2908,"context_line":"        # Lets sort created port order_map by given index."},{"line_number":2909,"context_line":"        port_order_map \u003d sorted(port_order_map.items(),"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_7b15ace5","line":2906,"range":{"start_line":2906,"start_character":53,"end_line":2906,"end_character":59},"in_reply_to":"3f79a3b5_259f98f6","updated":"2018-11-05 08:19:03.000000000","message":"Ok","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"361079664631222e88639db212c48c4a41b1306c","unresolved":false,"context_lines":[{"line_number":2903,"context_line":"            # Find port index if it was attached before."},{"line_number":2904,"context_line":"            for vif in vifs:"},{"line_number":2905,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2906,"context_line":"                    port_order_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2907,"context_line":""},{"line_number":2908,"context_line":"        # Lets sort created port order_map by given index."},{"line_number":2909,"context_line":"        port_order_map \u003d sorted(port_order_map.items(),"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_259f98f6","line":2906,"range":{"start_line":2906,"start_character":53,"end_line":2906,"end_character":59},"in_reply_to":"3f79a3b5_cf6073a7","updated":"2018-10-29 08:41:22.000000000","message":"Yes, right, thats why I sort dict by values","commit_id":"0df0d34d3b77457a3cf8e7b8afcd0a5f893cf1e4"},{"author":{"_account_id":13692,"name":"Roman Dobosz","email":"gryf73@gmail.com","username":"gryf"},"change_message_id":"b37aa5f76b1f283df9a3d953818e5ecc572ed59a","unresolved":false,"context_lines":[{"line_number":2910,"context_line":"                ports_without_order.append(port.get(\u0027id\u0027))"},{"line_number":2911,"context_line":""},{"line_number":2912,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2913,"context_line":"        port_order_list \u003d list(map(lambda x: x[0],"},{"line_number":2914,"context_line":"                                   sorted(port_order_map.items(),"},{"line_number":2915,"context_line":"                                          key\u003dlambda kv: kv[1])))"},{"line_number":2916,"context_line":""},{"line_number":2917,"context_line":"        # Add ports without order to the end of list"},{"line_number":2918,"context_line":"        port_order_list.extend(ports_without_order)"}],"source_content_type":"text/x-python","patch_set":6,"id":"3f79a3b5_b4498030","line":2915,"range":{"start_line":2913,"start_character":0,"end_line":2915,"end_character":65},"updated":"2018-10-30 12:50:10.000000000","message":"OMG It\u0027s a monster! Kill it with fire :D! How about list comprehension :D?\n\n    port_order_list \u003d [x[0] for x in\n                       sorted(port_order_map.items(),\n                              key\u003dlambda v: v[1])]","commit_id":"cfd07002ba679aec993cf67d5b604b21240c4142"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"0eca1e15a940ad75972238427f4ef203eb55814e","unresolved":false,"context_lines":[{"line_number":2910,"context_line":"                ports_without_order.append(port.get(\u0027id\u0027))"},{"line_number":2911,"context_line":""},{"line_number":2912,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2913,"context_line":"        port_order_list \u003d list(map(lambda x: x[0],"},{"line_number":2914,"context_line":"                                   sorted(port_order_map.items(),"},{"line_number":2915,"context_line":"                                          key\u003dlambda kv: kv[1])))"},{"line_number":2916,"context_line":""},{"line_number":2917,"context_line":"        # Add ports without order to the end of list"},{"line_number":2918,"context_line":"        port_order_list.extend(ports_without_order)"}],"source_content_type":"text/x-python","patch_set":6,"id":"3f79a3b5_52dc9f42","line":2915,"range":{"start_line":2913,"start_character":0,"end_line":2915,"end_character":65},"in_reply_to":"3f79a3b5_49e731ad","updated":"2018-10-31 14:41:28.000000000","message":"Thats perfect! Thanks!","commit_id":"cfd07002ba679aec993cf67d5b604b21240c4142"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"70c344c8113b4d4306782f739b76b54be75d95c9","unresolved":false,"context_lines":[{"line_number":2910,"context_line":"                ports_without_order.append(port.get(\u0027id\u0027))"},{"line_number":2911,"context_line":""},{"line_number":2912,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2913,"context_line":"        port_order_list \u003d list(map(lambda x: x[0],"},{"line_number":2914,"context_line":"                                   sorted(port_order_map.items(),"},{"line_number":2915,"context_line":"                                          key\u003dlambda kv: kv[1])))"},{"line_number":2916,"context_line":""},{"line_number":2917,"context_line":"        # Add ports without order to the end of list"},{"line_number":2918,"context_line":"        port_order_list.extend(ports_without_order)"}],"source_content_type":"text/x-python","patch_set":6,"id":"3f79a3b5_9be5280a","line":2915,"range":{"start_line":2913,"start_character":0,"end_line":2915,"end_character":65},"in_reply_to":"3f79a3b5_52dc9f42","updated":"2018-11-05 08:19:03.000000000","message":"Yeah, +2 for Eric!\n\nPs. list(map(sorted())) looks nice too ;)","commit_id":"cfd07002ba679aec993cf67d5b604b21240c4142"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"941c872a58eb3aeb4f91ce351cdc28e11127a1a3","unresolved":false,"context_lines":[{"line_number":2910,"context_line":"                ports_without_order.append(port.get(\u0027id\u0027))"},{"line_number":2911,"context_line":""},{"line_number":2912,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2913,"context_line":"        port_order_list \u003d list(map(lambda x: x[0],"},{"line_number":2914,"context_line":"                                   sorted(port_order_map.items(),"},{"line_number":2915,"context_line":"                                          key\u003dlambda kv: kv[1])))"},{"line_number":2916,"context_line":""},{"line_number":2917,"context_line":"        # Add ports without order to the end of list"},{"line_number":2918,"context_line":"        port_order_list.extend(ports_without_order)"}],"source_content_type":"text/x-python","patch_set":6,"id":"3f79a3b5_49e731ad","line":2915,"range":{"start_line":2913,"start_character":0,"end_line":2915,"end_character":65},"in_reply_to":"3f79a3b5_b4498030","updated":"2018-10-30 16:09:02.000000000","message":"or\n\n sorted(port_order_map, key\u003dlambda k: port_order_map[k])\n\n...which saves you at least one list walk and one in-memory copy of the dict data.","commit_id":"cfd07002ba679aec993cf67d5b604b21240c4142"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"70c344c8113b4d4306782f739b76b54be75d95c9","unresolved":false,"context_lines":[{"line_number":2901,"context_line":""},{"line_number":2902,"context_line":"            # Find port index if it was attached before."},{"line_number":2903,"context_line":"            for vif in vifs:"},{"line_number":2904,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2905,"context_line":"                    port_order_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2906,"context_line":"                    break"},{"line_number":2907,"context_line":""}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_1b96f83e","line":2904,"range":{"start_line":2904,"start_character":31,"end_line":2904,"end_character":45},"updated":"2018-11-05 08:19:03.000000000","message":"That is called three times in loop `for port in current_neutron_ports`. How about var port_id \u003d port.get(\u0027id\u0027) and using it in this line, L2905 and L2908?","commit_id":"c51d25658341c327aff3487ea475277b693edb6a"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"c2e83510444048b052b3fe0de1b96bea4d9980bb","unresolved":false,"context_lines":[{"line_number":2901,"context_line":""},{"line_number":2902,"context_line":"            # Find port index if it was attached before."},{"line_number":2903,"context_line":"            for vif in vifs:"},{"line_number":2904,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2905,"context_line":"                    port_order_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2906,"context_line":"                    break"},{"line_number":2907,"context_line":""}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_4c283197","line":2904,"range":{"start_line":2904,"start_character":31,"end_line":2904,"end_character":45},"in_reply_to":"3f79a3b5_1b96f83e","updated":"2018-11-05 15:50:12.000000000","message":"Its really that important :)?","commit_id":"c51d25658341c327aff3487ea475277b693edb6a"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"ad49ecb8ec0dd96227c98378a425a8e90b839e0a","unresolved":false,"context_lines":[{"line_number":2901,"context_line":""},{"line_number":2902,"context_line":"            # Find port index if it was attached before."},{"line_number":2903,"context_line":"            for vif in vifs:"},{"line_number":2904,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2905,"context_line":"                    port_order_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2906,"context_line":"                    break"},{"line_number":2907,"context_line":""}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_b2ab29d2","line":2904,"range":{"start_line":2904,"start_character":31,"end_line":2904,"end_character":45},"in_reply_to":"3f79a3b5_4c283197","updated":"2018-11-07 12:41:59.000000000","message":"I would do it, but no pressure :D","commit_id":"c51d25658341c327aff3487ea475277b693edb6a"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"70c344c8113b4d4306782f739b76b54be75d95c9","unresolved":false,"context_lines":[{"line_number":2903,"context_line":"            for vif in vifs:"},{"line_number":2904,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2905,"context_line":"                    port_order_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2906,"context_line":"                    break"},{"line_number":2907,"context_line":""},{"line_number":2908,"context_line":"            if port.get(\u0027id\u0027) not in port_order_map:"},{"line_number":2909,"context_line":"                # Assume that it\u0027s new port and add it to the end of port list."}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_db72c04b","line":2906,"range":{"start_line":2906,"start_character":20,"end_line":2906,"end_character":25},"updated":"2018-11-05 08:19:03.000000000","message":"Why is that break here? Comparing to PS4 it is new.\n\nIt will break only loop `for vif in vifs:` which means that order in vifs is important and first element from vifs will be taken into the account.","commit_id":"c51d25658341c327aff3487ea475277b693edb6a"},{"author":{"_account_id":25618,"name":"Paweł Suder","email":"pawel@suder.info","username":"SuderPawel"},"change_message_id":"ad49ecb8ec0dd96227c98378a425a8e90b839e0a","unresolved":false,"context_lines":[{"line_number":2903,"context_line":"            for vif in vifs:"},{"line_number":2904,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2905,"context_line":"                    port_order_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2906,"context_line":"                    break"},{"line_number":2907,"context_line":""},{"line_number":2908,"context_line":"            if port.get(\u0027id\u0027) not in port_order_map:"},{"line_number":2909,"context_line":"                # Assume that it\u0027s new port and add it to the end of port list."}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_f2a52102","line":2906,"range":{"start_line":2906,"start_character":20,"end_line":2906,"end_character":25},"in_reply_to":"3f79a3b5_0c2b199b","updated":"2018-11-07 12:41:59.000000000","message":"OK, got it!","commit_id":"c51d25658341c327aff3487ea475277b693edb6a"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"c2e83510444048b052b3fe0de1b96bea4d9980bb","unresolved":false,"context_lines":[{"line_number":2903,"context_line":"            for vif in vifs:"},{"line_number":2904,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2905,"context_line":"                    port_order_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2906,"context_line":"                    break"},{"line_number":2907,"context_line":""},{"line_number":2908,"context_line":"            if port.get(\u0027id\u0027) not in port_order_map:"},{"line_number":2909,"context_line":"                # Assume that it\u0027s new port and add it to the end of port list."}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_0c2b199b","line":2906,"range":{"start_line":2906,"start_character":20,"end_line":2906,"end_character":25},"in_reply_to":"3f79a3b5_db72c04b","updated":"2018-11-05 15:50:12.000000000","message":"Its intentional. There should be only one row, see virtual_interfaces table: \n\n UNIQUE KEY `uniq_virtual_interfaces0address0deleted` (`address`,`deleted`),\n\nand inside address there is stored \u0027mac/port_id\u0027. \n\nSo no way to have two interfaces with the same port_id and same mac. So after finding the first one I can break and not verify others.","commit_id":"c51d25658341c327aff3487ea475277b693edb6a"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"f1184ad47eb7f263d42c18b571918551dee65411","unresolved":false,"context_lines":[{"line_number":2910,"context_line":"                ports_without_order.append(port.get(\u0027id\u0027))"},{"line_number":2911,"context_line":""},{"line_number":2912,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2913,"context_line":"        port_order_list \u003d list(sorted(port_order_map,"},{"line_number":2914,"context_line":"                                      key\u003dlambda k: port_order_map[k]))"},{"line_number":2915,"context_line":""},{"line_number":2916,"context_line":"        # Add ports without order to the end of list"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_bb970feb","line":2913,"range":{"start_line":2913,"start_character":26,"end_line":2913,"end_character":30},"updated":"2018-10-31 16:00:49.000000000","message":"You don\u0027t need the list() (which is making another copy). sorted() already returns a list.","commit_id":"c51d25658341c327aff3487ea475277b693edb6a"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"c2e83510444048b052b3fe0de1b96bea4d9980bb","unresolved":false,"context_lines":[{"line_number":2910,"context_line":"                ports_without_order.append(port.get(\u0027id\u0027))"},{"line_number":2911,"context_line":""},{"line_number":2912,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2913,"context_line":"        port_order_list \u003d list(sorted(port_order_map,"},{"line_number":2914,"context_line":"                                      key\u003dlambda k: port_order_map[k]))"},{"line_number":2915,"context_line":""},{"line_number":2916,"context_line":"        # Add ports without order to the end of list"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_ac7d45c4","line":2913,"range":{"start_line":2913,"start_character":26,"end_line":2913,"end_character":30},"in_reply_to":"3f79a3b5_bb970feb","updated":"2018-11-05 15:50:12.000000000","message":"You\u0027re right. Thanks for catch.","commit_id":"c51d25658341c327aff3487ea475277b693edb6a"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"14359c2c2e2fb1110b7115d748dadf59ee0a8159","unresolved":false,"context_lines":[{"line_number":2354,"context_line":"        return port[\u0027device_id\u0027]"},{"line_number":2355,"context_line":""},{"line_number":2356,"context_line":"    def get_vifs_by_instance(self, context, instance):"},{"line_number":2357,"context_line":"        return objects.VirtualInterfaceList.get_by_instance_uuid(context,"},{"line_number":2358,"context_line":"                                                                 instance.uuid)"},{"line_number":2359,"context_line":""},{"line_number":2360,"context_line":"    def get_vif_by_mac_address(self, context, mac_address):"},{"line_number":2361,"context_line":"        raise NotImplementedError()"}],"source_content_type":"text/x-python","patch_set":9,"id":"3f79a3b5_f7ecda06","line":2358,"range":{"start_line":2357,"start_character":8,"end_line":2358,"end_character":79},"updated":"2018-11-12 23:15:11.000000000","message":"this makes sense but im kind of curious why this was not implemented previously.","commit_id":"0352a92edf01f6c17880d2752fb50dc17a618329"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"31209aca79cf7d9c3f800d81493a27c88865187e","unresolved":false,"context_lines":[{"line_number":2354,"context_line":"        return port[\u0027device_id\u0027]"},{"line_number":2355,"context_line":""},{"line_number":2356,"context_line":"    def get_vifs_by_instance(self, context, instance):"},{"line_number":2357,"context_line":"        return objects.VirtualInterfaceList.get_by_instance_uuid(context,"},{"line_number":2358,"context_line":"                                                                 instance.uuid)"},{"line_number":2359,"context_line":""},{"line_number":2360,"context_line":"    def get_vif_by_mac_address(self, context, mac_address):"},{"line_number":2361,"context_line":"        raise NotImplementedError()"}],"source_content_type":"text/x-python","patch_set":9,"id":"3f79a3b5_6cac5feb","line":2358,"range":{"start_line":2357,"start_character":8,"end_line":2358,"end_character":79},"in_reply_to":"3f79a3b5_f7ecda06","updated":"2018-11-30 14:10:01.000000000","message":"This class touch neutron API, so implementing get_vifs_by_instance() this way is kind confusing, but I needed to make it this way.","commit_id":"0352a92edf01f6c17880d2752fb50dc17a618329"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"14359c2c2e2fb1110b7115d748dadf59ee0a8159","unresolved":false,"context_lines":[{"line_number":2748,"context_line":"    def _build_network_info_model(self, context, instance, networks\u003dNone,"},{"line_number":2749,"context_line":"                                  port_ids\u003dNone, admin_client\u003dNone,"},{"line_number":2750,"context_line":"                                  preexisting_port_ids\u003dNone,"},{"line_number":2751,"context_line":"                                  refresh_vif_id\u003dNone, force_refresh\u003dFalse):"},{"line_number":2752,"context_line":"        \"\"\"Return list of ordered VIFs attached to instance."},{"line_number":2753,"context_line":""},{"line_number":2754,"context_line":"        :param context: Request context."}],"source_content_type":"text/x-python","patch_set":9,"id":"3f79a3b5_57ca6e7b","line":2751,"range":{"start_line":2751,"start_character":69,"end_line":2751,"end_character":74},"updated":"2018-11-12 23:15:11.000000000","message":"note to self defaulting to false to keep legacy behavior when invoked outside of heal periodic task which will pass true to enable new behavior.","commit_id":"0352a92edf01f6c17880d2752fb50dc17a618329"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"14359c2c2e2fb1110b7115d748dadf59ee0a8159","unresolved":false,"context_lines":[{"line_number":2770,"context_line":"                        cache rather than the entire cache. This can be"},{"line_number":2771,"context_line":"                        triggered via a \"network-changed\" server external event"},{"line_number":2772,"context_line":"                        from Neutron."},{"line_number":2773,"context_line":"        :paramm force_refresh: If ``networks`` and ``port_ids`` are both None,"},{"line_number":2774,"context_line":"                        by default the instance.info_cache will be used to"},{"line_number":2775,"context_line":"                        refresh the network info. Pass ``True`` to force"},{"line_number":2776,"context_line":"                        collection of ports and networks from neutron directly."}],"source_content_type":"text/x-python","patch_set":9,"id":"3f79a3b5_b70f42d3","line":2773,"range":{"start_line":2773,"start_character":14,"end_line":2773,"end_character":15},"updated":"2018-11-12 23:15:11.000000000","message":"extra m","commit_id":"0352a92edf01f6c17880d2752fb50dc17a618329"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"31209aca79cf7d9c3f800d81493a27c88865187e","unresolved":false,"context_lines":[{"line_number":2770,"context_line":"                        cache rather than the entire cache. This can be"},{"line_number":2771,"context_line":"                        triggered via a \"network-changed\" server external event"},{"line_number":2772,"context_line":"                        from Neutron."},{"line_number":2773,"context_line":"        :paramm force_refresh: If ``networks`` and ``port_ids`` are both None,"},{"line_number":2774,"context_line":"                        by default the instance.info_cache will be used to"},{"line_number":2775,"context_line":"                        refresh the network info. Pass ``True`` to force"},{"line_number":2776,"context_line":"                        collection of ports and networks from neutron directly."}],"source_content_type":"text/x-python","patch_set":9,"id":"3f79a3b5_0c57ebce","line":2773,"range":{"start_line":2773,"start_character":14,"end_line":2773,"end_character":15},"in_reply_to":"3f79a3b5_b70f42d3","updated":"2018-11-30 14:10:01.000000000","message":"Will be fixed, thanks","commit_id":"0352a92edf01f6c17880d2752fb50dc17a618329"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"14359c2c2e2fb1110b7115d748dadf59ee0a8159","unresolved":false,"context_lines":[{"line_number":2888,"context_line":"    def _get_ordered_port_list(self, context, instance, current_neutron_ports):"},{"line_number":2889,"context_line":"        \"\"\"Returns ordered port list using nova virtual_interface data.\"\"\""},{"line_number":2890,"context_line":""},{"line_number":2891,"context_line":"        port_order_map \u003d {}"},{"line_number":2892,"context_line":"        port_order_list \u003d []"},{"line_number":2893,"context_line":"        ports_without_order \u003d []"},{"line_number":2894,"context_line":""}],"source_content_type":"text/x-python","patch_set":9,"id":"3f79a3b5_57810efd","line":2891,"range":{"start_line":2891,"start_character":8,"end_line":2891,"end_character":27},"updated":"2018-11-12 23:15:11.000000000","message":"in pyhton 2.7 insertion order in not gurrenteed\n\nas such we should not rely on it.\n\nin pthon 3.6+ it is but for now you will need to use\n\ncollections.ordered dict if you wasnt to use the insertion order into the map to preserve ordering.","commit_id":"0352a92edf01f6c17880d2752fb50dc17a618329"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"31209aca79cf7d9c3f800d81493a27c88865187e","unresolved":false,"context_lines":[{"line_number":2888,"context_line":"    def _get_ordered_port_list(self, context, instance, current_neutron_ports):"},{"line_number":2889,"context_line":"        \"\"\"Returns ordered port list using nova virtual_interface data.\"\"\""},{"line_number":2890,"context_line":""},{"line_number":2891,"context_line":"        port_order_map \u003d {}"},{"line_number":2892,"context_line":"        port_order_list \u003d []"},{"line_number":2893,"context_line":"        ports_without_order \u003d []"},{"line_number":2894,"context_line":""}],"source_content_type":"text/x-python","patch_set":9,"id":"3f79a3b5_cce9f318","line":2891,"range":{"start_line":2891,"start_character":8,"end_line":2891,"end_character":27},"in_reply_to":"3f79a3b5_57810efd","updated":"2018-11-30 14:10:01.000000000","message":"The name is wrong, this dict could be unsorted also. I\u0027ll change it to make clear.","commit_id":"0352a92edf01f6c17880d2752fb50dc17a618329"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"14359c2c2e2fb1110b7115d748dadf59ee0a8159","unresolved":false,"context_lines":[{"line_number":2909,"context_line":"                # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2910,"context_line":"                ports_without_order.append(port.get(\u0027id\u0027))"},{"line_number":2911,"context_line":""},{"line_number":2912,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2913,"context_line":"        port_order_list \u003d sorted(port_order_map,"},{"line_number":2914,"context_line":"                                 key\u003dlambda k: port_order_map[k])"},{"line_number":2915,"context_line":""},{"line_number":2916,"context_line":"        # Add ports without order to the end of list"},{"line_number":2917,"context_line":"        port_order_list.extend(ports_without_order)"}],"source_content_type":"text/x-python","patch_set":9,"id":"3f79a3b5_f7961a3c","line":2914,"range":{"start_line":2912,"start_character":7,"end_line":2914,"end_character":65},"updated":"2018-11-12 23:15:11.000000000","message":"that said you seam to be sorting by the vif id of the ports you currently know about so you are not preserving the insertion order into the map.","commit_id":"0352a92edf01f6c17880d2752fb50dc17a618329"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"31209aca79cf7d9c3f800d81493a27c88865187e","unresolved":false,"context_lines":[{"line_number":2909,"context_line":"                # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2910,"context_line":"                ports_without_order.append(port.get(\u0027id\u0027))"},{"line_number":2911,"context_line":""},{"line_number":2912,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2913,"context_line":"        port_order_list \u003d sorted(port_order_map,"},{"line_number":2914,"context_line":"                                 key\u003dlambda k: port_order_map[k])"},{"line_number":2915,"context_line":""},{"line_number":2916,"context_line":"        # Add ports without order to the end of list"},{"line_number":2917,"context_line":"        port_order_list.extend(ports_without_order)"}],"source_content_type":"text/x-python","patch_set":9,"id":"3f79a3b5_8cbc5b09","line":2914,"range":{"start_line":2912,"start_character":7,"end_line":2914,"end_character":65},"in_reply_to":"3f79a3b5_f7961a3c","updated":"2018-11-30 14:10:01.000000000","message":"I take the dict with ports and its ids from vif table and based on that id I sort and produce list.\n\nSo the data are: \n{ \u0027port_id_1\u0027: 12,\n  \u0027port_id_2: 1\u0027}\n\nThe result will be [port_id_2, port_id_1]","commit_id":"0352a92edf01f6c17880d2752fb50dc17a618329"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"14359c2c2e2fb1110b7115d748dadf59ee0a8159","unresolved":false,"context_lines":[{"line_number":2916,"context_line":"        # Add ports without order to the end of list"},{"line_number":2917,"context_line":"        port_order_list.extend(ports_without_order)"},{"line_number":2918,"context_line":""},{"line_number":2919,"context_line":"        return port_order_list"},{"line_number":2920,"context_line":""},{"line_number":2921,"context_line":"    def _get_subnets_from_port(self, context, port, client\u003dNone):"},{"line_number":2922,"context_line":"        \"\"\"Return the subnets for a given port.\"\"\""}],"source_content_type":"text/x-python","patch_set":9,"id":"3f79a3b5_37e332da","line":2919,"range":{"start_line":2919,"start_character":15,"end_line":2919,"end_character":30},"updated":"2018-11-12 23:15:11.000000000","message":"so the final list is a partil sort on vif ids where\nany vif not currently know by nova that was returned by neutron is appended to the end.\n\nis that what you wanted because i would have assumed you would have wanted to have all vifs nova knows about come first in the order they were presented followed by the addtional ones form neutron.\n\nthe vif ids are just uuids so in general it is unlikely that an interface with 3 interfaces will have 3 vifs tahta are lexically orderd such that this will not result in the order changing.","commit_id":"0352a92edf01f6c17880d2752fb50dc17a618329"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"31209aca79cf7d9c3f800d81493a27c88865187e","unresolved":false,"context_lines":[{"line_number":2916,"context_line":"        # Add ports without order to the end of list"},{"line_number":2917,"context_line":"        port_order_list.extend(ports_without_order)"},{"line_number":2918,"context_line":""},{"line_number":2919,"context_line":"        return port_order_list"},{"line_number":2920,"context_line":""},{"line_number":2921,"context_line":"    def _get_subnets_from_port(self, context, port, client\u003dNone):"},{"line_number":2922,"context_line":"        \"\"\"Return the subnets for a given port.\"\"\""}],"source_content_type":"text/x-python","patch_set":9,"id":"3f79a3b5_4c4ba328","line":2919,"range":{"start_line":2919,"start_character":15,"end_line":2919,"end_character":30},"in_reply_to":"3f79a3b5_37e332da","updated":"2018-11-30 14:10:01.000000000","message":"Yes, for me the final list is ordered list with know vifs, and then unordered that are not in nova, but in neutron (like new port).\n\nI don\u0027t get what you mean about second part.","commit_id":"0352a92edf01f6c17880d2752fb50dc17a618329"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"483be0e26387cb1bc39eb9325ea0e58da7c232d9","unresolved":false,"context_lines":[{"line_number":2938,"context_line":"                    port_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2939,"context_line":"                    break"},{"line_number":2940,"context_line":""},{"line_number":2941,"context_line":"            if port.get(\u0027id\u0027) not in port_map:"},{"line_number":2942,"context_line":"                # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2943,"context_line":"                ports_without_order.append(port.get(\u0027id\u0027))"},{"line_number":2944,"context_line":""}],"source_content_type":"text/x-python","patch_set":11,"id":"3f79a3b5_972fed55","line":2941,"range":{"start_line":2941,"start_character":12,"end_line":2941,"end_character":46},"updated":"2018-12-07 16:53:23.000000000","message":"Not a big issue but isn\u0027t this always going to be true? If the port ID had matched one of the VIFs, it would be in this list. If not, it wouldn\u0027t. It\u0027s not like we can have ports or VIFs with the same (uu)id.","commit_id":"e5abb201a19efcf7e67a84897e0e11ae5846583e"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"768d8bdb675decb8b8692a509ef6a5708c3b5989","unresolved":false,"context_lines":[{"line_number":2938,"context_line":"                    port_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2939,"context_line":"                    break"},{"line_number":2940,"context_line":""},{"line_number":2941,"context_line":"            if port.get(\u0027id\u0027) not in port_map:"},{"line_number":2942,"context_line":"                # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2943,"context_line":"                ports_without_order.append(port.get(\u0027id\u0027))"},{"line_number":2944,"context_line":""}],"source_content_type":"text/x-python","patch_set":11,"id":"3f79a3b5_ed2d1bad","line":2941,"range":{"start_line":2941,"start_character":12,"end_line":2941,"end_character":46},"in_reply_to":"3f79a3b5_972fed55","updated":"2018-12-10 08:57:12.000000000","message":"Sometimes port could be in current_neutron_ports but not in VirtualIntefaceList object (vifs). It could be when instance has been created in release older than Newton or the port has been just added. Thats why it should be added to the end of port_list (L2950).","commit_id":"e5abb201a19efcf7e67a84897e0e11ae5846583e"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"aa8004dad4a6f18deb226d8e812c6fb96c335a8e","unresolved":false,"context_lines":[{"line_number":2938,"context_line":"                    port_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2939,"context_line":"                    break"},{"line_number":2940,"context_line":""},{"line_number":2941,"context_line":"            if port.get(\u0027id\u0027) not in port_map:"},{"line_number":2942,"context_line":"                # Assume that it\u0027s new port and add it to the end of port list."},{"line_number":2943,"context_line":"                ports_without_order.append(port.get(\u0027id\u0027))"},{"line_number":2944,"context_line":""}],"source_content_type":"text/x-python","patch_set":11,"id":"3f79a3b5_33c92679","line":2941,"range":{"start_line":2941,"start_character":12,"end_line":2941,"end_character":46},"in_reply_to":"3f79a3b5_ed2d1bad","updated":"2018-12-10 16:58:50.000000000","message":"it also can happen in some error conditions where the nova db get out of sync with neutron. the most common case of this is a contoler reboot or network partion that results in the db translation to commit the vitualinterface table update to fail after the call to associate teh port with the vm success in neutron.","commit_id":"e5abb201a19efcf7e67a84897e0e11ae5846583e"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"3e57e00b8ab5780870f24eeab32e616836967acb","unresolved":false,"context_lines":[{"line_number":2805,"context_line":"                        from Neutron."},{"line_number":2806,"context_line":"        :param force_refresh: If ``networks`` and ``port_ids`` are both None,"},{"line_number":2807,"context_line":"                        by default the instance.info_cache will be used to"},{"line_number":2808,"context_line":"                        refresh the network info. Pass ``True`` to force"},{"line_number":2809,"context_line":"                        collection of ports and networks from neutron directly."},{"line_number":2810,"context_line":"        \"\"\""},{"line_number":2811,"context_line":""}],"source_content_type":"text/x-python","patch_set":13,"id":"1f769fc5_fa9eb861","line":2808,"range":{"start_line":2808,"start_character":24,"end_line":2808,"end_character":31},"updated":"2019-01-02 18:44:57.000000000","message":"s/refresh/populate/ (it\u0027s a small but important distinction for the reader of this docstring)","commit_id":"35505c09dee5a3490411a37f9790d96e3a3acbbf"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"d7f3545693d8b2864e58903760c76e444b04c1cf","unresolved":false,"context_lines":[{"line_number":2805,"context_line":"                        from Neutron."},{"line_number":2806,"context_line":"        :param force_refresh: If ``networks`` and ``port_ids`` are both None,"},{"line_number":2807,"context_line":"                        by default the instance.info_cache will be used to"},{"line_number":2808,"context_line":"                        refresh the network info. Pass ``True`` to force"},{"line_number":2809,"context_line":"                        collection of ports and networks from neutron directly."},{"line_number":2810,"context_line":"        \"\"\""},{"line_number":2811,"context_line":""}],"source_content_type":"text/x-python","patch_set":13,"id":"ffd0ebdf_bcbe2efd","line":2808,"range":{"start_line":2808,"start_character":24,"end_line":2808,"end_character":31},"in_reply_to":"1f769fc5_fa9eb861","updated":"2019-01-03 13:29:34.000000000","message":"done","commit_id":"35505c09dee5a3490411a37f9790d96e3a3acbbf"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"3e57e00b8ab5780870f24eeab32e616836967acb","unresolved":false,"context_lines":[{"line_number":2899,"context_line":"        else:"},{"line_number":2900,"context_line":"            # We are refreshing the full cache using the existing cache rather"},{"line_number":2901,"context_line":"            # than what is currently in neutron."},{"line_number":2902,"context_line":"            networks, port_ids \u003d self._gather_port_ids_and_networks("},{"line_number":2903,"context_line":"                    context, instance, networks, port_ids, client)"},{"line_number":2904,"context_line":""},{"line_number":2905,"context_line":"        nw_info \u003d network_model.NetworkInfo()"}],"source_content_type":"text/x-python","patch_set":13,"id":"1f769fc5_9a878410","line":2902,"range":{"start_line":2902,"start_character":39,"end_line":2902,"end_character":67},"updated":"2019-01-02 18:44:57.000000000","message":"consider renaming this method to _get_cached_network_info() or something similar to differentiate it from getting that information from Neutron. Though, I will say that it is an incredibly confusing method/interface that accepts a networks/ports parameter and returns a networks/ports result... maybe a better name for the method would be _refresh_cached_network_info()?","commit_id":"35505c09dee5a3490411a37f9790d96e3a3acbbf"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"d7f3545693d8b2864e58903760c76e444b04c1cf","unresolved":false,"context_lines":[{"line_number":2899,"context_line":"        else:"},{"line_number":2900,"context_line":"            # We are refreshing the full cache using the existing cache rather"},{"line_number":2901,"context_line":"            # than what is currently in neutron."},{"line_number":2902,"context_line":"            networks, port_ids \u003d self._gather_port_ids_and_networks("},{"line_number":2903,"context_line":"                    context, instance, networks, port_ids, client)"},{"line_number":2904,"context_line":""},{"line_number":2905,"context_line":"        nw_info \u003d network_model.NetworkInfo()"}],"source_content_type":"text/x-python","patch_set":13,"id":"ffd0ebdf_9c8eca2c","line":2902,"range":{"start_line":2902,"start_character":39,"end_line":2902,"end_character":67},"in_reply_to":"1f769fc5_9a878410","updated":"2019-01-03 13:29:34.000000000","message":"Yes, its confusing here. This method doesn\u0027t refresh anything so I would name it as _get_cached_network_info().\nI added a new, separated patch that is parent of this patch.","commit_id":"35505c09dee5a3490411a37f9790d96e3a3acbbf"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"3e57e00b8ab5780870f24eeab32e616836967acb","unresolved":false,"context_lines":[{"line_number":2934,"context_line":""},{"line_number":2935,"context_line":"            # Find port index if it was attached before."},{"line_number":2936,"context_line":"            for vif in vifs:"},{"line_number":2937,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2938,"context_line":"                    port_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2939,"context_line":"                    break"},{"line_number":2940,"context_line":""}],"source_content_type":"text/x-python","patch_set":13,"id":"1f769fc5_1ac1342f","line":2937,"range":{"start_line":2937,"start_character":31,"end_line":2937,"end_character":46},"updated":"2019-01-02 18:44:57.000000000","message":"similar comment about using [\u0027id\u0027] instead of get() if we expect the field to always be available. Using get() hides potential data expectation/corruption errors.","commit_id":"35505c09dee5a3490411a37f9790d96e3a3acbbf"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"d7f3545693d8b2864e58903760c76e444b04c1cf","unresolved":false,"context_lines":[{"line_number":2934,"context_line":""},{"line_number":2935,"context_line":"            # Find port index if it was attached before."},{"line_number":2936,"context_line":"            for vif in vifs:"},{"line_number":2937,"context_line":"                if vif.uuid \u003d\u003d port.get(\u0027id\u0027):"},{"line_number":2938,"context_line":"                    port_map[port.get(\u0027id\u0027)] \u003d vif.id"},{"line_number":2939,"context_line":"                    break"},{"line_number":2940,"context_line":""}],"source_content_type":"text/x-python","patch_set":13,"id":"ffd0ebdf_1c473a20","line":2937,"range":{"start_line":2937,"start_character":31,"end_line":2937,"end_character":46},"in_reply_to":"1f769fc5_1ac1342f","updated":"2019-01-03 13:29:34.000000000","message":"Ok, changed.","commit_id":"35505c09dee5a3490411a37f9790d96e3a3acbbf"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"10cc80da73e08b3f940a9a5498f6f194c14053f7","unresolved":false,"context_lines":[{"line_number":1667,"context_line":"        # Otherwise multiple requests could collide and cause cache"},{"line_number":1668,"context_line":"        # corruption."},{"line_number":1669,"context_line":"        compute_utils.refresh_info_cache_for_instance(context, instance)"},{"line_number":1670,"context_line":"        force_refresh \u003d kwargs.get(\u0027force_refresh\u0027, False)"},{"line_number":1671,"context_line":"        nw_info \u003d self._build_network_info_model(context, instance, networks,"},{"line_number":1672,"context_line":"                                                 port_ids, admin_client,"},{"line_number":1673,"context_line":"                                                 preexisting_port_ids,"}],"source_content_type":"text/x-python","patch_set":17,"id":"dfd5e7cf_2a63aade","line":1670,"updated":"2019-01-08 15:12:41.000000000","message":"is there a reason we didn\u0027t just add a force_refresh kwarg to the _get_instance_nw_info() method signature? Not that this even has a docstring... so, meh I guess :)","commit_id":"32a550a6ff315166e29e3ee9bb3d60fb87cf3d1b"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"36678008ddd8bde40f2d3561d7920401f5eefce5","unresolved":false,"context_lines":[{"line_number":1667,"context_line":"        # Otherwise multiple requests could collide and cause cache"},{"line_number":1668,"context_line":"        # corruption."},{"line_number":1669,"context_line":"        compute_utils.refresh_info_cache_for_instance(context, instance)"},{"line_number":1670,"context_line":"        force_refresh \u003d kwargs.get(\u0027force_refresh\u0027, False)"},{"line_number":1671,"context_line":"        nw_info \u003d self._build_network_info_model(context, instance, networks,"},{"line_number":1672,"context_line":"                                                 port_ids, admin_client,"},{"line_number":1673,"context_line":"                                                 preexisting_port_ids,"}],"source_content_type":"text/x-python","patch_set":17,"id":"dfd5e7cf_c55e91e5","line":1670,"in_reply_to":"dfd5e7cf_2a63aade","updated":"2019-01-08 15:49:46.000000000","message":"I was trying to find why Matt did it this way but I failed. So lets try, going to move it do function signature.","commit_id":"32a550a6ff315166e29e3ee9bb3d60fb87cf3d1b"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"10cc80da73e08b3f940a9a5498f6f194c14053f7","unresolved":false,"context_lines":[{"line_number":1680,"context_line":"        \"\"\"Return an instance\u0027s complete list of port_ids and networks."},{"line_number":1681,"context_line":""},{"line_number":1682,"context_line":"        The results are based on the instance info_cache in the nova db, not"},{"line_number":1683,"context_line":"        the instance\u0027s current list of ports in neutron."},{"line_number":1684,"context_line":"        \"\"\""},{"line_number":1685,"context_line":""},{"line_number":1686,"context_line":"        if ((networks is None and port_ids is not None) or"}],"source_content_type":"text/x-python","patch_set":17,"id":"dfd5e7cf_caa9bedf","line":1683,"updated":"2019-01-08 15:12:41.000000000","message":"✔ thank you for adding that docstring","commit_id":"32a550a6ff315166e29e3ee9bb3d60fb87cf3d1b"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"10cc80da73e08b3f940a9a5498f6f194c14053f7","unresolved":false,"context_lines":[{"line_number":2886,"context_line":"        if nw_info_refresh and force_refresh:"},{"line_number":2887,"context_line":"            # Use the current set of ports from neutron rather than the cache."},{"line_number":2888,"context_line":"            port_ids \u003d []"},{"line_number":2889,"context_line":"            net_ids \u003d []"},{"line_number":2890,"context_line":""},{"line_number":2891,"context_line":"            port_ids \u003d self._get_ordered_port_list(context, instance,"},{"line_number":2892,"context_line":"                                                   current_neutron_ports)"}],"source_content_type":"text/x-python","patch_set":17,"id":"dfd5e7cf_0ad7c64d","line":2889,"updated":"2019-01-08 15:12:41.000000000","message":"the above two lines are not necessary, since those two variables have their values overwritten on lines 2891-2894","commit_id":"32a550a6ff315166e29e3ee9bb3d60fb87cf3d1b"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"36678008ddd8bde40f2d3561d7920401f5eefce5","unresolved":false,"context_lines":[{"line_number":2886,"context_line":"        if nw_info_refresh and force_refresh:"},{"line_number":2887,"context_line":"            # Use the current set of ports from neutron rather than the cache."},{"line_number":2888,"context_line":"            port_ids \u003d []"},{"line_number":2889,"context_line":"            net_ids \u003d []"},{"line_number":2890,"context_line":""},{"line_number":2891,"context_line":"            port_ids \u003d self._get_ordered_port_list(context, instance,"},{"line_number":2892,"context_line":"                                                   current_neutron_ports)"}],"source_content_type":"text/x-python","patch_set":17,"id":"dfd5e7cf_455141d8","line":2889,"in_reply_to":"dfd5e7cf_0ad7c64d","updated":"2019-01-08 15:49:46.000000000","message":"Right.","commit_id":"32a550a6ff315166e29e3ee9bb3d60fb87cf3d1b"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"10cc80da73e08b3f940a9a5498f6f194c14053f7","unresolved":false,"context_lines":[{"line_number":2943,"context_line":"                ports_without_order.append(port[\u0027id\u0027])"},{"line_number":2944,"context_line":""},{"line_number":2945,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2946,"context_line":"        port_order_list \u003d sorted(port_map,"},{"line_number":2947,"context_line":"                                 key\u003dlambda k: port_map[k])"},{"line_number":2948,"context_line":""},{"line_number":2949,"context_line":"        # Add ports without order to the end of list"},{"line_number":2950,"context_line":"        port_order_list.extend(ports_without_order)"}],"source_content_type":"text/x-python","patch_set":17,"id":"dfd5e7cf_8a697626","line":2947,"range":{"start_line":2946,"start_character":0,"end_line":2947,"end_character":59},"updated":"2019-01-08 15:12:41.000000000","message":"this isn\u0027t particularly clear to me, since you\u0027re sorting a map by the map\u0027s value. I don\u0027t actually think there\u0027s a need to use a map at all, since get_vifs_by_instance() returns a list of VIFs already sorted by \"port index\", right? [1]\n\nI think what you really want to do is something like this?\n\n ordered_ports \u003d []\n new_ports \u003d []\n\n # get the list of virtual interfaces sorted by the attached\n # port\u0027s \"index\" (i.e. the port\u0027s insertion order)\n vifs \u003d self.get_vifs_by_instance(context, instance)\n vif_uuids \u003d set(v.uuid for v in vifs)\n for vif in vifs:\n     for port in current_neutron_ports:\n         if port[\u0027id\u0027] in vif_uuids:\n             ordered_ports.append(vif.uuid)\n         else:\n             new_ports.append(port[\u0027id\u0027])\n \n return ordered_ports + new_ports\n\n[1] https://github.com/openstack/nova/blob/1351f031b86418b49ea9fae82856e6b3e84cd1ce/nova/db/sqlalchemy/api.py#L1608","commit_id":"32a550a6ff315166e29e3ee9bb3d60fb87cf3d1b"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"36678008ddd8bde40f2d3561d7920401f5eefce5","unresolved":false,"context_lines":[{"line_number":2943,"context_line":"                ports_without_order.append(port[\u0027id\u0027])"},{"line_number":2944,"context_line":""},{"line_number":2945,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2946,"context_line":"        port_order_list \u003d sorted(port_map,"},{"line_number":2947,"context_line":"                                 key\u003dlambda k: port_map[k])"},{"line_number":2948,"context_line":""},{"line_number":2949,"context_line":"        # Add ports without order to the end of list"},{"line_number":2950,"context_line":"        port_order_list.extend(ports_without_order)"}],"source_content_type":"text/x-python","patch_set":17,"id":"dfd5e7cf_e52ab5e5","line":2947,"range":{"start_line":2946,"start_character":0,"end_line":2947,"end_character":59},"in_reply_to":"dfd5e7cf_8a697626","updated":"2019-01-08 15:49:46.000000000","message":"I would like to have a list of port_ids that neutron claims this instance has, sorted by historical data that are stored in VirtualInterfaceList objects.\n\nAs you see in what you\u0027ve written: you loop over vifs taken from nova DB (so the nova point of view). I would like to have `fresh` list of interfaces, so I loop over `current_neutron_ports`.\n\nIn your example when port is not yet ready it will not be added to list.","commit_id":"32a550a6ff315166e29e3ee9bb3d60fb87cf3d1b"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"ca16a6cdaa30be529617678bb976f8e0611c53e6","unresolved":false,"context_lines":[{"line_number":2943,"context_line":"                ports_without_order.append(port[\u0027id\u0027])"},{"line_number":2944,"context_line":""},{"line_number":2945,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2946,"context_line":"        port_order_list \u003d sorted(port_map,"},{"line_number":2947,"context_line":"                                 key\u003dlambda k: port_map[k])"},{"line_number":2948,"context_line":""},{"line_number":2949,"context_line":"        # Add ports without order to the end of list"},{"line_number":2950,"context_line":"        port_order_list.extend(ports_without_order)"}],"source_content_type":"text/x-python","patch_set":17,"id":"dfd5e7cf_80e39705","line":2947,"range":{"start_line":2946,"start_character":0,"end_line":2947,"end_character":59},"in_reply_to":"dfd5e7cf_e02dc346","updated":"2019-01-08 15:57:14.000000000","message":"I can rename this dict to port_info or something similar to be clear, what do you think?","commit_id":"32a550a6ff315166e29e3ee9bb3d60fb87cf3d1b"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"c3191ddbc027e073fc451813f654bf68b4a7f15d","unresolved":false,"context_lines":[{"line_number":2943,"context_line":"                ports_without_order.append(port[\u0027id\u0027])"},{"line_number":2944,"context_line":""},{"line_number":2945,"context_line":"        # Lets sort created port order_list by given index."},{"line_number":2946,"context_line":"        port_order_list \u003d sorted(port_map,"},{"line_number":2947,"context_line":"                                 key\u003dlambda k: port_map[k])"},{"line_number":2948,"context_line":""},{"line_number":2949,"context_line":"        # Add ports without order to the end of list"},{"line_number":2950,"context_line":"        port_order_list.extend(ports_without_order)"}],"source_content_type":"text/x-python","patch_set":17,"id":"dfd5e7cf_e02dc346","line":2947,"range":{"start_line":2946,"start_character":0,"end_line":2947,"end_character":59},"in_reply_to":"dfd5e7cf_e52ab5e5","updated":"2019-01-08 15:55:30.000000000","message":"ack, yeah, that makes sense. just feels weird to me to use sorted() on a map :) Maybe it would be easier for me to grok if you used a simple list instead of a map...","commit_id":"32a550a6ff315166e29e3ee9bb3d60fb87cf3d1b"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"d82564f06ea6dd067cce5be050b6a6f6565f881c","unresolved":false,"context_lines":[{"line_number":2887,"context_line":"            # Use the current set of ports from neutron rather than the cache."},{"line_number":2888,"context_line":"            port_ids \u003d self._get_ordered_port_list(context, instance,"},{"line_number":2889,"context_line":"                                                   current_neutron_ports)"},{"line_number":2890,"context_line":"            net_ids \u003d [current_neutron_port_map.get(port_id).get(\u0027network_id\u0027)"},{"line_number":2891,"context_line":"                       for port_id in port_ids]"},{"line_number":2892,"context_line":""},{"line_number":2893,"context_line":"            # This is copied from _gather_port_ids_and_networks."},{"line_number":2894,"context_line":"            networks \u003d self._get_available_networks("}],"source_content_type":"text/x-python","patch_set":21,"id":"bfdaf3ff_618e7dd1","line":2891,"range":{"start_line":2890,"start_character":12,"end_line":2891,"end_character":47},"updated":"2019-01-16 16:13:33.000000000","message":"Should this be a set, or doesn\u0027t it matter? Surely you could have multiple ports attached that are on the same network so you could have duplicates in this list.","commit_id":"477e455ff253b8eccb7c25a1496a1bdf64f56cf5"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"f645f004149746daf9609d78aad7989145d27e96","unresolved":false,"context_lines":[{"line_number":2887,"context_line":"            # Use the current set of ports from neutron rather than the cache."},{"line_number":2888,"context_line":"            port_ids \u003d self._get_ordered_port_list(context, instance,"},{"line_number":2889,"context_line":"                                                   current_neutron_ports)"},{"line_number":2890,"context_line":"            net_ids \u003d [current_neutron_port_map.get(port_id).get(\u0027network_id\u0027)"},{"line_number":2891,"context_line":"                       for port_id in port_ids]"},{"line_number":2892,"context_line":""},{"line_number":2893,"context_line":"            # This is copied from _gather_port_ids_and_networks."},{"line_number":2894,"context_line":"            networks \u003d self._get_available_networks("}],"source_content_type":"text/x-python","patch_set":21,"id":"bfdaf3ff_c1140951","line":2891,"range":{"start_line":2890,"start_character":12,"end_line":2891,"end_character":47},"in_reply_to":"bfdaf3ff_618e7dd1","updated":"2019-01-16 16:16:46.000000000","message":"Looks like we don\u0027t care about duplicates in _gather_port_ids_and_networks either, so it must have never been a problem. We could theoretically blow up the query to neutron when filtering on a list of let\u0027s say 50 duplicate networks or something, but that bug would exist in multiple places. Seems like a similar issue to I5b52ff81f74ae7cb11e6f012ab7e53cfc6821486.","commit_id":"477e455ff253b8eccb7c25a1496a1bdf64f56cf5"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"5935506a989a3880533cf7d60263fce5d38dfb60","unresolved":false,"context_lines":[{"line_number":2887,"context_line":"            # Use the current set of ports from neutron rather than the cache."},{"line_number":2888,"context_line":"            port_ids \u003d self._get_ordered_port_list(context, instance,"},{"line_number":2889,"context_line":"                                                   current_neutron_ports)"},{"line_number":2890,"context_line":"            net_ids \u003d [current_neutron_port_map.get(port_id).get(\u0027network_id\u0027)"},{"line_number":2891,"context_line":"                       for port_id in port_ids]"},{"line_number":2892,"context_line":""},{"line_number":2893,"context_line":"            # This is copied from _gather_port_ids_and_networks."},{"line_number":2894,"context_line":"            networks \u003d self._get_available_networks("}],"source_content_type":"text/x-python","patch_set":21,"id":"bfdaf3ff_444b4758","line":2891,"range":{"start_line":2890,"start_character":12,"end_line":2891,"end_character":47},"in_reply_to":"bfdaf3ff_c1140951","updated":"2019-01-16 16:20:04.000000000","message":"Yes, we could modify it to be a set not list, but it\u0027s detail.","commit_id":"477e455ff253b8eccb7c25a1496a1bdf64f56cf5"}],"nova/tests/unit/network/test_neutronv2.py":[{"author":{"_account_id":13478,"name":"Boris Bobrov","email":"b.bobrov@sap.com","username":"bbobrov"},"change_message_id":"0fb8ae5258d5b99922f177c3ff1c6aa349211269","unresolved":false,"context_lines":[{"line_number":7003,"context_line":"        # Assert that the port is in the cache now."},{"line_number":7004,"context_line":"        self.assertIsNotNone(self._get_vif_in_cache(nwinfo, uuids.port_id))"},{"line_number":7005,"context_line":""},{"line_number":7006,"context_line":"    def test__get_ordered_port_list(self):"},{"line_number":7007,"context_line":"        \"\"\"This test if port_list is sorted by VirtualInterface id"},{"line_number":7008,"context_line":"        sequence."},{"line_number":7009,"context_line":"        \"\"\""}],"source_content_type":"text/x-python","patch_set":11,"id":"3f79a3b5_c3fbddc2","line":7006,"range":{"start_line":7006,"start_character":12,"end_line":7006,"end_character":14},"updated":"2018-12-14 14:27:12.000000000","message":"is this and other __ below expected to be here or is this a typo?","commit_id":"e5abb201a19efcf7e67a84897e0e11ae5846583e"},{"author":{"_account_id":24791,"name":"Maciej Jozefczyk","email":"jeicam.pl@gmail.com","username":"maciej.jozefczyk"},"change_message_id":"196d2d5e80bbf94e776a0fb118aa8fa203beb1f7","unresolved":false,"context_lines":[{"line_number":7003,"context_line":"        # Assert that the port is in the cache now."},{"line_number":7004,"context_line":"        self.assertIsNotNone(self._get_vif_in_cache(nwinfo, uuids.port_id))"},{"line_number":7005,"context_line":""},{"line_number":7006,"context_line":"    def test__get_ordered_port_list(self):"},{"line_number":7007,"context_line":"        \"\"\"This test if port_list is sorted by VirtualInterface id"},{"line_number":7008,"context_line":"        sequence."},{"line_number":7009,"context_line":"        \"\"\""}],"source_content_type":"text/x-python","patch_set":11,"id":"3f79a3b5_e3b7f986","line":7006,"range":{"start_line":7006,"start_character":12,"end_line":7006,"end_character":14},"in_reply_to":"3f79a3b5_c3fbddc2","updated":"2018-12-14 14:51:09.000000000","message":"Im testing helper function that starts with \u0027_\u0027. So that\u0027s why :)","commit_id":"e5abb201a19efcf7e67a84897e0e11ae5846583e"}]}
