Re: [devel] [PATCH 1/1] clm: add tool commands clm-adm, clm-state, clm-find [#2394]
Ack with one comment: --admin_op should be renamed to --admin-op (dash instead of underscore as word separator). regards, Anders Widell On 05/12/2017 11:54 AM, Praveen wrote: > This is V2 which incorporates comments given on V1. > > clm-adm: for performing CLM admin operations on CLM node and cluser. > clm-find: for finding out object(s) configured for CLM classes SaClmCluster >and SaClmNode. Additional options like membership status and admin > state > can also be given to find out objects which satisfy this criteria. > clm-state: for listing CLM node(s) and their important attributes. > --- > opensaf.spec.in | 3 + > src/clm/Makefile.am | 5 ++ > src/clm/tools/clm-adm | 105 ++ > src/clm/tools/clm-find | 84 +++ > src/clm/tools/clm-state | 148 > > 5 files changed, 345 insertions(+) > create mode 100644 src/clm/tools/clm-adm > create mode 100644 src/clm/tools/clm-find > create mode 100644 src/clm/tools/clm-state > > diff --git a/opensaf.spec.in b/opensaf.spec.in > index 0078fc2..70056b6 100644 > --- a/opensaf.spec.in > +++ b/opensaf.spec.in > @@ -1445,6 +1445,9 @@ fi > %{_bindir}/ntfsubscribe > %{_bindir}/ntfread > %{_bindir}/saflogger > +%{_bindir}/clm-adm > +%{_bindir}/clm-find > +%{_bindir}/clm-state > %if %is_ais_smf > %{_bindir}/smf-adm > %{_bindir}/smf-find > diff --git a/src/clm/Makefile.am b/src/clm/Makefile.am > index ad9f90a..da2d7d9 100644 > --- a/src/clm/Makefile.am > +++ b/src/clm/Makefile.am > @@ -166,6 +166,11 @@ bin_osafclmna_LDADD = \ > lib/libSaAmf.la \ > lib/libopensaf_core.la > > +dist_bin_SCRIPTS += \ > + src/clm/tools/clm-adm \ > + src/clm/tools/clm-find \ > + src/clm/tools/clm-state > + > if ENABLE_TESTS > > bin_PROGRAMS += bin/clmtest > diff --git a/src/clm/tools/clm-adm b/src/clm/tools/clm-adm > new file mode 100644 > index 000..ae75fe5 > --- /dev/null > +++ b/src/clm/tools/clm-adm > @@ -0,0 +1,105 @@ > +#! /bin/sh > +# -*- OpenSAF -*- > +# > +# Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved. > +# > +# This program is distributed in the hope that it will be useful, but > +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY > +# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed > +# under the GNU Lesser General Public License Version 2.1, February 1999. > +# The complete license can be accessed from the following location: > +# http://opensource.org/licenses/lgpl-license.php > +# See the Copying file included with the OpenSAF distribution for full > +# licensing terms. > +# > + > +usage() > +{ > + echo "" > + echo "USAGE: $(basename "$0") [-t value] <-o op_name> " > + echo "" > + echo "OPTIONS:" > + echo "-t or --timeout : command timeout in seconds (default=60) > (optional)" > + echo "-o or --admin_op: operation name (mandatory)" > + echo " 'lock' for admin lock " > + echo " 'unlock' for admin unlock " > + echo " 'shutdown' for admin shutdown " > + echo " 'reset'for admin reset of cluster" > + echo "DN : a valid DN name of CLM node or cluster > (mandatory)" > + echo "" > + echo "" > +} > + > +options=$(getopt -o t:o:h -l timeout:,admin_op:,help -- "$@") > +status=$? > +if [ $status -ne 0 ] ; then > + echo "Try '$(basename "$0") -h or --help' for more information" > + exit 1 > +fi > +eval set -- "$options" > + > +DN="" > +CMD="" > +TIMEOUT="" > + > +while true; do > + case $1 in > +-t|--timeout) > +shift 1 > +TIMEOUT=$1; > +shift 1 > +;; > +-o|--admin_op) > +shift 1 > +if [ "$1" = "unlock" ]; then > + CMD=1 > +elif [ "$1" = "lock" ]; then > + CMD=2 > +elif [ "$1" = "shutdown" ]; then > + CMD=3 > +elif [ "$1" = "reset" ]; then > + CMD=4 > +else > + echo "Invalid operation name" > + exit 1 > +fi > +shift 1 > +;; > +-h|--help) > +usage > +exit 0 > +;; > +\?) > +echo "Invalid option" > +exit 1 > +;; > +--) > +shift; > +break; > +;; > +esac > +done > + > +if [ "$CMD" = "" ]; then > + echo "operation name is mandatory" > + echo "Try '$(basename "$0") -h or --help' for more information" > + exit 1 > +fi > + > +shift $((OPTIND -1)) > + > +DN="$*" > +if [ "$DN" = "" ]; then > + echo "DN name is mandatory" > + echo "Try '$(basename "$0") -h or
[devel] [PATCH 1/1] clm: add tool commands clm-adm, clm-state, clm-find [#2394]
This is V2 which incorporates comments given on V1. clm-adm: for performing CLM admin operations on CLM node and cluser. clm-find: for finding out object(s) configured for CLM classes SaClmCluster and SaClmNode. Additional options like membership status and admin state can also be given to find out objects which satisfy this criteria. clm-state: for listing CLM node(s) and their important attributes. --- opensaf.spec.in | 3 + src/clm/Makefile.am | 5 ++ src/clm/tools/clm-adm | 105 ++ src/clm/tools/clm-find | 84 +++ src/clm/tools/clm-state | 148 5 files changed, 345 insertions(+) create mode 100644 src/clm/tools/clm-adm create mode 100644 src/clm/tools/clm-find create mode 100644 src/clm/tools/clm-state diff --git a/opensaf.spec.in b/opensaf.spec.in index 0078fc2..70056b6 100644 --- a/opensaf.spec.in +++ b/opensaf.spec.in @@ -1445,6 +1445,9 @@ fi %{_bindir}/ntfsubscribe %{_bindir}/ntfread %{_bindir}/saflogger +%{_bindir}/clm-adm +%{_bindir}/clm-find +%{_bindir}/clm-state %if %is_ais_smf %{_bindir}/smf-adm %{_bindir}/smf-find diff --git a/src/clm/Makefile.am b/src/clm/Makefile.am index ad9f90a..da2d7d9 100644 --- a/src/clm/Makefile.am +++ b/src/clm/Makefile.am @@ -166,6 +166,11 @@ bin_osafclmna_LDADD = \ lib/libSaAmf.la \ lib/libopensaf_core.la +dist_bin_SCRIPTS += \ + src/clm/tools/clm-adm \ + src/clm/tools/clm-find \ + src/clm/tools/clm-state + if ENABLE_TESTS bin_PROGRAMS += bin/clmtest diff --git a/src/clm/tools/clm-adm b/src/clm/tools/clm-adm new file mode 100644 index 000..ae75fe5 --- /dev/null +++ b/src/clm/tools/clm-adm @@ -0,0 +1,105 @@ +#! /bin/sh +# -*- OpenSAF -*- +# +# Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed +# under the GNU Lesser General Public License Version 2.1, February 1999. +# The complete license can be accessed from the following location: +# http://opensource.org/licenses/lgpl-license.php +# See the Copying file included with the OpenSAF distribution for full +# licensing terms. +# + +usage() +{ + echo "" + echo "USAGE: $(basename "$0") [-t value] <-o op_name> " + echo "" + echo "OPTIONS:" + echo "-t or --timeout : command timeout in seconds (default=60) (optional)" + echo "-o or --admin_op: operation name (mandatory)" + echo " 'lock' for admin lock " + echo " 'unlock' for admin unlock " + echo " 'shutdown' for admin shutdown " + echo " 'reset'for admin reset of cluster" + echo "DN : a valid DN name of CLM node or cluster (mandatory)" + echo "" + echo "" +} + +options=$(getopt -o t:o:h -l timeout:,admin_op:,help -- "$@") +status=$? +if [ $status -ne 0 ] ; then + echo "Try '$(basename "$0") -h or --help' for more information" + exit 1 +fi +eval set -- "$options" + +DN="" +CMD="" +TIMEOUT="" + +while true; do + case $1 in +-t|--timeout) +shift 1 +TIMEOUT=$1; +shift 1 +;; +-o|--admin_op) +shift 1 +if [ "$1" = "unlock" ]; then + CMD=1 +elif [ "$1" = "lock" ]; then + CMD=2 +elif [ "$1" = "shutdown" ]; then + CMD=3 +elif [ "$1" = "reset" ]; then + CMD=4 +else + echo "Invalid operation name" + exit 1 +fi +shift 1 +;; +-h|--help) +usage +exit 0 +;; +\?) +echo "Invalid option" +exit 1 +;; +--) +shift; +break; +;; +esac +done + +if [ "$CMD" = "" ]; then + echo "operation name is mandatory" + echo "Try '$(basename "$0") -h or --help' for more information" + exit 1 +fi + +shift $((OPTIND -1)) + +DN="$*" +if [ "$DN" = "" ]; then + echo "DN name is mandatory" + echo "Try '$(basename "$0") -h or --help' for more information" + exit 1 +fi + +if [ "$TIMEOUT" = "" ]; then + immadm -o "$CMD" "$DN" +else + immadm -t "$TIMEOUT" -o "$CMD" "$DN" +fi + +exit $? + diff --git a/src/clm/tools/clm-find b/src/clm/tools/clm-find new file mode 100644 index 000..3073fb5 --- /dev/null +++ b/src/clm/tools/clm-find @@ -0,0 +1,84 @@ +#! /bin/sh + +# -*- OpenSAF -*- +# +# Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved. +# +# This program is distributed in the hope that