OnCommand Unified Manager PowerShell CmdLets

by Frequent Contributor on ‎2013-11-12 01:55 AM - edited on ‎2014-10-08 03:41 PM by allison Former NetApp Employee

Hi All

 

I thought it would be helpful to provide an example of how to create a custom powershell cmdlet and Invoke API's for OnCommand Unified Manager 6.X (as it does not have any command line interface anymore). Unfortunatley OCUM6.X does not support Web Services (WSDL\SOAP) posted previously here:

 

https://communities.netapp.com/thread/32479

 

It took me some time to figure out a powershell solution so thought i'd share it. Hopefully this will generate some interest and providing a starting point for an "OnCommand Unified Manager 6.X PowerShell Module". Hopefully the product team can help to provide some resources for this to. I've included the C# sharp cmdlet source code and the compiled "ocum6.dll" which you can import into your powershell session. The cmdlet's assume that you are using a local OnCommand user to authenticate (ie "admin") within a PSCredential Object. All CmdLet's use https only. Use the following code to import the module. This assumes you've created an "ocum6" folder in your powershell modules directory "C:\windows\system32\windowspowershell\v1.0\modules" and copied the .dll files to that directory.

 

PS C:\> $hostname    = "ocum6.sydlab.netapp.au"

PS C:\> $credentials = Get-Credential -Credential "admin"

PS C:\> $systemPath  = [Environment]::SystemDirectory

PS C:\> $modulePath  = "$systemPath\WindowsPowerShell\v1.0\modules\ocum6"

PS C:\> $fileSpec    = "$modulePath\ocum6.dll"

PS C:\> $moduleName  = "ocum6"

PS C:\> Import-Module $fileSpec

 

Here are the CmdLet's available in this module:

 

PS C:\> Get-Command -Module ocum6

CommandType    Name                                                Definition
-----------    ----                                                ----------
Cmdlet          Get-NaOcAggregate                                  Get-NaOcAggregate [-Hostname] <String> [-Credent...
Cmdlet          Get-NaOcCluster                                    Get-NaOcCluster [-Hostname] <String> [-Credentia...
Cmdlet          Get-NaOcLun                                        Get-NaOcLun [-Hostname] <String> [-Credential] <...
Cmdlet          Get-NaOcResourcePool                                Get-NaOcResourcePool [-Hostname] <String> [-Cred...
Cmdlet          Get-NaOcVolume                                      Get-NaOcVolume [-Hostname] <String> [-Credential...
Cmdlet          Get-NaOcVserver                                    Get-NaOcVserver [-Hostname] <String> [-Credentia...

 

All CmdLet's output the API results to a PSObject with NoteProperties so you can parse it to the pipeline. EG:

 

PS C:\> $vservers = Get-NaOcVserver -Hostname $hostname -Credential $credentials

PS C:\> $vservers | Where-Object {$_.ClusterName -Match "dka-"} | Select-Object -Property ClusterName, VserverName, VserverState

ClusterName                            VserverName                            VserverState
-----------                            -----------                            ------------
dka-ter                                dka-svm-ter                            running
dka-prod                                dka-svm-pri                            running
dka-dr                                  dka-svm-sec                            running
dka-prod                                dka-svm-pri-2k8                        running

 

Here's another example of using the module to query all aggregates monitor by OCUM6 and filtering the results to display the aggregate name and cluster nodes they are assigned to:

 

PS C:\> $aggregates = Get-NaOcAggregate -Hostname $hostname -Credential $credentials

PS C:\> $aggregates | Where-Object {$_.ClusterName -Match "krusty"} | Select-Object -Property AggregateName, ClusterNodeName, AggregateState

AggregateName                          ClusterNodeName                        AggregateState
-------------                          ---------------                        --------------
scratchy:scratchy_aggr4                scratchy                                online
scratchy:aggr0_scratchy                scratchy                                online
itchy:itchy_aggr2                      itchy                                  online
scratchy:scratchy_aggr3                scratchy                                online
itchy:itchy_aggr5                      itchy                                  online
itchy:itchy_aggr1                      itchy                                  online
itchy:aggr0_itchy                      itchy                                  online

 

Feel free to use the included the C# source code as basis for writing your own CmdLet's! Hope that helps. Happy Coding...

 

Cheers Matt

Comments
Occasional Contributor

I used your cmdlets in a few scripts for a customer and they worked great, thanks for sharing!

Dan

Occasional Contributor

 Hi Matt, 

Thanks for sharing.

 

i plane on using those soon on a costumer site.

did you get any respond from the product team ?

did you tried it already with OCUM 6.2 ?

Can i get capacity trends using this ?

 

Tomer.

Frequent Contributor

Hi Tomer,

 

The API's i used to write these CmdLet examples haven't changed in OCUM6.2 so it should still work with this version...however it is somewhat redundant given i discovered an easier method to query the MySQL database in OCUM6.X. See the example in link below:

 

http://community.netapp.com/t5/Developer-Network-Articles-and-Resources/Query-OCUM6-Database-using-PowerShell/ta-p/98184

 

You can query the database table views from a remote server however you'd need to update the SQL query for capacity trends. Please let me know if you have any questions? cheers

 

/matt

 

Occasional Contributor

Hi Matt, 

Thanks for replying, and sorry for my late responed, i guess i missed that.

 

i have a script already the connects to OPM database and get performance data, but with OCUM i dont know how should i calculate the trends.

any tip on that ?

Member

HI Mate

 

Thax for sharing this. This really made my life easy

 

Shibu

Warning!

This NetApp Community is public and open website that is indexed by search engines such as Google. Participation in the NetApp Community is voluntary. All content posted on the NetApp Community is publicly viewable and available. This includes the rich text editor which is not encrypted for https.

In accordance to our Code of Conduct and Community Terms of Use DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information
  • Copyrighted materials without the permission of the copyright owner

Files and content that do not abide by the Community Terms of Use or Code of Conduct will be removed. Continued non-compliance may result in NetApp Community account restrictions or termination.