)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":13995,"name":"Nate Johnston","email":"nate.johnston@redhat.com","username":"natejohnston"},"change_message_id":"997ba1d79deebc48967a9ef86048c85ece0807a2","unresolved":false,"context_lines":[{"line_number":10,"context_line":"service plugin. The only case that neutron server will store the"},{"line_number":11,"context_line":"segment-host mapping into db, is enabling the segments service plugin."},{"line_number":12,"context_line":"That means the info should be availabled just in routed network resource"},{"line_number":13,"context_line":"operation."},{"line_number":14,"context_line":""},{"line_number":15,"context_line":"Change-Id: I65a42aa2129bef696906a18d82575461dc02ba21"},{"line_number":16,"context_line":"Closes-Bug: #1799328"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":6,"id":"3f79a3b5_f9820b51","line":13,"updated":"2018-11-21 15:16:19.000000000","message":"There are a few grammatical issues with this paragraph.  If I may, let me try to reword it and you tell me if the meaning is still correct:\n\n\"This patch adds a check to determine if the segments service plugin is enabled.  The segment-host mapping should only be saved to the db if the segments service plugin is enabled.  The data should be available only in a routed network resource situation.\"","commit_id":"bed9c0a331a730d650be5258d34434f731f0b05f"},{"author":{"_account_id":15309,"name":"zhaobo","email":"bzhaojyathousandy@gmail.com","username":"ZhaoBo"},"change_message_id":"fc54e757c45941ee6c41258d219c2f7d02ee79ee","unresolved":false,"context_lines":[{"line_number":10,"context_line":"service plugin. The only case that neutron server will store the"},{"line_number":11,"context_line":"segment-host mapping into db, is enabling the segments service plugin."},{"line_number":12,"context_line":"That means the info should be availabled just in routed network resource"},{"line_number":13,"context_line":"operation."},{"line_number":14,"context_line":""},{"line_number":15,"context_line":"Change-Id: I65a42aa2129bef696906a18d82575461dc02ba21"},{"line_number":16,"context_line":"Closes-Bug: #1799328"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":6,"id":"3f79a3b5_16cc6abc","line":13,"in_reply_to":"3f79a3b5_f9820b51","updated":"2018-11-22 01:18:00.000000000","message":"Thanks for your kind suggest and very nice reword. ;-). Ha. I update it now.","commit_id":"bed9c0a331a730d650be5258d34434f731f0b05f"}],"neutron/services/segments/db.py":[{"author":{"_account_id":15309,"name":"zhaobo","email":"bzhaojyathousandy@gmail.com","username":"ZhaoBo"},"change_message_id":"04e2068fca3ce66dcab58c3d5882d4a7d80badf8","unresolved":false,"context_lines":[{"line_number":222,"context_line":""},{"line_number":223,"context_line":"reported_hosts \u003d set()"},{"line_number":224,"context_line":""},{"line_number":225,"context_line":"# NOTE: Module level variable of segments plugin. It should be removed once"},{"line_number":226,"context_line":"# segments becomes a default plugin."},{"line_number":227,"context_line":"segments_plugin \u003d None"},{"line_number":228,"context_line":""},{"line_number":229,"context_line":""},{"line_number":230,"context_line":"def get_segments_with_phys_nets(context, phys_nets):"}],"source_content_type":"text/x-python","patch_set":1,"id":"3f79a3b5_dfa7ecba","line":227,"range":{"start_line":225,"start_character":0,"end_line":227,"end_character":22},"updated":"2018-10-24 06:04:25.000000000","message":"Here. ;-)","commit_id":"5a5b94cad10a63daf60499c36b341c0bc820d98b"},{"author":{"_account_id":27654,"name":"Hongbin Lu","email":"kira034@163.com","username":"hongbin.lu"},"change_message_id":"becf7d9fc290259093e21c2e55cf1f88dc19c159","unresolved":false,"context_lines":[{"line_number":285,"context_line":"        return"},{"line_number":286,"context_line":"    cp \u003d directory.get_plugin()"},{"line_number":287,"context_line":"    check_segment_for_agent \u003d getattr(cp, \u0027check_segment_for_agent\u0027, None)"},{"line_number":288,"context_line":"    if extension.SEGMENTS not in directory.get_plugins() or not hasattr("},{"line_number":289,"context_line":"            cp, \u0027get_agents\u0027) or not check_segment_for_agent:"},{"line_number":290,"context_line":"        # not an agent-supporting plugin"},{"line_number":291,"context_line":"        registry.unsubscribe(_add_segment_host_mapping_for_segment,"}],"source_content_type":"text/x-python","patch_set":1,"id":"3f79a3b5_33dbc27a","line":288,"range":{"start_line":288,"start_character":7,"end_line":288,"end_character":56},"updated":"2018-10-23 18:32:55.000000000","message":"How about \"if directory.get_plugin(\u0027segments\u0027) or ..\"","commit_id":"5a5b94cad10a63daf60499c36b341c0bc820d98b"},{"author":{"_account_id":27654,"name":"Hongbin Lu","email":"kira034@163.com","username":"hongbin.lu"},"change_message_id":"b4c3c20b8aacc95f554479a5299b39fa6b79c998","unresolved":false,"context_lines":[{"line_number":285,"context_line":"        return"},{"line_number":286,"context_line":"    cp \u003d directory.get_plugin()"},{"line_number":287,"context_line":"    check_segment_for_agent \u003d getattr(cp, \u0027check_segment_for_agent\u0027, None)"},{"line_number":288,"context_line":"    if extension.SEGMENTS not in directory.get_plugins() or not hasattr("},{"line_number":289,"context_line":"            cp, \u0027get_agents\u0027) or not check_segment_for_agent:"},{"line_number":290,"context_line":"        # not an agent-supporting plugin"},{"line_number":291,"context_line":"        registry.unsubscribe(_add_segment_host_mapping_for_segment,"}],"source_content_type":"text/x-python","patch_set":1,"id":"3f79a3b5_d815cd4d","line":288,"range":{"start_line":288,"start_character":17,"end_line":288,"end_character":25},"updated":"2018-10-23 18:23:58.000000000","message":"This constant is for API extension. Using it to refer the \u0027segment\u0027 service plugin looks a bit confusing although it happens to be the same.","commit_id":"5a5b94cad10a63daf60499c36b341c0bc820d98b"},{"author":{"_account_id":15309,"name":"zhaobo","email":"bzhaojyathousandy@gmail.com","username":"ZhaoBo"},"change_message_id":"04e2068fca3ce66dcab58c3d5882d4a7d80badf8","unresolved":false,"context_lines":[{"line_number":285,"context_line":"        return"},{"line_number":286,"context_line":"    cp \u003d directory.get_plugin()"},{"line_number":287,"context_line":"    check_segment_for_agent \u003d getattr(cp, \u0027check_segment_for_agent\u0027, None)"},{"line_number":288,"context_line":"    if extension.SEGMENTS not in directory.get_plugins() or not hasattr("},{"line_number":289,"context_line":"            cp, \u0027get_agents\u0027) or not check_segment_for_agent:"},{"line_number":290,"context_line":"        # not an agent-supporting plugin"},{"line_number":291,"context_line":"        registry.unsubscribe(_add_segment_host_mapping_for_segment,"}],"source_content_type":"text/x-python","patch_set":1,"id":"3f79a3b5_506bc91a","line":288,"range":{"start_line":288,"start_character":7,"end_line":288,"end_character":56},"in_reply_to":"3f79a3b5_33dbc27a","updated":"2018-10-24 06:04:25.000000000","message":"Yeah, I also didn\u0027t found a alias in neutron-lib/plugin/constaint.py , but I found segment service plugin will be a default plugin, see L225. So I saw the extension API defination, the extension resource definition looks like, they will use the alias like http://git.openstack.org/cgit/openstack/neutron/tree/neutron/extensions/segment.py#n122 . So I use the same with that for future fix, as that fix may be in another patch. ;-) ..\nBut the second comment is valuable for me. Thanks. ;-)","commit_id":"5a5b94cad10a63daf60499c36b341c0bc820d98b"},{"author":{"_account_id":4694,"name":"Miguel Lavalle","email":"miguel@mlavalle.com","username":"minsel"},"change_message_id":"6d2794ec619fcb80c4ee386e25791aefdb637a44","unresolved":false,"context_lines":[{"line_number":254,"context_line":"def _update_segment_host_mapping_for_agent(resource, event, trigger,"},{"line_number":255,"context_line":"                                           context, host, plugin, agent):"},{"line_number":256,"context_line":"    check_segment_for_agent \u003d getattr(plugin, \u0027check_segment_for_agent\u0027, None)"},{"line_number":257,"context_line":"    if not check_segment_for_agent:"},{"line_number":258,"context_line":"        return"},{"line_number":259,"context_line":"    phys_nets \u003d _get_phys_nets(agent)"},{"line_number":260,"context_line":"    if not phys_nets:"}],"source_content_type":"text/x-python","patch_set":3,"id":"3f79a3b5_76ae4fe5","line":257,"range":{"start_line":257,"start_character":5,"end_line":257,"end_character":35},"updated":"2018-11-03 00:54:41.000000000","message":"we need the same check as in L288 below","commit_id":"7570e1be0ae1822e590383df7e998cced045ac9c"},{"author":{"_account_id":4694,"name":"Miguel Lavalle","email":"miguel@mlavalle.com","username":"minsel"},"change_message_id":"6d2794ec619fcb80c4ee386e25791aefdb637a44","unresolved":false,"context_lines":[{"line_number":285,"context_line":"        return"},{"line_number":286,"context_line":"    cp \u003d directory.get_plugin()"},{"line_number":287,"context_line":"    check_segment_for_agent \u003d getattr(cp, \u0027check_segment_for_agent\u0027, None)"},{"line_number":288,"context_line":"    if not directory.get_plugin(\u0027segments\u0027) or not hasattr("},{"line_number":289,"context_line":"            cp, \u0027get_agents\u0027) or not check_segment_for_agent:"},{"line_number":290,"context_line":"        # not an agent-supporting plugin"},{"line_number":291,"context_line":"        registry.unsubscribe(_add_segment_host_mapping_for_segment,"}],"source_content_type":"text/x-python","patch_set":3,"id":"3f79a3b5_e03036ed","line":288,"updated":"2018-11-03 00:54:41.000000000","message":"This is not the proper way to implement this check. It won\u0027t work. After this change, depending on the timing of requests, we may continue adding and updating rows in the segment host mapping. This is why:\n\n1) The ML2 plugin imports the segments service plugin (https://github.com/openstack/neutron/blob/master/neutron/plugins/ml2/plugin.py#L104) to perform this check: https://github.com/openstack/neutron/blob/master/neutron/plugins/ml2/plugin.py#L2011\n\n2) The segments service plugin imports this module (https://github.com/openstack/neutron/blob/master/neutron/services/segments/plugin.py#L45) and the callbacks are registered: https://github.com/openstack/neutron/blob/master/neutron/services/segments/db.py#L325\n\n3) Note that this callback, which is called when networks are deleted, is going to load the segments service plugin: https://github.com/openstack/neutron/blob/master/neutron/services/segments/db.py#L297\n\n4) As a consequence, checking directory.get_plugin(\u0027segments\u0027) becomes true\n\nWhat we need to check is whether the segments service plugin was configures by the user:\n\nhttps://github.com/openstack/neutron/blob/master/doc/source/admin/config-routed-networks.rst#controller-node\n\nIn other words, we need to check whether cfg.CONF.service_plugins includes \u0027segments\u0027 or \u0027neutron.services.segments.plugin:Plugin, (https://github.com/openstack/neutron/blob/master/setup.cfg#L70). If the user configured it, that signals segment host mapping has to be generated. I would advice to include a note clarifying this in the above indicated document","commit_id":"7570e1be0ae1822e590383df7e998cced045ac9c"},{"author":{"_account_id":11975,"name":"Slawek Kaplonski","email":"skaplons@redhat.com","username":"slaweq"},"change_message_id":"2e9471348989005cf7b00931ec7e03aca0c624d3","unresolved":false,"context_lines":[{"line_number":41,"context_line":"def check_user_configured_segment_plugin():"},{"line_number":42,"context_line":"    segment_class \u003d \u0027neutron.services.segments.plugin.Plugin\u0027"},{"line_number":43,"context_line":"    return any(p in cfg.CONF.service_plugins"},{"line_number":44,"context_line":"               for p in [\u0027segments\u0027, segment_class])"},{"line_number":45,"context_line":""},{"line_number":46,"context_line":""},{"line_number":47,"context_line":"class SegmentDbMixin(common_db_mixin.CommonDbMixin):"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_47aaeecf","line":44,"updated":"2018-11-27 08:50:26.000000000","message":"You could do some cache and check it only once instead of checking it every time. Something like:\n\n    _USER_CONFIGURED_SEGMENT_PLUGIN \u003d None\n    def check_user_configured_segment_plugin():\n        global  _USER_CONFIGURED_SEGMENT_PLUGIN\n        if  _USER_CONFIGURED_SEGMENT_PLUGIN is None:\n            segment_class \u003d \u0027neutron.services.segments.plugin.Plugin\u0027\n            _USER_CONFIGURED_SEGMENT_PLUGIN any(p in cfg.CONF.service_plugins\n                for p in [\u0027segments\u0027, segment_class])\n\n        return _USER_CONFIGURED_SEGMENT_PLUGIN","commit_id":"965c4b72e3f533caadf4af6d3397e08ae4e2155f"},{"author":{"_account_id":15309,"name":"zhaobo","email":"bzhaojyathousandy@gmail.com","username":"ZhaoBo"},"change_message_id":"6df86863e790a4b0abdd93900924c086a6246ea7","unresolved":false,"context_lines":[{"line_number":41,"context_line":"def check_user_configured_segment_plugin():"},{"line_number":42,"context_line":"    segment_class \u003d \u0027neutron.services.segments.plugin.Plugin\u0027"},{"line_number":43,"context_line":"    return any(p in cfg.CONF.service_plugins"},{"line_number":44,"context_line":"               for p in [\u0027segments\u0027, segment_class])"},{"line_number":45,"context_line":""},{"line_number":46,"context_line":""},{"line_number":47,"context_line":"class SegmentDbMixin(common_db_mixin.CommonDbMixin):"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_a71e620c","line":44,"in_reply_to":"3f79a3b5_47aaeecf","updated":"2018-11-27 08:57:43.000000000","message":"Oh, yeah. Thank you for pointing out.","commit_id":"965c4b72e3f533caadf4af6d3397e08ae4e2155f"},{"author":{"_account_id":11975,"name":"Slawek Kaplonski","email":"skaplons@redhat.com","username":"slaweq"},"change_message_id":"2828f69cd7b50411fb60c261d6eb0664b1993501","unresolved":false,"context_lines":[{"line_number":265,"context_line":"                                           context, host, plugin, agent,"},{"line_number":266,"context_line":"                                           status):"},{"line_number":267,"context_line":"    check_segment_for_agent \u003d getattr(plugin, \u0027check_segment_for_agent\u0027, None)"},{"line_number":268,"context_line":"    if (not check_user_configured_segment_plugin() or"},{"line_number":269,"context_line":"            not check_segment_for_agent):"},{"line_number":270,"context_line":"        return"},{"line_number":271,"context_line":"    phys_nets \u003d _get_phys_nets(agent)"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_f165264b","line":268,"updated":"2018-11-23 09:02:12.000000000","message":"instead of this function You can probably use something similar to what is done e.g. in l3agent_scheduler module, see https://github.com/openstack/neutron/blob/a388701ddfe628e9a5bd16a78422164799b11ef8/neutron/extensions/l3agentscheduler.py#L47","commit_id":"965c4b72e3f533caadf4af6d3397e08ae4e2155f"},{"author":{"_account_id":15309,"name":"zhaobo","email":"bzhaojyathousandy@gmail.com","username":"ZhaoBo"},"change_message_id":"6df86863e790a4b0abdd93900924c086a6246ea7","unresolved":false,"context_lines":[{"line_number":265,"context_line":"                                           context, host, plugin, agent,"},{"line_number":266,"context_line":"                                           status):"},{"line_number":267,"context_line":"    check_segment_for_agent \u003d getattr(plugin, \u0027check_segment_for_agent\u0027, None)"},{"line_number":268,"context_line":"    if (not check_user_configured_segment_plugin() or"},{"line_number":269,"context_line":"            not check_segment_for_agent):"},{"line_number":270,"context_line":"        return"},{"line_number":271,"context_line":"    phys_nets \u003d _get_phys_nets(agent)"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_8717a6ef","line":268,"in_reply_to":"3f79a3b5_6764cae6","updated":"2018-11-27 08:57:43.000000000","message":"Thanks very much for helping me to clear. ;-)","commit_id":"965c4b72e3f533caadf4af6d3397e08ae4e2155f"},{"author":{"_account_id":11975,"name":"Slawek Kaplonski","email":"skaplons@redhat.com","username":"slaweq"},"change_message_id":"2e9471348989005cf7b00931ec7e03aca0c624d3","unresolved":false,"context_lines":[{"line_number":265,"context_line":"                                           context, host, plugin, agent,"},{"line_number":266,"context_line":"                                           status):"},{"line_number":267,"context_line":"    check_segment_for_agent \u003d getattr(plugin, \u0027check_segment_for_agent\u0027, None)"},{"line_number":268,"context_line":"    if (not check_user_configured_segment_plugin() or"},{"line_number":269,"context_line":"            not check_segment_for_agent):"},{"line_number":270,"context_line":"        return"},{"line_number":271,"context_line":"    phys_nets \u003d _get_phys_nets(agent)"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_6764cae6","line":268,"in_reply_to":"3f79a3b5_9cd08954","updated":"2018-11-27 08:50:26.000000000","message":"Ok, I see now Miguel\u0027s comment. So this approach seems that is good.","commit_id":"965c4b72e3f533caadf4af6d3397e08ae4e2155f"},{"author":{"_account_id":15309,"name":"zhaobo","email":"bzhaojyathousandy@gmail.com","username":"ZhaoBo"},"change_message_id":"141fd77ffa727bf5dc7d9a5bdb11df2c3057ffaf","unresolved":false,"context_lines":[{"line_number":265,"context_line":"                                           context, host, plugin, agent,"},{"line_number":266,"context_line":"                                           status):"},{"line_number":267,"context_line":"    check_segment_for_agent \u003d getattr(plugin, \u0027check_segment_for_agent\u0027, None)"},{"line_number":268,"context_line":"    if (not check_user_configured_segment_plugin() or"},{"line_number":269,"context_line":"            not check_segment_for_agent):"},{"line_number":270,"context_line":"        return"},{"line_number":271,"context_line":"    phys_nets \u003d _get_phys_nets(agent)"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_9cd08954","line":268,"in_reply_to":"3f79a3b5_f165264b","updated":"2018-11-23 09:47:07.000000000","message":"Hi, Thanks for review. But as Miguel\u0027s comments in PS#3, that\u0027s true that we load \"segments\" plugin to delete network segment such as network deleting(which will loading the segment service plugin to delete segment), but no add segment into lib registerd plugins,so this seems another way to do this is check whether the \u0027segments\u0027 is configured in the neutron conf file. This is based on my knowledge, Right? ;-)","commit_id":"965c4b72e3f533caadf4af6d3397e08ae4e2155f"}],"neutron/tests/unit/extensions/test_segment.py":[{"author":{"_account_id":11975,"name":"Slawek Kaplonski","email":"skaplons@redhat.com","username":"slaweq"},"change_message_id":"f4b2b983153c24b2fbe5a3a38f80e7f12491e0f1","unresolved":false,"context_lines":[{"line_number":2676,"context_line":"        db.subscribe()"},{"line_number":2677,"context_line":""},{"line_number":2678,"context_line":"    @mock.patch(\u0027neutron.services.segments.db.map_segment_to_hosts\u0027)"},{"line_number":2679,"context_line":"    def test_no_segmenthostmapping_when_disable_segment(self, mock):"},{"line_number":2680,"context_line":"        with self.network("},{"line_number":2681,"context_line":"                arg_list\u003d(\u0027provider:network_type\u0027,"},{"line_number":2682,"context_line":"                          \u0027provider:physical_network\u0027,"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_596e952d","line":2679,"range":{"start_line":2679,"start_character":62,"end_line":2679,"end_character":66},"updated":"2018-10-24 07:49:23.000000000","message":"Please change this name to something more \"verbose\". Naming this variable in same way how imported module is named might be confusing. Maybe something like map_segment_to_hosts_mock or something similar?","commit_id":"e327570829d91d6e513159cb95a14a93bb42aec1"},{"author":{"_account_id":15309,"name":"zhaobo","email":"bzhaojyathousandy@gmail.com","username":"ZhaoBo"},"change_message_id":"2e5c5c55bf5c34f1cd67a79a19256e618a0a4397","unresolved":false,"context_lines":[{"line_number":2676,"context_line":"        db.subscribe()"},{"line_number":2677,"context_line":""},{"line_number":2678,"context_line":"    @mock.patch(\u0027neutron.services.segments.db.map_segment_to_hosts\u0027)"},{"line_number":2679,"context_line":"    def test_no_segmenthostmapping_when_disable_segment(self, mock):"},{"line_number":2680,"context_line":"        with self.network("},{"line_number":2681,"context_line":"                arg_list\u003d(\u0027provider:network_type\u0027,"},{"line_number":2682,"context_line":"                          \u0027provider:physical_network\u0027,"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_1991fdf7","line":2679,"range":{"start_line":2679,"start_character":62,"end_line":2679,"end_character":66},"in_reply_to":"3f79a3b5_596e952d","updated":"2018-10-24 07:56:37.000000000","message":"Yeah, you are totally correct. Thank you very much. ;-)","commit_id":"e327570829d91d6e513159cb95a14a93bb42aec1"},{"author":{"_account_id":11975,"name":"Slawek Kaplonski","email":"skaplons@redhat.com","username":"slaweq"},"change_message_id":"f4b2b983153c24b2fbe5a3a38f80e7f12491e0f1","unresolved":false,"context_lines":[{"line_number":2685,"context_line":"                   \u0027provider:physical_network\u0027: \u0027phys_net1\u0027,"},{"line_number":2686,"context_line":"                   \u0027provider:segmentation_id\u0027: \u0027400\u0027}) as network:"},{"line_number":2687,"context_line":"            network[\u0027network\u0027]"},{"line_number":2688,"context_line":"        self.assertFalse(mock.mock_calls)"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_7916f1a3","line":2688,"updated":"2018-10-24 07:49:23.000000000","message":"nit: there is method to check that mock is not called:\n\n    mock.assert_not_called()","commit_id":"e327570829d91d6e513159cb95a14a93bb42aec1"},{"author":{"_account_id":15309,"name":"zhaobo","email":"bzhaojyathousandy@gmail.com","username":"ZhaoBo"},"change_message_id":"2e5c5c55bf5c34f1cd67a79a19256e618a0a4397","unresolved":false,"context_lines":[{"line_number":2685,"context_line":"                   \u0027provider:physical_network\u0027: \u0027phys_net1\u0027,"},{"line_number":2686,"context_line":"                   \u0027provider:segmentation_id\u0027: \u0027400\u0027}) as network:"},{"line_number":2687,"context_line":"            network[\u0027network\u0027]"},{"line_number":2688,"context_line":"        self.assertFalse(mock.mock_calls)"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_f99be112","line":2688,"in_reply_to":"3f79a3b5_7916f1a3","updated":"2018-10-24 07:56:37.000000000","message":"Thanks, ;-). Let me change it.","commit_id":"e327570829d91d6e513159cb95a14a93bb42aec1"}]}
