Skip to content

Commit

Permalink
feat(baremetal): enable private network and options management (#2656)
Browse files Browse the repository at this point in the history
Co-authored-by: Rémy Léone <rleone@scaleway.com>
  • Loading branch information
scaleway-bot and remyleone authored Dec 2, 2022
1 parent 88bcc1c commit 77118eb
Show file tree
Hide file tree
Showing 16 changed files with 489 additions and 27 deletions.
25 changes: 25 additions & 0 deletions cmd/scw/testdata/test-all-usage-baremetal-options-add-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Add an option to a specific server.

USAGE:
scw baremetal options add [arg=value ...]

EXAMPLES:
Add a given option to a server
scw baremetal options add server-id=11111111-1111-1111-1111-111111111111 option-id=11111111-1111-1111-1111-111111111111

ARGS:
server-id ID of the server
option-id ID of the option to add
[expires-at] Auto expire the option after this date
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | nl-ams-1)

FLAGS:
-h, --help help for add

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,24 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Delete an option from a specific server.

USAGE:
scw baremetal options delete [arg=value ...]

EXAMPLES:
Delete a given option from a server
scw baremetal options delete server-id=11111111-1111-1111-1111-111111111111 option-id=11111111-1111-1111-1111-111111111111

ARGS:
server-id ID of the server
option-id ID of the option to delete
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | nl-ams-1)

FLAGS:
-h, --help help for delete

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
23 changes: 23 additions & 0 deletions cmd/scw/testdata/test-all-usage-baremetal-options-get-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Return specific option for the given ID.

USAGE:
scw baremetal options get [arg=value ...]

EXAMPLES:
Get a server option with the given ID
scw baremetal options get zone=fr-par-1 option-id=11111111-1111-1111-1111-111111111111

ARGS:
option-id ID of the option
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | nl-ams-1)

FLAGS:
-h, --help help for get

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,27 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
List all options matching with filters.

USAGE:
scw baremetal options list [arg=value ...]

EXAMPLES:
List all server options in the default zone
scw baremetal options list

List all server options in fr-par-1 zone
scw baremetal options list zone=fr-par-1

ARGS:
[offer-id] Filter options by offer_id
[name] Filter options by name
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | nl-ams-1)

FLAGS:
-h, --help help for list

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
23 changes: 23 additions & 0 deletions cmd/scw/testdata/test-all-usage-baremetal-options-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
A Server has additional options that let you personalize it to better fit your needs.

USAGE:
scw baremetal options <command>

AVAILABLE COMMANDS:
add Add server option
delete Delete server option
get Get option
list List options

FLAGS:
-h, --help help for options

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

Use "scw baremetal options [command] --help" for more information about a command.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ USAGE:
ARGS:
server-id The ID of the server
private-network-id The ID of the private network
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | nl-ams-1)
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-2)

FLAGS:
-h, --help help for add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ USAGE:
ARGS:
server-id The ID of the server
private-network-id The ID of the private network
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | nl-ams-1)
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-2)

FLAGS:
-h, --help help for delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ARGS:
[private-network-id] Filter private networks by private network ID
[project-id] Filter private networks by project ID
[organization-id] Filter private networks by organization 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 | nl-ams-1)
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-2)

FLAGS:
-h, --help help for list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ USAGE:
ARGS:
server-id The ID of the server
private-network-ids.{index} The IDs of the private networks
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | nl-ams-1)
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-2)

