Skip to content
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

feat(instance): add attach/detach ip commands #1911

Merged
merged 10 commits into from
May 19, 2021
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
24 changes: 24 additions & 0 deletions cmd/scw/testdata/test-all-usage-instance-ip-attach-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Attach an IP to a given server.

USAGE:
scw instance ip attach <ip ...> [arg=value ...]

EXAMPLES:
Attach an IP to the given server
scw instance ip attach 1.2.3.4 server-id=11111111-1111-1111-1111-111111111111

ARGS:
ip IP or UUID of the IP.
server-id UUID of the server to attach the IP to
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config

FLAGS:
-h, --help help for attach

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
26 changes: 26 additions & 0 deletions cmd/scw/testdata/test-all-usage-instance-ip-detach-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Detach an ip from its server.

USAGE:
scw instance ip detach <ip ...> [arg=value ...]

EXAMPLES:
Detach an IP by using its UUID
scw instance ip detach 11111111-1111-1111-1111-111111111111

Detach an IP by using its IP address
scw instance ip detach 1.2.3.4

ARGS:
ip IP or UUID of the IP.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config

FLAGS:
-h, --help help for detach

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
2 changes: 2 additions & 0 deletions cmd/scw/testdata/test-all-usage-instance-ip-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ USAGE:
scw instance ip <command>

AVAILABLE COMMANDS:
attach Attach an IP to a given server
create Reserve a flexible IP
delete Delete a flexible IP
detach Detach an ip from its server
get Get a flexible IP
list List all flexible IPs
update Update a flexible IP
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Attach an IP to a server

USAGE:
scw instance server attach-ip <server-id ...> [arg=value ...]

EXAMPLES:
Attach an IP to a server
scw instance server attach-ip 11111111-1111-1111-1111-111111111111 ip=11111111-1111-1111-1111-111111111111

Attach an IP to a server
scw instance server attach-ip 11111111-1111-1111-1111-111111111111 ip=1.2.3.4

ARGS:
server-id ID of the server
ip UUID of the IP to attach or its UUID
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config

FLAGS:
-h, --help help for attach-ip

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Detach an IP from a server

USAGE:
scw instance server detach-ip <server-id ...> [arg=value ...]

EXAMPLES:
Detach IP from a given server
scw instance server detach-ip 11111111-1111-1111-1111-111111111111

ARGS:
server-id UUID of the server.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config

FLAGS:
-h, --help help for detach-ip

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
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ USAGE:
scw instance server <command>

AVAILABLE COMMANDS:
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-ip Detach an IP from a server
detach-volume Detach a volume from its server
get Get a server
list List all servers
Expand Down
136 changes: 136 additions & 0 deletions docs/commands/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ Instance API
- [List instance images](#list-instance-images)
- [Wait for image to reach a stable state](#wait-for-image-to-reach-a-stable-state)
- [IP management commands](#ip-management-commands)
- [Attach an IP to a given server](#attach-an-ip-to-a-given-server)
- [Reserve a flexible IP](#reserve-a-flexible-ip)
- [Delete a flexible IP](#delete-a-flexible-ip)
- [Detach an ip from its server](#detach-an-ip-from-its-server)
- [Get a flexible IP](#get-a-flexible-ip)
- [List all flexible IPs](#list-all-flexible-ips)
- [Update a flexible IP](#update-a-flexible-ip)
Expand All @@ -33,11 +35,13 @@ Instance API
- [List security groups](#list-security-groups)
- [Update security group](#update-security-group)
- [Server management commands](#server-management-commands)
- [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 an IP from a server](#detach-an-ip-from-a-server)
- [Detach a volume from its server](#detach-a-volume-from-its-server)
- [Get a server](#get-a-server)
- [List all servers](#list-all-servers)
Expand Down Expand Up @@ -267,6 +271,37 @@ Be aware that attaching a flexible IP address to a server will remove the previo



### Attach an IP to a given server

Attach an IP to a given server.

**Usage:**

```
scw instance ip attach <ip ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| ip | Required | IP or UUID of the IP. |
| server-id | Required | UUID of the server to attach the IP to |
| zone | Default: `fr-par-1` | Zone to target. If none is passed will use default zone from the config |


**Examples:**


Attach an IP to the given server
```
scw instance ip attach 1.2.3.4 server-id=11111111-1111-1111-1111-111111111111
```




### Reserve a flexible IP

Reserve a flexible IP.
Expand Down Expand Up @@ -350,6 +385,41 @@ scw instance ip delete 51.15.253.183



### Detach an ip from its server

Detach an ip from its server.

**Usage:**

```
scw instance ip detach <ip ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| ip | Required | IP or UUID of the IP. |
| zone | Default: `fr-par-1` | Zone to target. If none is passed will use default zone from the config |


**Examples:**


Detach an IP by using its UUID
```
scw instance ip detach 11111111-1111-1111-1111-111111111111
```

Detach an IP by using its IP address
```
scw instance ip detach 1.2.3.4
```




### Get a flexible IP

Get details of an IP with the given ID or address.
Expand Down Expand Up @@ -1086,6 +1156,42 @@ For more information, refer to [GPU Instances](https://www.scaleway.com/en/gpu-i



### Attach an IP to a server



**Usage:**

```
scw instance server attach-ip <server-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| server-id | Required | ID of the server |
| ip | Required | UUID of the IP to attach or its UUID |
| zone | Default: `fr-par-1` | Zone to target. If none is passed will use default zone from the config |


**Examples:**


Attach an IP to a server
```
scw instance server attach-ip 11111111-1111-1111-1111-111111111111 ip=11111111-1111-1111-1111-111111111111
```

Attach an IP to a server
```
scw instance server attach-ip 11111111-1111-1111-1111-111111111111 ip=1.2.3.4
```




### Attach a volume to a server


Expand Down Expand Up @@ -1279,6 +1385,36 @@ scw instance server delete 11111111-1111-1111-1111-111111111111 zone=fr-par-1



### Detach an IP from a server



**Usage:**

```
scw instance server detach-ip <server-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| server-id | Required | UUID of the server. |
| zone | Default: `fr-par-1` | Zone to target. If none is passed will use default zone from the config |


**Examples:**


Detach IP from a given server
```
scw instance server detach-ip 11111111-1111-1111-1111-111111111111
```




### Detach a volume from its server


Expand Down
6 changes: 6 additions & 0 deletions internal/namespaces/instance/v1/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ func GetCommands() *core.Commands {
serverStandbyCommand(),
serverRebootCommand(),
serverWaitCommand(),
serverAttachIPCommand(),
serverDetachIPCommand(),
))

//
Expand All @@ -78,6 +80,10 @@ func GetCommands() *core.Commands {

cmds.MustFind("instance", "ip", "create").Override(ipCreateBuilder)
cmds.MustFind("instance", "ip", "list").Override(ipListBuilder)
cmds.Merge(core.NewCommands(
ipAttachCommand(),
ipDetachCommand(),
))

//
// Image
Expand Down
Loading