diff options
author | YAMAMOTO Takashi <yamamoto@valinux.co.jp> | 2014-03-12 12:52:28 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-03-16 20:28:08 +0900 |
commit | 6756ff595cd716bc1369d03d8c5b298befb52999 (patch) | |
tree | a882311a5fc9bddda3906ae97c086157f7fd92cb | |
parent | e8d7eafc6d2f5ac3128f6f7fb24cdeb0b3f705ac (diff) |
add ryu.cfg
also, make CONF accessible via RyuApp.CONF.
add a comment to explain the intention.
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/base/app_manager.py | 2 | ||||
-rw-r--r-- | ryu/cfg.py | 35 |
2 files changed, 37 insertions, 0 deletions
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py index 31e99985..669e58bb 100644 --- a/ryu/base/app_manager.py +++ b/ryu/base/app_manager.py @@ -19,6 +19,7 @@ import itertools import logging import sys +from ryu import cfg from ryu import utils from ryu.controller.handler import register_instance, get_dependent_services from ryu.controller.controller import Datapath @@ -120,6 +121,7 @@ class RyuApp(object): self.logger = logging.getLogger(self.__class__.LOGGER_NAME) else: self.logger = logging.getLogger(self.name) + self.CONF = cfg.CONF # prevent accidental creation of instances of this class outside RyuApp class _EventThreadStop(event.EventBase): diff --git a/ryu/cfg.py b/ryu/cfg.py new file mode 100644 index 00000000..871533cb --- /dev/null +++ b/ryu/cfg.py @@ -0,0 +1,35 @@ +# Copyright (C) 2014 Nippon Telegraph and Telephone Corporation. +# Copyright (C) 2014 YAMAMOTO Takashi <yamamoto at valinux co jp> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import oslo.config.cfg + +# there are 3 ways to access the configuration. +# +# a. ryu.cfg.CONF (used to register cli options) +# b. RyuApp.CONF (preferred way for ryu applications) +# c. oslo.config.cfg.CONF +# +# Currently all of above shares a single ConfigOpts instance. +# We will unshare c. (and stop using it) as soon as ofagent neutron agent +# is updated. +# We want to avoid using c. for our options as a python program which embeds +# ryu applications (eg. neutron agent) might want to its own set of cli +# options into it, which can conflict with ours. (Currently there seems +# no conflict for the neutron agent. But who knows?) +# At some point later we might want to unshare a. and b. as well, in order +# to allow app-specific options. + +CONF = oslo.config.cfg.CONF |