PowerCLI: Balance LUN paths for a Cluster

As I’ve been managing more and more infrastructures using fibre channel storage, I’ve found that it’s been somewhat difficult to keep the LUN paths to each host balanced. By balanced, I mean that for each LUN to each host, there is a number of paths and I want to make sure that, for example, each LUN 10 to each of the hosts is using path A as the primary and path B as the stand by. LUN 11 uses path B as the primary, LUN 12 back to path A, and so on.

It so happens that I’m using a DMX-4 for storage, and the policy we have is to use a fixed path policy. I realize that Round Robin would make this entire script moot, well, except for making sure that the PSP is correct. I also realize that PowerPath would be the ideal solution for EMC storage, but we don’t use it…that’s a story for another day.

This script is, admittedly, long…longer than I expected it to be. The original inspiration for this script came from Justin Emerson’s very functional and succinct script, however I was not satisfied with the way LUNs were balanced. His script queries the host for LUNs then sorts them by canonical name and round robins the paths based on the number of paths present for the first LUN.

This works well, so long as all the LUNs are present on all the hosts and they all have the same number of paths. I can only presume that he assumes that those cases have already been checked for, and fixed, prior to execution. I wanted to do that all in one script.

Additionally, and it’s rather petty, I wanted the LUNs to be balanced based off their LUN identifier rather than the canonical name…they don’t always follow the same order, and in the case of my hosts with two HBAs (and consequentially, two paths per LUN), I wanted all odd LUNs to use one path for the primary and all even LUNs to use the other. Justin’s script does an excellent job of ensuring that the paths are evenly distributed, as you will end up with the same number on each, but not in the pretty fashion I desired.

Also, thank you to Glenn, who helped me “powershellize” this script…my PowerShell looks and reads like Perl, and therefore doesn’t use a lot of the optimizations that PoSH brings…such as automatic parameter handling and other niceties.

So, without further ado…

Continue Reading »

PowerCLI
Powershell
vSphere

Comments (0)

Permalink

PowerCLI: Show HBA Path Status

When you have a lot of hosts, with a lot of LUNs, it can be difficult to keep abreast of the status of the paths for them. I have encountered issues where a path was unknowingly marked as dead, plus it’s generally a good idea to ensure that your storage paths are actually available.

Consequentially, I searched for a PowerCLI script that would give me a simple report of the status of each of the LUN paths to each of the HBAs on my hosts. I found John Milner’s post to be very helpful, and it gave me exactly the results that I wanted. However, it took forever to execute…almost 30 minutes for just one of my clusters (to be fair, that cluster has 12 hosts with > 100 LUNs and two paths to each).

Using his script as an example, and keeping a good bit of the formatting code, I have modified his script to use views of the host objects and cull the information from there. This makes it significantly faster…what took 28 minutes before now takes about 30 seconds.

Continue Reading »

PowerCLI
Powershell

Comments (2)

Permalink

Atlanta PowerShell User Group

Last week I had the pleasure of presenting to the Atlanta PowerShell User Group.  The presentation was available over live meeting, if you missed it the recording can be found below.  The scripts used in this presentation can also be downloaded here.  Note we had a little problem getting the audio working so fast forward to the 2:00 minute mark.

Atlanta PowerShell User Group August 2011 from Glenn Sizemore.

~Glenn

NetApp
Powershell

Comments (0)

Permalink

Perl Toolkit: Check ESX(i) host time

I had an issue recently where a single ESXi host’s clock was incorrect. The administrator had never set the clock initially, so NTP never kept it in sync cause it was too far off to begin.

Since I’ve got a large number of hosts and the idea of clicking to each one through VI Client and checking the configuration tab, I immediately turned to PowerCLI. Naturally, one of Luc‘s scripts was the top search result.

That solved my immediate need to check the hosts, but I also wanted to setup some general monitoring. Since my monitoring infrastructure is compromised, primarily, of a linux Nagios host, that means PowerCLI couldn’t help. So, I did the next best thing and ported Luc’s script to perl.

Below is the result of that porting. It can also be run from vMA for reporting via email or another mechanism.

Continue Reading »

ESX
ESXi
Perl

Comments (0)

Permalink

NetApp PowerGUI PowerPack, the inside story.

