Created
September 20, 2011 14:32
-
-
Save mo6020/1229251 to your computer and use it in GitHub Desktop.
Simple script to check SAN vFiler for existence of LUN clones.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'#----- 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