Hi Khanh,
Some comments inline from me.
B.R/Thang
-----Original Message-----
From: Khanh Q Nguyen <[email protected]>
Sent: Friday, March 24, 2023 5:01 PM
To: Thang Duc Nguyen <[email protected]>; Thien Minh Huynh
<[email protected]>
Cc: [email protected]; Khanh Q Nguyen
<[email protected]>
Subject: [PATCH 1/1] clm: Add an operation to excute a script [#2696]
Update the clm-adm command-line tool to support the new admin-ops added in
ticket [#2649].
-o or --admin-op: operation name (mandatory)
...
'execute' for executing action on remote nodei(s) -a or
--action : action name is a script stored in
/usr/lib/opensaf/clm-scripts
directory started with prefix "osafclm_"
---
src/clm/tools/clm-adm | 49 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 44 insertions(+), 5 deletions(-) mode change 100644 => 100755
src/clm/tools/clm-adm
diff --git a/src/clm/tools/clm-adm b/src/clm/tools/clm-adm old mode 100644 new
mode 100755 index 25445fff1..0122bf97f
--- a/src/clm/tools/clm-adm
+++ b/src/clm/tools/clm-adm
@@ -16,7 +16,7 @@
usage()
{
echo ""
- echo "USAGE: $(basename "$0") [-t value] <-o op_name> <DN>"
+ echo "USAGE: $(basename "$0") [-t value] <-o op_name> [-a action_name] <DN>"
echo ""
echo "OPTIONS:"
echo " -t or --timeout : command timeout in seconds (default=60)
(optional)"
@@ -24,13 +24,29 @@ usage()
echo " 'lock' for admin lock "
echo " 'unlock' for admin unlock "
echo " 'shutdown' for admin shutdown "
- echo " 'reset' for admin reset of cluster"
+ echo " 'reset' for admin reset of
node/cluster"
+ echo " 'execute' for executing action on remote
nodei(s)"
[Thang]: Suggest to replace "nodei(s)" by node/cluster. B/c it does not support
on multiple nodes.
One example,
clm-adm -o reset -a init safNode=PL-4,safCluster=myClmCluster
In this case command still work and option "-a init" is redundant.
+ echo " -a or --action : action name is a script stored in
/usr/lib/opensaf/clm-scripts"
+ echo " directory started with prefix "osafclm_""
echo " DN : a valid DN name of CLM node or cluster
(mandatory)"
echo ""
echo ""
+ echo "NOTES:"
+ echo " 1) -a is mandatory with 'execute' operation"
+ echo ""
+ echo ""
+ echo "EXAMPLES:"
+ echo " clm-adm -o execute -a test
safNode=SC-2,safCluster=myClmCluster"
+ echo " execute script locate on
/usr/lib/opensaf/clm-scripts/osafclm_test on SC-2"
+ echo " clm-adm -o reset safCluster=myClmCluster"
+ echo " Cluster reboot"
+ echo " clm-adm -o reset safNode=SC-2,safCluster=myClmCluster"
+ echo " Node SC-2 reboot"
+ echo ""
+ echo ""
}
-options=$(getopt -o t:o:h -l timeout:,admin-op:,help -- "$@")
+options=$(getopt -o t:o:a:h -l timeout:,admin-op:,action:,help -- "$@")
status=$?
if [ $status -ne 0 ] ; then
echo "Try '$(basename "$0") -h or --help' for more information"
@@ -41,6 +57,7 @@ eval set -- "$options"
DN=""
CMD=""
TIMEOUT=""
+ACTION=""
while true; do
case $1 in
@@ -59,12 +76,19 @@ while true; do
CMD=3
elif [ "$1" = "reset" ]; then
CMD=4
+ elif [ "$1" = "execute" ]; then
+ CMD=5
else
echo "Invalid operation name"
exit 1
fi
shift 1
;;
+ -a|--action)
+ shift 1
+ ACTION=$1
+ shift 1
+ ;;
-h|--help)
usage
exit 0
@@ -86,9 +110,16 @@ if [ "$CMD" = "" ]; then
exit 1
fi
+if [ "$CMD" = "5" ] && [ "$ACTION" = "" ]; then
+ echo "action name is mandatory in 'execute' operation"
+ 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"
@@ -96,9 +127,17 @@ if [ "$DN" = "" ]; then fi
if [ "$TIMEOUT" = "" ]; then
- immadm -o "$CMD" "$DN"
+ if [ "$ACTION" != "" ]; then
+ immadm -o "$CMD" -p "saClmAction:SA_STRING_T:$ACTION" "$DN"
+ else
+ immadm -o "$CMD" "$DN"
+ fi
else
- immadm -t "$TIMEOUT" -o "$CMD" "$DN"
+ if [ "$ACTION" != "" ]; then
+ immadm -t "$TIMEOUT" -o "$CMD" -p "saClmAction:SA_STRING_T:$ACTION" "$DN"
+ else
+ immadm -t "$TIMEOUT" -o "$CMD" "$DN"
+ fi
fi
exit $?
--
2.17.1
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel