Hi,

Any comments on this? I will push the patch this Wednesday if getting no comments.

Regards, Vu

On 01/08/2019 09:53, Vu Minh Nguyen wrote:
The tipc-config command is obsolete and no longer being maintained. We should
switch to using the "tipc" command instead
---
  Makefile.am                                   |  3 ++-
  opensaf.spec.in                               |  1 +
  .../archive/scripts => scripts}/tipc-config   | 15 ++++++++++++--
  src/nid/configure_tipc.in                     | 16 ++++++---------
  src/nid/opensafd.in                           | 20 +++++++++++--------
  tools/cluster_sim_uml/build_uml               |  2 +-
  6 files changed, 35 insertions(+), 22 deletions(-)
  rename {tools/cluster_sim_uml/archive/scripts => scripts}/tipc-config (83%)

diff --git a/Makefile.am b/Makefile.am
index b3d6553c1..6d86ec180 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -159,7 +159,8 @@ dist_osaf_execbin_SCRIPTS += \
        $(top_srcdir)/scripts/opensaf_reboot \
        $(top_srcdir)/scripts/opensaf_sc_active \
        $(top_srcdir)/scripts/opensaf_scale_out \
-       $(top_srcdir)/scripts/plm_scale_out
+       $(top_srcdir)/scripts/plm_scale_out \
+       $(top_srcdir)/scripts/tipc-config
include $(top_srcdir)/src/ais/Makefile.am
  include $(top_srcdir)/src/base/Makefile.am
diff --git a/opensaf.spec.in b/opensaf.spec.in
index 0effd59cd..37be5de6d 100644
--- a/opensaf.spec.in
+++ b/opensaf.spec.in
@@ -950,6 +950,7 @@ fi
  %{_pkglibdir}/plm_scale_out
  %{_pkglibdir}/opensaf_sc_active
  %{_pkglibdir}/configure_tipc
+%{_pkglibdir}/tipc-config
%files amf-libs
diff --git a/tools/cluster_sim_uml/archive/scripts/tipc-config 
b/scripts/tipc-config
similarity index 83%
rename from tools/cluster_sim_uml/archive/scripts/tipc-config
rename to scripts/tipc-config
index f9fd47937..34eb9a539 100755
--- a/tools/cluster_sim_uml/archive/scripts/tipc-config
+++ b/scripts/tipc-config
@@ -1,4 +1,4 @@
-#!/bin/ash
+#!/bin/bash
  #
  #      -*- OpenSAF  -*-
  #
@@ -39,7 +39,18 @@ fi
  while [ $# -gt 0 ]; do
      case "$1" in
        -addr)
