trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [07/13] incubator-trafodion git commit: Improved display for dcscheck script additional bug fixes
Date Tue, 22 Dec 2015 16:28:38 GMT
Improved display for dcscheck script
additional bug fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/bc691879
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/bc691879
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/bc691879

Branch: refs/heads/master
Commit: bc691879b0012888e12ee2be9d6eb948359e5f30
Parents: 34ff7b3
Author: Anuradha Hegde <Anuradha.Hegde@esgyn.com>
Authored: Wed Dec 16 18:15:30 2015 +0000
Committer: Anuradha Hegde <Anuradha.Hegde@esgyn.com>
Committed: Wed Dec 16 18:15:30 2015 +0000

----------------------------------------------------------------------
 core/sqf/sql/scripts/dcscheck     | 51 ++++++++++++++++++++++++----------
 dcs/bin/scripts/dcsbind.sh        | 11 ++++----
 dcs/bin/scripts/dcsunbind.sh      | 18 ++++++------
 dcs/bin/scripts/parse_dcs_site.py |  6 +++-
 4 files changed, 58 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/bc691879/core/sqf/sql/scripts/dcscheck
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/dcscheck b/core/sqf/sql/scripts/dcscheck
index fd7376f..15006d7 100755
--- a/core/sqf/sql/scripts/dcscheck
+++ b/core/sqf/sql/scripts/dcscheck
@@ -31,7 +31,7 @@ down_dcsmaster_cnt=0
 cfg_dcsserver_cnt=0
 actual_dcsserver_cnt=0
 down_dcsserver_cnt=0
-activeMaster=`hostname`
+activeMaster=localhost
 
 if [ -e $SQ_PDSH ]; then
    L_PDSH="$SQ_PDSH $MY_NODES "
@@ -67,7 +67,7 @@ if [[ $sq_stat == 0 ]]; then
   if [ -s ${DCS_INSTALL_DIR}/conf/backup-masters ]; then
      let backup_dcsmaster_cnt=`/bin/egrep -cv '#|^$' ${DCS_INSTALL_DIR}/conf/backup-masters`
      let cfg_dcsmaster_cnt=$backup_dcsmaster_cnt+1
-     list_of_backups=`cat ${DCS_INSTALL_DIR}/conf/backup-masters | /bin/egrep -v '^#|^$'`
+     list_of_backups=`cat ${DCS_INSTALL_DIR}/conf/backup-masters | /bin/egrep -v '^#|^$'|tr
-d '\n'`
    else
      let cfg_dcsmaster_cnt=1
    fi
@@ -85,14 +85,35 @@ if [[ $sq_stat == 0 ]]; then
 ### Get the node where the active master is running
    if [[ ! -z $CLUSTERNAME ]]; then
      if [[ ! -z $ENABLE_HA ]]; then
-        echo " This cluster \"$CLUSTERNAME\" is configured for HA"
-        gv_float_interface=`python $DCS_INSTALL_DIR/bin/scripts/parse_dcs_site.py|cut -d$'\n'
-f1`
-        activeMaster=`$L_PDSH /sbin/ip addr show |grep $gv_float_interface$ |cut -d':' -f1`
+        echo "Cluster Configuration: HA"
+        floatip_interface=`python $DCS_INSTALL_DIR/bin/scripts/parse_dcs_site.py|cut -d$'\n'
-f1`
+        floatip_port=`python $DCS_INSTALL_DIR/bin/scripts/parse_dcs_site.py|cut -d$'\n' -f3`
+        if [[ -z $floatip_port ]]; then
+            floatip_port=23400
+        fi
+        if [[ -z $AWS_CLOUD ]]; then
+           interface_to_use=$floatip_interface":"$floatip_port
+        else
+           interface_to_use=$floatip_interface
+        fi
+        activeMaster=`$L_PDSH /sbin/ip addr show |grep $interface_to_use$ |cut -d '/' -f1
|awk '{print $3}'`
+        if [[ ! -z $activeMaster ]]; then
+           activeDcsPid=`$L_PDSH $jpscmd |grep DcsMaster |grep $activeMaster |cut -d" " -f2
|tr -d '\n'`
+        fi
      else
-        activeMaster=`$L_PDSH $jpscmd |grep DcsMaster |cut -d":" -f1`
+        activeMaster=`$L_PDSH $jpscmd |grep DcsMaster |cut -d":" -f1 |tr -d '\n'`
      fi
+
+     if ( [ -z $activeMaster ] && [ "$actual_dcsmaster_cnt" '>' 0 ] &&
[ "$actual_dcsserver_cnt" '>' 0 ] ); then
+        echo "Cluster Running      : Non-HA"
+     fi
+   else
+     ### Get the pid of the active DcsMaster 
+     activeDcsPid=`$L_PDSH $jpscmd |grep DcsMaster |cut -d" " -f1`
    fi
 
+
+### Get the count of DcsMaster & DcsServers that are stopped
    if ( [ "$cfg_dcsserver_cnt" '!=' "$actual_dcsserver_cnt" ] ); then
      let down_dcsserver_cnt=cfg_dcsserver_cnt-actual_dcsserver_cnt
    else
