use of com.microsoft.azure.PagedList 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.PagedList 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.PagedList 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.PagedList in project azure-sdk-for-java by Azure.
the class ComputeNodesImpl method list.
/**
* Lists the compute nodes in the specified pool.
*
* @param poolId The id of the pool from which you want to list nodes.
* @throws BatchErrorException exception thrown from REST call
* @throws IOException exception thrown from serialization/deserialization
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List<ComputeNode> object wrapped in {@link ServiceResponseWithHeaders} if successful.
*/
public ServiceResponseWithHeaders<PagedList<ComputeNode>, ComputeNodeListHeaders> list(final String poolId) throws BatchErrorException, IOException, IllegalArgumentException {
if (poolId == null) {
throw new IllegalArgumentException("Parameter poolId is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
final ComputeNodeListOptions computeNodeListOptions = null;
String filter = null;
String select = null;
Integer maxResults = null;
Integer timeout = null;
String clientRequestId = null;
Boolean returnClientRequestId = null;
DateTime ocpDate = null;
DateTimeRfc1123 ocpDateConverted = null;
if (ocpDate != null) {
ocpDateConverted = new DateTimeRfc1123(ocpDate);
}
Call<ResponseBody> call = service.list(poolId, this.client.apiVersion(), this.client.acceptLanguage(), filter, select, maxResults, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
ServiceResponseWithHeaders<PageImpl<ComputeNode>, ComputeNodeListHeaders> response = listDelegate(call.execute());
PagedList<ComputeNode> result = new PagedList<ComputeNode>(response.getBody()) {
@Override
public Page<ComputeNode> nextPage(String nextPageLink) throws BatchErrorException, IOException {
return listNext(nextPageLink, null).getBody();
}
};
return new ServiceResponseWithHeaders<>(result, response.getHeaders(), response.getResponse());
}
use of com.microsoft.azure.PagedList in project azure-sdk-for-java by Azure.
the class PoolsImpl method listPoolUsageMetrics.
/**
* Lists the usage metrics, aggregated by pool across individual time intervals, for the specified account.
*
* @param poolListPoolUsageMetricsOptions Additional parameters for the operation
* @throws BatchErrorException exception thrown from REST call
* @throws IOException exception thrown from serialization/deserialization
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List<PoolUsageMetrics> object wrapped in {@link ServiceResponseWithHeaders} if successful.
*/
public ServiceResponseWithHeaders<PagedList<PoolUsageMetrics>, PoolListPoolUsageMetricsHeaders> listPoolUsageMetrics(final PoolListPoolUsageMetricsOptions poolListPoolUsageMetricsOptions) throws BatchErrorException, IOException, IllegalArgumentException {
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Validator.validate(poolListPoolUsageMetricsOptions);
DateTime startTime = null;
if (poolListPoolUsageMetricsOptions != null) {
startTime = poolListPoolUsageMetricsOptions.startTime();
}
DateTime endTime = null;
if (poolListPoolUsageMetricsOptions != null) {
endTime = poolListPoolUsageMetricsOptions.endTime();
}
String filter = null;
if (poolListPoolUsageMetricsOptions != null) {
filter = poolListPoolUsageMetricsOptions.filter();
}
Integer maxResults = null;
if (poolListPoolUsageMetricsOptions != null) {
maxResults = poolListPoolUsageMetricsOptions.maxResults();
}
Integer timeout = null;
if (poolListPoolUsageMetricsOptions != null) {
timeout = poolListPoolUsageMetricsOptions.timeout();
}
String clientRequestId = null;
if (poolListPoolUsageMetricsOptions != null) {
clientRequestId = poolListPoolUsageMetricsOptions.clientRequestId();
}
Boolean returnClientRequestId = null;
if (poolListPoolUsageMetricsOptions != null) {
returnClientRequestId = poolListPoolUsageMetricsOptions.returnClientRequestId();
}
DateTime ocpDate = null;
if (poolListPoolUsageMetricsOptions != null) {
ocpDate = poolListPoolUsageMetricsOptions.ocpDate();
}
DateTimeRfc1123 ocpDateConverted = null;
if (ocpDate != null) {
ocpDateConverted = new DateTimeRfc1123(ocpDate);
}
Call<ResponseBody> call = service.listPoolUsageMetrics(this.client.apiVersion(), this.client.acceptLanguage(), startTime, endTime, filter, maxResults, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
ServiceResponseWithHeaders<PageImpl<PoolUsageMetrics>, PoolListPoolUsageMetricsHeaders> response = listPoolUsageMetricsDelegate(call.execute());
PagedList<PoolUsageMetrics> result = new PagedList<PoolUsageMetrics>(response.getBody()) {
@Override
public Page<PoolUsageMetrics> nextPage(String nextPageLink) throws BatchErrorException, IOException {
PoolListPoolUsageMetricsNextOptions poolListPoolUsageMetricsNextOptions = null;
if (poolListPoolUsageMetricsOptions != null) {
poolListPoolUsageMetricsNextOptions = new PoolListPoolUsageMetricsNextOptions();
poolListPoolUsageMetricsNextOptions.withClientRequestId(poolListPoolUsageMetricsOptions.clientRequestId());
poolListPoolUsageMetricsNextOptions.withReturnClientRequestId(poolListPoolUsageMetricsOptions.returnClientRequestId());
poolListPoolUsageMetricsNextOptions.withOcpDate(poolListPoolUsageMetricsOptions.ocpDate());
}
return listPoolUsageMetricsNext(nextPageLink, poolListPoolUsageMetricsNextOptions).getBody();
}
};
return new ServiceResponseWithHeaders<>(result, response.getHeaders(), response.getResponse());
}
Aggregations