diff options
author | Kevin_Zheng <zhengzhenyu@huawei.com> | 2016-01-29 14:12:50 +0800 |
---|---|---|
committer | Kevin_Zheng <zhengzhenyu@huawei.com> | 2016-03-29 23:47:50 +0800 |
commit | 8b0b54bd4690f6bb63747b7e4fae02bfbaa69b84 (patch) | |
tree | d65bf10e14f08c890617108337bc15f953782a8f /nova | |
parent | ce018ecceab3e6101af7b1e1504c50716860cebd (diff) | |
download | nova-8b0b54bd4690f6bb63747b7e4fae02bfbaa69b84.tar.gz |
config options: centralize section: "keymgr"
The config options of the "nova.conf" section "keymgr" and
"barbican" got moved to the new central location "nova/conf/keymgr.py"
Change-Id: I018c3a408a8903be8d006760994de6947fb91168
Implements: blueprint centralize-config-options-newton
Diffstat (limited to 'nova')
-rw-r--r-- | nova/conf/__init__.py | 8 | ||||
-rw-r--r-- | nova/conf/barbican.py | 46 | ||||
-rw-r--r-- | nova/conf/keymgr.py | 40 | ||||
-rw-r--r-- | nova/keymgr/__init__.py | 11 | ||||
-rw-r--r-- | nova/keymgr/barbican.py | 25 | ||||
-rw-r--r-- | nova/keymgr/conf_key_mgr.py | 10 | ||||
-rw-r--r-- | nova/opts.py | 9 |
7 files changed, 98 insertions, 51 deletions
diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py index 439429486c..d3a2b4ea1d 100644 --- a/nova/conf/__init__.py +++ b/nova/conf/__init__.py @@ -23,7 +23,7 @@ from oslo_config import cfg # from nova.conf import api_database from nova.conf import availability_zone # from nova.conf import aws -# from nova.conf import barbican +from nova.conf import barbican # from nova.conf import base from nova.conf import cells from nova.conf import cert @@ -48,7 +48,7 @@ from nova.conf import hyperv # from nova.conf import imagecache # from nova.conf import image_file_url from nova.conf import ironic -# from nova.conf import keymgr +from nova.conf import keymgr # from nova.conf import keystone_authtoken # from nova.conf import libvirt # from nova.conf import matchmaker_redis @@ -83,7 +83,7 @@ CONF = cfg.CONF # api_database.register_opts(CONF) availability_zone.register_opts(CONF) # aws.register_opts(CONF) -# barbican.register_opts(CONF) +barbican.register_opts(CONF) # base.register_opts(CONF) cells.register_opts(CONF) cert.register_opts(CONF) @@ -108,7 +108,7 @@ hyperv.register_opts(CONF) # imagecache.register_opts(CONF) # image_file_url.register_opts(CONF) ironic.register_opts(CONF) -# keymgr.register_opts(CONF) +keymgr.register_opts(CONF) # keystone_authtoken.register_opts(CONF) # libvirt.register_opts(CONF) # matchmaker_redis.register_opts(CONF) diff --git a/nova/conf/barbican.py b/nova/conf/barbican.py new file mode 100644 index 0000000000..23de3f7c3b --- /dev/null +++ b/nova/conf/barbican.py @@ -0,0 +1,46 @@ +# 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 keystoneauth1 import loading as ks_loading +from oslo_config import cfg + +barbican_group = cfg.OptGroup( + 'barbican', + title='Barbican options') + +barbican_opts = [ + cfg.StrOpt('catalog_info', + default='key-manager:barbican:public', + help='Info to match when looking for barbican in the service ' + 'catalog. Format is: separated values of the form: ' + '<service_type>:<service_name>:<endpoint_type>'), + cfg.StrOpt('endpoint_template', + help='Override service catalog lookup with template for ' + 'barbican endpoint e.g. ' + 'http://localhost:9311/v1/%(project_id)s'), + cfg.StrOpt('os_region_name', + help='Region name of this node'), +] + + +def register_opts(conf): + conf.register_group(barbican_group) + conf.register_opts(barbican_opts, group=barbican_group) + ks_loading.register_session_conf_options(conf, barbican_group) + + +def list_opts(): + return { + barbican_group.name: barbican_opts + } diff --git a/nova/conf/keymgr.py b/nova/conf/keymgr.py new file mode 100644 index 0000000000..98eee6f269 --- /dev/null +++ b/nova/conf/keymgr.py @@ -0,0 +1,40 @@ +# Copyright 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 + +keymgr_group = cfg.OptGroup( + 'keymgr', + title='Key manager options') + +keymgr_opts = [ + cfg.StrOpt('api_class', + default='nova.keymgr.conf_key_mgr.ConfKeyManager', + help='The full class name of the key manager API class'), + cfg.StrOpt( + 'fixed_key', + help='Fixed key returned by key manager, specified in hex'), +] + + +def register_opts(conf): + conf.register_group(keymgr_group) + conf.register_opts(keymgr_opts, group=keymgr_group) + + +def list_opts(): + return { + keymgr_group.name: keymgr_opts + } diff --git a/nova/keymgr/__init__.py b/nova/keymgr/__init__.py index 79880b4d70..5e10b395b7 100644 --- a/nova/keymgr/__init__.py +++ b/nova/keymgr/__init__.py @@ -14,18 +14,11 @@ # under the License. -from oslo_config import cfg from oslo_utils import importutils +import nova.conf -keymgr_opts = [ - cfg.StrOpt('api_class', - default='nova.keymgr.conf_key_mgr.ConfKeyManager', - help='The full class name of the key manager API class'), -] - -CONF = cfg.CONF -CONF.register_opts(keymgr_opts, group='keymgr') +CONF = nova.conf.CONF def API(): diff --git a/nova/keymgr/barbican.py b/nova/keymgr/barbican.py index 99bd76eab8..50faf8ea29 100644 --- a/nova/keymgr/barbican.py +++ b/nova/keymgr/barbican.py @@ -24,36 +24,19 @@ import binascii from barbicanclient import client as barbican_client from keystoneauth1 import loading as ks_loading from keystoneauth1 import session -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils +import nova.conf + from nova import exception from nova.i18n import _ from nova.i18n import _LE from nova.keymgr import key as keymgr_key from nova.keymgr import key_mgr -barbican_opts = [ - cfg.StrOpt('catalog_info', - default='key-manager:barbican:public', - help='Info to match when looking for barbican in the service ' - 'catalog. Format is: separated values of the form: ' - '<service_type>:<service_name>:<endpoint_type>'), - cfg.StrOpt('endpoint_template', - help='Override service catalog lookup with template for ' - 'barbican endpoint e.g. ' - 'http://localhost:9311/v1/%(project_id)s'), - cfg.StrOpt('os_region_name', - help='Region name of this node'), -] - -CONF = cfg.CONF -BARBICAN_OPT_GROUP = 'barbican' - -CONF.register_opts(barbican_opts, group=BARBICAN_OPT_GROUP) -ks_loading.register_session_conf_options(CONF, BARBICAN_OPT_GROUP) +CONF = nova.conf.CONF LOG = logging.getLogger(__name__) @@ -92,7 +75,7 @@ class BarbicanKeyManager(key_mgr.KeyManager): try: _SESSION = ks_loading.load_session_from_conf_options( CONF, - BARBICAN_OPT_GROUP) + nova.conf.barbican.barbican_group) auth = ctxt.get_auth_plugin() service_type, service_name, interface = (CONF. diff --git a/nova/keymgr/conf_key_mgr.py b/nova/keymgr/conf_key_mgr.py index fac967429f..1e0a1ce14e 100644 --- a/nova/keymgr/conf_key_mgr.py +++ b/nova/keymgr/conf_key_mgr.py @@ -31,18 +31,12 @@ encrypted with a key provided by this key manager actually share the same encryption key so *any* volume can be decrypted once the fixed key is known. """ -from oslo_config import cfg - +import nova.conf from nova.i18n import _ from nova.keymgr import single_key_mgr -key_mgr_opts = [ - cfg.StrOpt('fixed_key', - help='Fixed key returned by key manager, specified in hex'), -] -CONF = cfg.CONF -CONF.register_opts(key_mgr_opts, group='keymgr') +CONF = nova.conf.CONF class ConfKeyManager(single_key_mgr.SingleKeyManager): diff --git a/nova/opts.py b/nova/opts.py index e2bf31d0a7..9cf184236b 100644 --- a/nova/opts.py +++ b/nova/opts.py @@ -35,9 +35,6 @@ import nova.exception import nova.image.download.file import nova.image.glance import nova.ipv6.api -import nova.keymgr -import nova.keymgr.barbican -import nova.keymgr.conf_key_mgr import nova.netconf import nova.notifications import nova.objects.network @@ -80,17 +77,11 @@ def list_opts(): nova.utils.utils_opts, nova.volume._volume_opts, )), - ('barbican', nova.keymgr.barbican.barbican_opts), ('cinder', nova.volume.cinder.cinder_opts), ('api_database', nova.db.sqlalchemy.api.api_db_opts), ('database', nova.db.sqlalchemy.api.oslo_db_options.database_opts), ('glance', nova.image.glance.glance_opts), ('image_file_url', [nova.image.download.file.opt_group]), - ('keymgr', - itertools.chain( - nova.keymgr.conf_key_mgr.key_mgr_opts, - nova.keymgr.keymgr_opts, - )), ('spice', itertools.chain( nova.cmd.spicehtml5proxy.opts, |