summaryrefslogtreecommitdiffstats
path: root/openlmi-mof-register
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-04-26 08:15:48 +0200
committerMichal Minar <miminar@redhat.com>2013-04-26 10:18:20 +0200
commit338851a8fe5b9dfec1e9695602d501e1fe918912 (patch)
tree7d67030c8365e798cc5a9db1e13d69fb0d890a21 /openlmi-mof-register
parentdc80290506189ef80da0c1d8c0e733574ab7eef0 (diff)
downloadopenlmi-providers-338851a8fe5b9dfec1e9695602d501e1fe918912.zip
openlmi-providers-338851a8fe5b9dfec1e9695602d501e1fe918912.tar.gz
openlmi-providers-338851a8fe5b9dfec1e9695602d501e1fe918912.tar.xz
registration script now allows to specify cimom
Until now openlmi-mof-register operated on both sfcbd and tog-pegasus if present on system. This fails when we target namespace present only in one of them (like "root/interop" for sfcbd or "root/PG_InterOp" for tog-pegasus). This patch adds "-c" option allowing to specify target cimom. For example: openlmi-mof-register -n root/PG_InterOp -c tog-pegasus \ --just-mofs unregister mof/70_LMI_SoftwareIndicationFilters.mof Removes instances of indication filters only from tog-pegasus.
Diffstat (limited to 'openlmi-mof-register')
-rwxr-xr-xopenlmi-mof-register83
1 files changed, 57 insertions, 26 deletions
diff --git a/openlmi-mof-register b/openlmi-mof-register
index 521c967..b2b1790 100755
--- a/openlmi-mof-register
+++ b/openlmi-mof-register
@@ -24,11 +24,15 @@ default_namespace="root/cimv2"
function usage()
{
- printf "Usage: $0 [ --just-mofs ] [ -n namespace ] CMD <mof> [mof] [...] [reg]
+ printf "Usage: $0 [ --just-mofs ] [ -n namespace ] [ -c cimom ]
+ CMD <mof> [mof] [...] [reg]
CMD is one of [ register, unregister ]
Default namespace is $default_namespace, which can be changed with '-n' option.
+ Supported cimoms are sfcbd and tog-pegasus. Without \"-c\" argument, the
+ operation is processed for any cimom present on system (all of them).
+
--just-mofs option causes that all arguments after CMD will be
treated as mof files - no registration file is expected.
@@ -46,14 +50,14 @@ function register()
shift
fi
mofs="$@"
- if [ $HAS_SFCBD -eq 1 ];
+ if [ $HAS_SFCBD -eq 1 ] && echo $cimom | grep -q 'all\|sfcbd';
then
- /usr/bin/sfcbstage ${reg:+-r} $reg $mofs
+ /usr/bin/sfcbstage -n $namespace ${reg:+-r} $reg $mofs
/usr/bin/sfcbrepos -f
/usr/bin/systemctl reload-or-try-restart sblim-sfcb.service
fi
- if [ $HAS_PEGASUS -eq 1 ];
+ if [ $HAS_PEGASUS -eq 1 ] && echo $cimom | grep -q 'all\|tog-pegasus';
then
/usr/sbin/cimserver --status > /dev/null 2>&1
if [ $? -eq 0 ];
@@ -64,7 +68,7 @@ function register()
fi
$CIMMOF -uc $mofs
- if [ $JUST_MOFS = 0 ]; then
+ if [ $JUST_MOFS -eq 0 ]; then
if [ -x $(dirname $0)/openlmi-register-pegasus ];
then
cat "$reg" | $(dirname $0)/openlmi-register-pegasus | $CIMMOF -uc -n root/PG_Interop
@@ -81,35 +85,39 @@ function unregister()
reg=$1
shift
fi
- # convert mofs to `basename mof`
- declare -a mofs=("$@")
- for ((i=0; i<${#mofs[@]}; i++)); do
- mofs[$i]=$(basename "${mofs[$i]}")
- done
- if [ $HAS_SFCBD -eq 1 ];
+ declare -a mofs=("$@")
+ if [ $HAS_SFCBD -eq 1 ] && echo $cimom | grep -q 'all\|sfcbd';
then
- /usr/bin/sfcbunstage ${reg:+-r} $(basename "$reg") ${mofs[@]}
+ # convert mofs to `basename mof`
+ declare -a bmofs
+ for ((i=0; i<${#mofs[@]}; i++)); do
+ bmofs[$i]=$(basename "${mofs[$i]}")
+ done
+ /usr/bin/sfcbunstage -n $namespace ${reg:+-r} $(basename "$reg") ${bmofs[@]}
/usr/bin/sfcbrepos -f
/usr/bin/systemctl reload-or-try-restart sblim-sfcb.service
fi
- if [ -x $(dirname $0)/openlmi-cimmof ]; then
- $(dirname $0)/openlmi-cimmof -n $namespace delete ${mofs[@]}
- else
- /usr/libexec/openlmi-cimmof -n $namespace delete ${mofs[@]}
- fi
- if [ -n "$reg" -a $HAS_PEGASUS -eq 1 ];
+ if [ $HAS_PEGASUS -eq 1 ] && echo $cimom | grep -q 'all\|tog-pegasus';
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
+ if [ -x $(dirname $0)/openlmi-cimmof ]; then
+ $(dirname $0)/openlmi-cimmof -n $namespace delete ${mofs[@]}
+ else
+ /usr/libexec/openlmi-cimmof -n $namespace delete ${mofs[@]}
+ fi
+ if [ -n "$reg" ];
+ 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
fi
}
JUST_MOFS=0
-optspec=":hn:-:"
+optspec=":hn:c:-:"
while getopts "$optspec" optchar; do
case "$optchar" in
@@ -121,6 +129,7 @@ while getopts "$optspec" optchar; do
*)
if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" != ":" ]; then
echo "Unknown option --${OPTARG}" >&2
+ exit 1
fi
;;
esac
@@ -128,6 +137,13 @@ while getopts "$optspec" optchar; do
n)
namespace="$OPTARG"
;;
+ c)
+ cimom="$OPTARG"
+ if [ "$cimom" != "sfcbd" -a "$cimom" != "tog-pegasus" ]; then
+ echo "Not supported cimom: $cimom" >&2
+ exit 1
+ fi
+ ;;
h)
usage;
exit 0;
@@ -135,6 +151,7 @@ while getopts "$optspec" optchar; do
*)
if [ "$OPTERR" != 1 ] || [ "${optspec:0:1}" = ":" ]; then
echo "Non-option argument: '-${OPTARG}'" >&2
+ exit 1
fi
;;
esac
@@ -142,6 +159,7 @@ done
shift $(($OPTIND - 1))
namespace=${namespace:-$default_namespace}
+cimom=${cimom:-all}
if [ $# -lt 2 ];
then
@@ -154,6 +172,10 @@ then
HAS_SFCBD=1
else
HAS_SFCBD=0
+ if [ $cimom != "sfcbd" ]; then
+ echo "Sfcbd not detected on system!" >&2
+ exit 1
+ fi
fi
if [ -e /usr/sbin/cimserver ];
@@ -161,6 +183,10 @@ then
HAS_PEGASUS=1
else
HAS_PEGASUS=0
+ if [ $cimom != "tog-pegasus" ]; then
+ echo "Pegasus not detected on system!" >&2
+ exit 1
+ fi
fi
# TODO: check if at least one server is installed
@@ -169,9 +195,14 @@ shift
# parse the reg and mofs - use $@ and remove the last item
declare -a ARGS=("$@")
-LEN=$(( ${#ARGS[@]} -1 ))
-REG=${ARGS[$LEN]}
-MOFS=(${ARGS[@]:0:$(($LEN))})
+if [ $JUST_MOFS -eq 0 ];
+then
+ LEN=$(( ${#ARGS[@]} -1 ))
+ REG=${ARGS[$LEN]}
+ MOFS=(${ARGS[@]:0:$(($LEN))})
+else
+ MOFS=("$@")
+fi
case $CMD in
register)