Skip to content

Commit e2b86ac

Browse files
committed
Fix Get-AzureVM
1 parent a67e9f6 commit e2b86ac

File tree

1 file changed

+9
-5
lines changed
  • src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/PersistentVMs

1 file changed

+9
-5
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/PersistentVMs/GetAzureVM.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,18 @@ protected override void ExecuteCommand()
101101
private List<T> GetVMContextList<T>(string serviceName, NSM.DeploymentGetResponse deployment)
102102
where T : PVM.PersistentVMRoleContext, new()
103103
{
104-
var vmRoles = new List<NSM.Role>(deployment.Roles.Where(
105-
r => string.IsNullOrEmpty(Name)
106-
|| r.RoleName.Equals(Name, StringComparison.InvariantCultureIgnoreCase)));
104+
Func<NSM.Role, bool> typeMatched =
105+
r => string.Equals(r.RoleType, PersistentVMRoleStr, StringComparison.OrdinalIgnoreCase);
107106

108-
return GetVMContextList<T>(serviceName, deployment, vmRoles);
107+
Func<NSM.Role, bool> nameMatched =
108+
r => string.IsNullOrEmpty(this.Name) || r.RoleName.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase);
109+
110+
var vmRoles = new List<NSM.Role>(deployment.Roles.Where(r => typeMatched(r) && nameMatched(r)));
111+
112+
return CreateVMContextList<T>(serviceName, deployment, vmRoles);
109113
}
110114

111-
private List<T> GetVMContextList<T>(string serviceName, NSM.DeploymentGetResponse deployment, List<NSM.Role> vmRoles)
115+
private List<T> CreateVMContextList<T>(string serviceName, NSM.DeploymentGetResponse deployment, List<NSM.Role> vmRoles)
112116
where T : PVM.PersistentVMRoleContext, new()
113117
{
114118
var roleContexts = new List<T>();

0 commit comments

Comments
 (0)