-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[MS] Adding support for Image Resources and Custom Images with Managed Disks #8
Merged
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
081d440
Adding support for Image Resources and Custom Images with Managed Disks
echuvyrov edbccac
Adding random values to the host names in tests to ensure uniqueness
echuvyrov 19c9450
Changed os_disk to a block, other changes requested for a PR merge
echuvyrov 8ba7c33
Merge branch 'master' of https://github.com/terraform-providers/terra…
echuvyrov 0d19808
Minor refactoring of DNS name inside the deprovisionVM func
echuvyrov d0ec942
Better formatting and validation
echuvyrov 457bb06
Changed properties, simplified code after review
echuvyrov af84909
Minor changes to Image properties
echuvyrov 2790ca2
Fixing the Creating from VHD example
tombuildsstuff bf1adf3
Managed Disk -> Managed Image
tombuildsstuff 8f91395
Updating the casings to match azure
tombuildsstuff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package azurerm | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/acctest" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestAccAzureRMImage_importStandalone(t *testing.T) { | ||
ri := acctest.RandInt() | ||
userName := "testadmin" | ||
password := "Password1234s!" | ||
hostName := fmt.Sprintf("tftestcustomimagesrc%[1]d", ri) | ||
sshPort := "22" | ||
preConfig := testAccAzureRMImage_standaloneImage_setup(ri, userName, password, hostName) | ||
postConfig := testAccAzureRMImage_standaloneImage_provision(ri, userName, password, hostName) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMImageDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
//need to create a vm and then reference it in the image creation | ||
Config: preConfig, | ||
Destroy: false, | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureVMExists("azurerm_virtual_machine.testsource", true), | ||
testGeneralizeVMImage(fmt.Sprintf("acctestRG-%[1]d", ri), "testsource", | ||
userName, password, hostName, sshPort), | ||
), | ||
}, | ||
resource.TestStep{ | ||
Config: postConfig, | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMImageExists("azurerm_image.test", true), | ||
), | ||
}, | ||
resource.TestStep{ | ||
ResourceName: "azurerm_image.test", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can safely default this field within the
testGeneralizeVMImage
function?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we could. I missed the random seed needed to avoid collisions between host names initially, but now that I put it in, the random seed is needed to generalize the VM since the DNS Name is one of the params to that function now. Open to different ideas here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, however we should be able to pass in only the username, password, hostname and region - as we can infer the rest from that?