-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8470 from jstachowiak/support-graceful-vm-shutdown
Support graceful Linux/Windows VM shutdown
- Loading branch information
Showing
8 changed files
with
253 additions
and
12 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
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 |
---|---|---|
|
@@ -613,6 +613,42 @@ func TestAccLinuxVirtualMachine_otherEncryptionAtHostEnabledWithCMK(t *testing.T | |
}) | ||
} | ||
|
||
func TestAccLinuxVirtualMachine_otherGracefulShutdownDisabled(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine", "test") | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { acceptance.PreCheck(t) }, | ||
Providers: acceptance.SupportedProviders, | ||
CheckDestroy: checkLinuxVirtualMachineIsDestroyed, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testLinuxVirtualMachine_otherGracefulShutdown(data, false), | ||
Check: resource.ComposeTestCheckFunc( | ||
checkLinuxVirtualMachineExists(data.ResourceName), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccLinuxVirtualMachine_otherGracefulShutdownEnabled(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine", "test") | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { acceptance.PreCheck(t) }, | ||
Providers: acceptance.SupportedProviders, | ||
CheckDestroy: checkLinuxVirtualMachineIsDestroyed, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testLinuxVirtualMachine_otherGracefulShutdown(data, true), | ||
Check: resource.ComposeTestCheckFunc( | ||
checkLinuxVirtualMachineExists(data.ResourceName), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testLinuxVirtualMachine_otherAllowExtensionOperationsDefault(data acceptance.TestData) string { | ||
template := testLinuxVirtualMachine_template(data) | ||
return fmt.Sprintf(` | ||
|
@@ -1739,3 +1775,78 @@ resource "azurerm_linux_virtual_machine" "test" { | |
} | ||
`, template, data.RandomInteger, enabled) | ||
} | ||
|
||
func testLinuxVirtualMachine_otherGracefulShutdown(data acceptance.TestData, gracefulShutdown bool) string { | ||
return fmt.Sprintf(` | ||
locals { | ||
first_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+wWK73dCr+jgQOAxNsHAnNNNMEMWOHYEccp6wJm2gotpr9katuF/ZAdou5AaW1C61slRkHRkpRRX9FA9CYBiitZgvCCz+3nWNN7l/Up54Zps/pHWGZLHNJZRYyAB6j5yVLMVHIHriY49d/GZTZVNB8GoJv9Gakwc/fuEZYYl4YDFiGMBP///TzlI4jhiJzjKnEvqPFki5p2ZRJqcbCiF4pJrxUQR/RXqVFQdbRLZgYfJ8xGB878RENq3yQ39d8dVOkq4edbkzwcUmwwwkYVPIoDGsYLaRHnG+To7FvMeyO7xDVQkMKzopTQV8AuKpyvpqu0a9pWOMaiCyDytO7GGN [email protected]" | ||
} | ||
provider "azurerm" { | ||
features { | ||
virtual_machine { | ||
graceful_shutdown = %t | ||
} | ||
} | ||
} | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
location = "%s" | ||
} | ||
resource "azurerm_virtual_network" "test" { | ||
name = "acctestnw-%d" | ||
address_space = ["10.0.0.0/16"] | ||
location = azurerm_resource_group.test.location | ||
resource_group_name = azurerm_resource_group.test.name | ||
} | ||
resource "azurerm_subnet" "test" { | ||
name = "internal" | ||
resource_group_name = azurerm_resource_group.test.name | ||
virtual_network_name = azurerm_virtual_network.test.name | ||
address_prefix = "10.0.2.0/24" | ||
} | ||
resource "azurerm_network_interface" "test" { | ||
name = "acctestnic-%d" | ||
location = azurerm_resource_group.test.location | ||
resource_group_name = azurerm_resource_group.test.name | ||
ip_configuration { | ||
name = "internal" | ||
subnet_id = azurerm_subnet.test.id | ||
private_ip_address_allocation = "Dynamic" | ||
} | ||
} | ||
resource "azurerm_linux_virtual_machine" "test" { | ||
name = "acctestVM-%d" | ||
resource_group_name = azurerm_resource_group.test.name | ||
location = azurerm_resource_group.test.location | ||
size = "Standard_F2" | ||
admin_username = "adminuser" | ||
network_interface_ids = [ | ||
azurerm_network_interface.test.id, | ||
] | ||
admin_ssh_key { | ||
username = "adminuser" | ||
public_key = local.first_public_key | ||
} | ||
os_disk { | ||
caching = "ReadWrite" | ||
storage_account_type = "Standard_LRS" | ||
} | ||
source_image_reference { | ||
publisher = "Canonical" | ||
offer = "UbuntuServer" | ||
sku = "16.04-LTS" | ||
version = "latest" | ||
} | ||
} | ||
`, gracefulShutdown, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger) | ||
} |
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
Oops, something went wrong.