-
Notifications
You must be signed in to change notification settings - Fork 67
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
xVHD - Add support for setting disk type (Fixed, Dynamic, Differencing) #77
Conversation
Hi @johnf, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
Hi @johnf - are you able to fix the problem in the MOF schema as reported by the AppVeyor tests failing? |
Fixed. Dumb typo |
@johnf - awesome job! Thanks for addressing this. Could you please add an entry to the #Unreleased section in the Readme.md listing the change? Could you also add this to this parameter to the Examples/Sample_xVHD_DiffVHD.ps1 (and to the same place in the Examples section of the Readme.md). It might be worth also creating an Examples/Sample_xVHD_FixedVHD.ps1 showing how the resource is used to create a fixed disk (and copy the example to the Readme.md) Unfortunately this resource doesn't contain any unit tests for xVHD yet so we can't add tests for this change. Thanks again for all your work on this! It is greatly appreciated. Reviewed 3 of 3 files at r1. DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 65 at r1 (raw file):
One thing that may be confusing here is that it would be possible for someone to specify a $Type of 'Dynamic' or 'Fixed' and also a $ParentPath set. This doesn't look like it would cause any problems, but it might imply to users that this was a possible combination of parameters (e.g. a Dynamic Differencing Disk- which isn't of course possible). It might be worth adding a parameter validation check into the Set-* and Test-* that would throw an exception if an invalid combination of parameters was requested. Comments from Reviewable |
I've updated my branch with your comments. I added the new Example but in the README rather than add a whole new example I updated the first one to be Fixed. |
@johnf We have diverged a bit with the Readme since this PR was created. Examples are no longer part of it. Instead links are added to the example in the Examples folder. Probably a good idea to rebase and address the comments so we can take the PR. Sorry to put you through this. Let me know if you are not comfortable with concepts as rebasing and such. Reviewed 1 of 3 files at r1, 4 of 4 files at r2. DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 64 at r2 (raw file):
Could you add DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 83 at r2 (raw file):
You'll also need something like if DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 151 at r2 (raw file):
Are you planning to implement this, if not, please remove DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 205 at r2 (raw file):
Same comments as with Set-TargetResource apply here DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 227 at r2 (raw file):
And here Comments from Reviewable |
Codecov Report
@@ Coverage Diff @@
## dev #77 +/- ##
===================================
+ Coverage 63% 71% +7%
===================================
Files 9 9
Lines 1022 1032 +10
Branches 12 12
===================================
+ Hits 651 733 +82
+ Misses 359 287 -72
Partials 12 12 |
I've rebased |
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.
Reviewable didn't make any sense anymore so switched to GitHub review for now. Couple of points still. Would be greatly appreciated if you can address them.
@@ -75,6 +80,17 @@ function Set-TargetResource | |||
Throw "Please ensure that Hyper-V role is installed with its PowerShell module" | |||
} | |||
|
|||
# Check the module combinations make sense | |||
if($ParentPath -and $Type -ne "Differencing") |
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.
Could you add a unit test for this resource. It doesn't have to cover the entire thing but at least validate these parameter conditions are working properly e.g. It 'Should throw when ParentPath defined and Type -ne Diff'
@@ -60,6 +60,11 @@ function Set-TargetResource | |||
# Size of Vhd to be created | |||
[Uint64]$MaximumSizeBytes, | |||
|
|||
# Type of Vhd to be created | |||
[parameter()] |
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.
Should be:
[Parameter()]
[ValidateSet('Dynamic', 'Fixed', 'Differencing')]
[String]
$Type = 'Dynamic',
|
||
if($null -eq $ParentPath -and $Type -eq "Differencing") | ||
{ | ||
Throw "Differencing requires a parent path" |
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.
And It 'Should throw when ParentPath is not defined and type is Differencing'
@@ -181,6 +207,11 @@ function Test-TargetResource | |||
[ValidateSet("Vhd","Vhdx")] | |||
[String]$Generation = "Vhd", | |||
|
|||
# Type of Vhd to be created | |||
[parameter()] |
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.
Same as with other comment
@@ -198,7 +229,18 @@ function Test-TargetResource | |||
{ | |||
Throw "Either specify ParentPath or MaximumSizeBytes property." | |||
} | |||
|
|||
|
|||
# Check the module combinations make sense |
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.
Could you remove this comment or move it up (so the earlier validation is included under the comment as well) and change the wording so that it says something like, Validating Parameters
I written some tests which are close but aren't working quite right. I've ticked |
…f the styling and indentation issues. added comment based help
… check parameter conditions
@johnf I've send in some commits to your repo to make some adjustments. Reviewed 2 of 3 files at r3, 2 of 2 files at r5. Comments from Reviewable |
… process. Fixed a bug when MaximumSizeBytes was not specified, resize was wrongly initialized.
Sorry about the minor nitpicks. Generally things look fine, but if you're going to do some rework on this module at some point then I've made some suggested changes. One other thing that you would want to address in any rework: Move strings to strings file. Reviewed 1 of 4 files at r2, 2 of 2 files at r6. DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 83 at r2 (raw file): Previously, bgelens (Ben Gelens) wrote…
I'd generally recommend creating an DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 233 at r3 (raw file): Previously, bgelens (Ben Gelens) wrote…
See my earlier comments about parameter validation in DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 37 at r6 (raw file):
Not required here (so please don't worry about fixing in this PR), but just a suggestion: convert to standard way of throwing custom errors. E.g. New-InvalidOperationException. DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 137 at r6 (raw file):
Nitpick: Need space between if and ( - just use global search/replace to fix them all. DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 197 at r6 (raw file):
Hope I'm not being too much of a pain, but won't this catch any kind of error - not just missing VHD files? DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 212 at r6 (raw file):
Please add blank line after end of code blocks. DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 282 at r6 (raw file):
Not required, please don't worry about doing this now, just a suggestion for future: The recommended way of doing this is to move it to an Examples/Sample_xVHD_FixedVHD.ps1, line 5 at r6 (raw file):
Please convert parameter block to be standard format. E.g. [Parameter()]
[String[]]
$NodeName = 'localhost',
[Parameter(Mandatory = $true)]
[String]
$Name Tests/Unit/MSFT_xVHD.tests.ps1, line 47 at r6 (raw file):
Add blank line here. Tests/Unit/MSFT_xVHD.tests.ps1, line 126 at r6 (raw file):
Please add blank line here. Tests/Unit/MSFT_xVHD.tests.ps1, line 162 at r6 (raw file):
Space after # Tests/Unit/MSFT_xVHD.tests.ps1, line 164 at r6 (raw file):
Please add blank line here. Comments from Reviewable |
No worries, keep up with the nitpicks! I've made some changes per your findings. Please approve these if they are to your liking 😄 I'm not going to improve / enhance this resource further within the scope of this PR. The additions I made to it, felt needed to have this PR merged (most important: adding the test cases which resulted in some of the code being changed due to bug findings 😉 ) Reviewed 2 of 2 files at r6. DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 137 at r6 (raw file): Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Done DSCResources/MSFT_xVHD/MSFT_xVHD.psm1, line 197 at r6 (raw file): Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
You are not, it is true and I was not happy with this myself. I already had made some changes to this PR original contributors code as this was actually the case with the type mismatch . Examples/Sample_xVHD_FixedVHD.ps1, line 5 at r6 (raw file): Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Done Tests/Unit/MSFT_xVHD.tests.ps1, line 47 at r6 (raw file): Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Done Tests/Unit/MSFT_xVHD.tests.ps1, line 126 at r6 (raw file): Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Done Tests/Unit/MSFT_xVHD.tests.ps1, line 162 at r6 (raw file): Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Done Tests/Unit/MSFT_xVHD.tests.ps1, line 164 at r6 (raw file): Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Done Comments from Reviewable |
Thanks for all your work on getting this PR out 😁 Nearly there! You're doing great stuff. Reviewed 1 of 4 files at r2, 4 of 4 files at r7. Examples/Sample_xVHD_DiffVHD.ps1, line 19 at r7 (raw file):
This file looks like it still needs it's parameter style fixed. Comments from Reviewable |
OK please check again 😉 Reviewed 4 of 4 files at r7, 4 of 4 files at r8. Examples/Sample_xVHD_DiffVHD.ps1, line 19 at r7 (raw file): Previously, PlagueHO (Daniel Scott-Raynsford) wrote…
Done plus all other xVHD examples Comments from Reviewable |
Great job and done! Reviewed 4 of 4 files at r8. Comments from Reviewable |
Add the ability to create Fixed disks
Fixes #72
This change is