Moved config options of metadata_service_app

Configuration options of metadata_service_app has been moved to
dragonflow/conf/df_metadata_service.py.

Change-Id: I546d39817681464744998db1abd046677e9669a2
Partially-Implements: blueprint centralize-config-options
This commit is contained in:
Rajiv Kumar 2016-11-07 11:33:56 +05:30 committed by Omer Anson
parent ae0fa42aa6
commit 64fc2162e1
8 changed files with 70 additions and 31 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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}

View File

@ -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)]

View File

@ -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

View File

@ -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'

View File

@ -1,4 +1,4 @@
[DEFAULT]
output_file = etc/dragonflow.ini.sample
wrap_width = 79
namespace = dragonflow
namespace = dragonflow.conf

View File

@ -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