Skip to content

feat(instance): add support for filesystems #4786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 10, 2025
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,21 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Attach a filesystem volume to an Instance.

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

ARGS:
server-id
[filesystem-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:
-h, --help help for attach-filesystem

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
--web open console page for the current ressource
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Detach a filesystem volume to an Instance.

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

ARGS:
server-id
[filesystem-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:
-h, --help help for detach-filesystem

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
--web open console page for the current ressource
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ USAGE:

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 a server
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-ip Detach an IP from a server
detach-volume Detach a volume from its server
enable-routed-ip Migrate server to IP mobility
Expand Down
44 changes: 44 additions & 0 deletions docs/commands/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ This API allows you to manage your CPU and GPU Instances.
- [Update security group rule](#update-security-group-rule)
- [Instance management commands](#instance-management-commands)
- [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 a server](#attach-a-volume-to-a-server)
- [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 an IP from a server](#detach-an-ip-from-a-server)
- [Detach a volume from its server](#detach-a-volume-from-its-server)
- [Migrate server to IP mobility](#migrate-server-to-ip-mobility)
Expand Down Expand Up @@ -1569,6 +1571,27 @@ scw instance server action 11111111-1111-1111-1111-111111111111 action=poweron



### Attach a filesystem volume to an Instance

Attach a filesystem volume to an Instance.

**Usage:**

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


**Args:**

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



### Attach an IP to a server


Expand Down Expand Up @@ -1820,6 +1843,27 @@ scw instance server delete 11111111-1111-1111-1111-111111111111 zone=fr-par-1



### Detach a filesystem volume to an Instance

Detach a filesystem volume to an Instance.

**Usage:**

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


**Args:**

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



### Detach an IP from a server


Expand Down
92 changes: 92 additions & 0 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(),
instanceServerAttachFilesystem(),
instanceServerDetachFilesystem(),
instanceImageList(),
instanceImageGet(),
instanceImageCreate(),
Expand Down Expand Up @@ -1142,6 +1144,96 @@ If the specified Instance offer is flagged as end of service, the best compatibl
}
}

func instanceServerAttachFilesystem() *core.Command {
return &core.Command{
Short: `Attach a filesystem volume to an Instance`,
Long: `Attach a filesystem volume to an Instance.`,
Namespace: "instance",
Resource: "server",
Verb: "attach-filesystem",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.AttachServerFileSystemRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "filesystem-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 interface{}) (i interface{}, e error) {
request := args.(*instance.AttachServerFileSystemRequest)

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

return api.AttachServerFileSystem(request)
},
}
}

func instanceServerDetachFilesystem() *core.Command {
return &core.Command{
Short: `Detach a filesystem volume to an Instance`,
Long: `Detach a filesystem volume to an Instance.`,
Namespace: "instance",
Resource: "server",
Verb: "detach-filesystem",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.DetachServerFileSystemRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "filesystem-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 interface{}) (i interface{}, e error) {
request := args.(*instance.DetachServerFileSystemRequest)

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

return api.DetachServerFileSystem(request)
},
}
}

func instanceImageList() *core.Command {
return &core.Command{
Short: `List Instance images`,
Expand Down
Loading