Skip to content

AzureRT: Fix Get-AzureVM #19

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

Merged
merged 19 commits into from
Mar 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1f907c5
Merge branch 'dev' of https://github.com/AzureRT/azure-powershell int…
huangpf Feb 20, 2015
f01a80b
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
huangpf Feb 25, 2015
5215cff
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
huangpf Feb 26, 2015
6a8537b
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
huangpf Feb 27, 2015
a3dff8c
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
huangpf Mar 5, 2015
5ff031e
Merge branch 'release-0.8.15' of https://github.com/Azure/azure-power…
huangpf Mar 5, 2015
9cb068d
Merge branch 'release-0.8.15' of https://github.com/Azure/azure-power…
huangpf Mar 5, 2015
0ae3559
Merge branch 'dev' of https://github.com/AzureRT/azure-powershell int…
huangpf Mar 5, 2015
459241b
Merge branch 'dev' of https://github.com/AzureRT/azure-powershell int…
huangpf Mar 5, 2015
616fd09
Merge branch 'release-0.8.15' of https://github.com/Azure/azure-power…
huangpf Mar 6, 2015
30479b9
Merge branch 'dev' of https://github.com/AzureRT/azure-powershell int…
huangpf Mar 6, 2015
43ef387
Merge branch 'release-0.8.15' of https://github.com/Azure/azure-power…
huangpf Mar 7, 2015
b2311fb
Merge branch 'release-0.8.15' of https://github.com/Azure/azure-power…
huangpf Mar 11, 2015
dcbf944
Merge branch 'master' of https://github.com/Azure/azure-powershell in…
huangpf Mar 13, 2015
a67e9f6
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
huangpf Mar 13, 2015
e2b86ac
Fix Get-AzureVM
huangpf Mar 13, 2015
f7ece7b
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
huangpf Mar 13, 2015
4b2da43
Test Get-AzureVM for PaaS deployment
huangpf Mar 13, 2015
bb43e0f
Merge branch 'dev' of https://github.com/AzureRT/azure-powershell int…
huangpf Mar 13, 2015
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
3 changes: 2 additions & 1 deletion src/AzurePowershell.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0MinimumVisualStudioVersion = 10.0.40219.1
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8531411A-0137-4E27-9C5E-49E07C245048}"
ProjectSection(SolutionItems) = preProject
local.runsettings = local.runsettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,12 @@ public void AzureDeploymentTest()
Assert.IsTrue(ce.Message.Contains("The date specified in parameter EndTime is not within the correct range."));
}

// Negative test for Get-AzureVM
var vmRoleList1 = vmPowershellCmdlets.GetAzureVM();
Assert.IsFalse(vmRoleList1.Any(r => r.DeploymentName == deploymentName));
var vmRoleList2 = vmPowershellCmdlets.GetAzureVM(serviceName);
Assert.IsFalse(vmRoleList2.Any(r => r.DeploymentName == deploymentName));

vmPowershellCmdlets.RemoveAzureDeployment(serviceName, DeploymentSlotType.Production, true);

pass &= Utilities.CheckRemove(vmPowershellCmdlets.GetAzureDeployment, serviceName, DeploymentSlotType.Production);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1330,9 +1330,9 @@ internal Collection<ManagementOperationContext> NewAzureVM(string serviceName, S
return result;
}

public Collection<SM.PersistentVMRoleListContext> GetAzureVM(string vmName = null)
public Collection<SM.PersistentVMRoleListContext> GetAzureVM(string serviceName = null)
{
return RunPSCmdletAndReturnAll<SM.PersistentVMRoleListContext>(new GetAzureVMCmdletInfo(vmName, null));
return RunPSCmdletAndReturnAll<SM.PersistentVMRoleListContext>(new GetAzureVMCmdletInfo(null, serviceName));
}

public SM.PersistentVMRoleContext GetAzureVM(string vmName, string serviceName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ protected override void ExecuteCommand()
private List<T> GetVMContextList<T>(string serviceName, NSM.DeploymentGetResponse deployment)
where T : PVM.PersistentVMRoleContext, new()
{
var vmRoles = new List<NSM.Role>(deployment.Roles.Where(
r => string.IsNullOrEmpty(Name)
|| r.RoleName.Equals(Name, StringComparison.InvariantCultureIgnoreCase)));
Func<NSM.Role, bool> typeMatched =
r => string.Equals(r.RoleType, PersistentVMRoleStr, StringComparison.OrdinalIgnoreCase);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it StringComparison.OrdinalIgnoreCase instead of StringComparison.InvariantCultureIgnoreCase ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are only handling ASCII characters, so I think the StringComparison.OrdinalIgnoreCase one is enough.


return GetVMContextList<T>(serviceName, deployment, vmRoles);
Func<NSM.Role, bool> nameMatched =
r => string.IsNullOrEmpty(this.Name) || r.RoleName.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase);

var vmRoles = new List<NSM.Role>(deployment.Roles.Where(r => typeMatched(r) && nameMatched(r)));

return CreateVMContextList<T>(serviceName, deployment, vmRoles);
}

private List<T> GetVMContextList<T>(string serviceName, NSM.DeploymentGetResponse deployment, List<NSM.Role> vmRoles)
private List<T> CreateVMContextList<T>(string serviceName, NSM.DeploymentGetResponse deployment, List<NSM.Role> vmRoles)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change this method name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to fix the function name so that it matches what it's doing. CreateVMContextList calls CreateVMContext and it's creating a new list of T objects, based on the input of NSM.Role (which also indicates maybe the verb shall be Convert or Map), where as the previous one GetVMContextList does mean "getting a list of VM context objects from the deployment.

where T : PVM.PersistentVMRoleContext, new()
{
var roleContexts = new List<T>();
Expand Down