summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-04-05 11:49:36 +0200
committerMichal Minar <miminar@redhat.com>2013-04-11 13:54:39 +0200
commit625a073a829f47ad548c65ad736f979c2f6f5b36 (patch)
tree9a726d20bca378de372e411c53893fb6a61a7bf0
parent666b177d48852c7954334d7ab0bad0aa4dba065e (diff)
downloadopenlmi-providers-625a073a829f47ad548c65ad736f979c2f6f5b36.zip
openlmi-providers-625a073a829f47ad548c65ad736f979c2f6f5b36.tar.gz
openlmi-providers-625a073a829f47ad548c65ad736f979c2f6f5b36.tar.xz
openlmi-mof-register gets support for different namespaces
openlmi-mof-register now supports optional -n parameter to choose another namespace for mof installation.
-rwxr-xr-xopenlmi-mof-register55
1 files changed, 43 insertions, 12 deletions
diff --git a/openlmi-mof-register b/openlmi-mof-register
index e322664..d7918e0 100755
--- a/openlmi-mof-register
+++ b/openlmi-mof-register
@@ -20,13 +20,16 @@
#
pegasus_repository="/var/lib/Pegasus/"
+default_namespace="root/cimv2"
function usage()
{
- printf "Usage: $0 [ --just-mofs ] CMD <mof> [mof] [...] [reg]
+ printf "Usage: $0 [ --just-mofs ] [ -n namespace ] CMD <mof> [mof] [...] [reg]
CMD is one of [ register, unregister ]
- just-mofs option causes that all arguments after CMD will be
+ Default namespace is $default_namespace, which can be changed with '-n' option.
+
+ --just-mofs option causes that all arguments after CMD will be
treated as mof files - no registration file is expected.
usage with --just-mofs:
@@ -55,9 +58,9 @@ function register()
/usr/sbin/cimserver --status > /dev/null 2>&1
if [ $? -eq 0 ];
then
- CIMMOF="/usr/bin/cimmof -aEV"
+ CIMMOF="/usr/bin/cimmof -aEV -n $namespace"
else
- CIMMOF="/usr/bin/cimmofl -aEV -R $pegasus_repository"
+ CIMMOF="/usr/bin/cimmofl -aEV -R $pegasus_repository -n $namespace"
fi
$CIMMOF -uc $mofs
@@ -100,7 +103,42 @@ function unregister()
fi
}
-if [ $# -lt 3 ];
+JUST_MOFS=0
+optspec=":hn:-:"
+
+while getopts "$optspec" optchar; do
+ case "$optchar" in
+ -) # long options parsing
+ case "$OPTARG" in
+ just-mofs)
+ JUST_MOFS=1
+ ;;
+ *)
+ if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" != ":" ]; then
+ echo "Unknown option --${OPTARG}" >&2
+ fi
+ ;;
+ esac
+ ;;
+ n)
+ namespace="$OPTARG"
+ ;;
+ h)
+ usage;
+ exit 0;
+ ;;
+ *)
+ if [ "$OPTERR" != 1 ] || [ "${optspec:0:1}" = ":" ]; then
+ echo "Non-option argument: '-${OPTARG}'" >&2
+ fi
+ ;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+namespace=${namespace:-$default_namespace}
+
+if [ $# -lt 2 ];
then
usage
exit 1
@@ -121,13 +159,6 @@ else
fi
# TODO: check if at least one server is installed
-
-if [ "$1" = "--just-mofs" ]; then
- JUST_MOFS=1
- shift
-else
- JUST_MOFS=0
-fi
CMD=$1
shift