Decouple Image Import Plugin Opts

This change decouples Image Import Plugin Options from glance/opts.py
so that the deployer who wishes to add 3rd party plugin does not
need to inject the details to the file that is cluttered with all
Glance internal details.

Change-Id: Idc31dbb673efae224c97d2cafa4afa053e049c76
Closes-Bug: #1747926
This commit is contained in:
Erno Kuvaja 2018-02-07 14:57:06 +00:00
parent 8682876a8b
commit 824badc189
2 changed files with 38 additions and 4 deletions

View File

@ -0,0 +1,34 @@
# Copyright 2018 Red Hat, Inc.
# 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.
import glance.async.flows.plugins.inject_image_metadata
# Note(jokke): This list contains tuples of config options for import plugins.
# When new plugin is introduced its config options need to be added to this
# list so that they can be processed, when config generator is used to generate
# the glance-image-import.conf.sample it will also pick up the details. The
# module needs to be imported as the Glance release packaged example(s) above
# and the first part of the tuple refers to the group the options gets
# registered under at the config file.
PLUGIN_OPTS = [
('inject_metadata_properties',
glance.async.flows.plugins.inject_image_metadata.inject_metadata_opts),
]
def get_plugin_opts():
return PLUGIN_OPTS

View File

@ -30,7 +30,7 @@ import glance.api.middleware.context
import glance.api.versions
import glance.async.flows.api_image_import
import glance.async.flows.convert
import glance.async.flows.plugins.inject_image_metadata
from glance.async.flows.plugins import plugin_opts
import glance.async.taskflow_executor
import glance.common.config
import glance.common.location_strategy
@ -109,8 +109,6 @@ _manage_opts = [
]
_image_import_opts = [
('image_import_opts', glance.async.flows.api_image_import.api_import_opts),
('inject_metadata_properties',
glance.async.flows.plugins.inject_image_metadata.inject_metadata_opts)
]
@ -162,4 +160,6 @@ def list_manage_opts():
def list_image_import_opts():
"""Return a list of oslo_config options available for Image Import"""
return [(g, copy.deepcopy(o)) for g, o in _image_import_opts]
opts = _image_import_opts.extend(plugin_opts.get_plugin_opts())
return [(g, copy.deepcopy(o)) for g, o in opts]