Search in sources :

Example 31 with SubscriptionDetail

use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.

the class ClusterManager method getClusterDetails.

private List<IClusterDetail> getClusterDetails(List<SubscriptionDetail> subscriptions, final Object project) throws AggregatedException {
    ExecutorService taskExecutor = Executors.newFixedThreadPool(MAX_CONCURRENT);
    final List<IClusterDetail> cachedClusterList = new ArrayList<>();
    final List<Exception> aggregateExceptions = new ArrayList<>();
    for (SubscriptionDetail subscription : subscriptions) {
        taskExecutor.execute(new CommonRunnable<SubscriptionDetail, Exception>(subscription) {

            @Override
            public void runSpecificParameter(SubscriptionDetail parameter) throws IOException, HDIException, AzureCmdException {
                IClusterOperation clusterOperation = new ClusterOperationImpl(project);
                List<ClusterRawInfo> clusterRawInfoList = clusterOperation.listCluster(parameter);
                if (clusterRawInfoList != null) {
                    for (ClusterRawInfo item : clusterRawInfoList) {
                        IClusterDetail tempClusterDetail = new ClusterDetail(parameter, item);
                        synchronized (ClusterManager.class) {
                            cachedClusterList.add(tempClusterDetail);
                        }
                    }
                }
            }

            @Override
            public void exceptionHandle(Exception e) {
                synchronized (aggregateExceptions) {
                    aggregateExceptions.add(e);
                }
            }
        });
    }
    taskExecutor.shutdown();
    try {
        taskExecutor.awaitTermination(TIME_OUT, TimeUnit.SECONDS);
    } catch (InterruptedException exception) {
        aggregateExceptions.add(exception);
    }
    if (aggregateExceptions.size() > 0) {
        throw new AggregatedException(aggregateExceptions);
    }
    return cachedClusterList;
}
Also used : ArrayList(java.util.ArrayList) AggregatedException(com.microsoft.azure.hdinsight.sdk.common.AggregatedException) IOException(java.io.IOException) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) AggregatedException(com.microsoft.azure.hdinsight.sdk.common.AggregatedException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) IOException(java.io.IOException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) ExecutorService(java.util.concurrent.ExecutorService) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) List(java.util.List) ArrayList(java.util.ArrayList)

Example 32 with SubscriptionDetail

use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.

the class AppInsightsMngmtPanel method loadInfoFirstTime.

private void loadInfoFirstTime() {
    try {
        if (AuthMethodManager.getInstance().isSignedIn()) {
            AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
            List<SubscriptionDetail> subList = azureManager.getSubscriptionManager().getSubscriptionDetails();
            if (subList.size() > 0) {
                //                if (!AzureSettings.getSafeInstance(myProject).isAppInsightsLoaded()) {
                updateApplicationInsightsResourceRegistry(subList, myProject);
            } else {
                // just show manually added list from preferences
                // Neither clear subscription list nor show sign in dialog as user may just want to add key manually.
                keeepManuallyAddedList(myProject);
            }
        //                } else {
        // show list from preferences - getTableContent() does it. So nothing to handle here
        //                }
        } else {
            // just show manually added list from preferences
            keeepManuallyAddedList(myProject);
        }
    } catch (Exception ex) {
        AzurePlugin.log(ex.getMessage(), ex);
    }
}
Also used : AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail)

Example 33 with SubscriptionDetail

use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.

the class ApplicationInsightsNewDialog method subscriptionListener.

private ItemListener subscriptionListener() {
    return new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            SubscriptionDetail newSub = (SubscriptionDetail) comboSub.getSelectedItem();
            String prevResGrpVal = (String) comboGrp.getSelectedItem();
            if (currentSub.equals(newSub)) {
                populateResourceGroupValues(currentSub.getSubscriptionId(), prevResGrpVal);
            } else {
                populateResourceGroupValues(currentSub.getSubscriptionId(), "");
            }
            currentSub = newSub;
        }
    };
}
Also used : ItemEvent(java.awt.event.ItemEvent) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) ItemListener(java.awt.event.ItemListener)

