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