- Community Home
- >
- Storage
- >
- HPE Nimble Storage
- >
- Array Performance and Data Protection
- >
- Unable to get snapshots in REST api
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2017 07:50 AM
тАО04-21-2017 07:50 AM
I have copied the powershell from the nimble examples. Everything is working, except snapshots. See error in the output at the bottom.
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
###########################
# Get Token
###########################
$array = "10.2.25.50"
$username = "admin"
$password = "admin"
$data = @{
username = $username
password = $password
}
$body = convertto-json (@{ data = $data })
$uri = "https://" + $array + ":5392/v1/tokens"
$token = Invoke-RestMethod -Uri $uri -Method Post -Body $body
$token = $token.data.session_token
"Testing snapshot issue"
###########################
# Get snapshot List
###########################
">>snapshot"
$header = @{ "X-Auth-Token" = $token }
$uri = "https://" + $array + ":5392/v1/snapshots"
$snapshot_list = Invoke-RestMethod -Uri $uri -Method Get -Header $header
foreach ($snapshot_id in $snapshot_list.data.id){
$uri = "https://" + $array + ":5392/v1/snapshots" + $snapshot_id
$snapshot = Invoke-RestMethod -Uri $uri -Method Get -Header $header
">snapshot"
$snapshot.data
}
Testing snapshot issue
>>snapshot
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At C:\Nimble\nimble_api_collector.ps1:39 char:18
+ ... apshot_list = Invoke-RestMethod -Uri $uri -Method Get -Header $header
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2017 09:24 AM
тАО04-21-2017 09:24 AM
SolutionGot this to work.
It takes the volume and gets snapshots based on the volume, then loops through the results.
"Testing snapshot issue"
###########################
# Get snapshot List
###########################
">>snapshot"
$header = @{ "X-Auth-Token" = $token }
$uri = "https://" + $array + ":5392/v1/volumes/"
$volume_list = Invoke-RestMethod -Uri $uri -Method Get -Header $header
foreach ($volume_id in $volume_list.data.id){
$uri = "https://" + $array + ":5392/v1/snapshots/detail?vol_id=" + $volume_id
$snapshot_list = Invoke-RestMethod -Uri $uri -Method Get -Header $header
foreach ($snapshot_id in $snapshot_list.data.id){
$uri = "https://" + $array + ":5392/v1/snapshots/" + $snapshot_id
$snapshot = Invoke-RestMethod -Uri $uri -Method Get -Header $header
">snapshot"
$snapshot.data
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2017 10:23 AM
тАО04-21-2017 10:23 AM
Re: Unable to get snapshots in REST api
It looks like Steve Hill beat me to the punch.
The snapshots API requires you to specify the volume for which you want to retrieve the snapshots. You cannot retrieve a list of all snapshots on the array in one fell swoop. As Steve's code shows, the way to pull all snapshots would be to iterate through each volume and retrieve that volume's snapshots.
To be fair, the examples were pulled together when the API was in beta and actually did allow for this. It looks like perhaps they haven't been updated. We'll get that fixed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2017 11:03 AM
тАО04-21-2017 11:03 AM
Re: Unable to get snapshots in REST api
Thanks Julian
Sent from my iPhone