diff --git a/dragonflow/cmd/eventlet/df_metadata_service.py b/dragonflow/cmd/eventlet/df_metadata_service.py index fc35c6b7a..1040dda02 100644 --- a/dragonflow/cmd/eventlet/df_metadata_service.py +++ b/dragonflow/cmd/eventlet/df_metadata_service.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_log import log from neutron.agent.common import utils @@ -21,6 +20,7 @@ from neutron import wsgi from dragonflow._i18n import _LI from dragonflow.common import common_params +from dragonflow import conf as cfg from dragonflow.controller import metadata_service_app import sys @@ -72,8 +72,6 @@ def main(): metadata_conf.register_meta_conf_opts( metadata_conf.METADATA_PROXY_HANDLER_OPTS) cfg.CONF.register_opts(common_params.DF_OPTS, 'df') - cfg.CONF.register_opts(metadata_service_app.DF_METADATA_OPTS, - 'df_metadata') config.init(sys.argv[1:]) config.setup_logging() environment_setup() diff --git a/dragonflow/conf/__init__.py b/dragonflow/conf/__init__.py new file mode 100644 index 000000000..640a0dea0 --- /dev/null +++ b/dragonflow/conf/__init__.py @@ -0,0 +1,21 @@ +# 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. + +from oslo_config import cfg + +from dragonflow.conf import df_metadata_service + + +CONF = cfg.CONF + + +df_metadata_service.register_opts() diff --git a/dragonflow/conf/df_metadata_service.py b/dragonflow/conf/df_metadata_service.py new file mode 100644 index 000000000..110f8ddaa --- /dev/null +++ b/dragonflow/conf/df_metadata_service.py @@ -0,0 +1,41 @@ +# Copyright (c) 2016 OpenStack Foundation. +# All Rights Reserved. +# +# 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. + + +from oslo_config import cfg + +from dragonflow._i18n import _ + + +df_metadata_opts = [ + cfg.IPOpt( + 'ip', + default='169.254.169.254', + help=_('The IP to which the DF metadata service proxy is bound'), + ), + cfg.PortOpt( + 'port', + default='18080', + help=_('The port to which the DF metadata service proxy is bound'), + ), +] + + +def register_opts(): + cfg.CONF.register_opts(df_metadata_opts, group='df_metadata') + + +def list_opts(): + return {'df_metadata': df_metadata_opts} diff --git a/dragonflow/opts.py b/dragonflow/conf/opts.py similarity index 86% rename from dragonflow/opts.py rename to dragonflow/conf/opts.py index 02057cf88..c7e202929 100644 --- a/dragonflow/opts.py +++ b/dragonflow/conf/opts.py @@ -10,17 +10,12 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg - from dragonflow.common import common_params +from dragonflow.conf import df_metadata_service from dragonflow.controller import df_local_controller from dragonflow.controller import dhcp_app from dragonflow.controller import dnat_app from dragonflow.controller import l2_ml2_app -from dragonflow.controller import metadata_service_app - - -CONF = cfg.CONF def list_opts(): @@ -30,4 +25,4 @@ def list_opts(): ('df_dhcp_app', dhcp_app.DF_DHCP_OPTS), ('df_dnat_app', dnat_app.DF_DNAT_APP_OPTS), ('df_l2_app', l2_ml2_app.DF_L2_APP_OPTS), - ('df_metadata', metadata_service_app.DF_METADATA_OPTS)] + ('df_metadata', df_metadata_service.df_metadata_opts)] diff --git a/dragonflow/controller/metadata_service_app.py b/dragonflow/controller/metadata_service_app.py index 9eeb1b84a..7d477e7a1 100644 --- a/dragonflow/controller/metadata_service_app.py +++ b/dragonflow/controller/metadata_service_app.py @@ -21,13 +21,13 @@ import six import six.moves.urllib.parse as urlparse import webob -from oslo_config import cfg from oslo_log import log from oslo_utils import encodeutils from dragonflow._i18n import _, _LW, _LE from dragonflow.common import exceptions from dragonflow.common import utils as df_utils +from dragonflow import conf as cfg from dragonflow.controller.common import arp_responder from dragonflow.controller.common import constants as const from dragonflow.controller import df_base_app @@ -50,20 +50,6 @@ TCP_SYN = 0x002 TCP_ACK = 0x010 -DF_METADATA_OPTS = [ - cfg.IPOpt( - 'ip', - default='169.254.169.254', - help=_('The IP to which the DF metadata service proxy is bound'), - ), - cfg.PortOpt( - 'port', - default='18080', - help=_('The port to which the DF metadata service proxy is bound'), - ), -] - - class MetadataServiceApp(df_base_app.DFlowApp): def __init__(self, api, db_store=None, vswitch_api=None, nb_api=None): super(MetadataServiceApp, self).__init__( @@ -75,7 +61,6 @@ class MetadataServiceApp(df_base_app.DFlowApp): self._arp_responder = None self._ofport = None self._interface_mac = "" - cfg.CONF.register_opts(DF_METADATA_OPTS, group='df_metadata') self._ip = cfg.CONF.df_metadata.ip self._port = cfg.CONF.df_metadata.port self._interface = cfg.CONF.df.metadata_interface diff --git a/dragonflow/tests/fullstack/test_metadata_service.py b/dragonflow/tests/fullstack/test_metadata_service.py index 0044bdbfe..9a15e79a5 100644 --- a/dragonflow/tests/fullstack/test_metadata_service.py +++ b/dragonflow/tests/fullstack/test_metadata_service.py @@ -18,7 +18,7 @@ from neutron.agent.linux import ip_lib from dragonflow._i18n import _LE from dragonflow.cmd.eventlet import df_metadata_service -from dragonflow.controller import metadata_service_app +from dragonflow.conf import df_metadata_service as df_metadata_service_conf from dragonflow.tests.fullstack import test_base @@ -29,8 +29,7 @@ class TestMetadataService(test_base.DFTestBase): def setUp(self): super(TestMetadataService, self).setUp() - cfg.CONF.register_opts(metadata_service_app.DF_METADATA_OPTS, - group='df_metadata') + df_metadata_service_conf.register_opts() # Override defaults to avoid collision with existing metadata service cfg.CONF.df_metadata.ip = '1.1.1.1' cfg.CONF.df.metadata_interface = 'tap-md-test' diff --git a/etc/oslo-config-generator/dragonflow.ini b/etc/oslo-config-generator/dragonflow.ini index 40590e5b7..99587751c 100644 --- a/etc/oslo-config-generator/dragonflow.ini +++ b/etc/oslo-config-generator/dragonflow.ini @@ -1,4 +1,4 @@ [DEFAULT] output_file = etc/dragonflow.ini.sample wrap_width = 79 -namespace = dragonflow +namespace = dragonflow.conf diff --git a/setup.cfg b/setup.cfg index 5b376cd18..d34331031 100644 --- a/setup.cfg +++ b/setup.cfg @@ -74,4 +74,4 @@ dragonflow.port_status_driver = neutron.service_plugins = df-l3 = dragonflow.neutron.services.l3_router_plugin:DFL3RouterPlugin oslo.config.opts = - dragonflow = dragonflow.opts:list_opts + dragonflow.conf = dragonflow.conf.opts:list_opts