Skip to content

Commit 276476e

Browse files
authored
Sort VM Skus (#276)
1 parent e999fe2 commit 276476e

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

src/main/java/com/microsoft/azure/vmagent/AzureVMAgentTemplate.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,12 +1309,9 @@ public ListBoxModel doFillVirtualMachineSizeItems(
13091309
if (StringUtils.isBlank(azureCredentialsId)) {
13101310
return model;
13111311
}
1312-
List<String> vmSizes = AzureClientHolder.getDelegate(azureCredentialsId).getVMSizes(location);
1313-
1314-
if (vmSizes != null) {
1315-
for (String vmSize : vmSizes) {
1316-
model.add(vmSize);
1317-
}
1312+
Set<String> vmSizes = AzureClientHolder.getDelegate(azureCredentialsId).getVMSizes(location);
1313+
for (String vmSize : vmSizes) {
1314+
model.add(vmSize);
13181315
}
13191316
return model;
13201317
}

src/main/java/com/microsoft/azure/vmagent/AzureVMManagementServiceDelegate.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,13 +1495,13 @@ public Set<String> getVirtualMachineLocations(String envNameOrUrl) {
14951495
* @param location Location to obtain VM sizes for
14961496
* @return List of VM sizes
14971497
*/
1498-
public List<String> getVMSizes(String location) {
1498+
public Set<String> getVMSizes(String location) {
14991499
if (location == null || location.isEmpty()) {
15001500
//if the location is not available we'll just return a default list with some of the most common VM sizes
1501-
return DEFAULT_VM_SIZES;
1501+
return new TreeSet<>(DEFAULT_VM_SIZES);
15021502
}
15031503
try {
1504-
List<String> ret = new ArrayList<>();
1504+
Set<String> ret = new TreeSet<>();
15051505
for (VirtualMachineSize vmSize : azureClient.virtualMachines().sizes().listByRegion(location)) {
15061506
ret.add(vmSize.name());
15071507
}
@@ -1511,7 +1511,7 @@ public List<String> getVMSizes(String location) {
15111511
"AzureVMManagementServiceDelegate: getVMSizes: "
15121512
+ "error while fetching the VM sizes {0}. Will return default list ",
15131513
e);
1514-
return AVAILABLE_ROLE_SIZES.get(location);
1514+
return new TreeSet<>(AVAILABLE_ROLE_SIZES.get(location));
15151515
}
15161516
}
15171517

0 commit comments

Comments
 (0)