My NetApp fanboyism is fairly well established at this point.  I devoted almost three years to developing a PowerShell module that would teach NetApp how PowerShell worked.  To my delight a year ago at TechED they took the storage world by surprise when they shipped an official module.  I was then humbled to learn that they had found PoshONTAP, and used it as a blueprint when developing the DataONTAP PowerShell toolkit.  This experience taught me a valuable lesson.  If you believe in something… just do it… life has a funny way of sorting it all out.  I took this philosophy an started anew , and my career ski rocketed.  The affirmation of all that work was when NetApp approached me six months ago.  At first I didn’t believe it was possible, but after many grueling interviews I started to realize I could do this job.  Fast forward two months and I’m all settled in at NetApp, and LOVING it!  This place is the google of the storage/IT world.  Everywhere you look there is another brilliant engineer, but something was still missing… The PowerShell toolkit had shipped and was doing fantastic, but PowerShell still wasn’t in the forefront of developers writing the tools for a windows administrators.  I thought about what I could do, again if you believe in something just do it.  Enter PowerGUI.

A while back Kirk had approached me about writting a PowerPack for NetApp, and I always thought it was a great idea.  So… I learned, and learned fast.  Turns out a PowerPack is fairly simple to author.  About a week later I had a working demo to show around internally.  I had my position papers worked out, and had the elevator pitch ready.  I was going to hit the streets and sell PowerShell using PowerGUI as my catalysis.  Then something amazing happened, everyone I showed PowerGUI to loved it! Furthermore they instantly knew the advantage of building a tool on top of PowerShell had.  I didn’t have to sell anything the tool simply sold itself.  At MMS this year if you stopped by during a lull you would have gotten an early alpha demo of the PowerPack.  I gave my boss said demo, and his guidance was clear, SHIP IT!  Over the past month with the help of the whole team, we went through the gambit from legal to marketing, but in the end my secret project shipped yesterday.  What started out as a sales tool ended up being such a compelling user interface that we just couldn’t keep it to ourselves.

If your a PowerGUI user of just a NetApp customer check out PowerGUI, and the PowerPack, as I think it is quite compelling.

~Glenn

Update: There is a known bug in PowerGUI where the first two objects returned don’t display alias properties, as the DataONTAP Toolkit uses alias’s heavily many object appear to be blank. Kirk’s team know about the issue and are working to fix it.

NetApp
Powershell

Comments (3)

Permalink

PowerShell: 2011 Scripting Games are almost uppon us!

2011 Scripting Games

Grab this badge here!

The 2011 Scripting Games are almost upon us, and I for one am very excited.  There will be some modifications made to the games this year.  For one this will be the first year that the games will only be in one language.  This was done for several resons, but they all boil down to one…. There is simply no reason to not be using PowerShell at this point!  As a reformed VBScritper I for one welcome the change.

Another modification is that you will only be allowed to enter in one catagory.  There was some heart ache last year, because I participated in every event.  This raised the bar so that anyone who wanted to win would have had to produce 20 scripts in 14 days.  The other side of the coin was that I was unfairly entering scripts that a true beginer shouldn’t have to compeate against.  Both are valid points, and in hind site perhaps entering in both catagories was a poor choice on my behalf.  That said, I welcome only participating in a single catagory, as delivering two high quality scripts per day for two weeks was a daunting task, and I was burned out after two weeks.

Another potentialy game changing modification is that the submitions may not be visiable until after the deadline for a given challenge.  Again I welcome this change as last years games only had one or two original solutions per event.  By making the submitions private until after the deadline every solution will be original.  This change by it’s very nature will enable cleaver, and uniqe approaches to a problem.  I don’t think cheeting was a problem last year, but instead if you saw a script that used a rare .net object, and that script got 5 starts…. well doesn’t that influence you to use the same rare .net object yourself?  Of coarse it does, it’s only human nature to want to deliver the best solution possible.

At the end of the day whether your new to scripting or a seasoned pro I highly encourage you to participate in the games this year.  I for one will attempt to defend my title, but there will be stiff competition, and I will be shocked if I can pull off a back to back championship.  Oh yeah, and did I mention first prize will land you a free pass to TechEd Atlanta!

