My sampleApp has occurred "AttributeError" as follows
$ sudo ./start_RyuBGPSpeaker.sh
sample_conf.py:1: RuntimeWarning: Parent module 'bgpspeaker' not found
while handling absolute import
import os
INFO 2014-07-20 00:50:25,612 base 207 API method core.start called with
args: {'router_id': '10.10.0.2', 'label_range': (100, 100000), 'waiter':
<ryu.lib.hub.Event object at 0x7f4abf36ae50>, 'local_as': 64512,
'bgp_server_port': 179, 'refresh_max_eor_time': 0,
'refresh_stalepath_time': 0}
INFO 2014-07-20 00:50:25,677 base 207 API method neighbor.create called
with args: {'remote_as': 64511, 'ip_address': '192.168.100.100'}
INFO 2014-07-20 00:50:25,678 base 207 API method network.add called with
args: {'prefix': '10.20.0.0/24'}
INFO 2014-07-20 00:50:25,679 base 207 API method network.add called with
args: {'prefix': '10.30.0.0/24'}
INFO 2014-07-20 00:50:25,679 base 207 API method network.add called with
args: {'prefix': '10.40.0.0/16'}
INFO 2014-07-20 00:50:25,679 base 207 API method network.add called with
args: {'prefix': '10.50.0.0/16'}
ERROR 2014-07-20 00:50:25,683 hub 60 hub: uncaught exception: Traceback
(most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ryu/lib/hub.py", line 52, in
_launch
func(*args, **kwargs)
File
"/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/base.py",
line 243, in start
self._run(*args, **kwargs)
File
"/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/net_ctrl.py",
line 342, in _run
server_thread.wait()
AttributeError: 'tuple' object has no attribute 'wait'
CRITICAL 2014-07-20 00:50:26,699 peer 1759 Connection to peer:
192.168.100.100 established
Signed-off-by: Tsuboi Toshiki <[email protected]>
---
ryu/services/protocols/bgp/net_ctrl.py | 2 +-
ryu/services/protocols/bgp/sampleApp/bgp.ini | 2 +
.../protocols/bgp/sampleApp/sample_conf.py | 109
+++++++++++++++++++++
.../protocols/bgp/sampleApp/start_RyuBGPSpeaker.sh | 22 +++++
4 files changed, 134 insertions(+), 1 deletion(-)
create mode 100644 ryu/services/protocols/bgp/sampleApp/bgp.ini
create mode 100644 ryu/services/protocols/bgp/sampleApp/sample_conf.py
create mode 100755
ryu/services/protocols/bgp/sampleApp/start_RyuBGPSpeaker.sh
diff --git a/ryu/services/protocols/bgp/net_ctrl.py
b/ryu/services/protocols/bgp/net_ctrl.py
index 47cf9d7..6bf2768 100644
--- a/ryu/services/protocols/bgp/net_ctrl.py
+++ b/ryu/services/protocols/bgp/net_ctrl.py
@@ -336,7 +336,7 @@ class _NetworkController(FlexinetPeer, Activity):
sock_addr = (apgw_rpc_bind_ip, apgw_rpc_bind_port)
LOG.debug('NetworkController started listening for connections...')
- server_thread = self._listen_tcp(sock_addr,
self._start_rpc_session)
+ server_thread, listen_sockets = self._listen_tcp(sock_addr,
self._start_rpc_session)
self.pause(0)
server_thread.wait()
diff --git a/ryu/services/protocols/bgp/sampleApp/bgp.ini
b/ryu/services/protocols/bgp/sampleApp/bgp.ini
new file mode 100644
index 0000000..f5be147
--- /dev/null
+++ b/ryu/services/protocols/bgp/sampleApp/bgp.ini
@@ -0,0 +1,2 @@
+[DEFAULT]
+bgp_config_file = sample_conf.py
diff --git a/ryu/services/protocols/bgp/sampleApp/sample_conf.py
b/ryu/services/protocols/bgp/sampleApp/sample_conf.py
new file mode 100644
index 0000000..2db14bf
--- /dev/null
+++ b/ryu/services/protocols/bgp/sampleApp/sample_conf.py
@@ -0,0 +1,109 @@
+import os
+
+#
=============================================================================
+# BGP configuration.
+#
=============================================================================
+BGP = {
+
+ # General BGP configuration.
+ 'routing': {
+ # ASN for this BGP instance.
+ 'local_as': 64512,
+
+ # BGP Router ID.
+ 'router_id': '10.10.0.2',
+
+ # We list all BGP neighbors below. We establish EBGP sessions with
peer
+ # with different AS number then configured above. We will
+ # establish IBGP session if AS number is same.
+ 'bgp_neighbors': {
+ '192.168.100.100': {
+ 'remote_as': 64511,
+ },
+ },
+
+ 'networks': [
+ '10.20.0.0/24',
+ '10.30.0.0/24',
+ '10.40.0.0/16',
+ '10.50.0.0/16',
+ ],
+ },
+
+}
+
+#
=============================================================================
+# Logging configuration.
+#
=============================================================================
+LOGGING = {
+
+ # We use python logging package for logging.
+ 'version': 1,
+ 'disable_existing_loggers': False,
+
+ 'formatters': {
+ 'verbose': {
+ 'format': '%(levelname)s %(asctime)s %(module)s ' +
+ '[%(process)d %(thread)d] %(message)s'
+ },
+ 'simple': {
+ 'format': '%(levelname)s %(asctime)s %(module)s %(lineno)s ' +
+ '%(message)s'
+ },
+ 'stats': {
+ 'format': '%(message)s'
+ },
+ },
+
+ 'handlers': {
+ # Outputs log to console.
+ 'console': {
+ 'level': 'INFO',
+ 'class': 'logging.StreamHandler',
+ 'formatter': 'simple'
+ },
+ 'console_stats': {
+ 'level': 'INFO',
+ 'class': 'logging.StreamHandler',
+ 'formatter': 'stats'
+ },
+ # Rotates log file when its size reaches 10MB.
+ 'log_file': {
+ 'level': 'ERROR',
+ 'class': 'logging.handlers.RotatingFileHandler',
+ 'filename': os.path.join('.', 'bgpspeaker.log'),
+ 'maxBytes': '10000000',
+ 'formatter': 'verbose'
+ },
+ 'stats_file': {
+ 'level': 'INFO',
+ 'class': 'logging.handlers.RotatingFileHandler',
+ 'filename': os.path.join('.', 'statistics_bgps.log'),
+ 'maxBytes': '10000000',
+ 'formatter': 'stats'
+ },
+ },
+
+ # Fine-grained control of logging per instance.
+ 'loggers': {
+ 'bgpspeaker': {
+ 'handlers': ['console', 'log_file'],
+ 'handlers': ['console'],
+ 'level': 'INFO',
+ 'propagate': False,
+ },
+ 'stats': {
+ 'handlers': ['stats_file', 'console_stats'],
+ 'level': 'INFO',
+ 'propagate': False,
+ 'formatter': 'stats',
+ },
+ },
+
+ # Root loggers.
+ 'root': {
+ 'handlers': ['console', 'log_file'],
+ 'level': 'INFO',
+ 'propagate': True,
+ },
+}
diff --git a/ryu/services/protocols/bgp/sampleApp/start_RyuBGPSpeaker.sh
b/ryu/services/protocols/bgp/sampleApp/start_RyuBGPSpeaker.sh
new file mode 100755
index 0000000..8b08062
--- /dev/null
+++ b/ryu/services/protocols/bgp/sampleApp/start_RyuBGPSpeaker.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+import time
+from oslo.config import cfg
+from ryu.lib import hub
+hub.patch()
+from ryu.services.protocols.bgp.application import RyuBGPSpeaker
+
+CONF = cfg.CONF
+
+def main():
+ CONF(default_config_files=['bgp.ini'])
+ bgp_router = RyuBGPSpeaker()
+ bgp_router.start()
+
+ while True:
+ time.sleep(999)
+
+
+if __name__ == "__main__":
+ main()
+
--
1.9.1
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel