Parse 'driver-notes-XXX' values

This seems to have been missed in the import from nova.

Change-Id: Ic38c16aca1e94a9a06ad6efc7f53772b660b68da
Signed-off-by: Stephen Finucane <stephen@that.guru>
This commit is contained in:
Stephen Finucane 2018-06-25 17:27:20 +01:00
parent 4f5ab257c2
commit c07a2e9cf6
5 changed files with 43 additions and 3 deletions

View File

@ -152,7 +152,8 @@ for every driver defined earlier in the file.
:Mandatory: No
Additional information about the implementation of this feature in driver
``XXX``.
``XXX``. While this is optional, it is highly recommended for implementations
in the ``partial`` state.
For example:
@ -175,6 +176,8 @@ For example:
block storage from a running instance.
cli=my-project detach-volume <instance> <volume>
driver.slow-driver=complete
driver-notes.slow-driver=Works without issue if instance is off. When
hotplugging, requires version foo of the driver.
driver.fast-driver=complete
Notice that a driver is only required to implement detach-volume if they
@ -213,4 +216,6 @@ This is simply the combined example from above.
block storage from a running instance.
cli=my-project detach-volume <instance> <volume>
driver.slow-driver=complete
driver-notes.slow-driver=Works without issue if instance is off. When
hotplugging, requires version foo of the driver.
driver.fast-driver=complete

View File

@ -0,0 +1,14 @@
---
features:
- |
You can now specify ``driver-notes.XXX`` values. These are useful to
provide additional context for features with a status of ``partial``. For
example::
[operation.Cool_Feature]
title=Cool Feature
status=optional
notes=A pretty darn cool feature.
driver.foo=complete
driver.bar=partial
driver-notes.bar=Requires hardware support.

View File

@ -104,7 +104,13 @@ class Matrix(object):
"one of (%s)" % (option, status, section, ", ".join(
Implementation.STATUS_ALL)))
impl = Implementation(status)
option_notes = ''.join([DRIVER_NOTES_PREFIX,
option[len(DRIVER_PREFIX):]])
notes = None
if cfg.has_option(section, option_notes):
notes = cfg.get(section, option_notes)
impl = Implementation(status=status, notes=notes)
feature.implementations[option] = impl
return feature
@ -160,8 +166,9 @@ class Implementation(object):
STATUS_ALL = [STATUS_COMPLETE, STATUS_MISSING,
STATUS_PARTIAL, STATUS_UNKNOWN]
def __init__(self, status=STATUS_MISSING):
def __init__(self, status=STATUS_MISSING, notes=None):
self.status = status
self.notes = notes
STATUS_SYMBOLS = {
@ -375,6 +382,9 @@ class Directive(rst.Directive):
ids=[key_id]),
]
if impl.notes is not None:
subitem.append(self._create_notes_paragraph(impl.notes))
impls.append(subitem)
para_divers.append(impls)

View File

@ -12,3 +12,4 @@ status=optional
notes=A pretty darn cool feature.
driver.foo=complete
driver.bar=partial
driver-notes.bar=Requires hardware support.

View File

@ -58,3 +58,13 @@ class MatrixTestCase(base.TestCase):
fake_driver = self.matrix.drivers[key]
self.assertEqual(title, fake_driver.title)
self.assertEqual(link, fake_driver.link)
@ddt.unpack
@ddt.data({'key': 'driver.foo', 'status': 'complete',
'notes': None},
{'key': 'driver.bar', 'status': 'partial',
'notes': 'Requires hardware support.'})
def test_implementations_set(self, key, status, notes):
fake_implementation = self.matrix.features[0].implementations[key]
self.assertEqual(status, fake_implementation.status)
self.assertEqual(notes, fake_implementation.notes)