ml2配置中port_security 打开后 neutron neutron net-list 报错。 修正port_security.py后neutron-server服务起不来。

shore_go 发布于 2018/08/24 11:50
阅读 137
收藏 0

问题:发现Kilo版本,neutron 模块ml2 配置中:一旦配置 extension_drivers = port_security  ,则neutron net-list 报错如下:
 

4'] get_ports_and_sgs /usr/lib/python2.7/site-packages/neutron/plugins/ml2/db.py:265
2018-08-24 10:33:16.210 2322 DEBUG neutron.plugins.ml2.managers [req-e9af911b-57c9-45bc-9d00-034025549c2b - - - - -] Extended port dict for driver 'port_security' extend_port_dict /usr/lib/python2.7/site-packages/neutron/plugil2/managers.py:798
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher [req-e9af911b-57c9-45bc-9d00-034025549c2b - - - - -] Exception during message handling: 'NoneType' object has no attribute '__getitem__'
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher Traceback (most recent call last):
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 138, in _dispatch_and_reply
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     incoming.message))
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 183, in _dispatch
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     return self._do_dispatch(endpoint, method, ctxt, args)
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 127, in _do_dispatch
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     result = func(ctxt, **new_args)
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/neutron/api/rpc/handlers/securitygroups_rpc.py", line 81, in security_group_info_for_devices
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     ports = self._get_devices_info(devices_info)
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/neutron/api/rpc/handlers/securitygroups_rpc.py", line 50, in _get_devices_info
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     for port in self.plugin.get_ports_from_devices(devices)
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/neutron/plugins/ml2/plugin.py", line 1467, in get_ports_from_devices
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     ports = db.get_ports_and_sgs(port_ids)
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/neutron/plugins/ml2/db.py", line 272, in get_ports_and_sgs
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     for port, sec_groups in ports_to_sg_ids.iteritems()]
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/neutron/plugins/ml2/db.py", line 307, in make_port_dict_with_security_groups
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     port_dict = plugin._make_port_dict(port)
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/neutron/db/db_base_plugin_v2.py", line 933, in _make_port_dict
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     attributes.PORTS, res, port)
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/neutron/db/common_db_mixin.py", line 162, in _apply_dict_extend_functions
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     func(*args)
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/neutron/plugins/ml2/plugin.py", line 498, in _ml2_md_extend_port_dict
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     self.extension_manager.extend_port_dict(session, portdb, result)
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/neutron/plugins/ml2/managers.py", line 796, in extend_port_dict
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     driver.obj.extend_port_dict(session, base_model, result)
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/neutron/plugins/ml2/extensions/port_security.py", line 63, in extend_port_dict
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     self._extend_port_security_dict(result, db_data)
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/neutron/plugins/ml2/extensions/port_security.py", line 67, in _extend_port_security_dict
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher     db_data['port_security'][psec.PORTSECURITY])
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher TypeError: 'NoneType' object has no attribute '__getitem__'
2018-08-24 10:33:16.211 2322 ERROR oslo_messaging.rpc.dispatcher 
2018-08-24 10:33:16.212 2322 ERROR oslo_messaging._drivers.common [req-e9af911b-57c9-45bc-9d00-034025549c2b - - - - -] Returning exception 'NoneType' object has no attribute '__getitem__' to caller
 

看到社区已经发现该问题为bug,参考https://bugs.launchpad.net/neutron/+bug/1461519

修正

neutron/plugins/ml2/extensions/port_security.py

