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 24, 2024
1 parent 0f5644b commit e75cf46
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 10 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
21 changes: 21 additions & 0 deletions ovh/resource_dedicated_server_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions ovh/resource_dedicated_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ import (

func dedicatedServerResourceTestConfig(updated bool) string {
var (
monitoring = true
noIntervention = false
baseTemplate = "debian11_64"
displayName = "First display name"
monitoring = true
noIntervention = false
baseTemplate = "debian11_64"
displayName = "First display name"
efiBootloaderPath = "\\efi\\grub\\grubx64.efi"
)

if updated {
monitoring = false
noIntervention = true
baseTemplate = "debian12_64"
displayName = "Second display name"
efiBootloaderPath = "\\efi\\boot\\bootx64.efi"
}

return fmt.Sprintf(`
Expand All @@ -33,6 +35,7 @@ func dedicatedServerResourceTestConfig(updated bool) string {
no_intervention = %t
display_name = "%s"
template_name = "%s"
efi_bootloader_path = "%s"
plan = [
{
Expand Down Expand Up @@ -84,7 +87,7 @@ func dedicatedServerResourceTestConfig(updated bool) string {
}
]
}
`, monitoring, noIntervention, displayName, baseTemplate)
`, monitoring, noIntervention, displayName, baseTemplate, efiBootloaderPath)
}

func TestAccDedicatedServer_basic(t *testing.T) {
Expand All @@ -107,6 +110,8 @@ func TestAccDedicatedServer_basic(t *testing.T) {
"ovh_dedicated_server.server", "iam.display_name", "First display name"),
resource.TestCheckResourceAttr(
"ovh_dedicated_server.server", "os", "debian11_64"),
resource.TestCheckResourceAttr(
"ovh_dedicated_server.server", "efi_bootloader_path", "\\efi\\grub\\grubx64.efi"),
),
},
{
Expand All @@ -122,6 +127,8 @@ func TestAccDedicatedServer_basic(t *testing.T) {
"ovh_dedicated_server.server", "iam.display_name", "Second display name"),
resource.TestCheckResourceAttr(
"ovh_dedicated_server.server", "os", "debian12_64"),
resource.TestCheckResourceAttr(
"ovh_dedicated_server.server", "efi_bootloader_path", "\\efi\\boot\\bootx64.efi"),
),
},
{
Expand All @@ -130,7 +137,7 @@ func TestAccDedicatedServer_basic(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIdentifierAttribute: "service_name",
ImportStateVerifyIgnore: []string{
"display_name", "order", "ovh_subsidiary", "plan", "plan_option", "template_name",
"display_name", "order", "ovh_subsidiary", "plan", "plan_option", "template_name", "efi_bootloader_path",
},
ImportStateIdFunc: func(s *terraform.State) (string, error) {
service, ok := s.RootModule().Resources["ovh_dedicated_server.server"]
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 e75cf46

Please sign in to comment.