Skip to content

Commit c54f012

Browse files
authored
feat(baremetal): add support for updateip (#2922)
1 parent 03b3a98 commit c54f012

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
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.
4+
5+
USAGE:
6+
scw baremetal server update-ip [arg=value ...]
7+
8+
ARGS:
9+
server-id ID of the server
10+
ip-id ID of the IP to update
11+
[reverse] New reverse IP to update, not updated if null
12+
[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)
13+
14+
FLAGS:
15+
-h, --help help for update-ip
16+
17+
GLOBAL FLAGS:
18+
-c, --config string The path to the config file
19+
-D, --debug Enable debug mode
20+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
21+
-p, --profile string The config profile to use

cmd/scw/testdata/test-all-usage-baremetal-server-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ AVAILABLE COMMANDS:
1717
start Start an Elastic Metal server
1818
stop Stop an Elastic Metal server
1919
update Update an Elastic Metal server
20+
update-ip Update IP
2021

2122
WORKFLOW COMMANDS:
2223
wait Wait for a server to reach a stable state (delivery and installation)

docs/commands/baremetal.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Elastic Metal API.
3434
- [Start an Elastic Metal server](#start-an-elastic-metal-server)
3535
- [Stop an Elastic Metal server](#stop-an-elastic-metal-server)
3636
- [Update an Elastic Metal server](#update-an-elastic-metal-server)
37+
- [Update IP](#update-ip)
3738
- [Wait for a server to reach a stable state (delivery and installation)](#wait-for-a-server-to-reach-a-stable-state-(delivery-and-installation))
3839
- [Settings management commands](#settings-management-commands)
3940
- [List all settings](#list-all-settings)
@@ -824,6 +825,28 @@ scw baremetal server update <server-id ...> [arg=value ...]
824825

825826

826827

828+
### Update IP
829+
830+
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.
831+
832+
**Usage:**
833+
834+
```
835+
scw baremetal server update-ip [arg=value ...]
836+
```
837+
838+
839+
**Args:**
840+
841+
| Name | | Description |
842+
|------|---|-------------|
843+
| server-id | Required | ID of the server |
844+
| ip-id | Required | ID of the IP to update |
845+
| reverse | | New reverse IP to update, not updated if null |
846+
| 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 |
847+
848+
849+
827850
### Wait for a server to reach a stable state (delivery and installation)
828851

829852
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.

internal/namespaces/baremetal/v1/baremetal_cli.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func GetGeneratedCommands() *core.Commands {
4141
baremetalBmcStart(),
4242
baremetalBmcGet(),
4343
baremetalBmcStop(),
44+
baremetalServerUpdateIP(),
4445
baremetalOptionsAdd(),
4546
baremetalOptionsDelete(),
4647
baremetalOfferList(),
@@ -885,6 +886,50 @@ func baremetalBmcStop() *core.Command {
885886
}
886887
}
887888

889+
func baremetalServerUpdateIP() *core.Command {
890+
return &core.Command{
891+
Short: `Update IP`,
892+
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.`,
893+
Namespace: "baremetal",
894+
Resource: "server",
895+
Verb: "update-ip",
896+
// Deprecated: false,
897+
ArgsType: reflect.TypeOf(baremetal.UpdateIPRequest{}),
898+
ArgSpecs: core.ArgSpecs{
899+
{
900+
Name: "server-id",
901+
Short: `ID of the server`,
902+
Required: true,
903+
Deprecated: false,
904+
Positional: false,
905+
},
906+
{
907+
Name: "ip-id",
908+
Short: `ID of the IP to update`,
909+
Required: true,
910+
Deprecated: false,
911+
Positional: false,
912+
},
913+
{
914+
Name: "reverse",
915+
Short: `New reverse IP to update, not updated if null`,
916+
Required: false,
917+
Deprecated: false,
918+
Positional: false,
919+
},
920+
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1),
921+
},
922+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
923+
request := args.(*baremetal.UpdateIPRequest)
924+
925+
client := core.ExtractClient(ctx)
926+
api := baremetal.NewAPI(client)
927+
return api.UpdateIP(request)
928+
929+
},
930+
}
931+
}
932+
888933
func baremetalOptionsAdd() *core.Command {
889934
return &core.Command{
890935
Short: `Add server option`,

0 commit comments

Comments
 (0)