Refactor _load_support_matrix

In the Sphinx extension, split up the _load_support_matrix method, so
its easier to understand the additions for the feature_classification
table.

Change-Id: Ic3654017f63dda2c2505057b0063acbc6d5f83c2
This commit is contained in:
John Garbutt 2016-01-06 11:59:14 +00:00
parent b583604f05
commit fbbe1cf316
1 changed files with 20 additions and 6 deletions

View File

@ -141,9 +141,17 @@ class SupportMatrixDirective(rst.Directive):
env.note_dependency(rel_fpath)
matrix = SupportMatrix()
matrix.targets = self._get_targets(cfg)
matrix.features = self._get_features(cfg, matrix.targets)
return matrix
def _get_targets(self, cfg):
# The 'targets' section is special - it lists all the
# hypervisors that this file records data for
targets = {}
for item in cfg.options("targets"):
if not item.startswith("driver-impl-"):
continue
@ -174,10 +182,16 @@ class SupportMatrixDirective(rst.Directive):
raise Exception("'%s' field is malformed in '[%s]' section" %
(item, "DEFAULT"))
matrix.targets[key] = target
targets[key] = target
return targets
def _get_features(self, cfg, targets):
# All sections except 'targets' describe some feature of
# the Nova hypervisor driver implementation
features = []
for section in cfg.sections():
if section == "targets":
continue
@ -225,7 +239,7 @@ class SupportMatrixDirective(rst.Directive):
continue
key = item[12:]
if key not in matrix.targets:
if key not in targets:
raise Exception(
"Driver impl '%s' in '[%s]' not declared" %
(item, section))
@ -242,19 +256,19 @@ class SupportMatrixDirective(rst.Directive):
if cfg.has_option(section, noteskey):
notes = cfg.get(section, noteskey)
target = matrix.targets[key]
target = targets[key]
impl = SupportMatrixImplementation(status,
notes)
feature.implementations[target.key] = impl
for key in matrix.targets:
for key in targets:
if key not in feature.implementations:
raise Exception("'%s' missing in '[%s]' section" %
(target.key, section))
matrix.features.append(feature)
features.append(feature)
return matrix
return features
def _build_markup(self, matrix):
"""Constructs the docutils content for the support matrix