X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Fspecification_parser.py;h=bf538836a9a64ce12d4248c368a5b7a4293aadd7;hp=f994a59b35ae3d721be38a1e26ca1d724295b862;hb=53f44d52b513fae893e7774d77e3cff160ed9abe;hpb=4ac3464851ff9dd688ab25d0324573284b6bf274 diff --git a/resources/tools/presentation/specification_parser.py b/resources/tools/presentation/specification_parser.py index f994a59b35..bf538836a9 100644 --- a/resources/tools/presentation/specification_parser.py +++ b/resources/tools/presentation/specification_parser.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Cisco and/or its affiliates. +# Copyright (c) 2019 Cisco and/or its affiliates. # 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: @@ -112,6 +112,15 @@ class Specification(object): """ return self._specification["configuration"]["ignore"] + @property + def alerting(self): + """Getter - Alerting. + + :returns: Specification of alerts. + :rtype: dict + """ + return self._specification["configuration"]["alerting"] + @property def input(self): """Getter - specification - inputs. @@ -383,6 +392,12 @@ class Specification(object): except KeyError: self._specification["environment"]["build-dirs"] = None + try: + self._specification["environment"]["testbeds"] = \ + self._cfg_yaml[idx]["testbeds"] + except KeyError: + self._specification["environment"]["testbeds"] = None + logging.info("Done.") def _parse_configuration(self): @@ -405,6 +420,8 @@ class Specification(object): # Data sets: Replace ranges by lists for set_name, data_set in self.configuration["data-sets"].items(): + if not isinstance(data_set, dict): + continue for job, builds in data_set.items(): if builds: if isinstance(builds, dict): @@ -417,6 +434,21 @@ class Specification(object): builds = [x for x in range(builds["start"], build_nr+1)] self.configuration["data-sets"][set_name][job] = builds + # Data sets: add sub-sets to sets (only one level): + for set_name, data_set in self.configuration["data-sets"].items(): + if isinstance(data_set, list): + new_set = dict() + for item in data_set: + try: + for key, val in self.configuration["data-sets"][item].\ + items(): + new_set[key] = val + except KeyError: + raise PresentationError( + "Data set {0} is not defined in " + "the configuration section.".format(item)) + self.configuration["data-sets"][set_name] = new_set + # Mapping table: mapping = None mapping_file_name = self._specification["configuration"].\ @@ -587,6 +619,27 @@ class Specification(object): self._specification["environment"]["paths"]) except KeyError: pass + + # add data sets + try: + for item in ("reference", "compare"): + if element.get(item, None): + data_set = element[item].get("data", None) + if isinstance(data_set, str): + element[item]["data"] = \ + self.configuration["data-sets"][data_set] + + if element.get("history", None): + for i in range(len(element["history"])): + data_set = element["history"][i].get("data", None) + if isinstance(data_set, str): + element["history"][i]["data"] = \ + self.configuration["data-sets"][data_set] + + except KeyError: + raise PresentationError("Wrong data set used in {0}.". + format(element.get("title", ""))) + self._specification["tables"].append(element) count += 1