Part 5 – LeftHand Scripting

      No Comments on Part 5 – LeftHand Scripting

In the last 4 posts I showed you how to configure a LeftHand VSA, create volumes, map them to servers, and then attach them to either a ESXi server or a physical Windows host.  Now we are going to learn how to do LeftHand scripting.  The scripting agent of the LeftHand SAN solution is pretty slick.  Alright, lets get right into it…

To start we need to ensure we have a few things in place.  I’m going to be working with a brand new physical server (doesn’t have to be) during this lab and the only item I need to install is the LeftHand CLIQ.  The LeftHand CLIQ is the LeftHand command line management utility.  To get it I suggest you contact your LeftHand support specialist and request it.  I’m not going to walk through the installation since its pretty straight forward but once you get it installed you’ll have access to the CLIQ interface at the command prompt.  In the next section I’m going to walk through a few commands that are of particular use in regards to the LeftHand SAN.  As an FYI you’ll need to enter your relevant info that is specified between the <> brackets.

Create a Snapshot of a volume
cliq createSnapshot volumeName=<volume name>  snapshotName=<snap shot name> login=<cluster IP address> userName=<username for the cluster> passWord=<password for the cluster>

Example – cliq createSnapshot volumeName=Volume1 snapshotName=BackupSnap login= userName=admin passWord=admin

Delete a Snapshot of a volume
cliq deleteSnapshot snapshotName=<snap shot name> login=<cluster IP address> userName=<username for the cluster> passWord=<password for the cluster> prompt=<True of False, if you want a prompt before you delete>

Example – cliq deleteSnapshot snapshotName=BackupSnap login= userName=admin passWord=admin prompt=false

Assign a snapshot/volume to a server
cliq assignVolume volumeName=<volume or snapshot name> initiator=<The ISCSI name of the host you want to attach to> login=<cluster IP address> userName=<username for cluster> passWord=<password for cluster>

Example – cliq assignVolume volumeName=Volume1 login= userName=admin passWord=admin

Unassign a snapshot/volume to a server
cliq unassignVolume volumeName=<volume or snapshot name> login=<cluster IP address> userName=<username for cluster> passWord=<password for cluster>

Example – cliq unassignVolume volumename=Volume1 login= username=admin pas

These are only 4 commands out of many more.  If you are interested I have attached a copy of the CLIQ user guide from LeftHand which walks through all of them.

Now that we know some basics of the CLIQ script interface let’s look at scripting with the MS ISCSI software initiator.  The MS scripting engine is installed by default when you install the initiator, all you have to do in order to access it is go to a command prompt and enter ‘iscsicli’ followed by the command of your choice.  Let’s walk through some of the basic commands.

Add a target portal 
iscsicli qaddtargetportal <Target’s IP address>

Example – iscsicli qaddtargetportal

Note: The full command here is addtargetportal.  The ‘q’ in front of the command specifies “quick” which means that you don’t have all of the available options for the command.  In this instance we only need to specify the Target’s IP address.  With the full command we can specify port number, CHAP user, CHAP Secret, etc…  If you need any of those options type in ‘iscsicli addtargetportal ?’ to get the full syntax.  In these examples I will not be using CHAP, rather I have specified the servers ISCSI IQN in the LeftHand CMC.

List the available volumes/targets
iscsicli listtargets

Example – iscsicli listtargets

Note: This will return all of the available targets or volumes that you can logon to.  I have found that sometimes I can’t simply add a new volume to the server in the LeftHand CMC and then have it appear when I list the targets.  Rather I have to remove the target portal and re-add it.  You’ll need the IQN value this command returns to use in the Logon command shown next.

Logon to volumes/targets
iscsicli qlogintarget <volume/target IQN>

Example – iscsicli qlogintarget

Note: Once you run this command the volume should appear under My Computer provided that it is formatted NTFS.  If not, check the Disk Manager to see if it’s showing up at all.  While doing some testing earlier I found that I couldn’t get the disk to appear despite the fact that it was listed as “connected” in the initiator.  After investing too much time in troubleshooting I uninstalled the initiator, rebooted the server, reinstalled the initiator and everything started working fine again.

Report the mappings
iscsicli reporttargetmappsings

Example – iscsicle reporttargetmappsings

Note: Once you logon to the target this command shows you the details of the actual connection.  For instance it shows you the session ID which is required for the logout command shown next.

Logout of volumes/targets
iscsicli logouttarget <session ID>

Example – iscsicli logouttarget ffffffff8585d6d4-400001370000000a

Note: After you logout of the target the initiator will still show the target.  The next command shows you how to remove that.

Remove a target portal
iscsicli removetargetportal <Target IP Address> <Target port Number (Default 3260)>

Example – iscsicli removetargetportal 3260

Note: For some reason I can’t find a ‘q’ version of this command so you need to specify a port number.

Again I have only gone over a few out of the large number of possible commands.  If you are interested in more I have attached the MS document on the ISCSI initiator which, starting on page 113, describes more ISCSICLI commands.

Summary: So as you can see you can do almost anything through both utilities scripting interfaces.  If you put all it all together and work in some temp file scripting (to pull variables) you can make your own backup scripts for your SAN.  If you aren’t interested in building your own, contact your local LeftHand technical resource.  They were able to provide me with quite a few examples.  I don’t think I have seen any that are ‘perfect’ as of yet, but everyone’s environment is different.

Leave a Reply

Your email address will not be published. Required fields are marked *