-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/r/dedicated_server_install_task: new resource
- Loading branch information
yann degat
committed
Dec 18, 2019
1 parent
ac6321b
commit 89a8f3a
Showing
5 changed files
with
241 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package ovh | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccDedicatedServerInstall_basic(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
testAccPreCheckCredentials(t) | ||
testAccPreCheckDedicatedServer(t) | ||
}, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDedicatedServerInstallConfig(), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr( | ||
"ovh_dedicated_server_update.server", "state", "ok"), | ||
resource.TestCheckResourceAttr( | ||
"ovh_dedicated_server_update.server", "monitoring", "true"), | ||
resource.TestCheckResourceAttr( | ||
"ovh_dedicated_server_update.server", "state", "ok"), | ||
resource.TestCheckResourceAttr( | ||
"ovh_dedicated_server_install_task.server_install", "function", "reinstallServer"), | ||
resource.TestCheckResourceAttr( | ||
"ovh_dedicated_server_install_task.server_install", "status", "done"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDedicatedServerInstallConfig() string { | ||
dedicated_server := os.Getenv("OVH_DEDICATED_SERVER") | ||
testName := acctest.RandomWithPrefix(test_prefix) | ||
sshKey := os.Getenv("OVH_SSH_KEY") | ||
if sshKey == "" { | ||
sshKey = "ssh-ed25519 AAAAC3NzaC1yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" | ||
} | ||
|
||
return fmt.Sprintf( | ||
testAccDedicatedServerInstallConfig_Basic, | ||
dedicated_server, | ||
testName, | ||
sshKey, | ||
testName, | ||
) | ||
|
||
} | ||
|
||
const testAccDedicatedServerInstallConfig_Basic = ` | ||
data ovh_dedicated_server_boots "harddisk" { | ||
service_name = "%s" | ||
boot_type = "harddisk" | ||
} | ||
resource "ovh_me_ssh_key" "key" { | ||
key_name = "%s" | ||
key = "%s" | ||
} | ||
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" | ||
} | ||
resource "ovh_me_installation_template" "debian" { | ||
base_template_name = "debian10_64" | ||
template_name = "%s" | ||
default_language = "en" | ||
customization { | ||
change_log = "v1" | ||
custom_hostname = "mytest" | ||
ssh_key_name = ovh_me_ssh_key.key.key_name | ||
} | ||
} | ||
resource ovh_dedicated_server_install_task "server_install" { | ||
service_name = data.ovh_dedicated_server_boots.harddisk.service_name | ||
template_name = ovh_me_installation_template.debian.template_name | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters