Skip to content

Commit

Permalink
baremetal: add list server command
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone committed Mar 10, 2020
1 parent b7c3ffe commit 8d131fb
Show file tree
Hide file tree
Showing 15 changed files with 579 additions and 19 deletions.
2 changes: 2 additions & 0 deletions cmd/scw/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/mattn/go-colorable"
"github.com/scaleway/scaleway-cli/internal/core"
autocompleteNamespace "github.com/scaleway/scaleway-cli/internal/namespaces/autocomplete"
baremetal "github.com/scaleway/scaleway-cli/internal/namespaces/baremetal/v1alpha1"
configNamespace "github.com/scaleway/scaleway-cli/internal/namespaces/config"
initNamespace "github.com/scaleway/scaleway-cli/internal/namespaces/init"
"github.com/scaleway/scaleway-cli/internal/namespaces/instance/v1"
Expand Down Expand Up @@ -39,6 +40,7 @@ func getCommands() *core.Commands {
// NB: Merge order impacts scw usage sort.
commands := core.NewCommands()
commands.Merge(instance.GetCommands())
commands.Merge(baremetal.GetCommands())
commands.Merge(k8s.GetCommands())
commands.Merge(marketplace.GetCommands())
commands.Merge(initNamespace.GetCommands())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Baseboard Management Controller (BMC) offers a low-level access to your baremetal instance.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The IPs failovers could be attach to any server in the same zone.
A server could be linked with multiple failovers.
.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Commercial offers.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
An Operating System (OS) is the underlying software installed on your server.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
List all created servers.

USAGE:
scw [global-flags] baremetal server list [flags] [arg=value ...]

EXAMPLES:
List all servers on your default zone
scw baremetal server list

ARGS:
[order-by] Order of the servers (created_at_asc | created_at_desc)
[tags.{index}] Filter servers by tags
[status.{index}] Filter servers by status
[name] Filter servers by name
[organization-id] Filter servers by organization ID
[zone] Zone to target. If none is passed will use default zone from the config (fr-par-2)

FLAGS:
-h, --help help for list

GLOBAL FLAGS:
-D, --debug Enable debug mode
-o, --output string Output format: json or human
-p, --profile string The config profile to use
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
A server is a denomination of a type of instances provided by Scaleway.

USAGE:
scw [global-flags] baremetal server <command> [flags]

AVAILABLE COMMANDS:
list List servers

FLAGS:
-h, --help help for server

GLOBAL FLAGS:
-D, --debug Enable debug mode
-o, --output string Output format: json or human
-p, --profile string The config profile to use

Use "scw baremetal server [command] --help" for more information about a command.
25 changes: 25 additions & 0 deletions cmd/scw/testdata/test-all-usage-baremetal-usage.stderr.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Baremetal API

USAGE:
scw [global-flags] baremetal <command> [flags]

AVAILABLE COMMANDS:
server A server is a denomination of a type of instances provided by Scaleway

FLAGS:
-h, --help help for baremetal

GLOBAL FLAGS:
-D, --debug Enable debug mode
-o, --output string Output format: json or human
-p, --profile string The config profile to use

Additional help topics:
scw baremetal os An Operating System (OS) is the underlying software installed on your server
scw baremetal ip The IPs failovers could be attach to any server in the same zone.
A server could be linked with multiple failovers.

scw baremetal bmc Baseboard Management Controller (BMC) offers a low-level access to your baremetal instance
scw baremetal offer Commercial offers

Use "scw baremetal [command] --help" for more information about a command.
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-main-usage-usage.stderr.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ USAGE:

AVAILABLE COMMANDS:
instance Instance API
baremetal Baremetal API
k8s This API allows you to manage your Kapsule clusters
marketplace Marketplace API
init Initialize the config
Expand Down
30 changes: 30 additions & 0 deletions internal/namespaces/baremetal/v1alpha1/baremetal_cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package baremetal

import (
"testing"

"github.com/scaleway/scaleway-cli/internal/core"
"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
"github.com/scaleway/scaleway-sdk-go/scw"
)

func init() {
if !core.UpdateCassettes {
instance.RetryInterval = 0
}
}

//
// Server
//
func Test_ListServer(t *testing.T) {
t.Run("Simple", core.Test(&core.TestConfig{
Commands: GetCommands(),
Cmd: "scw baremetal server list",
Check: core.TestCheckCombine(
core.TestCheckGolden(),
core.TestCheckExitCode(0),
),
DefaultZone: scw.ZoneFrPar2,
}))
}
8 changes: 8 additions & 0 deletions internal/namespaces/baremetal/v1alpha1/custom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package baremetal

import "github.com/scaleway/scaleway-cli/internal/core"

func GetCommands() *core.Commands {
cmds := GetGeneratedCommands()
return cmds
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- scaleway-sdk-go/v1.0.0-beta.5+dev (go1.14; darwin; amd64) cli-e2e-test
url: https://api.scaleway.com/baremetal/v1alpha1/zones/fr-par-2/servers?order_by=created_at_asc&page=1
method: GET
response:
body: '{"total_count":1,"servers":[{"id":"188b71df-4193-4f33-9151-df07234f3ef4","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","name":"bm-determined-ellis","description":"","updated_at":"2020-02-24T09:55:20.021923Z","created_at":"2020-02-24T09:54:57.367412Z","status":"ready","offer_id":"737f18c8-febc-4408-b69e-776bca0a3f48","install":{"os_id":"f2aeab5d-6015-4b7c-b4ed-d76e89093621","hostname":"bm-determined-ellis","ssh_key_ids":["77021435-ad22-4748-8861-0a1c512154d0","90bf1977-43ab-4eb7-b178-3dd96963ce99"],"status":"completed"},"tags":[],"ips":[{"id":"80e3d13b-b5df-4c00-b38c-afc4e96f8ea5","address":"51.159.0.4","reverse":"188b71df-4193-4f33-9151-df07234f3ef4.fr-par-2.baremetal.scw.cloud","version":"Ipv4","reverse_status":"active","reverse_status_message":null},{"id":"b7abae59-34a3-49fc-87b4-93e95da83207","address":"2001:0bc8:6005:0000:529a:4cff:fe84:ea3d","reverse":"188b71df-4193-4f33-9151-df07234f3ef4.fr-par-2.baremetal.scw.cloud","version":"Ipv6","reverse_status":"active","reverse_status_message":null}],"domain":"188b71df-4193-4f33-9151-df07234f3ef4.fr-par-2.baremetal.scw.cloud","boot_type":"normal","zone":"fr-par-2"}]}'
headers:
Content-Length:
- "1141"
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'
Content-Type:
- application/json
Date:
- Mon, 09 Mar 2020 13:22:06 GMT
Server:
- scaleway_api
Strict-Transport-Security:
- max-age=63072000
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Request-Id:
- 5afb66a6-c9ff-4fe7-8c2a-61e2d83fc937
status: 200 OK
code: 200
duration: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ID ORGANIZATION ID NAME DESCRIPTION UPDATED AT CREATED AT STATUS OFFER ID TAGS IPS DOMAIN BOOT TYPE ZONE
188b71df-4193-4f33-9151-df07234f3ef4 951df375-e094-4d26-97c1-ba548eeb9c42 bm-determined-ellis - few seconds ago few seconds ago ready 737f18c8-febc-4408-b69e-776bca0a3f48 [] 2 188b71df-4193-4f33-9151-df07234f3ef4.fr-par-2.baremetal.scw.cloud normal fr-par-2
Loading

0 comments on commit 8d131fb

Please sign in to comment.