Skip to content
Open
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
15 changes: 9 additions & 6 deletions ovh/resource_vps_gen.go

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

74 changes: 74 additions & 0 deletions ovh/resource_vps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,50 @@ resource "ovh_vps" "myvps" {
}
`

const testAccVpsDoNotSendPassword = `
data "ovh_me" "myaccount" {}

data "ovh_order_cart" "mycart" {
ovh_subsidiary = data.ovh_me.myaccount.ovh_subsidiary
}

data "ovh_order_cart_product_plan" "vps" {
cart_id = data.ovh_order_cart.mycart.id
price_capacity = "renew"
product = "vps"
plan_code = "vps-le-2-2-40"
}

resource "ovh_vps" "myvps" {
display_name = "%s"
netboot_mode = "rescue"

image_id = "45b2f222-ab10-44ed-863f-720942762b6f"
public_ssh_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDSD76EaLUzJjf70W8W2uU9FzEyl68di67Bd20qtYfBLJpFJuX/RJC9StI1y1RnXXqC1Lf/Yo+yJzvNx0iqLxCX1G7g0XYex74HkgC6a2QeNhp9M56ANZtA3TKKAbkZ1xobfhOPWpq3lEFp7dgJctcILBPL3l6OjKf6NIxHo5yF67Vy4D0nWl5utumNdWhhlX7MtVQooszLyIwPlNO+DzD3ZnJFCt2Z1jdRkhm/Oobtx17CZ+5SN23tgHXS6pLOgM6w30M11zkI510z95IAIHhRT7MbiXICkvG/0qHuSftz1j/CcHFbttNB27dH86vByumfSEgRKaoRkCqrn64IWrSsFr3Smsf7gZWLBlYLliGPyn8Tsr9bT5pRul6yTvVbfZ31RREBr1I0Lp4q++d+fIpa3LtMGRaMb9huJYy8cwW/Vfzbxsqfz9xzjIOFNcYl7J9l4cvz3hgSlai2Jgngw5ShNVlxcIKUdiynZWm09nQudlYNHgor9ID+JACzCfPkUZ8"
do_not_send_password = true

ovh_subsidiary = data.ovh_order_cart.mycart.ovh_subsidiary
plan = [
{
duration = "P1M"
plan_code = data.ovh_order_cart_product_plan.vps.plan_code
pricing_mode = "default"

configuration = [
{
label = "vps_datacenter"
value = "WAW"
},
{
label = "vps_os"
value = "Debian 10"
}
]
}
]
}
`

const testAccVpsReinstallImageOnly = `
data "ovh_me" "myaccount" {}

Expand Down Expand Up @@ -122,6 +166,36 @@ func TestAccResourceVps_basic(t *testing.T) {
})
}

func TestAccResourceVps_doNotSendPassword(t *testing.T) {
displayName := acctest.RandomWithPrefix(test_prefix)
config := fmt.Sprintf(
testAccVpsBasic,
displayName,
)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckOrderVPS(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"ovh_vps.myvps", "netboot_mode", "rescue"),
resource.TestCheckResourceAttr(
"ovh_vps.myvps", "display_name", displayName),
resource.TestCheckResourceAttr(
"ovh_vps.myvps", "public_ssh_key", "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDSD76EaLUzJjf70W8W2uU9FzEyl68di67Bd20qtYfBLJpFJuX/RJC9StI1y1RnXXqC1Lf/Yo+yJzvNx0iqLxCX1G7g0XYex74HkgC6a2QeNhp9M56ANZtA3TKKAbkZ1xobfhOPWpq3lEFp7dgJctcILBPL3l6OjKf6NIxHo5yF67Vy4D0nWl5utumNdWhhlX7MtVQooszLyIwPlNO+DzD3ZnJFCt2Z1jdRkhm/Oobtx17CZ+5SN23tgHXS6pLOgM6w30M11zkI510z95IAIHhRT7MbiXICkvG/0qHuSftz1j/CcHFbttNB27dH86vByumfSEgRKaoRkCqrn64IWrSsFr3Smsf7gZWLBlYLliGPyn8Tsr9bT5pRul6yTvVbfZ31RREBr1I0Lp4q++d+fIpa3LtMGRaMb9huJYy8cwW/Vfzbxsqfz9xzjIOFNcYl7J9l4cvz3hgSlai2Jgngw5ShNVlxcIKUdiynZWm09nQudlYNHgor9ID+JACzCfPkUZ8"),
resource.TestCheckResourceAttr(
"ovh_vps.myvps", "do_not_send_password", "true"),
resource.TestCheckResourceAttr(
"ovh_vps.myvps", "image_id", os.Getenv("OVH_VPS_IMAGE_ID")),
),
},
},
})
}

func TestAccResourceVps_reinstallImageOnly(t *testing.T) {
displayName := acctest.RandomWithPrefix(test_prefix)
config := fmt.Sprintf(
Expand Down
1 change: 1 addition & 0 deletions templates/resources/vps.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The following arguments are supported:
* `label` - (Required) Identifier of the resource
* `value` - (Required) Path to the resource in api.ovh.com
* `public_ssh_key` - (String) Public SSH key to pre-install on your VPS - if set, then `image_id` must also be set
* `do_not_send_password` - (Boolean) Indicates if default password should be set and sent by email. Default false: a password is set and an email is sent.

## Attributes Reference

Expand Down