summaryrefslogtreecommitdiff
path: root/ironic_python_agent/utils.py
diff options
context:
space:
mode:
authorLucas Alvares Gomes <lucasagomes@gmail.com>2016-05-19 10:48:02 +0100
committerLucas Alvares Gomes <lucasagomes@gmail.com>2016-05-26 14:52:15 +0100
commit33535cd572b90a817b9c96b42a0d2fe54751351d (patch)
treeaef488e6de5131a3978c3829a03b1ca46b718095 /ironic_python_agent/utils.py
parent962ee1afb5390080b30444652bc201dd59382220 (diff)
downloadironic-python-agent-33535cd572b90a817b9c96b42a0d2fe54751351d.tar.gz
Get root device hints from the node object
In order to support a more complex syntax for root device hints (e.g operators: greater than, less than, in, etc...) we need to stop relying on the kernel command line for passing the root device hints. This patch changes this approach by getting the root device hints from a cached node object that was set in the hardware module. Two new functions: "cache_node" and "get_cached_node" were added to the hardware module. The idea is to facilitate the access to a node object representation from the hardware extension methods without changing method signatures, which would break compatibility with out-of-tree hardware managers. Note that the new "get_cached_node" is just a guard function to facilitate the tests for the code. The function parse_root_device_hints() and its tests were removed since it's not used/needed anymore. Partial-Bug: #1561137 Change-Id: I830fe7da1a59b46e348213b6f451c2ee55f6008c
Diffstat (limited to 'ironic_python_agent/utils.py')
-rw-r--r--ironic_python_agent/utils.py38
1 files changed, 0 insertions, 38 deletions
diff --git a/ironic_python_agent/utils.py b/ironic_python_agent/utils.py
index d647e2dd..df5d7c67 100644
--- a/ironic_python_agent/utils.py
+++ b/ironic_python_agent/utils.py
@@ -233,44 +233,6 @@ def normalize(string):
return parse.unquote(string).lower().strip()
-def parse_root_device_hints():
- """Parse the root device hints.
-
- Parse the root device hints given by Ironic via kernel cmdline
- or vmedia.
-
- :returns: A dict with the hints or an empty dict if no hints are
- passed.
- :raises: DeviceNotFound if there are unsupported hints.
-
- """
- root_device = get_agent_params().get('root_device')
- if not root_device:
- return {}
-
- hints = dict((item.split('=') for item in root_device.split(',')))
-
- # Find invalid hints for logging
- not_supported = set(hints) - SUPPORTED_ROOT_DEVICE_HINTS
- if not_supported:
- error_msg = ('No device can be found because the following hints: '
- '"%(not_supported)s" are not supported by this version '
- 'of IPA. Supported hints are: "%(supported)s"',
- {'not_supported': ', '.join(not_supported),
- 'supported': ', '.join(SUPPORTED_ROOT_DEVICE_HINTS)})
- raise errors.DeviceNotFound(error_msg)
-
- # Normalise the values
- hints = {k: normalize(v) for k, v in hints.items()}
-
- if 'size' in hints:
- # NOTE(lucasagomes): Ironic should validate before passing to
- # the deploy ramdisk
- hints['size'] = int(hints['size'])
-
- return hints
-
-
class AccumulatedFailures(object):
"""Object to accumulate failures without raising exception."""