diff --git a/cmd/scw/testdata/test-all-usage-baremetal-ip-attach-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-ip-attach-usage.stderr.golden new file mode 100644 index 0000000000..6500134b7b --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-baremetal-ip-attach-usage.stderr.golden @@ -0,0 +1,17 @@ +Attach IP failovers to the given server ID. + +USAGE: + scw baremetal ip attach [arg=value ...] + +ARGS: + [ip-failover-ids.{index}] IP failover IDs to attach to the server + [server-id] ID of the server to attach to the IP failovers + [zone] Zone to target. If none is passed will use default zone from the config (fr-par-2) + +FLAGS: + -h, --help help for attach + +GLOBAL FLAGS: + -D, --debug Enable debug mode + -o, --output string Output format: json or human + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-baremetal-ip-create-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-ip-create-usage.stderr.golden new file mode 100644 index 0000000000..e0a2ea54d4 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-baremetal-ip-create-usage.stderr.golden @@ -0,0 +1,20 @@ +Create an IP failover. Once the IP failover is created, you probably want to attach it to a server. + +USAGE: + scw baremetal ip create [arg=value ...] + +ARGS: + [description] Description to associate to the IP failover, max 255 characters + [tags.{index}] Tags to associate to the IP failover + [mac-type] MAC type to use for the IP failover (unknown_mac_type | none | duplicate | vmware | xen | kvm) + [duplicate-mac-from] ID of the IP failover which must be duplicate + [organization-id] Organization ID to use. If none is passed will use default organization ID from the config + [zone] Zone to target. If none is passed will use default zone from the config (fr-par-2) + +FLAGS: + -h, --help help for create + +GLOBAL FLAGS: + -D, --debug Enable debug mode + -o, --output string Output format: json or human + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-baremetal-ip-delete-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-ip-delete-usage.stderr.golden new file mode 100644 index 0000000000..6bfb82b869 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-baremetal-ip-delete-usage.stderr.golden @@ -0,0 +1,16 @@ +Delete the IP failover associated with the given IP. + +USAGE: + scw baremetal ip delete [arg=value ...] + +ARGS: + ip-failover-id ID of the IP failover to delete + [zone] Zone to target. If none is passed will use default zone from the config (fr-par-2) + +FLAGS: + -h, --help help for delete + +GLOBAL FLAGS: + -D, --debug Enable debug mode + -o, --output string Output format: json or human + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-baremetal-ip-detach-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-ip-detach-usage.stderr.golden new file mode 100644 index 0000000000..fced805545 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-baremetal-ip-detach-usage.stderr.golden @@ -0,0 +1,16 @@ +Detach IP failovers to the given server ID. + +USAGE: + scw baremetal ip detach [arg=value ...] + +ARGS: + [ip-failover-ids.{index}] IP failover IDs to detach to the server + [zone] Zone to target. If none is passed will use default zone from the config (fr-par-2) + +FLAGS: + -h, --help help for detach + +GLOBAL FLAGS: + -D, --debug Enable debug mode + -o, --output string Output format: json or human + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-baremetal-ip-get-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-ip-get-usage.stderr.golden new file mode 100644 index 0000000000..3a7fdd8b12 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-baremetal-ip-get-usage.stderr.golden @@ -0,0 +1,16 @@ +Get the IP failover associated with the given ID. + +USAGE: + scw baremetal ip get [arg=value ...] + +ARGS: + ip-failover-id ID of the IP failover + [zone] Zone to target. If none is passed will use default zone from the config (fr-par-2) + +FLAGS: + -h, --help help for get + +GLOBAL FLAGS: + -D, --debug Enable debug mode + -o, --output string Output format: json or human + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-baremetal-ip-list-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-ip-list-usage.stderr.golden new file mode 100644 index 0000000000..d3b10f7143 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-baremetal-ip-list-usage.stderr.golden @@ -0,0 +1,20 @@ +List all created IP failovers. + +USAGE: + scw baremetal ip list [arg=value ...] + +ARGS: + [order-by] Order of the IP failovers (created_at_asc | created_at_desc) + [tags.{index}] Filter IP failovers by tags + [status.{index}] Filter IP failovers by status + [server-ids.{index}] Filter IP failovers by server IDs + [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 diff --git a/cmd/scw/testdata/test-all-usage-baremetal-ip-update-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-ip-update-usage.stderr.golden new file mode 100644 index 0000000000..9cb457f824 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-baremetal-ip-update-usage.stderr.golden @@ -0,0 +1,21 @@ +Update the IP failover associated with the given IP. + +USAGE: + scw baremetal ip update [arg=value ...] + +ARGS: + ip-failover-id ID of the IP failover to update + [description] Description to associate to the IP failover, max 255 characters, not updated if null + [tags] Tags to associate to the IP failover, not updated if null + [mac-type] MAC type to use for the IP failover, not updated if null (unknown_mac_type | none | duplicate | vmware | xen | kvm) + [duplicate-mac-from] ID of the IP failover which must be duplicate, not updated if null + [reverse] New reverse IP to update, not updated if null + [zone] Zone to target. If none is passed will use default zone from the config (fr-par-2) + +FLAGS: + -h, --help help for update + +GLOBAL FLAGS: + -D, --debug Enable debug mode + -o, --output string Output format: json or human + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-baremetal-ip-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-ip-usage.stderr.golden index f2bc7aa94d..7c72f5b693 100644 --- a/cmd/scw/testdata/test-all-usage-baremetal-ip-usage.stderr.golden +++ b/cmd/scw/testdata/test-all-usage-baremetal-ip-usage.stderr.golden @@ -1,2 +1,23 @@ IP fail-over management. +USAGE: + scw baremetal ip + +AVAILABLE COMMANDS: + create Create IP failover + get Get IP failover + list List IP failovers + delete Delete IP failover + update Update IP failover + attach Attach IP failovers + detach Detach IP failovers + +FLAGS: + -h, --help help for ip + +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 ip [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-baremetal-os-get-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-os-get-usage.stderr.golden new file mode 100644 index 0000000000..6aee249ca4 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-baremetal-os-get-usage.stderr.golden @@ -0,0 +1,16 @@ +Return specific OS for the given ID. + +USAGE: + scw baremetal os get [arg=value ...] + +ARGS: + os-id ID of the researched OS + [zone] Zone to target. If none is passed will use default zone from the config (fr-par-2) + +FLAGS: + -h, --help help for get + +GLOBAL FLAGS: + -D, --debug Enable debug mode + -o, --output string Output format: json or human + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-baremetal-os-list-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-os-list-usage.stderr.golden new file mode 100644 index 0000000000..8dd37d4e5d --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-baremetal-os-list-usage.stderr.golden @@ -0,0 +1,15 @@ +List all available OS that can be install on a baremetal server. + +USAGE: + scw baremetal os list [arg=value ...] + +ARGS: + [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 diff --git a/cmd/scw/testdata/test-all-usage-baremetal-os-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-os-usage.stderr.golden index 6c380b2939..54cb232f2f 100644 --- a/cmd/scw/testdata/test-all-usage-baremetal-os-usage.stderr.golden +++ b/cmd/scw/testdata/test-all-usage-baremetal-os-usage.stderr.golden @@ -1,2 +1,18 @@ An Operating System (OS) is the underlying software installed on your server. +USAGE: + scw baremetal os + +AVAILABLE COMMANDS: + list List OS + get Get OS + +FLAGS: + -h, --help help for os + +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 os [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-baremetal-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-baremetal-usage.stderr.golden index 463643b595..c0798ca38e 100644 --- a/cmd/scw/testdata/test-all-usage-baremetal-usage.stderr.golden +++ b/cmd/scw/testdata/test-all-usage-baremetal-usage.stderr.golden @@ -5,6 +5,8 @@ USAGE: AVAILABLE COMMANDS: server A server is a denomination of a type of instances provided by Scaleway + os An Operating System (OS) is the underlying software installed on your server + ip IP fail-over management FLAGS: -h, --help help for baremetal @@ -15,8 +17,6 @@ GLOBAL FLAGS: -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 IP fail-over management scw baremetal bmc Baseboard Management Controller (BMC) offers a low-level access to your baremetal instance scw baremetal offer Commercial offers diff --git a/internal/namespaces/baremetal/v1alpha1/baremetal_cli.go b/internal/namespaces/baremetal/v1alpha1/baremetal_cli.go index c9646e4979..b4e0cd778b 100644 --- a/internal/namespaces/baremetal/v1alpha1/baremetal_cli.go +++ b/internal/namespaces/baremetal/v1alpha1/baremetal_cli.go @@ -34,6 +34,15 @@ func GetGeneratedCommands() *core.Commands { baremetalServerReboot(), baremetalServerStart(), baremetalServerStop(), + baremetalIPCreate(), + baremetalIPGet(), + baremetalIPList(), + baremetalIPDelete(), + baremetalIPUpdate(), + baremetalIPAttach(), + baremetalIPDetach(), + baremetalOsList(), + baremetalOsGet(), ) } func baremetalRoot() *core.Command { @@ -414,3 +423,318 @@ func baremetalServerStop() *core.Command { }, } } + +func baremetalIPCreate() *core.Command { + return &core.Command{ + Short: `Create IP failover`, + Long: `Create an IP failover. Once the IP failover is created, you probably want to attach it to a server.`, + Namespace: "baremetal", + Resource: "ip", + Verb: "create", + ArgsType: reflect.TypeOf(baremetal.CreateIPFailoverRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "description", + Short: `Description to associate to the IP failover, max 255 characters`, + Required: false, + }, + { + Name: "tags.{index}", + Short: `Tags to associate to the IP failover`, + Required: false, + }, + { + Name: "mac-type", + Short: `MAC type to use for the IP failover`, + Required: false, + EnumValues: []string{"unknown_mac_type", "none", "duplicate", "vmware", "xen", "kvm"}, + }, + { + Name: "duplicate-mac-from", + Short: `ID of the IP failover which must be duplicate`, + Required: false, + }, + core.OrganizationIDArgSpec(), + core.ZoneArgSpec(scw.ZoneFrPar2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*baremetal.CreateIPFailoverRequest) + + client := core.ExtractClient(ctx) + api := baremetal.NewAPI(client) + return api.CreateIPFailover(request) + + }, + } +} + +func baremetalIPGet() *core.Command { + return &core.Command{ + Short: `Get IP failover`, + Long: `Get the IP failover associated with the given ID.`, + Namespace: "baremetal", + Resource: "ip", + Verb: "get", + ArgsType: reflect.TypeOf(baremetal.GetIPFailoverRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "ip-failover-id", + Short: `ID of the IP failover`, + Required: true, + }, + core.ZoneArgSpec(scw.ZoneFrPar2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*baremetal.GetIPFailoverRequest) + + client := core.ExtractClient(ctx) + api := baremetal.NewAPI(client) + return api.GetIPFailover(request) + + }, + } +} + +func baremetalIPList() *core.Command { + return &core.Command{ + Short: `List IP failovers`, + Long: `List all created IP failovers.`, + Namespace: "baremetal", + Resource: "ip", + Verb: "list", + ArgsType: reflect.TypeOf(baremetal.ListIPFailoversRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "order-by", + Short: `Order of the IP failovers`, + Required: false, + EnumValues: []string{"created_at_asc", "created_at_desc"}, + }, + { + Name: "tags.{index}", + Short: `Filter IP failovers by tags`, + Required: false, + }, + { + Name: "status.{index}", + Short: `Filter IP failovers by status`, + Required: false, + }, + { + Name: "server-ids.{index}", + Short: `Filter IP failovers by server IDs`, + Required: false, + }, + { + Name: "organization-id", + Short: `Filter servers by organization ID`, + Required: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*baremetal.ListIPFailoversRequest) + + client := core.ExtractClient(ctx) + api := baremetal.NewAPI(client) + resp, err := api.ListIPFailovers(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Failovers, nil + + }, + } +} + +func baremetalIPDelete() *core.Command { + return &core.Command{ + Short: `Delete IP failover`, + Long: `Delete the IP failover associated with the given IP.`, + Namespace: "baremetal", + Resource: "ip", + Verb: "delete", + ArgsType: reflect.TypeOf(baremetal.DeleteIPFailoverRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "ip-failover-id", + Short: `ID of the IP failover to delete`, + Required: true, + }, + core.ZoneArgSpec(scw.ZoneFrPar2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*baremetal.DeleteIPFailoverRequest) + + client := core.ExtractClient(ctx) + api := baremetal.NewAPI(client) + return api.DeleteIPFailover(request) + + }, + } +} + +func baremetalIPUpdate() *core.Command { + return &core.Command{ + Short: `Update IP failover`, + Long: `Update the IP failover associated with the given IP.`, + Namespace: "baremetal", + Resource: "ip", + Verb: "update", + ArgsType: reflect.TypeOf(baremetal.UpdateIPFailoverRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "ip-failover-id", + Short: `ID of the IP failover to update`, + Required: true, + }, + { + Name: "description", + Short: `Description to associate to the IP failover, max 255 characters, not updated if null`, + Required: false, + }, + { + Name: "tags", + Short: `Tags to associate to the IP failover, not updated if null`, + Required: false, + }, + { + Name: "mac-type", + Short: `MAC type to use for the IP failover, not updated if null`, + Required: false, + EnumValues: []string{"unknown_mac_type", "none", "duplicate", "vmware", "xen", "kvm"}, + }, + { + Name: "duplicate-mac-from", + Short: `ID of the IP failover which must be duplicate, not updated if null`, + Required: false, + }, + { + Name: "reverse", + Short: `New reverse IP to update, not updated if null`, + Required: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*baremetal.UpdateIPFailoverRequest) + + client := core.ExtractClient(ctx) + api := baremetal.NewAPI(client) + return api.UpdateIPFailover(request) + + }, + } +} + +func baremetalIPAttach() *core.Command { + return &core.Command{ + Short: `Attach IP failovers`, + Long: `Attach IP failovers to the given server ID.`, + Namespace: "baremetal", + Resource: "ip", + Verb: "attach", + ArgsType: reflect.TypeOf(baremetal.AttachIPFailoversRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "ip-failover-ids.{index}", + Short: `IP failover IDs to attach to the server`, + Required: false, + }, + { + Name: "server-id", + Short: `ID of the server to attach to the IP failovers`, + Required: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*baremetal.AttachIPFailoversRequest) + + client := core.ExtractClient(ctx) + api := baremetal.NewAPI(client) + return api.AttachIPFailovers(request) + + }, + } +} + +func baremetalIPDetach() *core.Command { + return &core.Command{ + Short: `Detach IP failovers`, + Long: `Detach IP failovers to the given server ID.`, + Namespace: "baremetal", + Resource: "ip", + Verb: "detach", + ArgsType: reflect.TypeOf(baremetal.DetachIPFailoversRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "ip-failover-ids.{index}", + Short: `IP failover IDs to detach to the server`, + Required: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*baremetal.DetachIPFailoversRequest) + + client := core.ExtractClient(ctx) + api := baremetal.NewAPI(client) + return api.DetachIPFailovers(request) + + }, + } +} + +func baremetalOsList() *core.Command { + return &core.Command{ + Short: `List OS`, + Long: `List all available OS that can be install on a baremetal server.`, + Namespace: "baremetal", + Resource: "os", + Verb: "list", + ArgsType: reflect.TypeOf(baremetal.ListOsRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ZoneArgSpec(scw.ZoneFrPar2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*baremetal.ListOsRequest) + + client := core.ExtractClient(ctx) + api := baremetal.NewAPI(client) + resp, err := api.ListOs(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Os, nil + + }, + } +} + +func baremetalOsGet() *core.Command { + return &core.Command{ + Short: `Get OS`, + Long: `Return specific OS for the given ID.`, + Namespace: "baremetal", + Resource: "os", + Verb: "get", + ArgsType: reflect.TypeOf(baremetal.GetOsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "os-id", + Short: `ID of the researched OS`, + Required: true, + }, + core.ZoneArgSpec(scw.ZoneFrPar2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*baremetal.GetOsRequest) + + client := core.ExtractClient(ctx) + api := baremetal.NewAPI(client) + return api.GetOs(request) + + }, + } +}