Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
The snapshot is exported in QCOW2 format.
The snapshot must not be in transient state.

USAGE:
scw block snapshot export-to-object-storage [arg=value ...]

ARGS:
snapshot-id UUID of the snapshot
[bucket] Scaleway Object Storage bucket where the object is stored
[key] The object key inside the given bucket
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | nl-ams-1 | nl-ams-3 | pl-waw-3)

FLAGS:
-h, --help help for export-to-object-storage

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
11 changes: 6 additions & 5 deletions cmd/scw/testdata/test-all-usage-block-snapshot-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ USAGE:
scw block snapshot <command>

AVAILABLE COMMANDS:
create Create a snapshot of a volume
delete Delete a snapshot
get Get a snapshot
list List all snapshots
update Update a snapshot
create Create a snapshot of a volume
delete Delete a snapshot
export-to-object-storage Export a snapshot to a Scaleway Object Storage bucket
get Get a snapshot
list List all snapshots
update Update a snapshot

FLAGS:
-h, --help help for snapshot
Expand Down
24 changes: 24 additions & 0 deletions docs/commands/block.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This API allows you to manage your Block Storage volumes.
- [A Block Storage snapshot is a read-only picture of a Block volume, taken at a specific time](#a-block-storage-snapshot-is-a-read-only-picture-of-a-block-volume,-taken-at-a-specific-time)
- [Create a snapshot of a volume](#create-a-snapshot-of-a-volume)
- [Delete a snapshot](#delete-a-snapshot)
- [Export a snapshot to a Scaleway Object Storage bucket](#export-a-snapshot-to-a-scaleway-object-storage-bucket)
- [Get a snapshot](#get-a-snapshot)
- [List all snapshots](#list-all-snapshots)
- [Update a snapshot](#update-a-snapshot)
Expand Down Expand Up @@ -67,6 +68,29 @@ scw block snapshot delete [arg=value ...]



### Export a snapshot to a Scaleway Object Storage bucket

The snapshot is exported in QCOW2 format.
The snapshot must not be in transient state.

**Usage:**

```
scw block snapshot export-to-object-storage [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| snapshot-id | Required | UUID of the snapshot |
| bucket | | Scaleway Object Storage bucket where the object is stored |
| key | | The object key inside the given bucket |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `nl-ams-1`, `nl-ams-3`, `pl-waw-3` | Zone to target. If none is passed will use default zone from the config |



### Get a snapshot

Retrieve technical information about a specific snapshot. Details such as size, volume type, and status are returned in the response.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
github.com/mattn/go-isatty v0.0.20
github.com/moby/buildkit v0.13.2
github.com/opencontainers/go-digest v1.0.0
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240725100043-c4e7d505fef5
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240726045210-a50e223d3177
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240725100043-c4e7d505fef5 h1:4QeufrUuqSmaDRLyEUAk6bLrARCruhfxWL5kVr0VVg8=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240725100043-c4e7d505fef5/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240726045210-a50e223d3177 h1:ZoIks68eACBasbPvFpSi4PwnMvpd32qljsL2s/ufXow=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29.0.20240726045210-a50e223d3177/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=
Expand Down
46 changes: 46 additions & 0 deletions internal/namespaces/block/v1alpha1/block_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func GetGeneratedCommands() *core.Commands {
blockSnapshotList(),
blockSnapshotGet(),
blockSnapshotCreate(),
blockSnapshotExportToObjectStorage(),
blockSnapshotDelete(),
blockSnapshotUpdate(),
)
Expand Down Expand Up @@ -507,6 +508,51 @@ If your volume is in a transient state, you need to wait until the end of the cu
}
}

func blockSnapshotExportToObjectStorage() *core.Command {
return &core.Command{
Short: `Export a snapshot to a Scaleway Object Storage bucket`,
Long: `The snapshot is exported in QCOW2 format.
The snapshot must not be in transient state.`,
Namespace: "block",
Resource: "snapshot",
Verb: "export-to-object-storage",
// Deprecated: false,
ArgsType: reflect.TypeOf(block.ExportSnapshotToObjectStorageRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "snapshot-id",
Short: `UUID of the snapshot`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "bucket",
Short: `Scaleway Object Storage bucket where the object is stored`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "key",
Short: `The object key inside the given bucket`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms3, scw.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*block.ExportSnapshotToObjectStorageRequest)

client := core.ExtractClient(ctx)
api := block.NewAPI(client)
return api.ExportSnapshotToObjectStorage(request)

},
}
}

func blockSnapshotDelete() *core.Command {
return &core.Command{
Short: `Delete a snapshot`,
Expand Down