use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.
the class SelectImageStep method fillOffers.
private void fillOffers() {
disableNext();
final VirtualMachinePublisher publisher = (VirtualMachinePublisher) publisherComboBox.getSelectedItem();
final AzureString title = AzureOperationBundle.title("vm|offer.list", publisher.name());
AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
progressIndicator.setIndeterminate(true);
RxJavaUtils.unsubscribeSubscription(fillOfferSubscription);
clearSelection(offerComboBox, skuComboBox, imageLabelList);
fillOfferSubscription = Observable.fromCallable(() -> publisher.offers().list()).subscribeOn(Schedulers.io()).subscribe(offerList -> DefaultLoader.getIdeHelper().invokeLater(() -> {
offerComboBox.setModel(new DefaultComboBoxModel(offerList.toArray()));
fillSkus();
}), error -> {
final String msg = String.format(ERROR_MESSAGE_FILL_SKUS, String.format(message("webappExpMsg"), error.getMessage()));
handleError(msg, error);
});
}));
}
use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.
the class SettingsStep method retrieveNetworkSecurityGroups.
private void retrieveNetworkSecurityGroups() {
final AzureString title = AzureOperationBundle.title("vm.list_security_groups");
AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
progressIndicator.setIndeterminate(true);
if (networkSecurityGroups == null) {
networkSecurityGroups = azure.networkSecurityGroups().list();
}
AzureTaskManager.getInstance().runLater(() -> nsgCombo.setModel(getNsgModel(model.getNetworkSecurityGroup())));
}));
if (networkSecurityGroups == null) {
AzureTaskManager.getInstance().runAndWait(new Runnable() {
@Override
public void run() {
final DefaultComboBoxModel loadingNsgModel = new DefaultComboBoxModel(new String[] { NONE, "<Loading...>" }) {
@Override
public void setSelectedItem(Object o) {
super.setSelectedItem(o);
if (NONE.equals(o)) {
model.setNetworkSecurityGroup(null);
} else {
}
}
};
loadingNsgModel.setSelectedItem(null);
nsgCombo.setModel(loadingNsgModel);
}
}, AzureTask.Modality.ANY);
}
}
use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.
the class SettingsStep method retrievePublicIpAddresses.
private void retrievePublicIpAddresses() {
final AzureString title = AzureOperationBundle.title("vm.list_public_ips");
AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
progressIndicator.setIndeterminate(true);
if (publicIpAddresses == null) {
publicIpAddresses = azure.publicIPAddresses().list();
}
AzureTaskManager.getInstance().runLater(() -> pipCombo.setModel(getPipAddressModel(model.getPublicIpAddress())));
}));
if (publicIpAddresses == null) {
AzureTaskManager.getInstance().runAndWait(new Runnable() {
@Override
public void run() {
final DefaultComboBoxModel loadingPipModel = new DefaultComboBoxModel(new String[] { NONE, CREATE_NEW, "<Loading...>" }) {
@Override
public void setSelectedItem(Object o) {
super.setSelectedItem(o);
if (CREATE_NEW.equals(o)) {
model.setWithNewPip(true);
} else if (NONE.equals(o)) {
model.setPublicIpAddress(null);
model.setWithNewPip(false);
} else {
}
}
};
loadingPipModel.setSelectedItem(null);
pipCombo.setModel(loadingPipModel);
}
}, AzureTask.Modality.ANY);
}
}
use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.
the class SettingsStep method onFinish.
@Override
public boolean onFinish() {
final boolean isNewResourceGroup = createNewRadioButton.isSelected();
final String resourceGroupName = isNewResourceGroup ? resourceGrpField.getText() : resourceGrpCombo.getSelectedItem().toString();
Operation operation = TelemetryManager.createOperation(VM, CREATE_VM);
final AzureString title = AzureOperationBundle.title("vm.create", model.getName());
AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
progressIndicator.setIndeterminate(true);
try {
operation.start();
String certificate = model.getCertificate();
byte[] certData = new byte[0];
if (!certificate.isEmpty()) {
File certFile = new File(certificate);
if (certFile.exists()) {
try (FileInputStream certStream = new FileInputStream(certFile)) {
certData = new byte[(int) certFile.length()];
if (certStream.read(certData) != certData.length) {
throw new Exception("Unable to process certificate: stream longer than informed size.");
}
} finally {
}
}
}
// create storage account when use choose to create new one
if (Objects.nonNull(model.getStorageAccountConfig())) {
model.setStorageAccount(CreateStorageAccountAction.createStorageAccount(model.getStorageAccountConfig()));
}
final com.microsoft.azure.management.compute.VirtualMachine vm = AzureSDKManager.createVirtualMachine(model.getSubscription().getId(), model.getName(), resourceGroupName, createNewRadioButton.isSelected(), model.getSize(), model.getRegion().getName(), model.getVirtualMachineImage(), model.getKnownMachineImage(), model.isKnownMachineImage(), model.getStorageAccount(), model.getVirtualNetwork(), model.getNewNetwork(), model.isWithNewNetwork(), model.getSubnet(), model.getPublicIpAddress(), model.isWithNewPip(), model.getAvailabilitySet(), model.isWithNewAvailabilitySet(), model.getUserName(), model.getPassword(), certData.length > 0 ? new String(certData) : null);
AzureTaskManager.getInstance().runLater(() -> {
try {
parent.addChildNode(new com.microsoft.tooling.msservices.serviceexplorer.azure.vmarm.VMNode(parent, model.getSubscription().getId(), vm));
} catch (AzureCmdException e) {
String msg = "An error occurred while attempting to refresh the list of virtual machines.";
DefaultLoader.getUIHelper().showException(msg, e, "Azure Services Explorer - Error Refreshing VM List", false, true);
AzurePlugin.log(msg, e);
}
});
} catch (Exception e) {
EventUtil.logError(operation, ErrorType.userError, e, null, null);
String msg = "An error occurred while attempting to create the specified virtual machine." + "<br>" + String.format(message("webappExpMsg"), e.getMessage());
DefaultLoader.getUIHelper().showException(msg, e, message("errTtl"), false, true);
AzurePlugin.log(msg, e);
} finally {
operation.complete();
}
}));
return super.onFinish();
}
use of com.microsoft.azure.toolkit.lib.common.bundle.AzureString in project azure-tools-for-java by Microsoft.
the class ProfileFlightRecordAction method actionPerformed.
@Override
protected void actionPerformed(NodeActionEvent nodeActionEvent) {
EventUtil.executeWithLog(TelemetryConstants.WEBAPP, "start-flight-recorder", op -> {
op.trackProperty(TelemetryConstants.SUBSCRIPTIONID, subscriptionId);
final AzureString title = AzureOperationBundle.title("appservice|flight_recorder.profile");
final AzureTask task = new AzureTask(project, title, true, this::doProfileFlightRecorderAll, AzureTask.Modality.ANY);
AzureTaskManager.getInstance().runInBackground(task);
});
}
Aggregations