From 93fbd26f63771930cd3fc1f7ae9cfb91cbf1de65 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Wed, 18 Dec 2013 13:43:40 +0100 Subject: Fixed openlmi-mof-register not to crash when CIMOM is down. /usr/bin/mofcomp requires that Pegasus runs at the time the script is executed. Therefore we could not register any MOF files into database if Pegasus was down. To fix this, openlmi-mof-register now does not depend on mofcomp and contains its own MOF parser to parse just '#pragma include' directives, comments and string literals. --- openlmi-mof-register | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'openlmi-mof-register') diff --git a/openlmi-mof-register b/openlmi-mof-register index 6a0c154..0e31eb7 100755 --- a/openlmi-mof-register +++ b/openlmi-mof-register @@ -30,6 +30,7 @@ import re import sqlite3 from tempfile import NamedTemporaryFile from shutil import copyfile +from lmi.base.mofparse import MOFParser global PEGASUS_REPOSITORY global DEFAULT_NAMESPACE @@ -309,17 +310,8 @@ def db_get_registrations(cursor, mofs, reg): def parse_includes(mofs, namespace): # Get list of all files included from mofs, including the original mofs - # Misuse mofcomp --dry-run - out = subprocess.check_output(["/usr/bin/mofcomp", "-v", "-d", "-n", namespace] - + mofs) - - final_mofs = [] - include = re.compile("^Compiling file (.*)") - for line in out.split("\n"): - match = include.match(line) - if match: - final_mofs.append(match.group(1)) - return final_mofs + parser = MOFParser() + return parser.parse_includes(mofs) def db_register(mofs, reg, version, namespace, cimom): db = db_init() @@ -501,7 +493,7 @@ def main(): cmd = args[0] if cmd == "register" or cmd == "unregister": if (just_mofs and (len(args) < 2)) or ((not just_mofs) and (len(args) < 3)): - sys.stderr.write("Not enough parameters.\n" ) + sys.stderr.write("Not enough parameters.\n") usage() sys.exit(1) if (not just_mofs) and (version is None): -- cgit