Advertisement
Guest User

Untitled

a guest
Nov 9th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.56 KB | None | 0 0
  1. diff --git a/t0backend/src/main/python/t0/backend/raidcreate/raidcreate.py b/t0backend/src/main/python/t0/backend/raidcreate/raidcreate.py
  2. index 052c64a..0ef2c3c 100755
  3. --- a/t0backend/src/main/python/t0/backend/raidcreate/raidcreate.py
  4. +++ b/t0backend/src/main/python/t0/backend/raidcreate/raidcreate.py
  5. @@ -82,6 +82,67 @@ rm -f $tmp
  6.  
  7.  crm_initial_conf = '/var/lib/mdraidscripts/initial.crm'
  8.  
  9. +check_disks = '''
  10. +    function check_disks () {
  11. +        OPTIND=1;
  12. +        while getopts ":e:f:z:s:" opt; do
  13. +            case "$opt" in
  14. +              e)  empty_slots="$empty_slots $OPTARG"
  15. +                  ;;
  16. +              f)  failed_slots="$failed_slots $OPTARG"
  17. +                  ;;
  18. +              z)  zero_cap_slots="$zero_cap_slots $OPTARG"
  19. +                  ;;
  20. +              s)  enclosure=$OPTARG
  21. +                  ;;
  22. +            esac
  23. +        done
  24. +        for slot in $empty_slots; do
  25. +          present=$(wbcli $enclosure "getdrivestatus $slot" | awk -F"[[:space:]]+:[[:space:]]+" '/present/{print $2}');
  26. +          if [[ "x$present" == "xyes" ]]; then
  27. +            failed_slots="$failed_slots $slot"
  28. +          fi;
  29. +        done;
  30. +        failed_slots="$failed_slots $zero_cap_slots"
  31. +        slots_count=$(wbcli $encl "getdrivebaycount" | awk '/Found [0-9]+ bays/{print $2}');
  32. +        i=0;
  33. +        while [ $i -lt $slots_count ]; do
  34. +          if [[ $failed_slots =~ $i ]]; then
  35. +            wbcli $enclosure "setdriveindicator $slot";
  36. +            echo "Disk checking: slot $slot of enclosure $enclosure is failed!" >&1;
  37. +          else
  38. +            wbcli $enclosure "cleardriveindecator $i";
  39. +          fi
  40. +          let "i += 1";
  41. +        done
  42. +        if [[ ! $failed_slots =~ ^[[:space:]]*$ ]]; then
  43. +          exit 1;
  44. +        fi
  45. +        exit 0;
  46. +    }
  47. +    export -f check_disks;
  48. +    dm_report | awk -F":[[:space:]]+|,[[:space:]]" \
  49. +    'BEGIN {  first_encl=1; empty_slots="";
  50. +              failed_slots=""; zero_cap_slots="";
  51. +              error=0;
  52. +           }
  53. +     /^encl\:/{  if (!first_encl) {
  54. +                   e=system("check_disks " empty_slots " " failed_slots " " zero_cap_slots " -s " encl);
  55. +                   error = (e > error) ? e : error;
  56. +                 }
  57. +                 first_encl=0; encl=$6;
  58. +                 empty_slots=""; failed_slots=""; zero_cap_slots=""
  59. +              };
  60. +     /status: (Empty)/{ empty_slots = empty_slots " -e " $2 };
  61. +     /status: (Failed)/{ failed_slots = failed_slots " -f " $2 };
  62. +     /cap:[[:space:]]+0/{ zero_cap_slots = zero_cap_slots " -z "  $2 };
  63. +     END {  e = system("check_disks " empty_slots " " failed_slots " " zero_cap_slots " -s " encl);
  64. +            exit (e > error) ? e : error;
  65. +         }'; && unset check_disks; &&
  66. +
  67. +'''
  68. +
  69. +
  70.  class PipelineItem(object):
  71.      """Holder for the pipeline item attributes like 'nodeset', 'chain', 'flags'"""
  72.  
  73. @@ -148,29 +209,29 @@ osg_create_chain = [
  74.      PipelineItem(nodeset='@all', chain=['rm -f /var/lib/mdraidscripts/mdadm.conf'],
  75.                   info="Deleting mdadm.conf"),
  76.      PipelineItem(nodeset="@oss=primary",
  77. -                 chain=['/usr/sbin/mdraid-gpfs -t %s'],
  78. +                 chain=[check_disks + '/usr/sbin/mdraid-gpfs -t %s'],
  79.                   info="Creating RAID structures on NSD nodes", tags=['gpfs']),
  80.      PipelineItem(nodeset="@oss=primary",
  81. -                 chain=[kvm_magic, '/usr/sbin/mdraid-create `cat /tmp/kvm_opts` %s -v oss'],
  82. +                 chain=[kvm_magic, check_disks + '/usr/sbin/mdraid-create `cat /tmp/kvm_opts` %s -v oss'],
  83.                   info="Creating RAID structures on OSS nodes", tags=['vanilla', 'hardened']),
  84.      PipelineItem(nodeset="@oss=primary",
  85.                   chain=['/usr/sbin/mdraid-regenerate-conf -c', '/usr/sbin/mdraid-activate -d -m'],
  86.                   info="Activating RAIDs on OSS nodes",
  87.                   ),
  88.      PipelineItem(nodeset="@mds=primary",
  89. -                 chain=[kvm_magic, '/usr/sbin/mdraid-create `cat /tmp/kvm_opts` %s -v mds --cmu_no_external'],
  90. +                 chain=[kvm_magic, check_disks + '/usr/sbin/mdraid-create `cat /tmp/kvm_opts` %s -v mds --cmu_no_external'],
  91.                   info="Creating RAID structures on MDS nodes", flags=[CREATE_MDS], tags=['classic']),
  92.      PipelineItem(nodeset="@mds=primary",
  93. -                 chain=[kvm_magic, '/usr/sbin/mdraid-create `cat /tmp/kvm_opts` %s -v mds --config=ls300 --force_node_attr=primary --cmu_no_external'],
  94. +                 chain=[kvm_magic, check_disks + '/usr/sbin/mdraid-create `cat /tmp/kvm_opts` %s -v mds --config=ls300 --force_node_attr=primary --cmu_no_external'],
  95.                   info="Creating RAID structures on MDS nodes", flags=[CREATE_MDS], tags=['l300']),
  96.      PipelineItem(nodeset="@mgmt=primary",
  97. -                 chain=[kvm_magic, '/usr/sbin/mdraid-create `cat /tmp/kvm_opts` %s -v smu'],
  98. +                 chain=[kvm_magic, check_disks + '/usr/sbin/mdraid-create `cat /tmp/kvm_opts` %s -v smu'],
  99.                   info="Creating RAID structures on MGMT nodes", tags=['smu']),
  100.      PipelineItem(nodeset="@mgmt",
  101.                   chain=['/sbin/service diskmonitor restart'],
  102.                   info="Restarting diskmonitor on MGMT nodes", tags=['gpfs']),
  103.      PipelineItem(nodeset="@mgmt=primary",
  104. -                 chain=['/usr/sbin/mdraid-gpfs -p mgmt %s'],
  105. +                 chain=[check_disks + '/usr/sbin/mdraid-gpfs -p mgmt %s'],
  106.                   info="Creating RAID structures on MGMT nodes", tags=['gpfs']),
  107.      PipelineItem(nodeset="@mgmt",
  108.                   chain=['/usr/sbin/crm_attribute --type node --lifetime forever --name csflavor --update gpfs'],
  109. @@ -458,7 +519,7 @@ class RaidScriptOSGRun():
  110.              self.flavor = Config.get_flavor()
  111.              add_tag(self.flavor)
  112.          else:
  113. -            add_tag(self.flavor) #force flavor
  114. +            add_tag(self.flavor) #force flavor
  115.              trace("Force running for flavor: "+self.flavor)
  116.  
  117.          if keep_data:
  118. @@ -525,7 +586,7 @@ class RaidScriptOSGRun():
  119.                              self, node, cmd.format(
  120.                                  p_host=p_host, ipmi_user=ipmi_user,
  121.                                  ipmi_pass=ipmi_pass, s_host=s_host, sec_ipmi_netmask=sec_ipmi_netmask,
  122. -                                sec_ipmi_gateway=sec_ipmi_gateway, gem_stonith=gem_stonith, fscontext=fscontext,
  123. +                                sec_ipmi_gateway=sec_ipmi_gateway, gem_stonith=gem_stonith, fscontext=fscontext,
  124.                 ), info=step.info, logical_step="stonith_mds")
  125.              elif step.flags and STONITH_OSS in step.flags:
  126.                  for node in NodeSet.expand(step.nodeset):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement