Tuesday, January 19, 2016

Tegile Zebi Storage and PowerShell

For any of you that use SAN products from Tegile, they have had a REST API available since 2014 to access the SAN controllers, but it's never been really useful.  They tell me that this will be changing and they will actually have some commandlets available soon.

The user guide for the API is written from a PERL viewpoint and all the examples are in PERL.  That's great except that I use very little PERL in my day-to-day life.

I decided to try and convert to PowerShell and see what I could see.  There are a number of examples of using REST API via PowerShell around the net.  After trying variations of a number of them I would up with the code below.  It will pull out the Zebi version information from the array.

It's still very limited as to what you can do, but it's a start.  The full list of commands available are in the REST API user guide over at the Tegile support site.

This script is functional but not pretty.  It was basically just proving that it worked.



Clear-Host

$Username = Read-Host "Enter the username"
$Password = Read-Host "Enter the password"
$EncodedAuthorization = [System.Text.Encoding]::UTF8.GetBytes($Username + ':' + $Password)
$EncodedPassword = [System.Convert]::ToBase64String($EncodedAuthorization)
$IP = Read-Host "Enter the IP Address"
$BaseURL = 'https://' + $IP
$Headers = @{"Authorization"="Basic $($EncodedPassword)"}

$ResourceURL = "/zebi/api/v1/listShares"                      #--[ Remove the body option if using this ]--
$Body = '[["ZEBI_API_VERSION","ZEBI_APPLIANCE_VERSION","ZEBI_API_MINOR_VERSION","ZEBI_APPLIANCE_MODEL","ZEBI_GUI_VERSION"]]'     #--[ Edit this as required ]--

$ResourceURL = "/zebi/api/v1/listProjects"                      #--[ Remove the body option if using this ]--

$ResourceURL = "/zebi/api/v1/listSystemProperties"            #--[ Edit this as required ]--
$Body = '[["ZEBI_API_VERSION","ZEBI_APPLIANCE_VERSION","ZEBI_API_MINOR_VERSION","ZEBI_APPLIANCE_MODEL","ZEBI_GUI_VERSION"]]'     #--[ Edit this as required ]--

$URI = $BaseURL + $ResourceURL


Try
     {
     $Result = Invoke-RestMethod -Uri $URI -Method post -Headers $Headers -ContentType "application/json; charset=utf-8" -ErrorAction Stop -Body $Body
     }
Catch
     {
    $ErrorMessage = $_.Exception.Message
    $FailedItem = $_.Exception.ItemName
    write-host "Error Message : "$ErrorMessage -ForegroundColor yellow
    write-host "Failed Item : "$FailedItem -ForegroundColor yellow
     }


write-host `n"     URL: "$URI -ForegroundColor Yellow
write-host " API Ver: "$Result[0] -ForegroundColor Yellow
write-host "Zebi Ver: "$Result[1] -ForegroundColor Yellow


$Result

2 comments:

  1. Have you attempted adding or removing LUN mappings?

    ReplyDelete
  2. Can't say that I have. We dropped the use of LUNs throughout our environment. NFS offers a lot of versatility. It also has some pitfalls as we found out during the last firmware upgrade. A "glitch" in Tegile's update scripts threw us offline for a day. Not fun. I don't see any reason why LUNs wouldn't work, you should be able to pump in teh proper commands without much trouble.

    ReplyDelete