Use ryu.cfg.CONF for options from Ryu

Cherry-picked from networking-ofagent 8bcc1bd80c8e3f4dfecbbabddca8bf4c3d016cb1
Closes-Bug: #1428936
Change-Id: I043a90f2f8addb8348b1842b13cec25d3c1015cb
This commit is contained in:
YAMAMOTO Takashi 2015-02-05 13:55:57 +09:00
parent 91a4593346
commit 61a5506adf
3 changed files with 20 additions and 9 deletions

View File

@ -1,5 +1,5 @@
# Copyright (C) 2014 VA Linux Systems Japan K.K. # Copyright (C) 2014,2015 VA Linux Systems Japan K.K.
# Copyright (C) 2014 YAMAMOTO Takashi <yamamoto at valinux co jp> # Copyright (C) 2014,2015 YAMAMOTO Takashi <yamamoto at valinux co jp>
# Copyright (C) 2014 Fumihiko Kakuma <kakuma at valinux co jp> # Copyright (C) 2014 Fumihiko Kakuma <kakuma at valinux co jp>
# All Rights Reserved. # All Rights Reserved.
# #
@ -26,6 +26,7 @@ import netaddr
from oslo.config import cfg from oslo.config import cfg
from ryu.app.ofctl import api as ryu_api from ryu.app.ofctl import api as ryu_api
from ryu.base import app_manager from ryu.base import app_manager
import ryu.cfg as ryu_cfg
from ryu.controller import handler from ryu.controller import handler
from ryu.controller import ofp_event from ryu.controller import ofp_event
from ryu.lib import hub from ryu.lib import hub
@ -108,12 +109,12 @@ class Bridge(flows.OFAgentIntegrationBridge, ovs_lib.OVSBridge):
protocols='OpenFlow13', protocols='OpenFlow13',
retry_max=cfg.CONF.AGENT.get_datapath_retry_times): retry_max=cfg.CONF.AGENT.get_datapath_retry_times):
if not controller_names: if not controller_names:
host = cfg.CONF.ofp_listen_host host = ryu_cfg.CONF.ofp_listen_host
if not host: if not host:
# 127.0.0.1 is a default for agent style of controller # 127.0.0.1 is a default for agent style of controller
host = '127.0.0.1' host = '127.0.0.1'
controller_names = ["tcp:%s:%d" % (host, controller_names = ["tcp:%s:%d" %
cfg.CONF.ofp_tcp_listen_port)] (host, ryu_cfg.CONF.ofp_tcp_listen_port)]
try: try:
self.set_protocols(protocols) self.set_protocols(protocols)
self.set_controller(controller_names) self.set_controller(controller_names)

View File

@ -1,6 +1,6 @@
# Copyright (C) 2014 VA Linux Systems Japan K.K. # Copyright (C) 2014,2015 VA Linux Systems Japan K.K.
# Copyright (C) 2014 Fumihiko Kakuma <kakuma at valinux co jp> # Copyright (C) 2014 Fumihiko Kakuma <kakuma at valinux co jp>
# Copyright (C) 2014 YAMAMOTO Takashi <yamamoto at valinux co jp> # Copyright (C) 2014,2015 YAMAMOTO Takashi <yamamoto at valinux co jp>
# All Rights Reserved. # All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -98,6 +98,7 @@ class _Mod(object):
def patch_fake_oflib_of(): def patch_fake_oflib_of():
ryu_mod = mock.Mock() ryu_mod = mock.Mock()
ryu_base_mod = ryu_mod.base ryu_base_mod = ryu_mod.base
ryu_cfg_mod = ryu_mod.cfg
ryu_ctrl_mod = ryu_mod.controller ryu_ctrl_mod = ryu_mod.controller
handler = _Mod('ryu.controller.handler') handler = _Mod('ryu.controller.handler')
handler.set_ev_cls = mock.Mock() handler.set_ev_cls = mock.Mock()
@ -128,6 +129,7 @@ def patch_fake_oflib_of():
ryu_ofctl_api = ryu_app_ofctl_mod.api ryu_ofctl_api = ryu_app_ofctl_mod.api
modules = {'ryu': ryu_mod, modules = {'ryu': ryu_mod,
'ryu.base': ryu_base_mod, 'ryu.base': ryu_base_mod,
'ryu.cfg': ryu_cfg_mod,
'ryu.controller': ryu_ctrl_mod, 'ryu.controller': ryu_ctrl_mod,
'ryu.controller.handler': handler, 'ryu.controller.handler': handler,
'ryu.controller.handler.set_ev_cls': handler.set_ev_cls, 'ryu.controller.handler.set_ev_cls': handler.set_ev_cls,

View File

@ -1,6 +1,6 @@
# Copyright (C) 2014 VA Linux Systems Japan K.K. # Copyright (C) 2014,2015 VA Linux Systems Japan K.K.
# Copyright (C) 2014 Fumihiko Kakuma <kakuma at valinux co jp> # Copyright (C) 2014 Fumihiko Kakuma <kakuma at valinux co jp>
# Copyright (C) 2014 YAMAMOTO Takashi <yamamoto at valinux co jp> # Copyright (C) 2014,2015 YAMAMOTO Takashi <yamamoto at valinux co jp>
# All Rights Reserved. # All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -55,6 +55,14 @@ class OFAAgentTestBase(OFATestBase):
def setUp(self): def setUp(self):
super(OFAAgentTestBase, self).setUp() super(OFAAgentTestBase, self).setUp()
ryu_cfg = importutils.import_module('ryu.cfg')
ryu_cfg.CONF = cfg.ConfigOpts()
ryu_cfg.CONF.register_cli_opts([
cfg.StrOpt('ofp-listen-host', default='',
help='openflow listen host'),
cfg.IntOpt('ofp-tcp-listen-port', default=6633,
help='openflow tcp listen port')
])
self.mod_agent = importutils.import_module(self._AGENT_NAME) self.mod_agent = importutils.import_module(self._AGENT_NAME)
self.ryuapp = mock.Mock() self.ryuapp = mock.Mock()