Here is a command procedure to automatically rename connections on HSG80 pairs, delete offline connections, and set the operating system type correctly.
Please note it requires that you have Command Scripter installed.
$! See end of file for comments.
$ say := write sys$output
$ symnames = "adapter,san_app"
$
$! Define san applicance name.adapter strings here. The name will be used to
$! construct the connection name, so no more than 6 chars, please.
$ san_app_1 = "SANAP1.1000-0000-xxxx-xxxx"
$ san_app_2 = "SANAP1.1000-0000-xxxx-xxxx"
$ san_app_3 = "SANAP2.1000-0000-xxxx-xxxx"
$
$! Retrieve all adapter names on all nodes in the cluster.
$ tmp_file = f$unique () + ".tmp"
$ com_file = f$unique () + ".com"
$ open/write com_file 'com_file'
$ write com_file "$ mcr sysman"
$ write com_file "$ deck"
$ write com_file "set environment/cluster"
$ write com_file "do/out=''tmp_file' show dev/full _fg"
$ write com_file "$ eod"
$ write com_file "$ exit"
$ close com_file
$ @'com_file'
$ deletex/nolog 'com_file';*
$ open tmp_file 'tmp_file'
$ ada_cnt = 0
$loop:
$ read/end_of_file=end_loop tmp_file rec
$ rec = f$edit (rec, "compress, trim")
$ if f$element (0, ",", rec) .eqs. "%SYSMAN-I-OUTPUT"
$ then
$ node = f$element (5, " ", rec)
$ goto loop
$ endif
$ if f$element (0, " ", rec) .eqs. "FC" .and. -
f$element (1, " ", rec) .eqs. "Port" .and. -
f$element (2, " ", rec) .eqs. "Name"
$ then
$ ada_cnt = ada_cnt + 1
$ adapter_'ada_cnt' = "''node'." + f$element (3, " ", rec)
$ endif
$ goto loop
$end_loop:
$ close tmp_file
$ deletex/nolog 'tmp_file';*
$
$! Create commands for command scripter
$ open/write out cmd.txt
$ write out "show this"
$ write out "show connections"
$ close out
$
$ if p1 .nes. ""
$ then
$ wild = p1
$ else
$ wild = "_$1$GGA*:"
$ endif
$
$ctrl_loop:
$ gga = f$device (wild)
$ if gga .eqs. ""
$ then
$ goto end_ctrl_loop
$ endif
$ if f$getdvi (gga, "unit") .gt. 9999
$ then
$! This ignores EMC frames, which by definition at this site are units >9999
$ goto ctrl_loop
$ endif
$ if f$getdvi (gga, "multipath")
$ then
$ current_path = f$getdvi (gga, "mpdev_current_path")
$ path_len = f$length (current_path)
$ which = f$extract (path_len - 1, 1, current_path)
$ if f$locate (which, "89ABCDEF") .lt. 8
$ then
$ goto ctrl_loop ! Ignore EVAs
$ endif
$ endif
$ out_gga = gga - "_" - ":"
$ out_gga = out_gga
$ do_gga = out_gga
$ out_gga = out_gga + ".out"
$ do_del_gga = do_gga + "_del.cmd"
$ do_ren_gga = do_gga + "_ren.cmd"
$ say "Retrieving connection info from ''gga'"
$ define/user sys$output 'out_gga'
$ define/user sys$input cmd.txt
$ mcr cmdscript -f "''gga'"
$ have_name = 0
$ have_id = 0
$ on_ctrl_a = 1
$ open in 'out_gga'
$ open/write delout 'do_del_gga'
$ open/write renout 'do_ren_gga'
$conn_loop:
$ read/end_of_file=end_conn_loop in rec
$ rec = f$edit (rec, "trim,compress")
$ len = f$length (rec)
$ if f$locate ("SCSI address 6", rec) .lt. len
$ then
$ on_ctrl_a = 0
$ endif
$ if f$locate ("THIS", rec) .lt. len .or. -
f$locate ("OTHER", rec) .lt. len
$ then
$ name = f$element (0, " ", rec)
$ os = f$element (1, " ", rec)
$ which_ctrl = f$element (2, " ", rec)
$ port = f$element (3, " ", rec)
$ state = f$element (4, " ", rec)
$ if state .nes. "OL" .and. -
state .nes. "offline"
$ then
$ state = f$element (5, " ", rec)
$ endif
$ have_name = 1
$ endif
$ if f$locate ("HOST_ID", rec) .lt. len
$ then
$ rec = f$edit (rec, "collapse")
$ adapter = f$element (2, "=", rec)
$ if f$length (adapter) .gt. 19
$ then
$ adapter = f$extract (0, 19, adapter)
$ endif
$ have_id = 1
$ endif
$ if have_name .and. have_id
$ then
$ have_name = 0
$ have_id = 0
$ if state .eqs. "offline"
$ then
$ write delout "delete ''name'"
$ goto conn_loop
$ endif
$ gosub make_name
$ if canonical_name .nes. name
$ then
$ write renout "rename ''name' ''canonical_name'"
$ endif
$ if canonical_os .nes. os
$ then
$ write renout "set ''canonical_name' operating_system = " + -
"''canonical_os'"
$ endif
$ endif
$ goto conn_loop
$end_conn_loop:
$ close in
$ close delout
$ close renout
$ deletex/nolog 'out_gga';*
$ append 'do_ren_gga' 'do_del_gga'
$ say "Correcting connection information on " + gga
$ define/user sys$output nl:
$ define/user sys$input 'do_del_gga'
$ mcr cmdscript -f 'gga'
$ if f$search (do_ren_gga) .nes. ""
$ then
$ deletex/nolog 'do_ren_gga';*
$ endif
$ if f$search (do_del_gga) .nes. ""
$ then
$ deletex/nolog 'do_del_gga';*
$ endif
$ goto ctrl_loop
$end_ctrl_loop:
$ deletex/nolog cmd.txt;*
$ exit
$!------------------------------------------------------------------------------
$make_name:
$ canonical_name = ""
$ canonical_os = ""
$ prev_node = ""
$ sym_cnt = 0
$sym_loop:
$ symbol = f$element (sym_cnt, ",", symnames)
$ if symbol .eqs. ","
$ then
$ goto end_sym_loop
$ endif
$
$ mn_cnt = 0
$mn_loop:
$ mn_cnt = mn_cnt + 1
$ if f$type ('symbol'_'mn_cnt') .eqs. ""
$ then
$ goto end_mn_loop
$ endif
$ a = f$element (1, ".", 'symbol'_'mn_cnt')
$ n = f$element (0, ".", 'symbol'_'mn_cnt')
$ if n .nes. prev_node
$ then
$ adapter_number = 1
$ prev_node = n
$ else
$ adapter_number = adapter_number + 1
$ if adapter_number .gt. 9
$ then
$ say "Error - HOW many adapters does this machine have?"
$ exit 44
$ endif
$ endif
$ if a .eqs. adapter
$ then
$ canonical_name = f$element (0, ".", 'symbol'_'mn_cnt')
$ if symbol .eqs. "san_app"
$ then
$ canonical_os = "WINNT"
$ else
$ canonical_os = "VMS"
$ endif
$ goto got_name
$ endif
$ goto mn_loop
$end_mn_loop:
$ sym_cnt = sym_cnt + 1
$ prev_node = ""
$ goto sym_loop
$end_sym_loop:
$ if canonical_name .eqs. ""
$ then
$ say "Error - can't decode name " + adapter
$ exit 44
$ endif
$got_name:
$ canonical_name = canonical_name + f$string (adapter_number)
$ if on_ctrl_a
$ then
$ if which_ctrl .eqs. "THIS"
$ then
$ ctrl_letter = "A"
$ else
$ ctrl_letter = "B"
$ endif
$ else
$ if which_ctrl .eqs. "THIS"
$ then
$ ctrl_letter = "B"
$ else
$ ctrl_letter = "A"
$ endif
$ endif
$ canonical_name = canonical_name + ctrl_letter + port
$ return
$!++
$!
$! DESCRIPTION:
$!
$! This command procedure finds all the fibrechannel adapters on the
$! cluster and constructs symbols containing the name of the host and
$! the name of the adapter, separated by a dot. For example, we might
$! have:
$!
$! adapter_1 = "HOST1.1000-0000-C859-8585"
$! adapter_2 = "HOST1.1000-0000-C859-8586"
$! adapter_3 = "HOST2.1000-0000-5893-95F1"
$! adapter_4 = "HOST2.1000-0000-458E-9854"
$!
$! and so on.
$!
$! In addition to discovered adapters, you can define SAN appliances
$! at the top of the procedure in the SAN_APP_n symbols. Note that
$! adapters defined here will be set to operating system type WINNT,
$! and discovered adapters will be set to operating system type VMS.
$!
$! Once the adapters are discovered, the command procedure uses Command
$! Scripter to collect all the connection information from HSG80
$! controllers, and for each connection, it calculates what the name of
$! the connection should be, based on locating the wwid of the adapter
$! for the connection. Additionally, the connection name has the
$! controller number of the adapter on the host (so FGA0 becomes 1,
$! FGB0 becomes 2, etc), followed by the HSG controller letter (either
$! A or B) and the controller port that the connection refers to.
$!
$! So for example, a connection name might become:
$!
$! HOST22B1
$!
$! which means HOST2, fibrechannel adapter B (ie, FGB0), port 1 of the "B"
$! side of the controller pair.
$!
$! Again, based on which set of symbols the adapter wwid is found in, the
$! operating system is selected (adapter_n symbols result in VMS and
$! san_app_n symbols result in WINNT).
$!
$! The procedure then constructs a set of HSG commands to delete offline
$! adapters, rename adapters that have the wrong name, and set the
$! operating system type if it's incorrect.
$!
$! It then executes those commands on the HSG via Command Scripter.
$!
$! By specifying the appropriate GGA device as P1, you can just process
$! a single HSG80. Don't forget the leading underscore.
$!
$! Author:
$!
$! James F. Duff
$!
$! Creation Date:
$!
$! 12-Oct-2005
$!
$! Modification History:
$!
$! 12-Oct-2005 JFD
$! Original version of module.
$!
$! 02-Dec-2005 JFD
$! Sort deletes first, then renames.
$!--
parhaps you could submit this to dcl.openvms.org ?
It appears useful but I have no FC disks to try it on.
Posted by: Ian Miller at October 14, 2005 4:18 AM
Comments are closed