Skip to content

Commit

Permalink
govc: Add support for CNS volume snapshots
Browse files Browse the repository at this point in the history
Add support for creating, listing and removing snapshots from CNS volumes by implementing the following commands:
- govc volume.snapshot.create VOL_ID DESC
- govc volume.snapshot.ls VOL_ID
- govc volume.snapshot.rm SNAP_ID VOL_ID

Batch operations are supported by 'volume.snapshot.ls' and 'volume.snapshot.rm'.
  • Loading branch information
grandeit committed Apr 3, 2023
1 parent c2cf82e commit daaaca0
Show file tree
Hide file tree
Showing 7 changed files with 549 additions and 5 deletions.
51 changes: 48 additions & 3 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
Abhijeet Kasurde <[email protected]>
abrarshivani <[email protected]>
Adam Chalkley <[email protected]>
Adam Fowler <[email protected]>
Adam Shannon <[email protected]>
Akanksha Panse <[email protected]>
akutz <[email protected]>
Al Biheiri <[email protected]>
Alessandro Cortiana <[email protected]>
Alex <[email protected]>
Expand All @@ -28,6 +31,7 @@ aniketGslab <[email protected]>
Ankit Vaidya <[email protected]>
Ankur Huralikoppi <[email protected]>
Anna Carrigan <[email protected]>
Antony Saba <[email protected]>
Ariel Chinn <[email protected]>
Arran Walker <[email protected]>
Artem Anisimov <[email protected]>
Expand All @@ -41,19 +45,23 @@ Ben Corrie <[email protected]>
Ben Vickers <[email protected]>
Benjamin Davini <[email protected]>
Benjamin Peterson <[email protected]>
Benjamin Vickers <[email protected]>
Bhavya Choudhary <[email protected]>
Bob Killen <[email protected]>
Brad Fitzpatrick <[email protected]>
Brian Rak <[email protected]>
brian57860 <[email protected]>
Bruce Downs <[email protected]>
Cédric Blomart <cblomart@gmail.com>
Bryan Venteicher <bryanventeicher@gmail.com>
Cheng Cheng <[email protected]>
Chethan Venkatesh <[email protected]>
Choudhury Sarada Prasanna Nanda <[email protected]>
Chris Marchesi <[email protected]>
Christian Höltje <[email protected]>
Clint Greenwood <[email protected]>
cpiment <[email protected]>
CuiHaozhi <[email protected]>
Cédric Blomart <[email protected]>
Dan Ilan <[email protected]>
Dan Norris <[email protected]>
Daniel Frederick Crisman <[email protected]>
Expand All @@ -66,19 +74,24 @@ David Gress <[email protected]>
David Stark <[email protected]>
Davide Agnello <[email protected]>
Davinder Kumar <[email protected]>
Defa <[email protected]>
demarey <[email protected]>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Deric Crago <[email protected]>
ditsuke <[email protected]>
Divyen Patel <[email protected]>
Dnyanesh Gate <[email protected]>
Doug MacEachern <[email protected]>
East <[email protected]>
Eloy Coto <[email protected]>
embano1 <[email protected]>
Eng Zer Jun <[email protected]>
Eric Edens <[email protected]>
Eric Graham <[email protected]>
Eric Gray <[email protected]>
Eric Yutao <[email protected]>
Erik Hollensbe <[email protected]>
Essodjolo KAHANAM <[email protected]>
Ethan Kaley <[email protected]>
Evan Chu <[email protected]>
Fabio Rapposelli <[email protected]>
Expand All @@ -92,11 +105,14 @@ Gavrie Philipson <[email protected]>
George Hicken <[email protected]>
Gerrit Renker <[email protected]>
gthombare <[email protected]>
Hakan Halil <[email protected]>
HakanSunay <[email protected]>
Hasan Mahmood <[email protected]>
Haydon Ryan <[email protected]>
Heiko Reese <[email protected]>
Henrik Hodne <[email protected]>
hkumar <[email protected]>
Hrabur Stoyanov <[email protected]>
hui luo <[email protected]>
Ian Eyberg <[email protected]>
Isaac Rodman <[email protected]>
Expand All @@ -109,12 +125,13 @@ Jeremy Canady <[email protected]>
jeremy-clerc <[email protected]>
Jiatong Wang <[email protected]>
jingyizPensando <[email protected]>
João Pereira <[email protected]>
Jonas Ausevicius <[email protected]>
Jorge Sevilla <[email protected]>
João Pereira <[email protected]>
Julien PILLON <[email protected]>
Justin J. Novack <[email protected]>
kayrus <[email protected]>
Keenan Brock <[email protected]>
Kevin George <[email protected]>
Knappek <[email protected]>
Leslie Wang <[email protected]>
Expand All @@ -124,44 +141,64 @@ Liping Xue <[email protected]>
Louie Jiang <[email protected]>
Luther Monson <[email protected]>
Madanagopal Arunachalam <[email protected]>
makelarisjr <[email protected]>
Manuel Grandeit <[email protected]>
maplain <[email protected]>
Marc Carmier <[email protected]>
Marcus Tan <[email protected]>
Maria Ntalla <[email protected]>
Marin Atanasov Nikolov <[email protected]>
Mario Trangoni <[email protected]>
Mark Dechiaro <[email protected]>
Mark Peek <[email protected]>
Mark Rexwinkel <[email protected]>
martin <[email protected]>
Matt Clay <[email protected]>
Matt Moore <[email protected]>
Matt Moriarity <[email protected]>
Matthew Cosgrove <[email protected]>
mbhadale <[email protected]>
Merlijn Sebrechts <[email protected]>
Mevan Samaratunga <[email protected]>
Michael Gasch <[email protected]>
Michael Gasch <[email protected]>
Michal Jankowski <[email protected]>
Mike Schinkel <[email protected]>
Mincho Tonev <[email protected]>
mingwei <[email protected]>
Nicolas Lamirault <[email protected]>
nikhaild <[email protected]>
Nikhil Kathare <[email protected]>
Nikhil R Deshpande <[email protected]>
Nikolas Grottendieck <[email protected]>
Nils Elde <[email protected]>
nirbhay <[email protected]>
Nobuhiro MIKI <[email protected]>
Om Kumar <[email protected]>
Omar Kohl <[email protected]>
Parham Alvani <[email protected]>
Parveen Chahal <[email protected]>
Paul Martin <[email protected]>
Pierre Gronlier <[email protected]>
Pieter Noordhuis <[email protected]>
pradeepj <[email protected]>
Pranshu Jain <[email protected]>
prydin <[email protected]>
rconde01 <[email protected]>
rHermes <[email protected]>
Rianto Wahyudi <[email protected]>
Ricardo Katz <[email protected]>
Robin Watkins <[email protected]>
Rowan Jacobs <[email protected]>
Roy Ling <[email protected]>
rsikdar <[email protected]>
runner.mei <[email protected]>
Ryan Johnson <[email protected]>
S R Ashrith <[email protected]>
S.Çağlar Onur <[email protected]>
Saad Malik <[email protected]>
Sam Zhu <[email protected]>
samzhu333 <[email protected]>
Sandeep Pissay Srinivasa Rao <[email protected]>
Scott Holden <[email protected]>
Sergey Ignatov <[email protected]>
Expand All @@ -172,11 +209,15 @@ Shaozhen Ding <[email protected]>
Shawn Neal <[email protected]>
shylasrinivas <[email protected]>
sky-joker <[email protected]>
smaftoul <[email protected]>
smahadik <[email protected]>
Sten Feldman <[email protected]>
Stepan Mazurov <[email protected]>
Steve Purcell <[email protected]>
Sudhindra Aithal <[email protected]>
SUMIT AGRAWAL <[email protected]>
Syuparn <[email protected]>
Sunny Carter <[email protected]>
syuparn <[email protected]>
Takaaki Furukawa <[email protected]>
Tamas Eger <[email protected]>
Tanay Kothari <[email protected]>
Expand All @@ -189,6 +230,7 @@ Tjeu Kayim <[email protected]>
Toomas Pelberg <[email protected]>
Trevor Dawe <[email protected]>
tshihad <[email protected]>
Ueli Banholzer <[email protected]>
Uwe Bessle <[email protected]>
Vadim Egorov <[email protected]>
Vikram Krishnamurthy <[email protected]>
Expand All @@ -198,14 +240,17 @@ Waldek Maleska <[email protected]>
William Lam <[email protected]>
Witold Krecicki <[email protected]>
xing-yang <[email protected]>
xinyanw409 <[email protected]>
Yang Yang <[email protected]>
yangxi <[email protected]>
Yann Hodique <[email protected]>
Yash Nitin Desai <[email protected]>
Yassine TIJANI <[email protected]>
Yi Jiang <[email protected]>
yiyingy <[email protected]>
ykakarap <[email protected]>
Yogesh Sobale <[email protected]>
Your Name <[email protected]>
Yue Yin <[email protected]>
Yun Zhou <[email protected]>
Yuya Kusakabe <[email protected]>
Expand Down
56 changes: 56 additions & 0 deletions govc/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ but appear via `govc $cmd -h`:
- [vm.vnc](#vmvnc)
- [volume.ls](#volumels)
- [volume.rm](#volumerm)
- [volume.snapshot.create](#volumesnapshotcreate)
- [volume.snapshot.ls](#volumesnapshotls)
- [volume.snapshot.rm](#volumesnapshotrm)
- [vsan.change](#vsanchange)
- [vsan.info](#vsaninfo)

Expand Down Expand Up @@ -6337,6 +6340,59 @@ Examples:
Options:
```

## volume.snapshot.create

```
Usage: govc volume.snapshot.create [OPTIONS] [ID] [DESC]
Create snapshot of volume ID with description DESC.
Examples:
govc volume.snapshot.create df86393b-5ae0-4fca-87d0-b692dbc67d45 my-snapshot
govc volume.snapshot.create -i df86393b-5ae0-4fca-87d0-b692dbc67d45 my-snapshot
Options:
-i=false Output snapshot ID and volume ID only
```

## volume.snapshot.ls

```
Usage: govc volume.snapshot.ls [OPTIONS] [ID]...
List all snapshots of volume ID.
Use a list of volume IDs to list all snapshots of multiple volumes at once.
Examples:
govc volume.snapshot.ls df86393b-5ae0-4fca-87d0-b692dbc67d45
govc volume.snapshot.ls -i df86393b-5ae0-4fca-87d0-b692dbc67d45
govc volume.snapshot.ls -l df86393b-5ae0-4fca-87d0-b692dbc67d45
govc volume.snapshot.ls -l $(govc volume.ls -i)
Options:
-i=false List snapshot ID and volume ID only
-l=false Long listing format
```

## volume.snapshot.rm

```
Usage: govc volume.snapshot.rm [OPTIONS] [SNAP_ID VOL_ID]...
Remove snapshot SNAP_ID from volume VOL_ID.
Use a list of [SNAP_ID VOL_ID] pairs to remove multiple snapshots at once.
Examples:
govc volume.snapshot.rm f75989dc-95b9-4db7-af96-8583f24bc59d df86393b-5ae0-4fca-87d0-b692dbc67d45
govc volume.snapshot.rm $(govc volume.snapshot.ls -i df86393b-5ae0-4fca-87d0-b692dbc67d45)
govc volume.snapshot.rm $(govc volume.snapshot.create -i df86393b-5ae0-4fca-87d0-b692dbc67d45 my-snapshot)
govc volume.snapshot.rm $(govc volume.snapshot.ls -i $(govc volume.ls -i))
Options:
```

## vsan.change

```
Expand Down
5 changes: 3 additions & 2 deletions govc/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2022 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -110,6 +110,7 @@ import (
_ "github.com/vmware/govmomi/govc/vm/rdm"
_ "github.com/vmware/govmomi/govc/vm/snapshot"
_ "github.com/vmware/govmomi/govc/volume"
_ "github.com/vmware/govmomi/govc/volume/snapshot"
_ "github.com/vmware/govmomi/govc/vsan"
)

Expand Down
13 changes: 13 additions & 0 deletions govc/test/volume.bats
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@ load test_helper
run govc volume.ls
assert_success ""
}

@test "volume.snapshot" {
vcsim_env

run govc volume.snapshot.ls
assert_failure

run govc volume.snapshot.rm
assert_failure

run govc volume.snapshot.create
assert_failure
}
Loading

0 comments on commit daaaca0

Please sign in to comment.