~Glenn

Powershell

Comments (0)

Permalink

I’m famous… well sorta

Recently I was asked to do a guest post on the illustrious “Hey, Scripting Guy!” blog. I was very happy, and excited by this opportunity, but didn’t know what to write. I kicked it around for a couple days, and still nothing. So I called an old friend and asked him what his pain points were. He informed me that his shop was now operating under a 24×7 operations cycle, and it was impossible to keep his 3000+ workstations patched. With that I had my topic; having worked in these environments before I was acutely aware of the strain they put on the sysadmin to stay compliant. A couple days later I had compiled all the best techniques for detecting if a user was active on his/her PC, and shipped my draft off the scripting guy. This morning Google reader greeted me with my very own post!

http://blogs.technet.com/b/heyscriptingguy/archive/2011/03/17/use-powershell-to-detect-if-a-workstation-is-in-use.aspx

Thanks to the Scripting Guy again for this awesome opportunity and I hope you enjoy the post!

~Glenn

Powershell

Comments (0)

Permalink

PowerShell: NetApp DataONTAP toolkit credentials management

I’ve had the pleasure of spending the last several days talking to the development team here at NetApp about the DataONTAP PowerShell Toolkit.  As a result we’ve all learned alot, one of the more interesting features they brought to my attention was the credential management solution included with the toolkit.  I found this very compelling, you see embedding credentials within a script is as old as scripting itself.  There was a time not too long ago when it was considered taboo.  However with PowerShell came access to the .net Security.Cryptography encryption/decryption methods.  Scripters have unknowingly been accessing said methods indirectly whenever they would use the credential management funcions that Hal amd BSonPosh wrote long ago.

Which brings me to the DataONTAP toolkit.  The Development team has steped it up a notch and included a full credential management solution with the latest version of the toolkit.  The way it works is first you need to save logon information by using the Add-NaCredential cmdlet to save the credentials for a given NetApp controller onto the local machine.  Then the next time you run the Connect-NaController cmdlet the credentials you previously saved will be used. So how do we use this new feature, and why do you care?

Continue Reading »

NetApp
Powershell

Comments (0)

Permalink

PowerShell: A note on Execution policy.

While driving up to RTP today I was listening to the PowerScritpting podcast episode 140.  Hal and Johnathan received a question about execution policy settings.  The conclusion they reached was that remote signed was a good compromise.  I would like to expand on this a bit.  The real fear with script execution is that you’ll unintentionally run code that has malicious intent buried within it.  Personally I don’t run around running code before I review and test it, but that doesn’t mean I’m safe.  As PowerShell MVP and trainer extraordinaire Don Jones has previously stated the risk is with your profile.

Continue Reading »

Powershell

Comments (3)

Permalink

PowerCLI: Why you need this book!

The VMware vSphere PowerCLI Reference will officially go on sale April 12th, and if your a vSphere administrator this one is a must have. We gathered the collective automation experience of four vEXPERTS and a MVP, and then filtered it through a fifth vEXPERT. The end result was a collection of polished solutions that are not only technically proficient, but more importantly will work the first time every time! Having all built and maintained large infrastructures we combined our collective knowledge and wrote a complete reference, we cover the entire life cycle from creating your environment to monitoring it long term. I mean it, we left no stone unturned where VMware had no PowerCLI solution we wrote our own. This book includes a PowerShell Module with 79 custom advanced functions! We also considered how you would use our book, and chose to take a task driven approach, this enabled you to just flip to the answer you need. You don’t have to “read” all 780 pages… instead think of this book as a fire extinguisher for your virtual infrastructure.

So that’s great, but who needs a book? With blogs and the community forums you can just find the answer right? Yes, yes you can eventually, but if you do that your shopping at a fishery. In this book we WILL teach you to fish! As a commitment to that end we created a dedicated web site to support our work. If you find a bug, or if we missed something you can post a question in our forum!

Admittedly this is my first published work, but I couldn’t be prouder of it. In my opinion The ONYX, and vSphere SDK chapters alone would be worth the cover price. I look forward to the release, and to your honest opinions of our work!

~Glenn

PowerCLI
Powershell
Virtulization
VMware
vSphere

Comments (0)

Permalink