Skip to content

Commit

Permalink
Add efiBootloaderPath for dedicated server resource (and dedicated
Browse files Browse the repository at this point in the history
server update)
  • Loading branch information
bigbigbang committed Oct 17, 2024
1 parent cc4b079 commit ac7d0b5
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 4 deletions.
6 changes: 6 additions & 0 deletions ovh/data_dedicated_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func dataSourceDedicatedServer() *schema.Resource {
Computed: true,
Description: "dedicated datacenter localisation (bhs1,bhs2,...)",
},
"efi_bootloader_path": {
Type: schema.TypeString,
Computed: true,
Description: "path of the EFI bootloader",
},
"ip": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -215,6 +220,7 @@ func dataSourceDedicatedServerRead(d *schema.ResourceData, meta interface{}) err
d.Set("boot_script", ds.BootScript)
d.Set("commercial_range", ds.CommercialRange)
d.Set("datacenter", ds.Datacenter)
d.Set("efi_bootloader_path", ds.EfiBootloaderPath)
d.Set("ip", ds.Ip)
d.Set("link_speed", ds.LinkSpeed)
d.Set("monitoring", ds.Monitoring)
Expand Down
2 changes: 2 additions & 0 deletions ovh/data_dedicated_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func TestAccDedicatedServerDataSource_basic(t *testing.T) {
"data.ovh_dedicated_server.server", "vnis.0.server_name", dedicated_server),
resource.TestCheckResourceAttr(
"data.ovh_dedicated_server.server", "boot_script", ""),
resource.TestCheckResourceAttrSet(
"data.ovh_dedicated_server.server", "efi_bootloader_path"),
resource.TestCheckResourceAttrSet(
"data.ovh_dedicated_server.server", "urn"),
resource.TestCheckResourceAttrSet(
Expand Down
6 changes: 6 additions & 0 deletions ovh/resource_dedicated_server_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ func resourceDedicatedServerUpdate() *schema.Resource {
Description: "The boot script of your dedicated server.",
Optional: true,
},
"efi_bootloader_path": {
Type: schema.TypeString,
Description: "The path of the EFI bootloader.",
Optional: true,
},
"monitoring": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -113,6 +118,7 @@ func resourceDedicatedServerUpdateRead(ctx context.Context, d *schema.ResourceDa

d.Set("boot_id", ds.BootId)
d.Set("boot_script", ds.BootScript)
d.Set("efi_bootloader_path", ds.EfiBootloaderPath)
d.Set("monitoring", ds.Monitoring)
d.Set("state", ds.State)
d.Set("display_name", ds.DisplayName)
Expand Down
6 changes: 6 additions & 0 deletions ovh/resource_dedicated_server_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func TestAccDedicatedServerUpdate_basic(t *testing.T) {
"ovh_dedicated_server_update.server", "state", "ok"),
resource.TestCheckResourceAttr(
"ovh_dedicated_server_update.server", "boot_script", ""),
resource.TestCheckResourceAttr(
"ovh_dedicated_server_update.server", "efi_bootloader_path", "\\efi\\boot\\bootx64.efi"),
resource.TestCheckResourceAttr(
"ovh_dedicated_server_update.server", "display_name", "An awesome display name"),
),
Expand All @@ -40,6 +42,8 @@ func TestAccDedicatedServerUpdate_basic(t *testing.T) {
"ovh_dedicated_server_update.server", "state", "ok"),
resource.TestCheckResourceAttr(
"ovh_dedicated_server_update.server", "boot_script", ""),
resource.TestCheckResourceAttr(
"ovh_dedicated_server_update.server", "efi_bootloader_path", "\\efi\\boot\\bootx64.efi"),
resource.TestCheckResourceAttr(
"ovh_dedicated_server_update.server", "display_name", "An awesome display name restored"),
),
Expand Down Expand Up @@ -76,6 +80,7 @@ resource ovh_dedicated_server_update "server" {
monitoring = true
state = "ok"
display_name = "An awesome display name"
efi_bootloader_path = "\\efi\\boot\\bootx64.efi"
}
output test {
Expand All @@ -95,6 +100,7 @@ resource ovh_dedicated_server_update "server" {
monitoring = false
state = "ok"
display_name = "An awesome display name restored"
efi_bootloader_path = "\\efi\\boot\\bootx64.efi"
}
output test {
Expand Down
11 changes: 7 additions & 4 deletions ovh/types_dedicated_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type DedicatedServer struct {
BootScript string `json:"bootScript"`
CommercialRange string `json:"commercialRange"`
Datacenter string `json:"datacenter"`
EfiBootloaderPath string `json:"efiBootloaderPath"`
Ip string `json:"ip"`
LinkSpeed int `json:"linkSpeed"`
Monitoring bool `json:"monitoring"`
Expand All @@ -40,15 +41,17 @@ func (ds DedicatedServer) String() string {
}

type DedicatedServerUpdateOpts struct {
BootId *int64 `json:"bootId,omitempty"`
BootScript *string `json:"bootScript,omitempty"`
Monitoring *bool `json:"monitoring,omitempty"`
State *string `json:"state,omitempty"`
BootId *int64 `json:"bootId,omitempty"`
BootScript *string `json:"bootScript,omitempty"`
EfiBootloaderPath *string `json:"efiBootloaderPath,omitempty"`
Monitoring *bool `json:"monitoring,omitempty"`
State *string `json:"state,omitempty"`
}

func (opts *DedicatedServerUpdateOpts) FromResource(d *schema.ResourceData) *DedicatedServerUpdateOpts {
opts.BootId = helpers.GetNilInt64PointerFromData(d, "boot_id")
opts.BootScript = helpers.GetNilStringPointerFromData(d, "boot_script")
opts.EfiBootloaderPath = helpers.GetNilStringPointerFromData(d, "efi_bootloader_path")
opts.Monitoring = helpers.GetNilBoolPointerFromData(d, "monitoring")
opts.State = helpers.GetNilStringPointerFromData(d, "state")
return opts
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/dedicated_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ In addition, the following attributes are exported:
* `urn` - URN of the dedicated server instance
* `commercial_range` - Dedicated server commercial range
* `datacenter` - Dedicated datacenter localisation (bhs1,bhs2,...)
* `efi_bootloader_path` - Path of the EFI bootloader of the dedicated server
* `ip` - Dedicated server ip (IPv4)
* `ips` - Dedicated server ip blocks
* `link_speed` - Link speed of the server
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/dedicated_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ The `user_metadata` block supports many arguments, here is a non-exhaustive list
* `tags` - Resource tags. Tags that were internally computed are prefixed with `ovh:`
* `boot_id` - Boot id of the server
* `boot_script` - Boot script of the server
* `efi_bootloader_path` - Path of the EFI bootloader
* `link_speed` - Link speed of the server
* `monitoring` - Icmp monitoring state
* `no_intervention` - Prevent datacenter intervention
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/dedicated_server_update.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The following arguments are supported:
* `service_name` - (Required) The service_name of your dedicated server.
* `boot_id` - boot id of the server
* `boot_script` - boot script of the server
* `efi_bootloader_path` - path of the EFI bootloader
* `monitoring` - Icmp monitoring state
* `state` - error, hacked, hackedBlocked, ok
* `display_name` - display name of the dedicated server
Expand All @@ -46,6 +47,7 @@ The following attributes are exported:

* `service_name` - See Argument Reference above.
* `boot_id` - See Argument Reference above.
* `efi_bootloader_path` - See Argument Reference above.
* `monitoring` - See Argument Reference above.
* `state` - See Argument Reference above.
* `display_name` - See Argument Reference above.

0 comments on commit ac7d0b5

Please sign in to comment.