use of com.microsoft.azure.management.compute.VirtualMachineSize in project azure-tools-for-java by Microsoft.
the class MachineSettingsStep method getTitle.
@Override
public String getTitle() {
boolean isLinux;
if (wizard.isKnownMachineImage()) {
isLinux = wizard.getKnownMachineImage() instanceof KnownLinuxVirtualMachineImage;
} else {
isLinux = wizard.getVirtualMachineImage().osDiskImage().operatingSystem().equals(OperatingSystemTypes.LINUX);
}
if (isLinux) {
certificateCheckBox.setEnabled(true);
passwordCheckBox.setEnabled(true);
certificateCheckBoxSelected(false);
passwordCheckBox.setSelection(true);
} else {
certificateCheckBoxSelected(false);
passwordCheckBox.setSelection(true);
certificateCheckBox.setEnabled(false);
passwordCheckBox.setEnabled(false);
}
validateEmptyFields();
if (vmSizeComboBox.getItemCount() == 0) {
vmSizeComboBox.setItems(new String[] { LOADING });
DefaultLoader.getIdeHelper().runInBackground(null, "Loading VM sizes...", false, true, "", new Runnable() {
@Override
public void run() {
PagedList<com.microsoft.azure.management.compute.VirtualMachineSize> sizes = wizard.getAzure().virtualMachines().sizes().listByRegion(wizard.getRegion().name());
Collections.sort(sizes, new Comparator<VirtualMachineSize>() {
@Override
public int compare(VirtualMachineSize t0, VirtualMachineSize t1) {
if (t0.name().contains("Basic") && t1.name().contains("Basic")) {
return t0.name().compareTo(t1.name());
} else if (t0.name().contains("Basic")) {
return -1;
} else if (t1.name().contains("Basic")) {
return 1;
}
int coreCompare = Integer.valueOf(t0.numberOfCores()).compareTo(t1.numberOfCores());
if (coreCompare == 0) {
return Integer.valueOf(t0.memoryInMB()).compareTo(t1.memoryInMB());
} else {
return coreCompare;
}
}
});
DefaultLoader.getIdeHelper().invokeAndWait(new Runnable() {
@Override
public void run() {
vmSizeComboBox.removeAll();
for (VirtualMachineSize size : sizes) {
vmSizeComboBox.add(size.name());
vmSizeComboBox.setData(size.name(), size);
}
if (sizes.size() > 0) {
vmSizeComboBox.select(0);
}
// selectDefaultSize();
}
});
}
});
} else {
selectDefaultSize();
}
return super.getTitle();
}
use of com.microsoft.azure.management.compute.VirtualMachineSize in project azure-tools-for-java by Microsoft.
the class MachineSettingsStep method prepare.
@Override
public JComponent prepare(WizardNavigationState wizardNavigationState) {
rootPanel.revalidate();
boolean isLinux;
try {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
azure = azureManager.getAzure(((VMWizardModel) model).getSubscription().getSubscriptionId());
} catch (Exception ex) {
DefaultLoader.getUIHelper().logError("An error occurred when trying to authenticate\n\n" + ex.getMessage(), ex);
}
if (model.isKnownMachineImage()) {
isLinux = model.getKnownMachineImage() instanceof KnownLinuxVirtualMachineImage;
} else {
isLinux = model.getVirtualMachineImage().osDiskImage().operatingSystem().equals(OperatingSystemTypes.LINUX);
}
if (isLinux) {
certificateCheckBox.setEnabled(true);
passwordCheckBox.setEnabled(true);
certificateCheckBox.setSelected(false);
passwordCheckBox.setSelected(true);
} else {
certificateCheckBox.setSelected(false);
passwordCheckBox.setSelected(true);
certificateCheckBox.setEnabled(false);
passwordCheckBox.setEnabled(false);
}
validateEmptyFields();
if (vmSizeComboBox.getItemCount() == 0) {
vmSizeComboBox.setModel(new DefaultComboBoxModel(new String[] { "<Loading...>" }));
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Loading VM sizes...", false) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
progressIndicator.setIndeterminate(true);
PagedList<com.microsoft.azure.management.compute.VirtualMachineSize> sizes = azure.virtualMachines().sizes().listByRegion(model.getRegion().name());
Collections.sort(sizes, new Comparator<VirtualMachineSize>() {
@Override
public int compare(VirtualMachineSize t0, VirtualMachineSize t1) {
if (t0.name().contains("Basic") && t1.name().contains("Basic")) {
return t0.name().compareTo(t1.name());
} else if (t0.name().contains("Basic")) {
return -1;
} else if (t1.name().contains("Basic")) {
return 1;
}
int coreCompare = Integer.valueOf(t0.numberOfCores()).compareTo(t1.numberOfCores());
if (coreCompare == 0) {
return Integer.valueOf(t0.memoryInMB()).compareTo(t1.memoryInMB());
} else {
return coreCompare;
}
}
});
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
vmSizeComboBox.setModel(new DefaultComboBoxModel<>(sizes.stream().map(VirtualMachineSize::name).toArray(String[]::new)));
selectDefaultSize();
}
}, ModalityState.any());
}
});
} else {
selectDefaultSize();
}
return rootPanel;
}
use of com.microsoft.azure.management.compute.VirtualMachineSize in project azure-tools-for-java by Microsoft.
the class AzureNewDockerHostStep method updateDockerHostVMSizeComboBox.
private void updateDockerHostVMSizeComboBox(boolean prefferedSizesOnly) {
DefaultComboBoxModel<String> dockerHostVMSizeComboModel = new DefaultComboBoxModel<>();
if (prefferedSizesOnly) {
for (KnownDockerVirtualMachineSizes knownDockerVirtualMachineSize : KnownDockerVirtualMachineSizes.values()) {
dockerHostVMSizeComboModel.addElement(knownDockerVirtualMachineSize.name());
}
if (dockerHostVMSizeComboModel.getSize() > 0) {
dockerHostVMSizeComboModel.setSelectedItem(dockerHostVMSizeComboModel.getElementAt(0));
}
} else {
dockerHostVMSizeComboModel.addElement("<Loading...>");
ProgressManager.getInstance().run(new Task.Backgroundable(model.getProject(), "Loading VM Sizes...", false) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
progressIndicator.setIndeterminate(true);
Azure azureClient = ((AzureDockerSubscription) dockerSubscriptionComboBox.getSelectedItem()).azureClient;
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;
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
dockerHostVMSizeComboModel.removeAllElements();
if (sortedSizes != null) {
for (VirtualMachineSize vmSize : sortedSizes) {
dockerHostVMSizeComboModel.addElement(vmSize.name());
}
}
dockerHostVMSizeComboBox.repaint();
}
}, ModalityState.any());
}
});
}
dockerHostVMSizeComboBox.setModel(dockerHostVMSizeComboModel);
dockerHostVMSizeComboBox.setSelectedItem(newHost.hostVM.vmSize);
if (!newHost.hostVM.vmSize.equals((String) dockerHostVMSizeComboBox.getSelectedItem())) {
dockerHostVMSizeComboModel.addElement(newHost.hostVM.vmSize);
dockerHostVMSizeComboBox.setSelectedItem(newHost.hostVM.vmSize);
}
updateDockerSelectStorageComboBox((AzureDockerSubscription) dockerSubscriptionComboBox.getSelectedItem());
}
use of com.microsoft.azure.management.compute.VirtualMachineSize in project azure-sdk-for-java by Azure.
the class TestAvailabilitySet method createResource.
@Override
public AvailabilitySet createResource(AvailabilitySets availabilitySets) throws Exception {
final String newName = "as" + this.testId;
AvailabilitySet aset = availabilitySets.define(newName).withRegion(Region.US_EAST).withNewResourceGroup().withFaultDomainCount(2).withUpdateDomainCount(4).withTag("tag1", "value1").create();
PagedList<VirtualMachineSize> vmSizes = aset.listVirtualMachineSizes();
Assert.assertTrue(vmSizes.size() > 0);
for (VirtualMachineSize vmSize : vmSizes) {
Assert.assertNotNull(vmSize.name());
}
return aset;
}
use of com.microsoft.azure.management.compute.VirtualMachineSize in project azure-sdk-for-java by Azure.
the class TestVirtualMachineSizes method createResource.
@Override
public VirtualMachine createResource(VirtualMachines virtualMachines) throws Exception {
List<VirtualMachineSize> availableSizes = virtualMachines.sizes().listByRegion(Region.US_EAST);
Assert.assertTrue(availableSizes.size() > 0);
System.out.println("VM Sizes: " + availableSizes);
final String vmName = "vm" + this.testId;
VirtualMachine vm = virtualMachines.define(vmName).withRegion(Region.US_EAST).withNewResourceGroup().withNewPrimaryNetwork("10.0.0.0/28").withPrimaryPrivateIPAddressDynamic().withoutPrimaryPublicIPAddress().withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_R2_DATACENTER).withAdminUsername("testuser").withAdminPassword("12NewPA$$w0rd!").withSize(// Use the first size
availableSizes.get(0).name()).create();
Assert.assertTrue(vm.size().toString().equalsIgnoreCase(availableSizes.get(0).name()));
return vm;
}
Aggregations