diff --git a/cmd/scw/testdata/test-all-usage-baremetal-server-update-ip-usage.golden b/cmd/scw/testdata/test-all-usage-baremetal-server-update-ip-usage.golden new file mode 100644 index 0000000000..4fc17554b4 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-baremetal-server-update-ip-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Configure the IP address associated with the server ID and IP ID. You can use this method to set a reverse DNS for an IP address. + +USAGE: + scw baremetal server update-ip [arg=value ...] + +ARGS: + server-id ID of the server + ip-id ID of the IP to update + [reverse] New reverse IP to update, not updated if null + [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 update-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 diff --git a/cmd/scw/testdata/test-all-usage-baremetal-server-usage.golden b/cmd/scw/testdata/test-all-usage-baremetal-server-usage.golden index 9f17c649b6..4800a46f0a 100644 --- a/cmd/scw/testdata/test-all-usage-baremetal-server-usage.golden +++ b/cmd/scw/testdata/test-all-usage-baremetal-server-usage.golden @@ -17,6 +17,7 @@ AVAILABLE COMMANDS: start Start an Elastic Metal server stop Stop an Elastic Metal server update Update an Elastic Metal server + update-ip Update IP WORKFLOW COMMANDS: wait Wait for a server to reach a stable state (delivery and installation) diff --git a/docs/commands/baremetal.md b/docs/commands/baremetal.md index 1d3dd37c5c..c2bb78731e 100644 --- a/docs/commands/baremetal.md +++ b/docs/commands/baremetal.md @@ -34,6 +34,7 @@ Elastic Metal API. - [Start an Elastic Metal server](#start-an-elastic-metal-server) - [Stop an Elastic Metal server](#stop-an-elastic-metal-server) - [Update an Elastic Metal server](#update-an-elastic-metal-server) + - [Update IP](#update-ip) - [Wait for a server to reach a stable state (delivery and installation)](#wait-for-a-server-to-reach-a-stable-state-(delivery-and-installation)) - [Settings management commands](#settings-management-commands) - [List all settings](#list-all-settings) @@ -824,6 +825,28 @@ scw baremetal server update [arg=value ...] +### Update IP + +Configure the IP address associated with the server ID and IP ID. You can use this method to set a reverse DNS for an IP address. + +**Usage:** + +``` +scw baremetal server update-ip [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| server-id | Required | ID of the server | +| ip-id | Required | ID of the IP to update | +| reverse | | New reverse IP to update, not updated if null | +| zone | Default: `fr-par-1`
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 | + + + ### Wait for a server to reach a stable state (delivery and installation) Wait for a server to reach a stable state. This is similar to using --wait flag on other action commands, but without requiring a new action on the server. diff --git a/internal/namespaces/baremetal/v1/baremetal_cli.go b/internal/namespaces/baremetal/v1/baremetal_cli.go index 64b6cc0e7b..ebe6d04720 100644 --- a/internal/namespaces/baremetal/v1/baremetal_cli.go +++ b/internal/namespaces/baremetal/v1/baremetal_cli.go @@ -41,6 +41,7 @@ func GetGeneratedCommands() *core.Commands { baremetalBmcStart(), baremetalBmcGet(), baremetalBmcStop(), + baremetalServerUpdateIP(), baremetalOptionsAdd(), baremetalOptionsDelete(), baremetalOfferList(), @@ -885,6 +886,50 @@ func baremetalBmcStop() *core.Command { } } +func baremetalServerUpdateIP() *core.Command { + return &core.Command{ + Short: `Update IP`, + Long: `Configure the IP address associated with the server ID and IP ID. You can use this method to set a reverse DNS for an IP address.`, + Namespace: "baremetal", + Resource: "server", + Verb: "update-ip", + // Deprecated: false, + ArgsType: reflect.TypeOf(baremetal.UpdateIPRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "server-id", + Short: `ID of the server`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "ip-id", + Short: `ID of the IP to update`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "reverse", + Short: `New reverse IP to update, not updated if null`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*baremetal.UpdateIPRequest) + + client := core.ExtractClient(ctx) + api := baremetal.NewAPI(client) + return api.UpdateIP(request) + + }, + } +} + func baremetalOptionsAdd() *core.Command { return &core.Command{ Short: `Add server option`,