Example 34 with SubscriptionDetail

use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.

the class AppServiceCreateDialog method fillAppServicePlanLocations.

protected void fillAppServicePlanLocations() {
    int i = comboSubscription.getSelectionIndex();
    if (i < 0) {
        // empty
        System.out.println("No subscription is selected");
        return;
    }
    comboAppServicePlanLocation.removeAll();
    binderAppServicePlanLocation = new ArrayList<Location>();
    //List<Location> locl = AzureModel.getInstance().getSubscriptionToLocationMap().get(binderSubscriptionDetails.get(i));
    Map<SubscriptionDetail, List<Location>> sdlocMap = AzureModel.getInstance().getSubscriptionToLocationMap();
    SubscriptionDetail sd = binderSubscriptionDetails.get(i);
    List<Location> locl = sdlocMap.get(sd);
    comboAppServicePlanLocation.add("<select location>");
    binderAppServicePlanLocation.add(null);
    for (Location loc : locl) {
        comboAppServicePlanLocation.add(loc.displayName());
        binderAppServicePlanLocation.add(loc);
    }
    if (comboAppServicePlanLocation.getItemCount() > 0) {
        comboAppServicePlanLocation.select(0);
    }
}
Also used : SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Location(com.microsoft.azure.management.resources.Location)

Example 35 with SubscriptionDetail

use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.

the class SubscriptionStep method loadSubscriptions.

private void loadSubscriptions() {
    try {
        AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
        // not signed in
        if (azureManager == null) {
            model.getCurrentNavigationState().NEXT.setEnabled(false);
            return;
        }
        SubscriptionManager subscriptionManager = azureManager.getSubscriptionManager();
        List<SubscriptionDetail> subscriptionDetails = subscriptionManager.getSubscriptionDetails();
        List<SubscriptionDetail> selectedSubscriptions = subscriptionDetails.stream().filter(SubscriptionDetail::isSelected).collect(Collectors.toList());
        subscriptionComboBox.setModel(new DefaultComboBoxModel<>(selectedSubscriptions.toArray(new SubscriptionDetail[selectedSubscriptions.size()])));
        if (selectedSubscriptions.size() > 0) {
            model.setSubscription(selectedSubscriptions.get(0));
        }
    } catch (Exception ex) {
        DefaultLoader.getUIHelper().logError("An error occurred when trying to load Subscriptions\n\n" + ex.getMessage(), ex);
    }
//            if (manager.authenticated()) {
//                String upn = manager.getUserInfo().getUniqueName();
//                userInfoLabel.setText("Signed in as: " + (upn.contains("#") ? upn.split("#")[1] : upn));
//            } else {
//                userInfoLabel.setText("");
//            }
}
Also used : AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) SubscriptionManager(com.microsoft.azuretools.authmanage.SubscriptionManager)

Aggregations

SubscriptionDetail (com.microsoft.azuretools.authmanage.models.SubscriptionDetail)52 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)17 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)13 SubscriptionManager (com.microsoft.azuretools.authmanage.SubscriptionManager)13 IOException (java.io.IOException)9 AppServicePlan (com.microsoft.azure.management.appservice.AppServicePlan)7 Location (com.microsoft.azure.management.resources.Location)7 List (java.util.List)7 WebApp (com.microsoft.azure.management.appservice.WebApp)5 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 Azure (com.microsoft.azure.management.Azure)4 Subscription (com.microsoft.azure.management.resources.Subscription)4 WebAppDetails (com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails)4 HashMap (java.util.HashMap)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 GridData (org.eclipse.swt.layout.GridData)4 Label (org.eclipse.swt.widgets.Label)4 AccessTokenAzureManager (com.microsoft.azuretools.sdkmanage.AccessTokenAzureManager)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3