@@ -115,27 +136,29 @@ if [[ $sq_stat == 0 ]]; then
   else
     down_mxo_cnt=''
   fi 
-
+  echo
   if ( [ "$actual_dcsmaster_cnt" '!=' 0 ] && [ "$actual_dcsserver_cnt" '!=' 0 ] );
then
    echo "ls $dcsznode"|$DCS_INSTALL_DIR/bin/dcs zkcli > $dcstmp
    zkport=`cat $dcstmp | /usr/bin/head -n 1 | cut -d ":" -f2`
    if [ ! -z "$zkport" ]; then
-     echo "Zookeeper is listening on port \"$zkport\""
+     echo "Zookeeper listen port: $zkport"
    else
      echo "Zookeeper is not started..."
      exit 1
    fi
    masterport=`cat $dcstmp | /usr/bin/tail -n 1 | cut -d ":" -f4`
    if [ ! -z "$masterport" ]; then
-     echo "DcsMaster is listening on port \"$masterport\""
+     echo -e "DcsMaster listen port: $masterport\n"
      if [[ ! -z $primary_dcsmaster ]]; then
-        echo "Primary DcsMaster configured to run on node \"$primary_dcsmaster\""
-     fi
-     if [[ ! -z $activeMaster ]]; then
-        echo "Active DcsMaster is on node \"$activeMaster\""
+        echo "Configured Primary DcsMaster: \"$primary_dcsmaster\""
      fi
      if [[ ! -z $list_of_backups ]]; then
-        echo "Backup DcsMasters configured to run on nodes \"$list_of_backups\""
+        echo "Configured Backup DcsMasters: \"$list_of_backups\""
+     fi
+     if ( [ ! -z $activeMaster ] && [ ! -z $activeDcsPid ] ); then
+        echo "Active DcsMaster            : \"$activeMaster\", pid $activeDcsPid"
+     else
+        echo "Active DcsMaster            : \"$activeMaster\""
      fi
      echo
    fi

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/bc691879/dcs/bin/scripts/dcsbind.sh
----------------------------------------------------------------------
diff --git a/dcs/bin/scripts/dcsbind.sh b/dcs/bin/scripts/dcsbind.sh
index 038acc9..8436272 100755
--- a/dcs/bin/scripts/dcsbind.sh
+++ b/dcs/bin/scripts/dcsbind.sh
@@ -329,6 +329,7 @@ gv_float_external_interface=""
 gv_float_external_ip=""
 gv_float_internal_ip=""
 gv_port=0
+awscmd=/usr/local/bin/aws
 
 gv_ok=0
 gv_warn=1
@@ -361,23 +362,23 @@ else
     dcsEcho "Using device index $device_index_to_use for $gv_float_external_interface"
 
     # Get instance Id of the instance
-    INSTANCEID=`aws ec2 describe-instances |grep -i instances |grep -i $gv_myhostname |cut
-f8`
+    INSTANCEID=`$awscmd ec2 describe-instances |grep -i instances |grep -i $gv_myhostname
|cut -f8`
     dcsEcho "Using Instance id $INSTANCEID"
 
     # Get the network interface configured for the vpc
-    NETWORKINTERFACE=`aws ec2 describe-network-interfaces| grep -i networkinterfaces| grep
-i $gv_float_internal_ip|cut -f5`
+    NETWORKINTERFACE=`$awscmd ec2 describe-network-interfaces| grep -i networkinterfaces|
grep -i $gv_float_internal_ip|cut -f5`
     dcsEcho "Using network interface $NETWORKINTERFACE"
 
     # Get the attachment id for the network interface
-    ATTACH_ID=`aws ec2 describe-network-interfaces --network-interface-ids $NETWORKINTERFACE
|grep -i attachment |cut -f3`
+    ATTACH_ID=`$awscmd ec2 describe-network-interfaces --network-interface-ids $NETWORKINTERFACE
|grep -i attachment |cut -f3`
     if [ ! -z "$ATTACH_ID" ]; then
         dcsEcho "Detaching attachment Id:" $ATTACH_ID
-        aws ec2 detach-network-interface --attachment-id $ATTACH_ID
+        $awscmd ec2 detach-network-interface --attachment-id $ATTACH_ID
     fi
 
     dcsEcho "Going to attach network interface $NETWORKINTERFACE to the another instance"
     sleep 10
