diff --git a/watcher/common/clients.py b/watcher/common/clients.py index 0edc3d4da..f1227aa58 100644 --- a/watcher/common/clients.py +++ b/watcher/common/clients.py @@ -19,47 +19,14 @@ from neutronclient.neutron import client as netclient from novaclient import client as nvclient from oslo_config import cfg -from watcher._i18n import _ from watcher.common import exception +from watcher import conf -NOVA_CLIENT_OPTS = [ - cfg.StrOpt('api_version', - default='2', - help=_('Version of Nova API to use in novaclient.'))] - -GLANCE_CLIENT_OPTS = [ - cfg.StrOpt('api_version', - default='2', - help=_('Version of Glance API to use in glanceclient.'))] - -CINDER_CLIENT_OPTS = [ - cfg.StrOpt('api_version', - default='2', - help=_('Version of Cinder API to use in cinderclient.'))] - -CEILOMETER_CLIENT_OPTS = [ - cfg.StrOpt('api_version', - default='2', - help=_('Version of Ceilometer API to use in ' - 'ceilometerclient.'))] - -NEUTRON_CLIENT_OPTS = [ - cfg.StrOpt('api_version', - default='2.0', - help=_('Version of Neutron API to use in neutronclient.'))] - -cfg.CONF.register_opts(NOVA_CLIENT_OPTS, group='nova_client') -cfg.CONF.register_opts(GLANCE_CLIENT_OPTS, group='glance_client') -cfg.CONF.register_opts(CINDER_CLIENT_OPTS, group='cinder_client') -cfg.CONF.register_opts(CEILOMETER_CLIENT_OPTS, group='ceilometer_client') -cfg.CONF.register_opts(NEUTRON_CLIENT_OPTS, group='neutron_client') +CONF = conf.CONF _CLIENTS_AUTH_GROUP = 'watcher_clients_auth' -ka_loading.register_auth_conf_options(cfg.CONF, _CLIENTS_AUTH_GROUP) -ka_loading.register_session_conf_options(cfg.CONF, _CLIENTS_AUTH_GROUP) - class OpenStackClients(object): """Convenience class to create and cache client instances.""" diff --git a/watcher/conf/__init__.py b/watcher/conf/__init__.py index ec8a48fab..e68cdbc19 100644 --- a/watcher/conf/__init__.py +++ b/watcher/conf/__init__.py @@ -21,9 +21,15 @@ from oslo_config import cfg from watcher.conf import api from watcher.conf import applier +from watcher.conf import ceilometer_client +from watcher.conf import cinder_client +from watcher.conf import clients_auth from watcher.conf import db from watcher.conf import decision_engine from watcher.conf import exception +from watcher.conf import glance_client +from watcher.conf import neutron_client +from watcher.conf import nova_client from watcher.conf import paths from watcher.conf import planner from watcher.conf import service @@ -40,3 +46,9 @@ db.register_opts(CONF) planner.register_opts(CONF) applier.register_opts(CONF) decision_engine.register_opts(CONF) +nova_client.register_opts(CONF) +glance_client.register_opts(CONF) +cinder_client.register_opts(CONF) +ceilometer_client.register_opts(CONF) +neutron_client.register_opts(CONF) +clients_auth.register_opts(CONF) diff --git a/watcher/conf/_opts.py b/watcher/conf/_opts.py index c036c8baa..73398f196 100644 --- a/watcher/conf/_opts.py +++ b/watcher/conf/_opts.py @@ -18,12 +18,16 @@ from keystoneauth1 import loading as ka_loading -from watcher.common import clients from watcher.conf import api as conf_api from watcher.conf import applier as conf_applier +from watcher.conf import ceilometer_client as conf_ceilometer_client +from watcher.conf import cinder_client as conf_cinder_client from watcher.conf import db from watcher.conf import decision_engine as conf_de from watcher.conf import exception +from watcher.conf import glance_client as conf_glance_client +from watcher.conf import neutron_client as conf_neutron_client +from watcher.conf import nova_client as conf_nova_client from watcher.conf import paths from watcher.conf import planner as conf_planner from watcher.conf import utils @@ -44,11 +48,11 @@ def list_opts(): ('watcher_decision_engine', (conf_de.WATCHER_DECISION_ENGINE_OPTS + conf_de.WATCHER_CONTINUOUS_OPTS)), - ('nova_client', clients.NOVA_CLIENT_OPTS), - ('glance_client', clients.GLANCE_CLIENT_OPTS), - ('cinder_client', clients.CINDER_CLIENT_OPTS), - ('ceilometer_client', clients.CEILOMETER_CLIENT_OPTS), - ('neutron_client', clients.NEUTRON_CLIENT_OPTS), + ('nova_client', conf_nova_client.NOVA_CLIENT_OPTS), + ('glance_client', conf_glance_client.GLANCE_CLIENT_OPTS), + ('cinder_client', conf_cinder_client.CINDER_CLIENT_OPTS), + ('ceilometer_client', conf_ceilometer_client.CEILOMETER_CLIENT_OPTS), + ('neutron_client', conf_neutron_client.NEUTRON_CLIENT_OPTS), ('watcher_clients_auth', (ka_loading.get_auth_common_conf_options() + ka_loading.get_auth_plugin_conf_options('password') + diff --git a/watcher/conf/ceilometer_client.py b/watcher/conf/ceilometer_client.py new file mode 100644 index 000000000..184fa6eb5 --- /dev/null +++ b/watcher/conf/ceilometer_client.py @@ -0,0 +1,37 @@ +# -*- encoding: utf-8 -*- +# Copyright (c) 2016 Intel Corp +# +# Authors: Prudhvi Rao Shedimbi +# +# 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 + +ceilometer_client = cfg.OptGroup(name='ceilometer_client', + title='Configuration Options for Ceilometer') + +CEILOMETER_CLIENT_OPTS = [ + cfg.StrOpt('api_version', + default='2', + help='Version of Ceilometer API to use in ' + 'ceilometerclient.')] + + +def register_opts(conf): + conf.register_group(ceilometer_client) + conf.register_opts(CEILOMETER_CLIENT_OPTS, group=ceilometer_client) + + +def list_opts(): + return [('ceilometer_client', CEILOMETER_CLIENT_OPTS)] diff --git a/watcher/conf/cinder_client.py b/watcher/conf/cinder_client.py new file mode 100644 index 000000000..6021fadec --- /dev/null +++ b/watcher/conf/cinder_client.py @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- +# Copyright (c) 2016 Intel Corp +# +# Authors: Prudhvi Rao Shedimbi +# +# 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 + +cinder_client = cfg.OptGroup(name='cinder_client', + title='Configuration Options for Cinder') + +CINDER_CLIENT_OPTS = [ + cfg.StrOpt('api_version', + default='2', + help='Version of Cinder API to use in cinderclient.')] + + +def register_opts(conf): + conf.register_group(cinder_client) + conf.register_opts(CINDER_CLIENT_OPTS, group=cinder_client) + + +def list_opts(): + return [('cinder_client', CINDER_CLIENT_OPTS)] diff --git a/watcher/conf/clients_auth.py b/watcher/conf/clients_auth.py new file mode 100644 index 000000000..8e959fcdf --- /dev/null +++ b/watcher/conf/clients_auth.py @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- +# Copyright (c) 2016 Intel Corp +# +# Authors: Prudhvi Rao Shedimbi +# +# 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 keystoneauth1 import loading as ka_loading + +WATCHER_CLIENTS_AUTH = 'watcher_clients_auth' + + +def register_opts(conf): + ka_loading.register_session_conf_options(conf, WATCHER_CLIENTS_AUTH) + ka_loading.register_auth_conf_options(conf, WATCHER_CLIENTS_AUTH) + + +def list_opts(): + return [('watcher_clients_auth', ka_loading.get_session_conf_options() + + ka_loading.get_auth_common_conf_options())] diff --git a/watcher/conf/glance_client.py b/watcher/conf/glance_client.py new file mode 100644 index 000000000..a796ffdff --- /dev/null +++ b/watcher/conf/glance_client.py @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- +# Copyright (c) 2016 Intel Corp +# +# Authors: Prudhvi Rao Shedimbi +# +# 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 + +glance_client = cfg.OptGroup(name='glance_client', + title='Configuration Options for Glance') + +GLANCE_CLIENT_OPTS = [ + cfg.StrOpt('api_version', + default='2', + help='Version of Glance API to use in glanceclient.')] + + +def register_opts(conf): + conf.register_group(glance_client) + conf.register_opts(GLANCE_CLIENT_OPTS, group=glance_client) + + +def list_opts(): + return [('glance_client', GLANCE_CLIENT_OPTS)] diff --git a/watcher/conf/neutron_client.py b/watcher/conf/neutron_client.py new file mode 100644 index 000000000..15d089fe3 --- /dev/null +++ b/watcher/conf/neutron_client.py @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- +# Copyright (c) 2016 Intel Corp +# +# Authors: Prudhvi Rao Shedimbi +# +# 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 + +neutron_client = cfg.OptGroup(name='neutron_client', + title='Configuration Options for Neutron') + +NEUTRON_CLIENT_OPTS = [ + cfg.StrOpt('api_version', + default='2.0', + help='Version of Neutron API to use in neutronclient.')] + + +def register_opts(conf): + conf.register_group(neutron_client) + conf.register_opts(NEUTRON_CLIENT_OPTS, group=neutron_client) + + +def list_opts(): + return [('neutron_client', NEUTRON_CLIENT_OPTS)] diff --git a/watcher/conf/nova_client.py b/watcher/conf/nova_client.py new file mode 100644 index 000000000..64f969c5f --- /dev/null +++ b/watcher/conf/nova_client.py @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- +# Copyright (c) 2016 Intel Corp +# +# Authors: Prudhvi Rao Shedimbi +# +# 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 + +nova_client = cfg.OptGroup(name='nova_client', + title='Configuration Options for Nova') + +NOVA_CLIENT_OPTS = [ + cfg.StrOpt('api_version', + default='2', + help='Version of Nova API to use in novaclient.')] + + +def register_opts(conf): + conf.register_group(nova_client) + conf.register_opts(NOVA_CLIENT_OPTS, group=nova_client) + + +def list_opts(): + return [('nova_client', NOVA_CLIENT_OPTS)]