Skip to content

Commit c26348b

Browse files
authored
feat(instance): duplicate volume migration for snapshot (#4115)
1 parent f63450f commit c26348b

9 files changed

+130
-17
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
To be used, the call to this endpoint must be preceded by a call to the "Plan a migration" endpoint. To migrate all resources mentioned in the migration plan, the validation_key returned in the plan must be provided.
4+
5+
USAGE:
6+
scw instance snapshot apply-migration <snapshot-id ...> [arg=value ...]
7+
8+
ARGS:
9+
snapshot-id The snapshot to migrate, along with potentially other resources, according to the migration plan generated with a call to the "Plan a migration" endpoint.
10+
validation-key A value to be retrieved from a call to the "Plan a migration" endpoint, to confirm that the volume and/or snapshots specified in said plan should be migrated.
11+
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3)
12+
13+
FLAGS:
14+
-h, --help help for apply-migration
15+
16+
GLOBAL FLAGS:
17+
-c, --config string The path to the config file
18+
-D, --debug Enable debug mode
19+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
20+
-p, --profile string The config profile to use
21+
--web open console page for the current ressource
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Given a volume or snapshot, returns the migration plan for a call to the "Apply a migration plan" endpoint. This plan will include zero or one volume, and zero or more snapshots, which will need to be migrated together. This endpoint does not perform the actual migration itself, the "Apply a migration plan" endpoint must be used. The validation_key value returned by this endpoint must be provided to the call to the "Apply a migration plan" endpoint to confirm that all resources listed in the plan should be migrated.
4+
5+
USAGE:
6+
scw instance snapshot plan-migration <snapshot-id ...> [arg=value ...]
7+
8+
ARGS:
9+
snapshot-id The snapshot for which the migration plan will be generated.
10+
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3)
11+
12+
FLAGS:
13+
-h, --help help for plan-migration
14+
15+
GLOBAL FLAGS:
16+
-c, --config string The path to the config file
17+
-D, --debug Enable debug mode
18+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
19+
-p, --profile string The config profile to use
20+
--web open console page for the current ressource

cmd/scw/testdata/test-all-usage-instance-snapshot-usage.golden

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ USAGE:
1616
scw instance snapshot <command>
1717

1818
AVAILABLE COMMANDS:
19-
create Create a snapshot from a specified volume or from a QCOW2 file
20-
delete Delete a snapshot
21-
export Export a snapshot
22-
get Get a snapshot
23-
list List snapshots
24-
update Update a snapshot
19+
apply-migration Migrate a volume and/or snapshots to SBS (Scaleway Block Storage)
20+
create Create a snapshot from a specified volume or from a QCOW2 file
21+
delete Delete a snapshot
22+
export Export a snapshot
23+
get Get a snapshot
24+
list List snapshots
25+
plan-migration Get a volume or snapshot's migration plan
26+
update Update a snapshot
2527

2628
WORKFLOW COMMANDS:
27-
wait Wait for snapshot to reach a stable state
29+
wait Wait for snapshot to reach a stable state
2830

2931
FLAGS:
3032
-h, --help help for snapshot

cmd/scw/testdata/test-all-usage-instance-volume-apply-migration-usage.golden

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
To be used, the call to this endpoint must be preceded by a call to the "Plan a migration" endpoint. To migrate all resources mentioned in the migration plan, the validation_key returned in the plan must be provided.
44

55
USAGE:
6-
scw instance volume apply-migration [arg=value ...]
6+
scw instance volume apply-migration <volume-id ...> [arg=value ...]
77

88
ARGS:
9-
[volume-id] The volume to migrate, along with potentially other resources, according to the migration plan generated with a call to the "Plan a migration" endpoint.
10-
[snapshot-id] The snapshot to migrate, along with potentially other resources, according to the migration plan generated with a call to the "Plan a migration" endpoint.
9+
volume-id The volume to migrate, along with potentially other resources, according to the migration plan generated with a call to the "Plan a migration" endpoint.
1110
validation-key A value to be retrieved from a call to the "Plan a migration" endpoint, to confirm that the volume and/or snapshots specified in said plan should be migrated.
1211
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3)
1312

