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
@@ -1,17 +1,15 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Attach a volume to a server
Attach a volume to an Instance.

USAGE:
scw instance server attach-volume [arg=value ...]

EXAMPLES:
Attach a volume to a server
scw instance server attach-volume server-id=11111111-1111-1111-1111-111111111111 volume-id=22222222-1111-5555-2222-666666111111

ARGS:
server-id ID of the server
volume-id ID of the volume to attach
server-id
[volume-id]
[volume-type] (unknown_volume_type | l_ssd | b_ssd | sbs_volume)
[boot]
[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)

FLAGS:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Detach a filesystem volume to an Instance.
Detach a filesystem volume from an Instance.

USAGE:
scw instance server detach-filesystem [arg=value ...]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Detach a volume from its server
Detach a volume from an Instance.

USAGE:
scw instance server detach-volume [arg=value ...]

EXAMPLES:
Detach a volume from its server
scw instance server detach-volume volume-id=22222222-1111-5555-2222-666666111111

ARGS:
volume-id ID of the volume to detach
server-id ID of the server
server-id
[volume-id]
[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)

FLAGS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ AVAILABLE COMMANDS:
action Perform a raw API action on a server
attach-filesystem Attach a filesystem volume to an Instance
attach-ip Attach an IP to a server
attach-volume Attach a volume to an Instance
backup Backup server
console Connect to the serial console of an instance
create Create server
delete Delete server
detach-filesystem Detach a filesystem volume to an Instance
detach-filesystem Detach a filesystem volume from an Instance
detach-ip Detach an IP from a server
detach-volume Detach a volume from an Instance
enable-routed-ip Migrate server to IP mobility
get Get an Instance
get-compatible-types Get Instance compatible types
Expand Down
52 changes: 49 additions & 3 deletions docs/commands/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ This API allows you to manage your CPU and GPU Instances.
- [Perform a raw API action on a server](#perform-a-raw-api-action-on-a-server)
- [Attach a filesystem volume to an Instance](#attach-a-filesystem-volume-to-an-instance)
- [Attach an IP to a server](#attach-an-ip-to-a-server)
- [Attach a volume to an Instance](#attach-a-volume-to-an-instance)
- [Backup server](#backup-server)
- [Connect to the serial console of an instance](#connect-to-the-serial-console-of-an-instance)
- [Create server](#create-server)
- [Delete server](#delete-server)
- [Detach a filesystem volume to an Instance](#detach-a-filesystem-volume-to-an-instance)
- [Detach a filesystem volume from an Instance](#detach-a-filesystem-volume-from-an-instance)
- [Detach an IP from a server](#detach-an-ip-from-a-server)
- [Detach a volume from an Instance](#detach-a-volume-from-an-instance)
- [Migrate server to IP mobility](#migrate-server-to-ip-mobility)
- [Get an Instance](#get-an-instance)
- [Get Instance compatible types](#get-instance-compatible-types)
Expand Down Expand Up @@ -1626,6 +1628,29 @@ scw instance server attach-ip 11111111-1111-1111-1111-111111111111 ip=1.2.3.4



### Attach a volume to an Instance

Attach a volume to an Instance.

**Usage:**

```
scw instance server attach-volume [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| server-id | Required | |
| volume-id | | |
| volume-type | One of: `unknown_volume_type`, `l_ssd`, `b_ssd`, `sbs_volume` | |
| boot | | |
| 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 |



### Backup server

Create a new image based on the server.
Expand Down Expand Up @@ -1810,9 +1835,9 @@ scw instance server delete 11111111-1111-1111-1111-111111111111 zone=fr-par-1



### Detach a filesystem volume to an Instance
### Detach a filesystem volume from an Instance

Detach a filesystem volume to an Instance.
Detach a filesystem volume from an Instance.

**Usage:**

Expand Down Expand Up @@ -1861,6 +1886,27 @@ scw instance server detach-ip 11111111-1111-1111-1111-111111111111



### Detach a volume from an Instance

Detach a volume from an Instance.

**Usage:**

```
scw instance server detach-volume [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| server-id | Required | |
| volume-id | | |
| 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 |



### Migrate server to IP mobility

Enable routed IP for this server and migrate the nat public IP to routed
Expand Down
114 changes: 112 additions & 2 deletions internal/namespaces/instance/v1/instance_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ func GetGeneratedCommands() *core.Commands {
instanceUserDataSet(),
instanceUserDataGet(),
instanceServerGetCompatibleTypes(),
instanceServerAttachVolume(),
instanceServerDetachVolume(),
instanceServerAttachFilesystem(),
instanceServerDetachFilesystem(),
instanceImageList(),
Expand Down Expand Up @@ -1135,6 +1137,114 @@ If the specified Instance offer is flagged as end of service, the best compatibl
}
}

func instanceServerAttachVolume() *core.Command {
return &core.Command{
Short: `Attach a volume to an Instance`,
Long: `Attach a volume to an Instance.`,
Namespace: "instance",
Resource: "server",
Verb: "attach-volume",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.AttachServerVolumeRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "volume-id",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volume-type",
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{
"unknown_volume_type",
"l_ssd",
"b_ssd",
"sbs_volume",
},
},
{
Name: "boot",
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(
scw.ZoneFrPar1,
scw.ZoneFrPar2,
scw.ZoneFrPar3,
scw.ZoneNlAms1,
scw.ZoneNlAms2,
scw.ZoneNlAms3,
scw.ZonePlWaw1,
scw.ZonePlWaw2,
scw.ZonePlWaw3,
),
},
Run: func(ctx context.Context, args any) (i any, e error) {
request := args.(*instance.AttachServerVolumeRequest)

client := core.ExtractClient(ctx)
api := instance.NewAPI(client)

return api.AttachServerVolume(request)
},
}
}

func instanceServerDetachVolume() *core.Command {
return &core.Command{
Short: `Detach a volume from an Instance`,
Long: `Detach a volume from an Instance.`,
Namespace: "instance",
Resource: "server",
Verb: "detach-volume",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.DetachServerVolumeRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "volume-id",
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(
scw.ZoneFrPar1,
scw.ZoneFrPar2,
scw.ZoneFrPar3,
scw.ZoneNlAms1,
scw.ZoneNlAms2,
scw.ZoneNlAms3,
scw.ZonePlWaw1,
scw.ZonePlWaw2,
scw.ZonePlWaw3,
),
},
Run: func(ctx context.Context, args any) (i any, e error) {
request := args.(*instance.DetachServerVolumeRequest)

client := core.ExtractClient(ctx)
api := instance.NewAPI(client)

return api.DetachServerVolume(request)
},
}
}

func instanceServerAttachFilesystem() *core.Command {
return &core.Command{
Short: `Attach a filesystem volume to an Instance`,
Expand Down Expand Up @@ -1182,8 +1292,8 @@ func instanceServerAttachFilesystem() *core.Command {

func instanceServerDetachFilesystem() *core.Command {
return &core.Command{
Short: `Detach a filesystem volume to an Instance`,
Long: `Detach a filesystem volume to an Instance.`,
Short: `Detach a filesystem volume from an Instance`,
Long: `Detach a filesystem volume from an Instance.`,
Namespace: "instance",
Resource: "server",
Verb: "detach-filesystem",
Expand Down
Loading