Skip to content

Instantly share code, notes, and snippets.

@mo6020
Created September 20, 2011 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mo6020/1229251 to your computer and use it in GitHub Desktop.
Save mo6020/1229251 to your computer and use it in GitHub Desktop.
Simple script to check SAN vFiler for existence of LUN clones.
'#----- Check_LUN_Clone.vbs -----
'#----- -----
'# author: Ed Morgan [ed.morgan@hp.com] -----
'# version: 0.1 - 19/09/2011 -----
'# changelog: 0.1 - First Draft -----
'# -----
'# requires: ontapi.exe & vLAN access to SAN -----
'#-----------------------------------------------------------
'# Next functionality - check for locked snapshots
Option Explicit
Dim strVfilerID, strSANid, strRootPW, strCmdLine, strLogLine, strXMLLine strTargetServer, strLUNpath
Dim objCmd, objExecCmd, objLogFile, objXMLDoc, objGetLUNXML, objXMLdocroot, objLUNXMLlist, objLUNlist, objPath
'Get SAN hostname, vFiler info, and root password
strSANid = InputBox("Please enter the SANs hostname.")
strRootPW = InputBox("Please enter the root password.")
strVfilerID = InputBox("Please enter the target vFiler.")
'Set command to pass to the SAN
strCmdLine = ".\ontapi.exe -v " & strVfilerID & " " & strSanID & " root " & strRootPW & " lun-list-info"
setObjCmd = wscript.CreateObject("wscript.shell")
'Create XML for writing LUN list to
Set objGetLUNxml = CreateObject("Scripting.FileSystemObject")
Set objLUNXmlList = objGetLUNXML.CreateTextFile"(.\LunList.xml", true)
'Send command to SAN
Set objExecCmd = objCmd.Exec("%COMSPEC% /c " & strCmdLine)
'Set XML doctype, etc, because I'm anal.
objLunXMLlist.writeline "<!-- Generated by Check_Lun_Clone.vbs at " & Now() & " -- ed.morgan@hp.com -->"
objLunXMLlist.writeline "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>"
objLunXMLlist.writeline "<?xml-stylesheet type='text/xsl'?>"
'Check stdout for output
Do Until objExecCmd.stdOut.AtEndOfStream
strXMLLine = ""
strXMLline = objExecCmd.stdOut.ReadLine()
objLunXMLlist.WriteLine strXMLLine
Loop
objLunXMLlist.close
Set objLunXMLlist = Nothing
Set objLunXML = Nothing
'Read XML file and check for LUN clones
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
'Read in full XML doc before running
objXMLDoc.async = "False"
objXMLDoc.Load(".\LunList.xml")
Set objLUNlist = objXMLDoc.documentElement.selectNodes("luns/lun-info/path")
For Each objPath in objLUNlist
strLUNpath = objPath.text
If inStr(strLUNpath, ".rws") Then
msgbox "LUN clone fount: " & strLUNpath
End If
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment