Browse Source

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
tags/16.0.0.0rc1
Erno Kuvaja 1 year ago
parent
commit
824badc189
2 changed files with 38 additions and 4 deletions
  1. 34
    0
      glance/async/flows/plugins/plugin_opts.py
  2. 4
    4
      glance/opts.py

+ 34
- 0
glance/async/flows/plugins/plugin_opts.py View File

@@ -0,0 +1,34 @@
1
+# Copyright 2018 Red Hat, Inc.
2
+# All Rights Reserved.
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+# not use this file except in compliance with the License. You may obtain
6
+# a copy of the License at
7
+#
8
+#      http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+# License for the specific language governing permissions and limitations
14
+# under the License.
15
+
16
+
17
+import glance.async.flows.plugins.inject_image_metadata
18
+
19
+
20
+# Note(jokke): This list contains tuples of config options for import plugins.
21
+# When new plugin is introduced its config options need to be added to this
22
+# list so that they can be processed, when config generator is used to generate
23
+# the glance-image-import.conf.sample it will also pick up the details. The
24
+# module needs to be imported as the Glance release packaged example(s) above
25
+# and the first part of the tuple refers to the group the options gets
26
+# registered under at the config file.
27
+PLUGIN_OPTS = [
28
+    ('inject_metadata_properties',
29
+     glance.async.flows.plugins.inject_image_metadata.inject_metadata_opts),
30
+]
31
+
32
+
33
+def get_plugin_opts():
34
+    return PLUGIN_OPTS

+ 4
- 4
glance/opts.py View File

@@ -30,7 +30,7 @@ import glance.api.middleware.context
30 30
 import glance.api.versions
31 31
 import glance.async.flows.api_image_import
32 32
 import glance.async.flows.convert
33
-import glance.async.flows.plugins.inject_image_metadata
33
+from glance.async.flows.plugins import plugin_opts
34 34
 import glance.async.taskflow_executor
35 35
 import glance.common.config
36 36
 import glance.common.location_strategy
@@ -109,8 +109,6 @@ _manage_opts = [
109 109
 ]
110 110
 _image_import_opts = [
111 111
     ('image_import_opts', glance.async.flows.api_image_import.api_import_opts),
112
-    ('inject_metadata_properties',
113
-     glance.async.flows.plugins.inject_image_metadata.inject_metadata_opts)
114 112
 ]
115 113
 
116 114
 
@@ -162,4 +160,6 @@ def list_manage_opts():
162 160
 
163 161
 def list_image_import_opts():
164 162
     """Return a list of oslo_config options available for Image Import"""
165
-    return [(g, copy.deepcopy(o)) for g, o in _image_import_opts]
163
+
164
+    opts = _image_import_opts.extend(plugin_opts.get_plugin_opts())
165
+    return [(g, copy.deepcopy(o)) for g, o in opts]

Loading…
Cancel
Save