summaryrefslogtreecommitdiffstats
path: root/openlmi-mof-register
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2012-10-22 13:45:27 +0200
committerRadek Novacek <rnovacek@redhat.com>2012-10-22 13:45:27 +0200
commitb6917503f020b96c29c26940d50bb3f46b8edcb2 (patch)
tree4339b64ad877b44ba717e855444b661c5d06c29c /openlmi-mof-register
parent86a07232637625234cfa5116a96fb4602619b663 (diff)
downloadopenlmi-providers-b6917503f020b96c29c26940d50bb3f46b8edcb2.zip
openlmi-providers-b6917503f020b96c29c26940d50bb3f46b8edcb2.tar.gz
openlmi-providers-b6917503f020b96c29c26940d50bb3f46b8edcb2.tar.xz
Move registration scripts to proper directories0.0.10
register.py is renamed to openlmi-mof-register and moved to /usr/bin/, reg2pegasus is now openlmi-register-pegasus in /usr/libexec/.
Diffstat (limited to 'openlmi-mof-register')
-rwxr-xr-xopenlmi-mof-register93
1 files changed, 93 insertions, 0 deletions
diff --git a/openlmi-mof-register b/openlmi-mof-register
new file mode 100755
index 0000000..7a9aaa4
--- /dev/null
+++ b/openlmi-mof-register
@@ -0,0 +1,93 @@
+#!/bin/sh
+
+pegasus_repository="/var/lib/Pegasus/repository"
+
+function usage()
+{
+ printf "Usage: $0 [ register | unregister ] mof reg\n"
+}
+
+function register()
+{
+ mof=$1
+ reg=$2
+ if [ $HAS_SFCBD -eq 1 ];
+ then
+ /usr/bin/sfcbstage -r $reg $mof
+ /usr/bin/sfcbrepos -f
+ /usr/bin/systemctl reload-or-try-restart sblim-sfcb.service
+ fi
+
+ if [ $HAS_PEGASUS -eq 1 ];
+ then
+ /usr/sbin/cimserver --status > /dev/null 2>&1
+ if [ $? -eq 0 ];
+ then
+ CIMMOF="/usr/bin/cimmof"
+ else
+ CIMMOF="/usr/bin/cimmofl -R $pegasus_repository"
+ fi
+
+ $CIMMOF -uc $mof
+ if [ -x $(dirname $0)/openlmi-register-pegasus ];
+ then
+ cat $reg | $(dirname $0)/openlmi-register-pegasus | $CIMMOF -uc -n root/PG_Interop -
+ else
+ cat $reg | /usr/libexec/openlmi-register-pegasus | $CIMMOF -uc -n root/PG_Interop -
+ fi
+ fi
+}
+
+function unregister()
+{
+ mof=$1
+ reg=$2
+ if [ $HAS_SFCBD -eq 1 ];
+ then
+ /usr/bin/sfcbunstage -r $(basename $reg) $(basename $mof)
+ /usr/bin/sfcbrepos -f
+ /usr/bin/systemctl reload-or-try-restart sblim-sfcb.service
+ fi
+
+ if [ $HAS_PEGASUS -eq 1 ];
+ then
+ for provider in $(sed -n 's/ *location: *//p' $reg | sort | uniq);
+ do
+ /usr/bin/cimprovider -d -m ${provider} && /usr/bin/cimprovider -r -m ${provider}
+ done
+ fi
+}
+
+if [ $# -lt 3 ];
+then
+ usage
+ exit 1
+fi
+
+if [ -e /usr/sbin/sfcbd ];
+then
+ HAS_SFCBD=1
+else
+ HAS_SFCBD=0
+fi
+
+if [ -e /usr/sbin/cimserver ];
+then
+ HAS_PEGASUS=1
+else
+ HAS_PEGASUS=0
+fi
+
+# TODO: check if at least one server is installed
+
+case $1 in
+ register)
+ register $2 $3
+ break;;
+ unregister)
+ unregister $2 $3
+ break;;
+ **)
+ usage
+ exit 1
+esac