def init(): """ Initializes module :return: List of triggers for Plugin """ ids = risu.getids(include=["/core/openstack/mysql/seqno.sh"]) return ids
def runtest(testtype="False"): """ Actually run the test for UT :param testtype: argument to pass to setup script :return: returncode """ # testtype will be 'pass', 'fail', 'skipped' # We're iterating against the different UT tests defined in UT-tests folder tmpdir = tempfile.mkdtemp(prefix="risu-tmp") # Setup test for 'testtype' subprocess.check_output([uttest, uttest, testtype, tmpdir]) # Run test against it res = risu.dorisu(path=tmpdir, plugins=citplugs) plugid = risu.getids(plugins=citplugs)[0] # Get Return code if plugid in res: rc = res[plugid]["result"]["rc"] else: rc = testtype # Remove tmp folder shutil.rmtree(tmpdir) # Check if it passed return rc
def init(): """ Initializes module :return: List of triggers for Plugin """ ids = risu.getids(include=["/metadata/system/release.sh"]) return ids
def init(): """ Initializes module :return: List of triggers for Plugin """ triggers = risu.getids(include=["faraday/positive", "faraday/negative"]) return triggers
def plugidsforprofile(profile, plugins): """ Gets plugin id's related with profile includes/excludes :param profile: profile file to open :param plugins: plugins in risu execution :return: array of id's """ # Open Profile definition for read and fill filters for plugins include = [] exclude = [] with open(profile, "r") as f: for line in f: if re.match(r"\A\+.*", line): include.append(line[1:].strip()) if re.match(r"\A\-.*", line): exclude.append(line[1:].strip()) ids = risu.getids(plugins=plugins, include=include, exclude=exclude) return ids
def run(data, quiet=False, options=None): # do not edit this line """ Executes plugin :param quiet: be more silent on returned information :param data: data to process :return: returncode, out, err """ # prefill plugins we had used: plugins = [] for item in data: plugin = {"plugin": data[item]["plugin"], "id": data[item]["id"]} plugins.append(plugin) if options and options.extraplugintree: folders = [ pluginsdir, os.path.join(options.extraplugintree, extension) ] else: folders = [pluginsdir] # Find available profile definitions try: include = options.include except: include = None try: exclude = options.exclude except: exclude = None profiles = risu.findplugins( folders=folders, executables=False, fileextension=".txt", include=include, exclude=exclude, ) for item in profiles: uid = risu.getids(plugins=[item])[0] profile = item["plugin"] plugin = dict(item) # Precreate storage for this profile name = "Profiles: %s" % os.path.basename( os.path.splitext(profile.replace(pluginsdir, ""))[0]) subcategory = "" category = name data[uid] = { "category": category, "hash": item["hash"], "plugin": item["plugin"], "name": name, "result": { "rc": 0, "err": "", "out": "" }, "time": 0, "backend": "profile", "id": uid, "subcategory": subcategory, } metadata = { "description": risu.regexpfile(filename=plugin["plugin"], regexp=r"\A# description:")[14:].strip(), "long_name": risu.regexpfile(filename=plugin["plugin"], regexp=r"\A# long_name:")[12:].strip(), "bugzilla": risu.regexpfile(filename=plugin["plugin"], regexp=r"\A# bugzilla:")[11:].strip(), "priority": int( risu.regexpfile(filename=plugin["plugin"], regexp=r"\A# priority:")[11:].strip() or 0), } data[uid].update(metadata) # start with OK status okay = int(os.environ["RC_OKAY"]) failed = int(os.environ["RC_FAILED"]) skipped = int(os.environ["RC_SKIPPED"]) info = int(os.environ["RC_INFO"]) # Start asembling data for the plugins relevant for profile data[uid]["result"]["err"] = "" ids = plugidsforprofile(profile=profile, plugins=plugins) new_results = [] overallitems = [] for id in ids: if id in data: if "sysinfo" in name and data[id]["result"]["rc"] == skipped: # Do nothing as we don't want to show skipped in sysinfo pass else: new_results.append({ "plugin_id": id, "plugin": data[id]["plugin"].replace( os.path.join(risu.risudir, "plugins"), ""), "err": data[id]["result"]["err"].strip(), "rc": data[id]["result"]["rc"], }) overallitems.append(data[id]["result"]["rc"]) if "sysinfo" in name: if okay in overallitems or failed in overallitems or info in overallitems: overall = info else: # No plugins matched, so skip it overall = skipped else: if failed in overallitems: overall = failed elif info in overallitems: overall = info elif skipped in overallitems: overall = skipped else: overall = okay data[uid]["result"]["err"] = json.dumps(new_results) data[uid]["components"] = ids data[uid]["result"]["rc"] = overall return data
def run(data, quiet=False, options=None): # do not edit this line """ Executes plugin :param quiet: be more silent on returned information :param data: data to process :return: returncode, out, err """ # Act on all faraday-exec plugins idstodel = [] datatoadd = [] # Loop over plugin id's in data faradayids = risu.getids(include=["faraday/positive", "faraday/negative"]) for pluginid in data: if data[pluginid]["id"] in faradayids: # Make a copy of dict for working on it plugin = dict(data[pluginid]) # Add plugin ID to be removed for resulting data so magui doesn't compare the whole set of nics at the same time idstodel.append(str(pluginid)) err = str(plugin["result"]["err"]) rc = int(plugin["result"]["rc"]) plugpath = str(plugin["plugin"]) id = str(plugin["id"]) ln = str(plugin["long_name"]) desc = str(plugin["description"]) name = str(plugin["name"]) kb = str(plugin["kb"]) # Iterate over NIC pairs for pair in err.split(";"): if pair != "": # For each value split and fake plugin entry newid = "%s-%s" % (id, risu.calcid(string=pair.split(":")[0])) update = { "id": newid, "description": "%s: %s" % (desc, pair.split(":")[0]), "long_name": "%s: %s" % (ln, pair.split(":")[0]), "plugin": "%s-%s" % (plugpath, pair.split(":")[0]), "name": "Faraday: %s" % name, "kb": kb, } resultupdate = {"result": {"err": pair, "out": "", "rc": rc}} update.update(resultupdate) # Update plugin dictionary with forged values plugin.update(dict(update)) plugin["result"]["err"] = str(pair) # Append new modified plugin to dataset datatoadd.append({newid: dict(plugin)}) # Process id's to remove for id in idstodel: del data[id] # Process data to add for item in datatoadd: data.update(item) return data