summaryrefslogtreecommitdiffstats
path: root/openlmi-mof-register
diff options
context:
space:
mode:
authorJan Safranek <jsafrane@redhat.com>2013-12-18 13:43:40 +0100
committerJan Safranek <jsafrane@redhat.com>2013-12-18 13:43:40 +0100
commit93fbd26f63771930cd3fc1f7ae9cfb91cbf1de65 (patch)
treec6644f35786e131b5a05200274d8edb37a84bd35 /openlmi-mof-register
parent3da04a083697de1d0784da37449e312c06e151f6 (diff)
downloadopenlmi-providers-93fbd26f63771930cd3fc1f7ae9cfb91cbf1de65.zip
openlmi-providers-93fbd26f63771930cd3fc1f7ae9cfb91cbf1de65.tar.gz
openlmi-providers-93fbd26f63771930cd3fc1f7ae9cfb91cbf1de65.tar.xz
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.
Diffstat (limited to 'openlmi-mof-register')
-rwxr-xr-xopenlmi-mof-register16
1 files changed, 4 insertions, 12 deletions
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):