/smp_utils-0.97/examples/zoning_ex.sh

# · Shell · 161 lines · 98 code · 16 blank · 47 comment · 14 complexity · a4a71b5b6cd4cf87d40e8d8193cba60f MD5 · raw file

  1. #!/bin/sh
  2. # This is an example script showing a SAS-2 zoning being set up
  3. # by calling various smp_utils utilities.
  4. # This is a relatively generic script for setting up zoning. The
  5. # customization of the zone groups (who can access whom) is in the
  6. # PERMISSION_FILE while the mapping of expander phy_ids to zone
  7. # groups in in the PHYINFO_FILE.
  8. if [ $1 ] ; then
  9. if [ "-h" = $1 ] || [ "--help" = $1 ] ; then
  10. echo "Usage: zoning_ex.sh [<smp_dev> [<permf> [<pconf>]]]"
  11. echo " where:"
  12. echo " <smp_dev> expander device node"
  13. echo " <permf> permission table file name"
  14. echo " <pconf> phy information file name"
  15. echo
  16. echo "zoning_ex.sh sets up zoning on <smp_dev> according to data in the "
  17. echo "<permf> and <pconf> files. If these are not given, they default"
  18. echo "to values coded within this script which may need editing."
  19. exit 0
  20. fi
  21. fi
  22. # Set SMP_DEV to the first argument given to this script or the fixed
  23. # name shown below. This identifies an expander device (using a bsg
  24. # device node in the fixed name shown below)). Place SMP_DEV
  25. # on the command line of each smp_utils invocation. If the fixed name
  26. # below is used it will probably need to be changed (e.g. look at
  27. # 'ls /dev/bsg' output for available expander nodes).
  28. if [ $1 ] ; then
  29. SMP_DEV="$1"
  30. else
  31. SMP_DEV="/dev/bsg/expander-6:0"
  32. fi
  33. # Assumptions are made in the zone permission table file and the zone phy
  34. # information file. The zone permission table file name is either the
  35. # second argument, or defaults:
  36. if [ $2 ] ; then
  37. PERMISSION_FILE="$2"
  38. else
  39. PERMISSION_FILE="permf_8i9t.txt"
  40. fi
  41. # the zone phy information file name is either the third argument, or
  42. # defaults:
  43. if [ $3 ] ; then
  44. PHYINFO_FILE="$3"
  45. else
  46. PHYINFO_FILE="pconf_2i2t.txt"
  47. fi
  48. # First a SMP ZONE LOCK function is required. Assume the zone manager
  49. # password is zero (i.e. all 32 bytes are zero) or disabled (i.e. all
  50. # 32 bytes 0xff) with the physical presence switch on.
  51. echo "smp_zone_lock $SMP_DEV"
  52. smp_zone_lock $SMP_DEV
  53. res=$?
  54. if [ $res -ne 0 ] ; then
  55. echo "smp_zone_lock failed with exit status: $res"
  56. exit $res
  57. fi
  58. echo
  59. # Then a SMP CONFIGURE ZONE PERMISSION TABLE function is sent.
  60. # Since --save=SAV is not given, only the shadow values are updated
  61. # (and won't be copied to the saved value during the activate step).
  62. # Even though the expander support 256 zone groups, it is still possible
  63. # to provide 128 zone group style descriptors (which is the default for
  64. # this utility). Note that smp_rep_zone_perm_tbl will output 256 style
  65. # descriptors in this case.
  66. echo "smp_conf_zone_perm_tbl --permf=$PERMISSION_FILE --deduce $SMP_DEV"
  67. smp_conf_zone_perm_tbl --permf=$PERMISSION_FILE --deduce $SMP_DEV
  68. res=$?
  69. if [ $res -ne 0 ] ; then
  70. echo "smp_conf_zone_perm_tbl failed with exit status: $res"
  71. echo "N.B. about to unlock the zone"
  72. smp_zone_unlock $SMP_DEV
  73. exit $res
  74. fi
  75. echo
  76. # Next a SMP CONFIGURE ZONE PHY INFORMATION function is sent.
  77. # Set up zone phy information descriptors and since --save=SAV is not
  78. # given, only the shadow values are updated (and won't be copied to the
  79. # saved value during the activate step).
  80. echo "smp_conf_zone_phy_info --pconf=$PHYINFO_FILE $SMP_DEV"
  81. smp_conf_zone_phy_info --pconf=$PHYINFO_FILE $SMP_DEV
  82. res=$?
  83. if [ $res -ne 0 ] ; then
  84. echo "smp_conf_zone_phy_info failed with exit status: $res"
  85. echo "N.B. about to unlock the zone"
  86. smp_zone_unlock $SMP_DEV
  87. exit $res
  88. fi
  89. echo
  90. # Then a SMP ENABLE DISABLE ZONING function is sent.
  91. # Enable zoning is the default action of this utility.
  92. echo "smp_ena_dis_zoning $SMP_DEV"
  93. smp_ena_dis_zoning $SMP_DEV
  94. res=$?
  95. if [ $res -ne 0 ] ; then
  96. echo "smp_ena_dis_zoning failed with exit status: $res"
  97. echo "N.B. about to unlock the zone"
  98. smp_zone_unlock $SMP_DEV
  99. exit $res
  100. fi
  101. echo
  102. # Almost finished with a SMP ZONE ACTIVATE function being sent.
  103. # The above zone phy information, permission table and enable-disable
  104. # values are copied from the shadow values to the current values
  105. # making them "live". Note the "saved" values haven't been altered so
  106. # an expander power cycle (or a disable zoning) will undo any damage
  107. # done by this example.
  108. echo "smp_zone_activate $SMP_DEV"
  109. smp_zone_activate $SMP_DEV
  110. res=$?
  111. if [ $res -ne 0 ] ; then
  112. echo "smp_zone_activate failed with exit status: $res"
  113. echo "N.B. about to unlock the zone"
  114. smp_zone_unlock $SMP_DEV
  115. exit $res
  116. fi
  117. echo
  118. # And the last active step in the SMP ZONE UNLOCK function being sent.
  119. # This will send a Broadcast (Change) [to any affected phys] so any
  120. # connected servers will "see" the change [by doing a "discover process"].
  121. echo "smp_zone_unlock $SMP_DEV"
  122. smp_zone_unlock $SMP_DEV
  123. res=$?
  124. if [ $res -ne 0 ] ; then
  125. echo "smp_zone_unlock failed with exit status: $res"
  126. exit $res
  127. fi
  128. echo
  129. # To see if anything has happened, call smp_discover_list which uses
  130. # the SMP DISCOVER LIST function.
  131. echo "smp_discover_list $SMP_DEV"
  132. smp_discover_list $SMP_DEV
  133. res=$?
  134. if [ $res -ne 0 ] ; then
  135. echo "smp_smp_discover_list failed with exit status: $res"
  136. fi
  137. echo
  138. # Do smp_discover_list again this time with the "ignore zone group"
  139. # bit set.
  140. echo "smp_discover_list --ignore $SMP_DEV"
  141. smp_discover_list --ignore $SMP_DEV
  142. res=$?
  143. if [ $res -ne 0 ] ; then
  144. echo "smp_smp_discover_list failed with exit status: $res"
  145. fi