-    NEWATTACH_ID=`aws ec2 attach-network-interface --network-interface-id $NETWORKINTERFACE
--instance-id $INSTANCEID --device-index $device_index_to_use`
+    NEWATTACH_ID=`$awscmd ec2 attach-network-interface --network-interface-id $NETWORKINTERFACE
--instance-id $INSTANCEID --device-index $device_index_to_use`
     dcsEcho "New attachment Id " $NEWATTACH_ID
     sleep 10
     configure_route_tables

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/bc691879/dcs/bin/scripts/dcsunbind.sh
----------------------------------------------------------------------
diff --git a/dcs/bin/scripts/dcsunbind.sh b/dcs/bin/scripts/dcsunbind.sh
index e881606..65c661d 100755
--- a/dcs/bin/scripts/dcsunbind.sh
+++ b/dcs/bin/scripts/dcsunbind.sh
@@ -34,9 +34,9 @@ function check_node {
 	       # check if another interface is bound to this virtual ip address
 	       echo "$myifport" | grep "$tempinterface"  > /dev/null
 	       if [ $? -eq 1 -o "$1" != "$gv_myhostname" ]; then
-                   unbindip = `echo "$myifport" | awk '{print $2}' `
+                   unbindip=`echo "$myifport" | awk '{print $2}'`
 		   unbindlb=`echo "$myifport"|awk '{print $NF}'`
-		   echo "External ip $gv_float_external_ip is already in use on node $1 bound to interface
$myinterface($unbindlb) - unbind..."
+		   echo "External ip $gv_float_external_ip is in use on node $1 bound to interface $myinterface($unbindlb)
- unbind..."
 		   $SQ_PDSH -S -w $1 sudo /sbin/ip addr del $unbindip dev $myinterface label $unbindlb
                    status=$?
 		   if [ $status -ne 0 ]; then
@@ -45,8 +45,6 @@ function check_node {
                    else
                       echo "Unbind successful"
                    fi
-	       else
-	           echo "External ip $gv_float_external_ip is already bound to $myinterface on node
$1 - skip unbind"
 	       fi # endif node+name match
 	    fi # endif looking for external ip
         fi #endif checking external ip is set or not
@@ -71,20 +69,24 @@ function Check_VirtualIP_InUse_And_Unbind {
 gv_float_internal_ip=`python $DCS_INSTALL_DIR/bin/scripts/parse_dcs_site.py|cut -d$'\n' -f2`
 gv_float_external_ip=`python $DCS_INSTALL_DIR/bin/scripts/parse_dcs_site.py|cut -d$'\n' -f2`
 gv_float_interface=`python $DCS_INSTALL_DIR/bin/scripts/parse_dcs_site.py|cut -d$'\n' -f1`
-gv_port=23400
+gv_port=`python $DCS_INSTALL_DIR/bin/scripts/parse_dcs_site.py|cut -d$'\n' -f3`
+if [[ -z $gv_port ]]; then
+   gv_port=23400
+fi
+awscmd=/usr/local/bin/aws
 gv_externalip_set=1
 gv_internalip_set=1
 
 if [[ ! -z $AWS_CLOUD ]]; then
    #Get the network interface
-   NETWORKINTERFACE=`aws ec2 describe-network-interfaces| grep -i networkinterfaces| grep
-i $gv_float_internal_ip|cut -f5`
+   NETWORKINTERFACE=`$awscmd ec2 describe-network-interfaces| grep -i networkinterfaces|
grep -i $gv_float_internal_ip|cut -f5`
 
    # Get the attachment id for the network interface
-   ATTACH_ID=`aws ec2 describe-network-interfaces --network-interface-ids $NETWORKINTERFACE
|grep -i attachment |cut -f3`
+   ATTACH_ID=`$awscmd ec2 describe-network-interfaces --network-interface-ids $NETWORKINTERFACE
|grep -i attachment |cut -f3`
 
    echo "Detaching attachment Id:" $ATTACH_ID
    if [ ! -z "$ATTACH_ID" ]; then
-      aws ec2 detach-network-interface --attachment-id $ATTACH_ID
+      $awscmd ec2 detach-network-interface --attachment-id $ATTACH_ID
       echo "Detached interface :" $NETWORKINTERFACE
    fi
 else

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/bc691879/dcs/bin/scripts/parse_dcs_site.py
----------------------------------------------------------------------
diff --git a/dcs/bin/scripts/parse_dcs_site.py b/dcs/bin/scripts/parse_dcs_site.py
index 0fc7949..c5947a4 100755
--- a/dcs/bin/scripts/parse_dcs_site.py
+++ b/dcs/bin/scripts/parse_dcs_site.py
@@ -25,13 +25,17 @@ import os
 from xml.dom import minidom
 
 dcsconfig_dir = os.environ.get('DCS_CONF_DIR')
-if (dcsconfig_dir == null)
+if not dcsconfig_dir:
    name = os.environ.get('DCS_INSTALL_DIR')
    dcsconfig_dir=name+"/conf"   
 doc = minidom.parse(dcsconfig_dir+"/dcs-site.xml")
 props = doc.getElementsByTagName("property")
 for prop in props:
         pname = prop.getElementsByTagName("name")[0]
+        if (pname.firstChild.data == "dcs.master.port"):
+           pvalue = prop.getElementsByTagName("value")[0]
+           dcsPort=pvalue.firstChild.data
+           print("%s" % (dcsPort))
         if (pname.firstChild.data == "dcs.master.floating.ip.external.ip.address"):
            pvalue = prop.getElementsByTagName("value")[0]
            float_ipaddress=pvalue.firstChild.data


Mime
View raw message