- Community Home
- >
- Storage
- >
- HPE Nimble Storage
- >
- Array Performance and Data Protection
- >
- Rest API Get Snapshot Collection: Cannot index int...
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
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
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-08-2016 08:18 AM
04-08-2016 08:18 AM
Hi All.
I have a powershell script using the REST API to refresh dev/qa environments.
The refresh has been working great for some time. All of the sudden today I had 2 machines fail with Cannot index into a null array.
Here is the snippet of code:
$prod_array = @();
$ProdVolume_array = @();
$topsnapshot_array = @();
$uri = "https://" + $ArrayIP + "snapshot_collections/detail"
$snaplist = Invoke-RestMethod -Uri $uri -Method get -Header $header
$prod_array += $snaplist.data
$ProdVolume_array = $prod_array | select snapshots_list, name, creation_time |where-object name -like $ProdVolumeCollection* | sort-object -Property creation_time -descending
$topsnapshot_array = $ProdVolume_array[0].snapshots_list
$snaplist does have information in it. when I look at $prod_array and $ProdVolume_array I see nothing. I don't understand why.
Thanks,
Jeff
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2016 12:07 PM
04-12-2016 12:07 PM
Re: Rest API Get Snapshot Collection: Cannot index into a null array.
Hey Jeff,
Are you certain that $snaplist contains valid data? Depending on what value $ArrayIP has, I see a potential error. If it's simply the IP/hostname of the array as I expect it might be, then I suggest that you change this line:
$uri = "https://" + $ArrayIP + "snapshot_collections/detail"
to instead be
$uri = "https://" + $ArrayIP + ":5392/v1/snapshot_collections/detail"
Otherwise, when you invoke the API in the following line, you are likely to get an error. The only other thing that jumps out is that I don't know what $ProdVolumeCollection looks like here. If it's invalid, then $ProdVolume_array would wind up being empty.
Cheers,
Julian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2016 10:13 AM
04-13-2016 10:13 AM
Re: Rest API Get Snapshot Collection: Cannot index into a null array.
Not sure about the snapshot_collections failure, but the snapshots object failed with this error:
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
snapshots objectset does not support listing all objects. The complete response for this error would be some thing like this:
{
"messages":[
{
"code":"SM_http_bad_request",
"text":"The request could not be understood by the server."
},
{
"code":"SM_missing_arg",
"arguments":{
"arg":"vol_id"
},
"text":"Missing the argument 'vol_id' in the request."
}
]
}
You will have to provide the id of a particular volume to list the snapshots. For e.g. you can use a query URL like this:
https://<array-ip>:5392/v1/snapshots/detail?vol_id=0611f49156c08fdc81000000000000000000000007
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2016 02:27 PM
04-13-2016 02:27 PM
SolutionI may have found the problem:
changing
$ProdVolume_array = $prod_array | select snapshots_list, name, creation_time |where-object name -like $ProdVolumeCollection* | sort-object -Property creation_time -descending
to:
$ProdVolume_array = $prod_array | select * |where-object volcoll_name -eq $ProdVolumeCollection | sort-object -Property creation_time -descending
In some local testing this appears to take care of the issue, but I need to validate.
I'm still not sure why it all of the sudden failed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2016 08:12 AM
04-14-2016 08:12 AM
Re: Rest API Get Snapshot Collection: Cannot index into a null array.
This has corrected the problem.