cmd/scw/testdata/test-all-usage-instance-volume-plan-migration-usage.golden

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
Given a volume or snapshot, returns the migration plan for a call to the "Apply a migration plan" endpoint. This plan will include zero or one volume, and zero or more snapshots, which will need to be migrated together. This endpoint does not perform the actual migration itself, the "Apply a migration plan" endpoint must be used. The validation_key value returned by this endpoint must be provided to the call to the "Apply a migration plan" endpoint to confirm that all resources listed in the plan should be migrated.
44

55
USAGE:
6-
scw instance volume plan-migration [arg=value ...]
6+
scw instance volume plan-migration <volume-id ...> [arg=value ...]
77

88
ARGS:
9-
[volume-id] The volume for which the migration plan will be generated.
10-
[snapshot-id] The snapshot for which the migration plan will be generated.
9+
volume-id The volume for which the migration plan will be generated.
1110
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3)
1211

1312
FLAGS:

docs/commands/instance.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ This API allows you to manage your Instances.
7575
- [Get availability](#get-availability)
7676
- [List Instance types](#list-instance-types)
7777
- [Snapshot management commands](#snapshot-management-commands)
78+
- [Migrate a volume and/or snapshots to SBS (Scaleway Block Storage)](#migrate-a-volume-andor-snapshots-to-sbs-(scaleway-block-storage))
7879
- [Create a snapshot from a specified volume or from a QCOW2 file](#create-a-snapshot-from-a-specified-volume-or-from-a-qcow2-file)
7980
- [Delete a snapshot](#delete-a-snapshot)
8081
- [Export a snapshot](#export-a-snapshot)
8182
- [Get a snapshot](#get-a-snapshot)
8283
- [List snapshots](#list-snapshots)
84+
- [Get a volume or snapshot's migration plan](#get-a-volume-or-snapshot's-migration-plan)
8385
- [Update a snapshot](#update-a-snapshot)
8486
- [Wait for snapshot to reach a stable state](#wait-for-snapshot-to-reach-a-stable-state)
8587
- [SSH Utilities](#ssh-utilities)
@@ -2415,6 +2417,27 @@ A snapshot's volume type is its original volume's type (`l_ssd` or `b_ssd`).
24152417
Volumes can be created from snapshots of their own type.
24162418

24172419

2420+
### Migrate a volume and/or snapshots to SBS (Scaleway Block Storage)
2421+
2422+
To be used, the call to this endpoint must be preceded by a call to the "Plan a migration" endpoint. To migrate all resources mentioned in the migration plan, the validation_key returned in the plan must be provided.
2423+
2424+
**Usage:**
2425+
2426+
```
2427+
scw instance snapshot apply-migration <snapshot-id ...> [arg=value ...]
2428+
```
2429+
2430+
2431+
**Args:**
2432+
2433+
| Name | | Description |
2434+
|------|---|-------------|
2435+
| snapshot-id | | The snapshot to migrate, along with potentially other resources, according to the migration plan generated with a call to the "Plan a migration" endpoint. |
2436+
| validation-key | Required | A value to be retrieved from a call to the "Plan a migration" endpoint, to confirm that the volume and/or snapshots specified in said plan should be migrated. |
2437+
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2`, `pl-waw-3` | Zone to target. If none is passed will use default zone from the config |
2438+
2439+
2440+
24182441
### Create a snapshot from a specified volume or from a QCOW2 file
24192442

24202443
Create a snapshot from a specified volume or from a QCOW2 file in a specified Availability Zone.
@@ -2609,6 +2632,26 @@ scw instance snapshot list zone=fr-par-1
26092632

26102633

26112634

2635+
### Get a volume or snapshot's migration plan
2636+
2637+
Given a volume or snapshot, returns the migration plan for a call to the "Apply a migration plan" endpoint. This plan will include zero or one volume, and zero or more snapshots, which will need to be migrated together. This endpoint does not perform the actual migration itself, the "Apply a migration plan" endpoint must be used. The validation_key value returned by this endpoint must be provided to the call to the "Apply a migration plan" endpoint to confirm that all resources listed in the plan should be migrated.
2638+
2639+
**Usage:**
2640+
2641+
```
2642+
scw instance snapshot plan-migration <snapshot-id ...> [arg=value ...]
2643+
```
2644+
2645+
2646+
**Args:**
2647+
2648+
| Name | | Description |
2649+
|------|---|-------------|
2650+
| snapshot-id | | The snapshot for which the migration plan will be generated. |
2651+
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2`, `pl-waw-3` | Zone to target. If none is passed will use default zone from the config |
2652+
2653+
2654+
26122655
### Update a snapshot
26132656

26142657
Update the properties of a snapshot.
@@ -2899,7 +2942,7 @@ To be used, the call to this endpoint must be preceded by a call to the "Plan a
28992942
**Usage:**
29002943

29012944
```
2902-
scw instance volume apply-migration [arg=value ...]
2945+
scw instance volume apply-migration <volume-id ...> [arg=value ...]
29032946
```
29042947

29052948

@@ -2908,7 +2951,6 @@ scw instance volume apply-migration [arg=value ...]
29082951
| Name | | Description |
29092952
|------|---|-------------|
29102953
| volume-id | | The volume to migrate, along with potentially other resources, according to the migration plan generated with a call to the "Plan a migration" endpoint. |
2911-
| snapshot-id | | The snapshot to migrate, along with potentially other resources, according to the migration plan generated with a call to the "Plan a migration" endpoint. |
29122954
| validation-key | Required | A value to be retrieved from a call to the "Plan a migration" endpoint, to confirm that the volume and/or snapshots specified in said plan should be migrated. |
29132955
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2`, `pl-waw-3` | Zone to target. If none is passed will use default zone from the config |
29142956

@@ -3076,7 +3118,7 @@ Given a volume or snapshot, returns the migration plan for a call to the "Apply
30763118
**Usage:**
30773119

30783120
```
3079-
scw instance volume plan-migration [arg=value ...]
3121+
scw instance volume plan-migration <volume-id ...> [arg=value ...]
30803122
```
30813123

30823124

@@ -3085,7 +3127,6 @@ scw instance volume plan-migration [arg=value ...]
30853127
| Name | | Description |
30863128
|------|---|-------------|
30873129
| volume-id | | The volume for which the migration plan will be generated. |
3088-
| snapshot-id | | The snapshot for which the migration plan will be generated. |
30893130
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2`, `pl-waw-3` | Zone to target. If none is passed will use default zone from the config |
30903131

30913132

internal/namespaces/instance/v1/custom.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ func GetCommands() *core.Commands {
114114
cmds.MustFind("instance", "snapshot", "update").Override(snapshotUpdateBuilder)
115115
cmds.Merge(core.NewCommands(
116116
snapshotWaitCommand(),
117+
snapshotPlanMigrationCommand(),
118+
snapshotApplyMigrationCommand(),
117119
))
118120

119121
//
@@ -126,6 +128,8 @@ func GetCommands() *core.Commands {
126128

127129
cmds.MustFind("instance", "volume", "create").Override(volumeCreateBuilder)
128130
cmds.MustFind("instance", "volume", "list").Override(volumeListBuilder)
131+
cmds.MustFind("instance", "volume", "plan-migration").Override(volumeMigrationBuilder)
132+
cmds.MustFind("instance", "volume", "apply-migration").Override(volumeMigrationBuilder)
129133
cmds.Merge(core.NewCommands(
130134
volumeWaitCommand(),
131135
))

internal/namespaces/instance/v1/custom_snapshot.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,23 @@ func snapshotUpdateBuilder(c *core.Command) *core.Command {
158158

159159
return c
160160
}
161+
162+
func snapshotPlanMigrationCommand() *core.Command {
163+
cmd := instanceVolumePlanMigration()
164+
cmd.Resource = "snapshot"
165+
166+
cmd.ArgSpecs.DeleteByName("volume-id")
167+
cmd.ArgSpecs.GetByName("snapshot-id").Positional = true
168+
169+
return cmd
170+
}
171+
172+
func snapshotApplyMigrationCommand() *core.Command {
173+
cmd := instanceVolumeApplyMigration()
174+
cmd.Resource = "snapshot"
175+
176+
cmd.ArgSpecs.DeleteByName("volume-id")
177+
cmd.ArgSpecs.GetByName("snapshot-id").Positional = true
178+
179+
return cmd
180+
}

internal/namespaces/instance/v1/custom_volume.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,10 @@ func volumeWaitCommand() *core.Command {
140140
},
141141
}
142142
}
143+
144+
func volumeMigrationBuilder(c *core.Command) *core.Command {
145+
c.ArgSpecs.DeleteByName("snapshot-id")
146+
c.ArgSpecs.GetByName("volume-id").Positional = true
147+
148+
return c
149+
}

0 commit comments

Comments
 (0)