Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add efiBootloaderPath for dedicated server resource & update #755

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## 1.0.0 (October 21, 2024)

🎉 Features:

* New resource: `ovh_dbaas_logs_output_opensearch_alias` ([#742](https://github.com/ovh/terraform-provider-ovh/pull/742))
* New resource: `ovh_dbaas_logs_output_opensearch_index` ([#742](https://github.com/ovh/terraform-provider-ovh/pull/742))
* New datasource: `ovh_cloud_project_volume` ([#736](https://github.com/ovh/terraform-provider-ovh/pull/736))
* New datasource: `ovh_cloud_project_volumes` ([#736](https://github.com/ovh/terraform-provider-ovh/pull/736))
* New datasource: `ovh_dbaas_logs_output_opensearch_index` ([#742](https://github.com/ovh/terraform-provider-ovh/pull/742))

🧨 Breaking changes:

* `r/ovh_ip_service`: **BREAKING CHANGE** Fix resource import and use `service_name` as ID. This is a breaking change because the ID of the resource has been modified, but already existing resources will continue working. ([#754](https://github.com/ovh/terraform-provider-ovh/pull/754))
* `r/ovh_cloud_project`: **BREAKING CHANGE** Fix resource import and use `project_id` as ID. This is a breaking change because the ID of the resource has been modified, but already existing resources will continue working. ([#760](https://github.com/ovh/terraform-provider-ovh/pull/760))
* `r/ovh_domain_zone`: **BREAKING CHANGE** Fix resource import and use `name` as ID. This is a breaking change because the ID of the resource has been modified, but already existing resources will continue working. ([#760](https://github.com/ovh/terraform-provider-ovh/pull/760))
* `r/ovh_hosting_privatedatabase`: **BREAKING CHANGE** Fix resource import and use `service_name` as ID. This is a breaking change because the ID of the resource has been modified, but already existing resources will continue working. ([#760](https://github.com/ovh/terraform-provider-ovh/pull/760))
* `r/ovh_iploadbalancing`: **BREAKING CHANGE** Fix resource import and use `service_name` as ID. This is a breaking change because the ID of the resource has been modified, but already existing resources will continue working. ([#760](https://github.com/ovh/terraform-provider-ovh/pull/760))

💪 Improvements:

* Don't read order-related information (`ovh_subsidiary`, `plan` and `plan_option` fields) in Read functions of resources that are created using an order ([#754](https://github.com/ovh/terraform-provider-ovh/pull/754))

🐜 Bug fixes:

* `r/ovh_cloud_project_database`: Prevent setting `backup_time` on several engines ([#756](https://github.com/ovh/terraform-provider-ovh/pull/756))
* Fix marshal and unmarshal of null and unknown values ([#750](https://github.com/ovh/terraform-provider-ovh/pull/750))
* Fix products termination in the US region ([#754](https://github.com/ovh/terraform-provider-ovh/pull/754))

❤️ Thanks for your contributions ❤️

## 0.51.0 (October 11, 2024)

🎉 Features:
Expand Down
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
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.

24 changes: 13 additions & 11 deletions ovh/resource_dedicated_server_install_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ data ovh_dedicated_server_boots "harddisk" {
}

resource ovh_dedicated_server_update "server" {
service_name = data.ovh_dedicated_server_boots.harddisk.service_name
boot_id = data.ovh_dedicated_server_boots.harddisk.result[0]
monitoring = true
state = "ok"
service_name = data.ovh_dedicated_server_boots.harddisk.service_name
boot_id = data.ovh_dedicated_server_boots.harddisk.result[0]
monitoring = true
state = "ok"
efi_bootloader_path = "\\efi\\debian\\grubx64.efi"
}

resource "ovh_me_installation_template" "debian" {
Expand Down Expand Up @@ -186,10 +187,11 @@ data ovh_dedicated_server_boots "rescue" {
}

resource ovh_dedicated_server_update "server" {
service_name = data.ovh_dedicated_server_boots.harddisk.service_name
boot_id = data.ovh_dedicated_server_boots.harddisk.result[0]
monitoring = true
state = "ok"
service_name = data.ovh_dedicated_server_boots.harddisk.service_name
boot_id = data.ovh_dedicated_server_boots.harddisk.result[0]
monitoring = true
state = "ok"
efi_bootloader_path = "\\efi\\debian\\grubx64.efi"
}

resource ovh_dedicated_server_install_task "server_install" {
Expand All @@ -209,9 +211,9 @@ data ovh_dedicated_server_boots "harddisk" {
}

resource ovh_dedicated_server_update "server" {
service_name = data.ovh_dedicated_server_boots.harddisk.service_name
monitoring = true
state = "ok"
service_name = data.ovh_dedicated_server_boots.harddisk.service_name
monitoring = true
state = "ok"
}

resource ovh_dedicated_server_install_task "server_install" {
Expand Down
17 changes: 12 additions & 5 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 = ""
)

if updated {
monitoring = false
noIntervention = true
baseTemplate = "debian12_64"
displayName = "Second display name"
efiBootloaderPath = "\\efi\\debian\\grubx64.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", ""),
),
},
{
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\\debian\\grubx64.efi"),
),
},
{
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.