use of com.microsoft.azure.management.compute.VirtualMachineSize in project azure-sdk-for-java by Azure.
the class TestVirtualMachineSizes method updateResource.
@Override
public VirtualMachine updateResource(VirtualMachine virtualMachine) throws Exception {
List<VirtualMachineSize> resizableSizes = virtualMachine.availableSizes();
Assert.assertTrue(resizableSizes.size() > 1);
VirtualMachineSize newSize = null;
for (VirtualMachineSize resizableSize : resizableSizes) {
if (!resizableSize.name().equalsIgnoreCase(virtualMachine.size().toString())) {
newSize = resizableSize;
break;
}
}
Assert.assertNotNull(newSize);
virtualMachine = virtualMachine.update().withSize(newSize.name()).apply();
Assert.assertTrue(virtualMachine.size().toString().equalsIgnoreCase(newSize.name()));
return virtualMachine;
}
use of com.microsoft.azure.management.compute.VirtualMachineSize in project azure-tools-for-java by Microsoft.
the class AzureNewDockerConfigPage method updateDockerHostVMSizeComboBox.
private void updateDockerHostVMSizeComboBox(Composite mainContainer, boolean preferredSizesOnly) {
dockerHostVMSizeComboBox.deselectAll();
dockerHostVMSizeComboBox.removeAll();
dockerHostVMSizeComboBox.redraw();
if (preferredSizesOnly) {
int index = 0;
for (KnownDockerVirtualMachineSizes knownDockerVirtualMachineSize : KnownDockerVirtualMachineSizes.values()) {
dockerHostVMSizeComboBox.add(knownDockerVirtualMachineSize.name());
if (newHost.hostVM.vmSize.equals(knownDockerVirtualMachineSize.name())) {
dockerHostVMSizeComboBox.select(index);
}
index++;
}
if (index == 0 || !newHost.hostVM.vmSize.equals((String) dockerHostVMSizeComboBox.getText())) {
dockerHostVMSizeComboBox.add(newHost.hostVM.vmSize, 0);
dockerHostVMSizeComboBox.select(0);
}
updateDockerSelectStorageComboBox(mainContainer, getCurrentSubscription());
} else {
dockerHostVMSizeComboBox.add("<Loading...>", 0);
dockerHostVMSizeComboBox.select(0);
dockerHostVMSizeComboBox.redraw();
Azure azureClient = getCurrentSubscription().azureClient;
DefaultLoader.getIdeHelper().runInBackground(null, "Loading VM sizes...", false, true, "", new Runnable() {
@Override
public void run() {
PagedList<VirtualMachineSize> sizes = null;
try {
sizes = azureClient.virtualMachines().sizes().listByRegion(preferredLocation);
Collections.sort(sizes, new Comparator<VirtualMachineSize>() {
@Override
public int compare(VirtualMachineSize size1, VirtualMachineSize size2) {
if (size1.name().contains("Basic") && size2.name().contains("Basic")) {
return size1.name().compareTo(size2.name());
} else if (size1.name().contains("Basic")) {
return -1;
} else if (size2.name().contains("Basic")) {
return 1;
}
int coreCompare = Integer.valueOf(size1.numberOfCores()).compareTo(size2.numberOfCores());
if (coreCompare == 0) {
return Integer.valueOf(size1.memoryInMB()).compareTo(size2.memoryInMB());
} else {
return coreCompare;
}
}
});
} catch (Exception notHandled) {
}
PagedList<VirtualMachineSize> sortedSizes = sizes;
DefaultLoader.getIdeHelper().invokeAndWait(new Runnable() {
@Override
public void run() {
dockerHostVMSizeComboBox.deselectAll();
dockerHostVMSizeComboBox.removeAll();
if (sortedSizes != null) {
int index = 0;
for (VirtualMachineSize vmSize : sortedSizes) {
dockerHostVMSizeComboBox.add(vmSize.name());
if (vmSize.name().equals(newHost.hostVM.vmSize))
dockerHostVMSizeComboBox.select(index);
index++;
}
}
if (sortedSizes.size() != 0 && !newHost.hostVM.vmSize.equals((String) dockerHostVMSizeComboBox.getText())) {
dockerHostVMSizeComboBox.add(newHost.hostVM.vmSize, 0);
dockerHostVMSizeComboBox.select(0);
}
updateDockerSelectStorageComboBox(mainContainer, getCurrentSubscription());
dockerHostVMSizeComboBox.redraw();
}
});
}
});
}
}
Aggregations