3
# Linux-HA: CIM Provider register tool
5
# Author: Jia Ming Pan <jmltc@cn.ibm.com>
6
# Copyright (c) 2005 International Business Machines
7
# Licensed under the GNU GPL.
11
#---------- openwbem functions ---------------------------------------
14
openwbem_http_port=5988
15
openwbem_https_port=5989
16
openwbem_get_config_pathname()
18
owcimomd=`which owcimomd`
19
prefix=`dirname $owcimomd`
20
prefix=`dirname $prefix`
21
echo config file: "$prefix/etc/openwbem/openwbem.conf"
22
openwbem_config="$prefix/etc/openwbem/openwbem.conf"
25
openwbem_get_http_port()
27
openwbem_get_config_pathname
28
http_port=`grep -e "http_server.http_port.*=" $openwbem_config | sed -e 's/.*=\W*\(\D*\)/\1/'`
29
if [ "X$http_port" != "X" ]; then
30
openwbem_http_port=$http_port
32
echo openwbem_http_port: $openwbem_http_port
35
openwbem_get_https_port()
37
openwbem_get_config_pathname
38
https_port=`grep -e "http_server.https_port.*=" $openwbem_config | sed -e 's/.*=\W*\(\D*\)/\1/'`
39
if [ "X$https_port" != "X" ]; then
40
openwbem_https_port=$https_port
42
echo openwbem_https_port: $openwbem_https_port
50
ps -C owcimomd > /dev/null 2>&1
52
echo "owcimomd not running, start it first"
58
echo "owmofc not found, OpenWbem not installed?"
61
openwbem_get_http_port
62
$OWMOFC -u "http://localhost:$openwbem_http_port/root/cimv2" $mof_file
65
openwbem_unregister ()
70
ps -C owcimomd > /dev/null 2>&1
72
echo "owcimomd not running, start it first"
78
echo "owmofc not found, OpenWbem not installed?"
81
openwbem_get_http_port
82
$OWMOFC -u "http://localhost:$openwbem_http_port/root/cimv2" -r $mof_file
85
#---------- pegasus functions ----------------------------------------
93
modules=`cat $reg_file 2> /dev/null | grep -v '^[[:space:]]*#.*' | cut -d ' ' -f 4 | sort | uniq`
94
for module in $modules; do
95
cat >> $out_file <<EOF
96
instance of PG_ProviderModule
102
InterfaceType = "CMPI";
103
InterfaceVersion = "2.0.0";
110
pegasus_add_provider ()
116
providers=`cat $reg_file 2> /dev/null | grep -v '^[[:space:]]*#.*' | cut -d ' ' -f 3-4 | sort | uniq`
120
cat >> $out_file <<EOF
121
instance of PG_Provider
124
ProviderModuleName = "$2";
134
pegasus_add_capability ()
141
cat $reg_file | grep -v '^[[:space:]]*#.*' | \
142
while read classname namespace providername providermodule types
144
capid=`expr $capid + 1`
147
for type in $types; do
149
instance) type_no=2;;
150
association) type_no=3;;
151
indication) type_no=4;;
153
*) echo "Unknown provider type: $type"
156
if test "x$provider_types" = "x"; then
157
provider_types="$type_no"
159
provider_types="$provider_types, $type_no"
163
cat >> $out_file << EOF
164
instance of PG_ProviderCapabilities
166
ProviderModuleName = "$providermodule";
167
ProviderName = "$providername";
168
ClassName = "$classname";
169
ProviderType = { $provider_types };
170
Namespaces = {"$namespace"};
171
SupportedProperties = NULL;
172
SupportedMethods = NULL;
173
CapabilityID = "$capid";
186
if ps -C cimserver > /dev/null 2>&1
192
PEGASUSREPOSITORY="/opt/tog-pegasus/repository"
193
CIMMOF="$CIMMOF -R $PEGASUSREPOSITORY"
197
pegasus_add_module $mof_file $reg_file
198
pegasus_add_provider $mof_file $reg_file
199
pegasus_add_capability $mof_file $reg_file
201
$CIMMOF -n root/cimv2 $mof_file
202
$CIMMOF -n root/PG_Interop $REGFILE
205
pegasus_unregister ()
212
#---------- sfcb functions -------------------------------------------
218
cat $old_file | grep -v '^[[:space:]]*#.*' | \
219
while read classname namespace providername providermodule types
221
cat >> $new_file <<EOF
223
provider: $providername
224
location: $providermodule
226
namespace: $namespace
234
sfcb_running_check ()
236
ps -C sfcbd > /dev/null 2>&1
239
echo "sfcbd is running, please stop it first."
251
new_reg_file=/tmp/`basename $2`.reg
252
sfcb_transform $reg_file $new_reg_file
255
echo register to sfcb ...
256
sfcbstage -r $new_reg_file $mof_file
258
if [ $? -eq 1 ]; then
259
echo failed to register, exit
263
echo rebuild sfcb repository ...
265
if [ $? -eq 1 ]; then
266
echo failed to rebuild sfcb, exit
280
new_reg_file=/tmp/`basename $2`.reg
282
sfcb_transform $reg_file $new_reg_file
285
echo unregister to sfcb ...
286
sfcbunstage -r $new_reg_file $mof_file
288
if [ $? -eq 1 ]; then
289
echo failed to unregister, exit
293
echo rebuild sfcb repository ...
295
if [ $? -eq 1 ]; then
296
echo failed to rebuild sfcb, exit
303
#========== main ============================================
311
echo "usage: $0 [-t cimserver] [-u] -r regfile -m mof"
312
echo $'\t'-t cimserver: specify cimserver "[pegasus|openwbem|sfcb]".
313
echo $'\t'-u: Unregister
314
echo $'\t'-r regfile: specify reg file.
315
echo $'\t'-m moffile: specify mof file.
320
args=`getopt hut:r:m: $*`
323
if test $? != 0; then
327
while [ -n "$1" ]; do
333
if test "x$cimom" = "x"; then
336
echo CIM server already set, ignore [$1]
340
if test "x$mof_file" = "x"; then
343
echo MOF file already set, ignore [$1]
347
if test "x$reg_file" = "x"; then
350
echo Reg file already set, ignore [$1]
358
if test "x$unregister" != "xyes"; then
359
echo registering providers ...
361
echo unregistering providers ...
364
echo CIM Server: $cimom
365
echo mof file : $mof_file
366
echo registration file : $reg_file
375
REG_FUNC=${cimom}_register
376
UNREG_FUNC=${cimom}_unregister
378
if test "x$unregister" != "xyes"; then
379
$REG_FUNC $mof_file $reg_file
381
$UNREG_FUNC $mof_file $reg_file
385
#============== end of file =======================================