diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2016-11-15 11:23:17 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-11-15 20:58:18 +0900 |
commit | 8065784ab119c273f9dae6d006f656881f6fad74 (patch) | |
tree | bf56873f52a91b7c17a7efe416967417c602b24d | |
parent | 2b57fadd2c00d7f0218c6af0a00f4a63e6176959 (diff) |
BGPSpeaker: Confirm SSH feature to be optional
paramiko, which python library is used in bgp.operator.ssh, is defined
as the optional requirements.
This patch avoid to import this library in BGPSpeaker by the default.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/services/protocols/bgp/application.py | 6 | ||||
-rw-r--r-- | ryu/services/protocols/bgp/bgpspeaker.py | 17 |
2 files changed, 14 insertions, 9 deletions
diff --git a/ryu/services/protocols/bgp/application.py b/ryu/services/protocols/bgp/application.py index c8d0f6af..9a85fe16 100644 --- a/ryu/services/protocols/bgp/application.py +++ b/ryu/services/protocols/bgp/application.py @@ -31,7 +31,6 @@ from ryu.services.protocols.bgp.bgpspeaker import BGPSpeaker from ryu.services.protocols.bgp.net_ctrl import NET_CONTROLLER from ryu.services.protocols.bgp.net_ctrl import NC_RPC_BIND_IP from ryu.services.protocols.bgp.net_ctrl import NC_RPC_BIND_PORT -from ryu.services.protocols.bgp.operator.ssh import SSH_CLI_CONTROLLER from ryu.services.protocols.bgp.rtconf.base import RuntimeConfigError from ryu.services.protocols.bgp.rtconf.common import BGP_SERVER_PORT from ryu.services.protocols.bgp.rtconf.common import DEFAULT_BGP_SERVER_PORT @@ -123,7 +122,10 @@ class RyuBGPSpeaker(RyuApp): # Configure SSH settings, if available. if hasattr(settings, 'SSH'): LOG.debug('Loading SSH settings...') - hub.spawn(SSH_CLI_CONTROLLER.start, **settings.SSH) + # Note: paramiko used in bgp.operator.ssh is the optional + # requirements, imports bgp.operator.ssh here. + from ryu.services.protocols.bgp.operator import ssh + hub.spawn(ssh.SSH_CLI_CONTROLLER.start, **settings.SSH) # Start RPC server with the given RPC settings. rpc_settings = { diff --git a/ryu/services/protocols/bgp/bgpspeaker.py b/ryu/services/protocols/bgp/bgpspeaker.py index 4a1ce977..c56f8dd7 100644 --- a/ryu/services/protocols/bgp/bgpspeaker.py +++ b/ryu/services/protocols/bgp/bgpspeaker.py @@ -44,7 +44,6 @@ from ryu.services.protocols.bgp.api.prefix import TUNNEL_TYPE_NVGRE from ryu.services.protocols.bgp.api.prefix import ( PMSI_TYPE_NO_TUNNEL_INFO, PMSI_TYPE_INGRESS_REP) -from ryu.services.protocols.bgp.operator import ssh from ryu.services.protocols.bgp.rtconf.common import LOCAL_AS from ryu.services.protocols.bgp.rtconf.common import ROUTER_ID from ryu.services.protocols.bgp.rtconf.common import BGP_SERVER_PORT @@ -165,9 +164,7 @@ class BGPSpeaker(object): peer_down_handler=None, peer_up_handler=None, ssh_console=False, - ssh_port=ssh.DEFAULT_SSH_PORT, - ssh_host=ssh.DEFAULT_SSH_HOST, - ssh_host_key=ssh.DEFAULT_SSH_HOST_KEY, + ssh_port=None, ssh_host=None, ssh_host_key=None, label_range=DEFAULT_LABEL_RANGE): """Create a new BGPSpeaker object with as_number and router_id to listen on bgp_server_port. @@ -205,11 +202,14 @@ class BGPSpeaker(object): ``ssh_console`` specifies whether or not SSH CLI need to be started. ``ssh_port`` specifies the port number for SSH CLI server. + The default is bgp.operator.ssh.DEFAULT_SSH_PORT. ``ssh_host`` specifies the IP address for SSH CLI server. + The default is bgp.operator.ssh.DEFAULT_SSH_HOST. ``ssh_host_key`` specifies the path to the host key added to the keys list used by SSH CLI server. + The default is bgp.operator.ssh.DEFAULT_SSH_HOST_KEY. ``label_range`` specifies the range of MPLS labels generated automatically. @@ -230,10 +230,13 @@ class BGPSpeaker(object): self._peer_down_handler = peer_down_handler self._peer_up_handler = peer_up_handler if ssh_console: + # Note: paramiko used in bgp.operator.ssh is the optional + # requirements, imports bgp.operator.ssh here. + from ryu.services.protocols.bgp.operator import ssh ssh_settings = { - ssh.SSH_PORT: ssh_port, - ssh.SSH_HOST: ssh_host, - ssh.SSH_HOST_KEY: ssh_host_key, + ssh.SSH_PORT: ssh_port or ssh.DEFAULT_SSH_PORT, + ssh.SSH_HOST: ssh_host or ssh.DEFAULT_SSH_HOST, + ssh.SSH_HOST_KEY: ssh_host_key or ssh.DEFAULT_SSH_HOST_KEY, } hub.spawn(ssh.SSH_CLI_CONTROLLER.start, **ssh_settings) |