-
Notifications
You must be signed in to change notification settings - Fork 4k
add params to New-Azvm #15605
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
add params to New-Azvm #15605
Conversation
src/Compute/Compute/Strategies/ComputeRp/VirtualMachineStrategy.cs
Outdated
Show resolved
Hide resolved
src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs
Outdated
Show resolved
Hide resolved
List<SshPublicKey> sshPublicKeyList = new List<SshPublicKey>(); | ||
if (_cmdlet.ConfigAsyncVisited == true && (_cmdlet.SshKeyName != null || _cmdlet.GenerateSshKey == true)) | ||
{ | ||
if (ImageAndOsType?.OsType != OperatingSystemTypes.Linux) |
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.
if so, please add a new parameter set where -Linux, -SshKeyName, are required And remove this if block
src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs
Outdated
Show resolved
Hide resolved
src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs
Outdated
Show resolved
Hide resolved
src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs
Outdated
Show resolved
Hide resolved
src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs
Outdated
Show resolved
Hide resolved
src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs
Outdated
Show resolved
Hide resolved
src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs
Outdated
Show resolved
Hide resolved
@@ -42,28 +42,29 @@ public override void ExecuteCmdlet() | |||
base.ExecuteCmdlet(); | |||
ExecuteClientAction(() => | |||
{ | |||
string resourceGroupName = this.ResourceGroupName; |
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.
indentations are fixed in this file
@VeryEarly thank you for all your comments, I really appreciate it looking at it thoroughly. So you want me to add two new parameter sets branch off of DefaultParameterSet and SimpleParameter set that has '-Linux', '-SshKeyName' and '-GenerateSshKey'? Could you elaborate on why that would be better? I am hesitant because
Should I consult a PM? |
please correct me if I'm wrong, the exception thrown at line 452 (NewAzureVMCommand.cs), won't be executed until line 625 (NewAzureVMCommand.cs) was reached:
At this point, some other resources should be already created (storage/network? need your confirmation). This is too heavy for a parameter level behavior, that is to say, this exception can be discovered at the very beginning when cmdlet was invoked (using parameter set) while not to call any actual business logic. Please let me know if you have any concern. |
this part is right
but here no. Other resources are not created. the PowerShell sends one payload to Azure on this line 625, and in the backend, the storage resources, network resources, and VM are all created together. Many of the storage and network properties will default to a value in the backend because the simple parameter set provides very little bit of that.
|
Make sense. I suggest to
The reason I suggested to do so is because these business logics are not supposed to be blended with the concrete strategy, please let me know if you have any concerns. |
@VeryEarly I do have a concern about the last bullet point. The default parameter set does not use the Parameters class, and I still need to use "addSshPublicKey" and "SshKeyForLinux" for it. Shown azure-powershell/src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs Line 739 in 5a488b6
|
@VeryEarly I've implemented all your suggestions except for the last bullet point. I've made validate() a method of the cmdlet class. |
src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs
Outdated
Show resolved
Hide resolved
I see, it might need more refactor to this cmdlet then, I'm good with current implementation, thanks for your quick response. |
@VeryEarly pls review again! |
@VeryEarly pls merge |
adding '-SshKeyName' and 'GenerateSshKey' parameters to New-AzVm
and fixing small bug in New-AzSshKey
Description
Checklist
CONTRIBUTING.md
ChangeLog.md
file(s) has been updated:ChangeLog.md
file can be found atsrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
## Upcoming Release
header -- no new version header should be added