-           echo "node address: $(/sbin/tipc node get address)"
+               addr=$(/sbin/tipc node get address)
+               hex_pattern="^[0-9a-fA-F]+$"
+               if [[ $addr =~ $hex_pattern ]]; then
+                       dec_addr=$((16#$addr))
+                       # the algorithm is based on /usr/include/linux/tipc.h
+                       # to form tipc node address into 'Z.C.N' format.
+                       tipc_zone=$((dec_addr >> 24))
+                       tipc_cluster=$(((dec_addr >> 12) & 0xfff))
+                       tipc_node=$((dec_addr & 0xfff))
+                       addr="<$tipc_zone.$tipc_cluster.$tipc_node>"
+               fi
+               echo "node address: $addr"
            ;;
        -a=*)
            /sbin/tipc node set address "$(echo "$1" | cut -d= -f2)"
diff --git a/src/nid/configure_tipc.in b/src/nid/configure_tipc.in
index 33621a0ef..5d0bf6efb 100644
--- a/src/nid/configure_tipc.in
+++ b/src/nid/configure_tipc.in
@@ -78,12 +78,13 @@ if ! [ -x "${tipc}" ] && ! [ -x "${tipc_config}" ]; then
      exit 1
  fi
+# Prefer using `tipc` over the obsoleted `tipc-config`
+if [ -x "${tipc}" ]; then
+    tipc_config="${pkglibdir}"/tipc-config
+fi
+
  if [ "$MANAGE_TIPC" != "yes" ] && ! [ -s "$pkglocalstatedir/node_id" ]; then
-    if [ -x "${tipc}" ]; then
-       addr=$(tipc node get address | cut -d'<' -f2 | cut -d'>' -f1)
-    else
-       addr=$(tipc-config -addr | cut -d'<' -f2 | cut -d'>' -f1)
-    fi
+       addr=$(${tipc-config} -addr | cut -d'<' -f2 | cut -d'>' -f1)
      addr=$(echo "$addr" | cut -d. -f3)
      CHASSIS_ID=2
      SLOT_ID=$((addr & 255))
@@ -98,11 +99,6 @@ fi
  ETH_NAME=$2
  TIPC_NETID=$3
-if ! [ -x "${tipc_config}" ]; then
-    echo "error: tipc-config is not available"
-    exit 1
-fi
-
  # Get the Chassis Id and Slot Id from @sysconfdir@/@PACKAGE_NAME@/chassis_id 
and @sysconfdir@/@PACKAGE_NAME@/slot_id
  if ! test -f "$CHASSIS_ID_FILE"; then
     echo "$CHASSIS_ID_FILE doesnt exists, exiting ...."
diff --git a/src/nid/opensafd.in b/src/nid/opensafd.in
index 94888039a..f85cf5b0c 100644
--- a/src/nid/opensafd.in
+++ b/src/nid/opensafd.in
@@ -50,7 +50,7 @@ osafcshash=@INTERNAL_VERSION_ID@
  unload_tipc() {
# Unload TIPC if already loaded
-       if [ $MANAGE_TIPC = "yes" ] && grep tipc /proc/modules >/dev/null 2>&1; 
then
+       if [ "$MANAGE_TIPC" = "yes" ] && grep tipc /proc/modules >/dev/null 
2>&1; then
                modprobe -r tipc >/dev/null 2>&1
                if [ $? -eq 1 ]; then
                        logger -t $osafprog "warning: TIPC module unloading 
failed"
@@ -59,13 +59,17 @@ unload_tipc() {
  }
check_tipc() {
-       # Exit if tipc-config is not installed
-       if [ "$MANAGE_TIPC" = "yes" ] && [ ! -x /sbin/tipc-config ]; then
-               which tipc-config >/dev/null 2>&1
-               if [ $? -eq 1 ] ; then
-                       logger -s -t $osafprog "Can't find tipc-config in the PATH, 
exiting."
-                       exit 5
-               fi
+
+       if [ "$MANAGE_TIPC" != "yes" ]; then
+               return 0
+       fi
+
+       tipc=$(which tipc 2> /dev/null)
+       tipc_config=$(which tipc-config 2> /dev/null)
+
+       if ! [ -x "${tipc}" ] && ! [ -x "${tipc_config}" ]; then
+               logger -s -t $osafprog "error: neither tipc nor tipc-config is 
available"
+               exit 1
        fi
unload_tipc
diff --git a/tools/cluster_sim_uml/build_uml b/tools/cluster_sim_uml/build_uml
index ce9e8a9f5..8e48bb5a5 100755
--- a/tools/cluster_sim_uml/build_uml
+++ b/tools/cluster_sim_uml/build_uml
@@ -225,7 +225,7 @@ cmd_create_rootfs()
install -m 755 $archive/scripts/*.rc etc/init.d
      cp $scripts/profile etc
-    cp $scripts/reboot $scripts/shutdown $scripts/tipc-config usr/sbin
+    cp $scripts/reboot $scripts/shutdown $opensaf_home/scripts/tipc-config 
usr/sbin
      mkdir -p root/www/cgi-bin
      cp $scripts/rshd root/www/cgi-bin
      cp $scripts/rsh $scripts/rcp $scripts/sudo usr/bin



_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to