summaryrefslogtreecommitdiff
path: root/ironic
diff options
context:
space:
mode:
Diffstat (limited to 'ironic')
-rw-r--r--ironic/api/controllers/v1/node.py2
-rw-r--r--ironic/conf/__init__.py2
-rw-r--r--ironic/conf/inspector.py11
-rw-r--r--ironic/conf/inventory.py34
-rw-r--r--ironic/conf/opts.py1
-rw-r--r--ironic/drivers/modules/inspector.py6
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_node.py8
-rw-r--r--ironic/tests/unit/drivers/modules/test_inspector.py16
8 files changed, 53 insertions, 27 deletions
diff --git a/ironic/api/controllers/v1/node.py b/ironic/api/controllers/v1/node.py
index fc6d70481..d4ae22f10 100644
--- a/ironic/api/controllers/v1/node.py
+++ b/ironic/api/controllers/v1/node.py
@@ -1966,7 +1966,7 @@ class NodeInventoryController(rest.RestController):
"""
node = api_utils.check_node_policy_and_retrieve(
'baremetal:node:inventory:get', self.node_ident)
- store_data = CONF.inspector.inventory_data_backend
+ store_data = CONF.inventory.data_backend
if store_data == 'none':
raise exception.NotFound(
(_("Cannot obtain node inventory because it was not stored")))
diff --git a/ironic/conf/__init__.py b/ironic/conf/__init__.py
index ad1ba227c..c1a893181 100644
--- a/ironic/conf/__init__.py
+++ b/ironic/conf/__init__.py
@@ -34,6 +34,7 @@ from ironic.conf import healthcheck
from ironic.conf import ibmc
from ironic.conf import ilo
from ironic.conf import inspector
+from ironic.conf import inventory
from ironic.conf import ipmi
from ironic.conf import irmc
from ironic.conf import metrics
@@ -69,6 +70,7 @@ healthcheck.register_opts(CONF)
ibmc.register_opts(CONF)
ilo.register_opts(CONF)
inspector.register_opts(CONF)
+inventory.register_opts(CONF)
ipmi.register_opts(CONF)
irmc.register_opts(CONF)
metrics.register_opts(CONF)
diff --git a/ironic/conf/inspector.py b/ironic/conf/inspector.py
index bee6a3e67..a7f89c994 100644
--- a/ironic/conf/inspector.py
+++ b/ironic/conf/inspector.py
@@ -39,17 +39,6 @@ opts = [
'managed by ironic. Set this to True if your '
'installation of ironic-inspector does not have a '
'separate PXE boot environment.')),
- cfg.StrOpt('inventory_data_backend',
- help=_('The storage backend for storing introspection data.'),
- choices=[('none', _('introspection data will not be stored')),
- ('database', _('introspection data stored in an SQL '
- 'database')),
- ('swift', _('introspection data stored in Swift'))],
- default='database'),
- cfg.StrOpt('swift_inventory_data_container',
- default='introspection_data_container',
- help=_('The Swift introspection data container to store '
- 'the inventory data.')),
]
diff --git a/ironic/conf/inventory.py b/ironic/conf/inventory.py
new file mode 100644
index 000000000..52f31bf60
--- /dev/null
+++ b/ironic/conf/inventory.py
@@ -0,0 +1,34 @@
+#
+# 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 ironic.common.i18n import _
+
+opts = [
+ cfg.StrOpt('data_backend',
+ help=_('The storage backend for storing introspection data.'),
+ choices=[('none', _('introspection data will not be stored')),
+ ('database', _('introspection data stored in an SQL '
+ 'database')),
+ ('swift', _('introspection data stored in Swift'))],
+ default='database'),
+ cfg.StrOpt('swift_data_container',
+ default='introspection_data_container',
+ help=_('The Swift introspection data container to store '
+ 'the inventory data.')),
+]
+
+
+def register_opts(conf):
+ conf.register_opts(opts, group='inventory')
diff --git a/ironic/conf/opts.py b/ironic/conf/opts.py
index 7576264ee..fd2e51534 100644
--- a/ironic/conf/opts.py
+++ b/ironic/conf/opts.py
@@ -32,6 +32,7 @@ _opts = [
('healthcheck', ironic.conf.healthcheck.opts),
('ilo', ironic.conf.ilo.opts),
('inspector', ironic.conf.inspector.list_opts()),
+ ('inventory', ironic.conf.inventory.opts),
('ipmi', ironic.conf.ipmi.opts),
('irmc', ironic.conf.irmc.opts),
('anaconda', ironic.conf.anaconda.opts),
diff --git a/ironic/drivers/modules/inspector.py b/ironic/drivers/modules/inspector.py
index a4c8c1091..543eaba48 100644
--- a/ironic/drivers/modules/inspector.py
+++ b/ironic/drivers/modules/inspector.py
@@ -368,7 +368,7 @@ def _check_status(task):
elif status.is_finished:
_clean_up(task)
# If store_data == 'none', do not store the data
- store_data = CONF.inspector.inventory_data_backend
+ store_data = CONF.inventory.data_backend
if store_data == 'none':
LOG.debug('Introspection data storage is disabled, the data will '
'not be saved for node %(node)s', {'node': node.uuid})
@@ -417,7 +417,7 @@ def store_introspection_data(node_uuid, inventory_data, plugin_data):
"""
swift_api = swift.SwiftAPI()
swift_object_name = '%s-%s' % (_OBJECT_NAME_PREFIX, node_uuid)
- container = CONF.inspector.swift_inventory_data_container
+ container = CONF.inventory.swift_data_container
swift_api.create_object_from_data(swift_object_name + '-inventory',
inventory_data,
container)
@@ -436,7 +436,7 @@ def get_introspection_data(node_uuid):
"""
swift_api = swift.SwiftAPI()
swift_object_name = '%s-%s' % (_OBJECT_NAME_PREFIX, node_uuid)
- container = CONF.inspector.swift_inventory_data_container
+ container = CONF.inventory.swift_data_container
inventory_data = swift_api.get_object(swift_object_name + '-inventory',
container)
plugin_data = swift_api.get_object(swift_object_name + '-plugin',
diff --git a/ironic/tests/unit/api/controllers/v1/test_node.py b/ironic/tests/unit/api/controllers/v1/test_node.py
index 2f880db7d..b4f59be8a 100644
--- a/ironic/tests/unit/api/controllers/v1/test_node.py
+++ b/ironic/tests/unit/api/controllers/v1/test_node.py
@@ -7949,8 +7949,8 @@ class TestNodeInventory(test_api_base.BaseApiTest):
def test_get_inventory(self):
self._add_inventory()
- CONF.set_override('inventory_data_backend', 'database',
- group='inspector')
+ CONF.set_override('data_backend', 'database',
+ group='inventory')
ret = self.get_json('/nodes/%s/inventory' % self.node.uuid,
headers={api_base.Version.string: self.version})
self.assertEqual({'inventory': self.fake_inventory_data,
@@ -7958,8 +7958,8 @@ class TestNodeInventory(test_api_base.BaseApiTest):
@mock.patch.object(inspector, 'get_introspection_data', autospec=True)
def test_get_inventory_swift(self, mock_get_data):
- CONF.set_override('inventory_data_backend', 'swift',
- group='inspector')
+ CONF.set_override('data_backend', 'swift',
+ group='inventory')
mock_get_data.return_value = {"inventory": self.fake_inventory_data,
"plugin_data": self.fake_plugin_data}
ret = self.get_json('/nodes/%s/inventory' % self.node.uuid,
diff --git a/ironic/tests/unit/drivers/modules/test_inspector.py b/ironic/tests/unit/drivers/modules/test_inspector.py
index 00de10189..fcac0b632 100644
--- a/ironic/tests/unit/drivers/modules/test_inspector.py
+++ b/ironic/tests/unit/drivers/modules/test_inspector.py
@@ -555,8 +555,8 @@ class CheckStatusTestCase(BaseTestCase):
self.driver.boot.clean_up_ramdisk.assert_called_once_with(self.task)
def test_status_ok_store_inventory_in_db(self, mock_client):
- CONF.set_override('inventory_data_backend', 'database',
- group='inspector')
+ CONF.set_override('data_backend', 'database',
+ group='inventory')
mock_get = mock_client.return_value.get_introspection
mock_get.return_value = mock.Mock(is_finished=True,
error=None,
@@ -577,10 +577,10 @@ class CheckStatusTestCase(BaseTestCase):
@mock.patch.object(swift, 'SwiftAPI', autospec=True)
def test_status_ok_store_inventory_in_swift(self,
swift_api_mock, mock_client):
- CONF.set_override('inventory_data_backend', 'swift', group='inspector')
+ CONF.set_override('data_backend', 'swift', group='inventory')
CONF.set_override(
- 'swift_inventory_data_container', 'introspection_data',
- group='inspector')
+ 'swift_data_container', 'introspection_data',
+ group='inventory')
mock_get = mock_client.return_value.get_introspection
mock_get.return_value = mock.Mock(is_finished=True,
error=None,
@@ -602,7 +602,7 @@ class CheckStatusTestCase(BaseTestCase):
mock.call(object_name + '-plugin', fake_plugin_data, container)])
def test_status_ok_store_inventory_nostore(self, mock_client):
- CONF.set_override('inventory_data_backend', 'none', group='inspector')
+ CONF.set_override('data_backend', 'none', group='inventory')
mock_get = mock_client.return_value.get_introspection
mock_get.return_value = mock.Mock(is_finished=True,
error=None,
@@ -613,8 +613,8 @@ class CheckStatusTestCase(BaseTestCase):
mock_get_data.assert_not_called()
def test_status_error_dont_store_inventory(self, mock_client):
- CONF.set_override('inventory_data_backend', 'database',
- group='inspector')
+ CONF.set_override('data_backend', 'database',
+ group='inventory')
mock_get = mock_client.return_value.get_introspection
mock_get.return_value = mock.Mock(is_finished=True,
error='boom',