(https://review.openstack.org/#/c/188209/) 

重启neutron-server时还是起不来,提示无法加载/usr/share/neutron/api-paste.ini:

 2018-08-24 11:43:19.230 7304 INFO neutron.plugins.ml2.managers [-] Registered types: ['vlan']
2018-08-24 11:43:19.231 7304 INFO neutron.plugins.ml2.managers [-] Tenant network_types: ['vlan']
2018-08-24 11:43:19.231 7304 INFO neutron.plugins.ml2.managers [-] Configured extension driver names: ['port_security']
2018-08-24 11:43:19.232 7304 ERROR stevedore.extension [-] Could not load 'port_security': unindent does not match any outer indentation level (port_security.py, line 46)
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension [-] unindent does not match any outer indentation level (port_security.py, line 46)
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension Traceback (most recent call last):
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension   File "/usr/lib/python2.7/site-packages/stevedore/extension.py", line 163, in _load_plugins
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension     verify_requirements,
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension   File "/usr/lib/python2.7/site-packages/stevedore/named.py", line 123, in _load_one_plugin
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension     verify_requirements,
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension   File "/usr/lib/python2.7/site-packages/stevedore/extension.py", line 186, in _load_one_plugin
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension     plugin = ep.load(require=verify_requirements)
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension   File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension     entry = __import__(self.module_name, globals(),globals(), ['__name__'])
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension   File "/usr/lib/python2.7/site-packages/neutron/plugins/ml2/extensions/port_security.py", line 46
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension     self._process_network_port_security_create(context, data, result)
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension                                                                     ^
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension IndentationError: unindent does not match any outer indentation level
2018-08-24 11:43:19.233 7304 ERROR stevedore.extension 
2018-08-24 11:43:19.235 7304 DEBUG oslo_concurrency.lockutils [-] Lock "manager" released by "neutron.manager._create_instance" :: held 0.217s inner /usr/lib/python2.7/site-packages/oslo_concurrency/lockutils.py:282
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config [-] Unable to load neutron from configuration file /usr/share/neutron/api-paste.ini.
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config Traceback (most recent call last):
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/neutron/common/config.py", line 248, in load_paste_app
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     app = deploy.loadapp("config:%s" % config_path, name=app_name)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     return loadobj(APP, uri, name=name, **kw)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     return context.create()
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     return self.object_type.invoke(self)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 144, in invoke
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     **context.local_conf)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/util.py", line 56, in fix_call
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     val = callable(*args, **kw)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/urlmap.py", line 25, in urlmap_factory
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     app = loader.get_app(app_name, global_conf=global_conf)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 350, in get_app
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     name=name, global_conf=global_conf).create()
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     return self.object_type.invoke(self)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 144, in invoke
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     **context.local_conf)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/util.py", line 56, in fix_call
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     val = callable(*args, **kw)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/neutron/auth.py", line 71, in pipeline_factory
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     app = loader.get_app(pipeline[-1])
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 350, in get_app
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     name=name, global_conf=global_conf).create()
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     return self.object_type.invoke(self)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     return fix_call(context.object, context.global_conf, **context.local_conf)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/paste/deploy/util.py", line 56, in fix_call
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     val = callable(*args, **kw)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/neutron/api/v2/router.py", line 71, in factory
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     return cls(**local_config)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/neutron/api/v2/router.py", line 75, in __init__
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     plugin = manager.NeutronManager.get_plugin()
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/neutron/manager.py", line 222, in get_plugin
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     return weakref.proxy(cls.get_instance().plugin)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/neutron/manager.py", line 216, in get_instance
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     cls._create_instance()
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/oslo_concurrency/lockutils.py", line 271, in inner
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     return f(*args, **kwargs)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/neutron/manager.py", line 202, in _create_instance
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     cls._instance = cls()
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/neutron/manager.py", line 117, in __init__
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     plugin_provider)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/neutron/manager.py", line 143, in _get_plugin_instance
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     return plugin_class()
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/neutron/plugins/ml2/plugin.py", line 136, in __init__
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     self.extension_manager = managers.ExtensionManager()
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/neutron/plugins/ml2/managers.py", line 708, in __init__
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     name_order=True)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/stevedore/named.py", line 56, in __init__
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     self._init_plugins(extensions)
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/stevedore/named.py", line 112, in _init_plugins
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     self.extensions = [self[n] for n in self._names]
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config   File "/usr/lib/python2.7/site-packages/stevedore/extension.py", line 284, in __getitem__
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config     return self._extensions_by_name[name]
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config KeyError: 'port_security'
2018-08-24 11:43:19.235 7304 ERROR neutron.common.config 
2018-08-24 11:43:19.239 7304 ERROR neutron.service [-] Unrecoverable error: please check log for details.
2018-08-24 11:43:19.239 7304 ERROR neutron.service Traceback (most recent call last):
2018-08-24 11:43:19.239 7304 ERROR neutron.service   File "/usr/lib/python2.7/site-packages/neutron/service.py", line 103, in serve_wsgi
2018-08-24 11:43:19.239 7304 ERROR neutron.service     service.start()
2018-08-24 11:43:19.239 7304 ERROR neutron.service   File "/usr/lib/python2.7/site-packages/neutron/service.py", line 74, in start
2018-08-24 11:43:19.239 7304 ERROR neutron.service     self.wsgi_app = _run_wsgi(self.app_name)
2018-08-24 11:43:19.239 7304 ERROR neutron.service   File "/usr/lib/python2.7/site-packages/neutron/service.py", line 169, in _run_wsgi
2018-08-24 11:43:19.239 7304 ERROR neutron.service     app = config.load_paste_app(app_name)
2018-08-24 11:43:19.239 7304 ERROR neutron.service   File "/usr/lib/python2.7/site-packages/neutron/common/config.py", line 255, in load_paste_app
2018-08-24 11:43:19.239 7304 ERROR neutron.service     raise RuntimeError(msg)
2018-08-24 11:43:19.239 7304 ERROR neutron.service RuntimeError: Unable to load neutron from configuration file /usr/share/neutron/api-paste.ini.
2018-08-24 11:43:19.239 7304 ERROR neutron.service 
有专家知道怎么回事么? 

加载中
返回顶部
顶部