Skip to content

Commit 34fc155

Browse files
feat(instance): add support for filesystems (#4786)
Co-authored-by: Rémy Léone <[email protected]>
1 parent 33d2698 commit 34fc155

File tree

5 files changed

+180
-0
lines changed

5 files changed

+180
-0
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+
Attach a filesystem volume to an Instance.
4+
5+
USAGE:
6+
scw instance server attach-filesystem [arg=value ...]
7+
8+
ARGS:
9+
server-id
10+
[filesystem-id]
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 attach-filesystem
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Detach a filesystem volume to an Instance.
4+
5+
USAGE:
6+
scw instance server detach-filesystem [arg=value ...]
7+
8+
ARGS:
9+
server-id
10+
[filesystem-id]
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 detach-filesystem
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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ USAGE:
99

1010
AVAILABLE COMMANDS:
1111
action Perform a raw API action on a server
12+
attach-filesystem Attach a filesystem volume to an Instance
1213
attach-ip Attach an IP to a server
1314
attach-volume Attach a volume to a server
1415
backup Backup server
1516
console Connect to the serial console of an instance
1617
create Create server
1718
delete Delete server
19+
detach-filesystem Detach a filesystem volume to an Instance
1820
detach-ip Detach an IP from a server
1921
detach-volume Detach a volume from its server
2022
enable-routed-ip Migrate server to IP mobility

docs/commands/instance.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ This API allows you to manage your CPU and GPU Instances.
5050
- [Update security group rule](#update-security-group-rule)
5151
- [Instance management commands](#instance-management-commands)
5252
- [Perform a raw API action on a server](#perform-a-raw-api-action-on-a-server)
53+
- [Attach a filesystem volume to an Instance](#attach-a-filesystem-volume-to-an-instance)
5354
- [Attach an IP to a server](#attach-an-ip-to-a-server)
5455
- [Attach a volume to a server](#attach-a-volume-to-a-server)
5556
- [Backup server](#backup-server)
5657
- [Connect to the serial console of an instance](#connect-to-the-serial-console-of-an-instance)
5758
- [Create server](#create-server)
5859
- [Delete server](#delete-server)
60+
- [Detach a filesystem volume to an Instance](#detach-a-filesystem-volume-to-an-instance)
5961
- [Detach an IP from a server](#detach-an-ip-from-a-server)
6062
- [Detach a volume from its server](#detach-a-volume-from-its-server)
6163
- [Migrate server to IP mobility](#migrate-server-to-ip-mobility)
@@ -1569,6 +1571,27 @@ scw instance server action 11111111-1111-1111-1111-111111111111 action=poweron
15691571

15701572

15711573

1574+
### Attach a filesystem volume to an Instance
1575+
1576+
Attach a filesystem volume to an Instance.
1577+
1578+
**Usage:**
1579+
1580+
```
1581+
scw instance server attach-filesystem [arg=value ...]
1582+
```
1583+
1584+
1585+
**Args:**
1586+
1587+
| Name | | Description |
1588+
|------|---|-------------|
1589+
| server-id | Required | |
1590+
| filesystem-id | | |
1591+
| 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 |
1592+
1593+
1594+
15721595
### Attach an IP to a server
15731596

15741597

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

18211844

18221845

1846+
### Detach a filesystem volume to an Instance
1847+
1848+
Detach a filesystem volume to an Instance.
1849+
1850+
**Usage:**
1851+
1852+
```
1853+
scw instance server detach-filesystem [arg=value ...]
1854+
```
1855+
1856+
1857+
**Args:**
1858+
1859+
| Name | | Description |
1860+
|------|---|-------------|
1861+
| server-id | Required | |
1862+
| filesystem-id | | |
1863+
| 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 |
1864+
1865+
1866+
18231867
### Detach an IP from a server
18241868

18251869

internal/namespaces/instance/v1/instance_cli.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ func GetGeneratedCommands() *core.Commands {
4343
instanceUserDataSet(),
4444
instanceUserDataGet(),
4545
instanceServerGetCompatibleTypes(),
46+
instanceServerAttachFilesystem(),
47+
instanceServerDetachFilesystem(),
4648
instanceImageList(),
4749
instanceImageGet(),
4850
instanceImageCreate(),
@@ -1142,6 +1144,96 @@ If the specified Instance offer is flagged as end of service, the best compatibl
11421144
}
11431145
}
11441146

1147+
func instanceServerAttachFilesystem() *core.Command {
1148+
return &core.Command{
1149+
Short: `Attach a filesystem volume to an Instance`,
1150+
Long: `Attach a filesystem volume to an Instance.`,
1151+
Namespace: "instance",
1152+
Resource: "server",
1153+
Verb: "attach-filesystem",
1154+
// Deprecated: false,
1155+
ArgsType: reflect.TypeOf(instance.AttachServerFileSystemRequest{}),
1156+
ArgSpecs: core.ArgSpecs{
1157+
{
1158+
Name: "server-id",
1159+
Required: true,
1160+
Deprecated: false,
1161+
Positional: false,
1162+
},
1163+
{
1164+
Name: "filesystem-id",
1165+
Required: false,
1166+
Deprecated: false,
1167+
Positional: false,
1168+
},
1169+
core.ZoneArgSpec(
1170+
scw.ZoneFrPar1,
1171+
scw.ZoneFrPar2,
1172+
scw.ZoneFrPar3,
1173+
scw.ZoneNlAms1,
1174+
scw.ZoneNlAms2,
1175+
scw.ZoneNlAms3,
1176+
scw.ZonePlWaw1,
1177+
scw.ZonePlWaw2,
1178+
scw.ZonePlWaw3,
1179+
),
1180+
},
1181+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
1182+
request := args.(*instance.AttachServerFileSystemRequest)
1183+
1184+
client := core.ExtractClient(ctx)
1185+
api := instance.NewAPI(client)
1186+
1187+
return api.AttachServerFileSystem(request)
1188+
},
1189+
}
1190+
}
1191+
1192+
func instanceServerDetachFilesystem() *core.Command {
1193+
return &core.Command{
1194+
Short: `Detach a filesystem volume to an Instance`,
1195+
Long: `Detach a filesystem volume to an Instance.`,
1196+
Namespace: "instance",
1197+
Resource: "server",
1198+
Verb: "detach-filesystem",
1199+
// Deprecated: false,
1200+
ArgsType: reflect.TypeOf(instance.DetachServerFileSystemRequest{}),
1201+
ArgSpecs: core.ArgSpecs{
1202+
{
1203+
Name: "server-id",
1204+
Required: true,
1205+
Deprecated: false,
1206+
Positional: false,
1207+
},
1208+
{
1209+
Name: "filesystem-id",
1210+
Required: false,
1211+
Deprecated: false,
1212+
Positional: false,
1213+
},
1214+
core.ZoneArgSpec(
1215+
scw.ZoneFrPar1,
1216+
scw.ZoneFrPar2,
1217+
scw.ZoneFrPar3,
1218+
scw.ZoneNlAms1,
1219+
scw.ZoneNlAms2,
1220+
scw.ZoneNlAms3,
1221+
scw.ZonePlWaw1,
1222+
scw.ZonePlWaw2,
1223+
scw.ZonePlWaw3,
1224+
),
1225+
},
1226+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
1227+
request := args.(*instance.DetachServerFileSystemRequest)
1228+
1229+
client := core.ExtractClient(ctx)
1230+
api := instance.NewAPI(client)
1231+
1232+
return api.DetachServerFileSystem(request)
1233+
},
1234+
}
1235+
}
1236+
11451237
func instanceImageList() *core.Command {
11461238
return &core.Command{
11471239
Short: `List Instance images`,

0 commit comments

Comments
 (0)