- Community Home
- >
- Storage
- >
- HPE Nimble Storage
- >
- Application Integration
- >
- Re: Powershell: Remove a Volume that is in a Volum...
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-24-2015 09:26 AM
04-24-2015 09:26 AM
Hi All!
I have a powershell script that is refreshing volumes, but has one flaw.
I want to drop a volume (let's say for a test box) and then create a clone from a snapshot (let's say the latest Production Snapshot).
To delete the volume I have to remove it from the volume collection first. A pain...and it really isn't automated this way.
So it would be great if I could remove the volume from the powershell script or force the delete on the volume.
Has anybody done this?
Any help would be appreciated.
Thanks,
Jeff
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2015 08:43 AM
07-21-2015 08:43 AM
SolutionHi Jeff,
In NimbleOS 2.3, there are REST APIs available that you can use to do exactly this. (I have a blog post coming soon that explains this in more detail.) The following PowerShell code will call the API and do exactly what you need. It first modifies the volume to take it offline and set its volcoll id to an empty string. This disassociates the volume from the volcoll. Then it makes another API call to delete the volume once it's offline:
param([string]$vol="")
if ($vol -eq "") {
write-host "`n`nUsage: delete-volume <VOLUME>`n`n";
exit
}
###########################
# Enable HTTPS
###########################
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
###########################
# Get Token
###########################
$array = "<ARRAYNAME>"
$username = "admin"
$password = "<PASSWORD>"
$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
###########################
# Find a Volume by Name
###########################
$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/volumes/" + $volume_id
$volume = Invoke-RestMethod -Uri $uri -Method Get -Header $header
if ($volume.data.name -eq $vol){
$vol_id = $volume.data.id
}
}
write-host "`n`nDeleting volume $vol with ID: $vol_id`n";
#########################################
# Offline a Volume and Disassociate from volcoll
#########################################
$data = @{
online = "false"
force = "true"
volcoll_id = ""
}
$body = convertto-json (@{ data = $data })
$header = @{ "X-Auth-Token" = $token }
$uri = "https://" + $array + ":5392/v1/volumes/" + $vol_id
$result = Invoke-RestMethod -Uri $uri -Method Put -Body $body -Header $header
###########################
# Delete a Volume
###########################
$header = @{ "X-Auth-Token" = $token }
$uri = "https://" + $array + ":5392/v1/volumes/" + $vol_id
$result = Invoke-RestMethod -Uri $uri -Method Delete -Header $header
Cheers,
Julian