FLAGS:
-h, --help help for set
Expand Down
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-baremetal-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ USAGE:
AVAILABLE COMMANDS:
bmc Baseboard Management Controller (BMC) management commands
offer Server offer management commands
options Server options management commands
os Operating System (OS) management commands
private-network Private network management command
server Server management commands
Expand Down
148 changes: 144 additions & 4 deletions docs/commands/baremetal.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Elastic metal API
- [Server offer management commands](#server-offer-management-commands)
- [Get offer](#get-offer)
- [List offers](#list-offers)
- [Server options management commands](#server-options-management-commands)
- [Add server option](#add-server-option)
- [Delete server option](#delete-server-option)
- [Get option](#get-option)
- [List options](#list-options)
- [Operating System (OS) management commands](#operating-system-(os)-management-commands)
- [Get an OS with a given ID](#get-an-os-with-a-given-id)
- [List all available OS that can be install on an elastic metal server](#list-all-available-os-that-can-be-install-on-an-elastic-metal-server)
Expand Down Expand Up @@ -177,6 +182,141 @@ scw baremetal offer list zone=fr-par-1



## Server options management commands

A Server has additional options that let you personalize it to better fit your needs.



### Add server option

Add an option to a specific server.

**Usage:**

```
scw baremetal options add [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| server-id | Required | ID of the server |
| option-id | Required | ID of the option to add |
| expires-at | | Auto expire the option after this date |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `nl-ams-1` | Zone to target. If none is passed will use default zone from the config |


**Examples:**


Add a given option to a server
```
scw baremetal options add server-id=11111111-1111-1111-1111-111111111111 option-id=11111111-1111-1111-1111-111111111111
```




### Delete server option

Delete an option from a specific server.

**Usage:**

```
scw baremetal options delete [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| server-id | Required | ID of the server |
| option-id | Required | ID of the option to delete |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `nl-ams-1` | Zone to target. If none is passed will use default zone from the config |


**Examples:**


Delete a given option from a server
```
scw baremetal options delete server-id=11111111-1111-1111-1111-111111111111 option-id=11111111-1111-1111-1111-111111111111
```




### Get option

Return specific option for the given ID.

**Usage:**

```
scw baremetal options get [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| option-id | Required | ID of the option |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `nl-ams-1` | Zone to target. If none is passed will use default zone from the config |


**Examples:**


Get a server option with the given ID
```
scw baremetal options get zone=fr-par-1 option-id=11111111-1111-1111-1111-111111111111
```




### List options

List all options matching with filters.

**Usage:**

```
scw baremetal options list [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| offer-id | | Filter options by offer_id |
| name | | Filter options by name |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `nl-ams-1` | Zone to target. If none is passed will use default zone from the config |


**Examples:**


List all server options in the default zone
```
scw baremetal options list
```

List all server options in fr-par-1 zone
```
scw baremetal options list zone=fr-par-1
```




## Operating System (OS) management commands

An Operating System (OS) is the underlying software installed on your server
Expand Down Expand Up @@ -262,7 +402,7 @@ scw baremetal private-network add [arg=value ...]
|------|---|-------------|
| server-id | Required | The ID of the server |
| private-network-id | Required | The ID of the private network |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `nl-ams-1` | Zone to target. If none is passed will use default zone from the config |
| zone | Default: `fr-par-1`<br />One of: `fr-par-2` | Zone to target. If none is passed will use default zone from the config |



Expand All @@ -283,7 +423,7 @@ scw baremetal private-network delete [arg=value ...]
|------|---|-------------|
| server-id | Required | The ID of the server |
| private-network-id | Required | The ID of the private network |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `nl-ams-1` | Zone to target. If none is passed will use default zone from the config |
| zone | Default: `fr-par-1`<br />One of: `fr-par-2` | Zone to target. If none is passed will use default zone from the config |



Expand All @@ -307,7 +447,7 @@ scw baremetal private-network list [arg=value ...]
| private-network-id | | Filter private networks by private network ID |
| project-id | | Filter private networks by project ID |
| organization-id | | Filter private networks by organization ID |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `nl-ams-1` | Zone to target. If none is passed will use default zone from the config |
| zone | Default: `fr-par-1`<br />One of: `fr-par-2` | Zone to target. If none is passed will use default zone from the config |



Expand All @@ -328,7 +468,7 @@ scw baremetal private-network set [arg=value ...]
|------|---|-------------|
| server-id | Required | The ID of the server |
| private-network-ids.{index} | Required | The IDs of the private networks |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `nl-ams-1` | Zone to target. If none is passed will use default zone from the config |
| zone | Default: `fr-par-1`<br />One of: `fr-par-2` | Zone to target. If none is passed will use default zone from the config |



Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/kubernetes-client/go-base v0.0.0-20190205182333-3d0e39759d98
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-isatty v0.0.16
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221117163236-af2cd7649327
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221130161646-e0f8387f73a0
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221117163236-af2cd7649327 h1:qC5FcsIXIOXoow932RDOV4pvjEKP9KvAbvrtl/ZXZ10=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221117163236-af2cd7649327/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221130161646-e0f8387f73a0 h1:pSsfbPPYDUGIeqhoIzHIMrynJPOXTPwnjiVH6sXfZ8c=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221130161646-e0f8387f73a0/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
Expand Down
Loading

0 comments on commit 77118eb

Please sign in to comment.