HPE OneView
1827807 Members
3041 Online
109969 Solutions
New Discussion

Custom Report -> HPE API and/or PowerShell

 
SOLVED
Go to solution
gcj2021
Advisor

Custom Report -> HPE API and/or PowerShell

Hello - sucessfully pull in all server hardware using API, but the request now is to add the enclosure rack location as a column on the blade server report.

Since I can't create a custom report within OneView (we don't have global and won't be getting it), is there a way to create a custom report using the powershell commandlets? 

Thanks!

 

4 REPLIES 4
ChrisLynch
HPE Pro

Re: Custom Report -> HPE API and/or PowerShell

OneView Global Dashboard is a no-cost product that any OneView customer is entitled to download and use.

Rack information is an Index resource.  So, to get the rack information of servers, you can use the following to get the rack name associated with the server resource:

# Index base URI
$baseUri = '/rest/index/associations?name=RACK_TO_PHYSICAL_DEVICE&childUri={0}'

# Get list of rack mount servers
$Servers = Get-OVServer | Where { $null -eq $_.locationUri }

ForEach ($server in $Servers) {

    $uri = $baseUri -f $server.uri

    # Get the resource association
    $indexResource = Send-OVRequest -Uri $uri

    # Get the rack
    $associatedRack = Send-OVRequest -Uri $indexResource.members[0].parentUri

    Write-Host $server.name "is associated with" $associatedRack.name

}
I work at HPE
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
gcj2021
Advisor

Re: Custom Report -> HPE API and/or PowerShell

Thanks @ChrisLynch ! Oddly that doesn't provide any output for me. It doesn't error and does finish, but nothing in the console. 

My pre-req command was just using Connect-OVMgmt to connect to my oneview appliance. 

ChrisLynch
HPE Pro
Solution

Re: Custom Report -> HPE API and/or PowerShell

The code filters out BL and SY servers from the appliance.  Both of which have a different method of obtaining the rack information.  This code would work for those types of devices:

# Index base URI
$baseUri = '/rest/index/associations?name=RACK_TO_PHYSICAL_DEVICE&childUri={0}'

# Get list of rack mount servers
$Servers = Get-OVServer | Where { $null -ne $_.locationUri }

ForEach ($server in $Servers) {

    # The locationUri value is the Enclosure resource's URI
    $uri = $baseUri -f $server.locationUri

    # Get the enclosure resource only for reporting purposes
    $enclosureResource = Send-OVRequest -Uri $server.locationUri

    # Get the resource association
    $indexResource = Send-OVRequest -Uri $uri

    # Get the rack
    $associatedRack = Send-OVRequest -Uri $indexResource.members[0].parentUri

    "{0} is associated with {1} enclosure, associated with {2} rack" -f $server.name, $enclosureResource.name, $associatedRack.name | Write-Host

}

 

I work at HPE
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
gcj2021
Advisor

Re: Custom Report -> HPE API and/or PowerShell


@ChrisLynch  Perfecto! Thanks!!