Search in sources :

Example 96 with Azure

use of com.microsoft.azure.management.Azure in project azure-tools-for-java by Microsoft.

the class AccessTokenAzureManager method getAzure.

@Override
public Azure getAzure(String sid) throws IOException {
    if (sidToAzureMap.containsKey(sid)) {
        return sidToAzureMap.get(sid);
    }
    String tid = subscriptionManager.getSubscriptionTenant(sid);
    Azure azure = authTid(tid).withSubscription(sid);
    // TODO: remove this call after Azure SDK properly implements handling of unregistered provider namespaces
    AzureRegisterProviderNamespaces.registerAzureNamespaces(azure);
    sidToAzureMap.put(sid, azure);
    return azure;
}
Also used : Azure(com.microsoft.azure.management.Azure)

Example 97 with Azure

use of com.microsoft.azure.management.Azure in project azure-tools-for-java by Microsoft.

the class WebAppUtils method createAppService.

public static WebApp createAppService(IProgressIndicator progressIndicator, CreateAppServiceModel model) throws IOException, WebAppException, InterruptedException, AzureCmdException {
    AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
    // not signed in
    if (azureManager == null) {
        return null;
    }
    Azure azure = azureManager.getAzure(model.subscriptionDetail.getSubscriptionId());
    AppServicePlan appServicePlan = null;
    if (model.isAppServicePlanCreateNew) {
        AppServicePlan.DefinitionStages.WithGroup ds1 = azure.appServices().appServicePlans().define(model.appServicePlanNameCreateNew).withRegion(model.appServicePlanLocationCreateNew.name());
        AppServicePlan.DefinitionStages.WithPricingTier ds2;
        if (model.isResourceGroupCreateNew) {
            ds2 = ds1.withNewResourceGroup(model.resourceGroupNameCreateNew);
        } else {
            ds2 = ds1.withExistingResourceGroup(model.resourceGroup);
        }
        appServicePlan = ds2.withPricingTier(model.appServicePricingTierCreateNew).withOperatingSystem(OperatingSystem.WINDOWS).create();
    } else {
        appServicePlan = model.appServicePlan;
    }
    WebApp.DefinitionStages.Blank definitionStages = azure.webApps().define(model.webAppName);
    WebAppBase.DefinitionStages.WithCreate<WebApp> withCreate;
    WebApp.DefinitionStages.ExistingWindowsPlanWithGroup ds1 = definitionStages.withExistingWindowsPlan(appServicePlan);
    if (model.isResourceGroupCreateNew) {
        withCreate = ds1.withNewResourceGroup(model.resourceGroupNameCreateNew);
    } else {
        withCreate = ds1.withExistingResourceGroup(model.resourceGroup);
    }
    if (model.jdkDownloadUrl == null) {
        // no custom jdk
        withCreate = withCreate.withJavaVersion(JavaVersion.JAVA_8_NEWEST).withWebContainer(model.webContainer);
    }
    WebApp myWebApp = withCreate.create();
    if (model.jdkDownloadUrl != null) {
        progressIndicator.setText("Deploying custom jdk...");
        WebAppUtils.deployCustomJdk(myWebApp, model.jdkDownloadUrl, model.webContainer, progressIndicator);
    }
    // update cache
    if (model.isResourceGroupCreateNew) {
        ResourceGroup rg = azure.resourceGroups().getByName(model.resourceGroupNameCreateNew);
        if (rg == null) {
            throw new AzureCmdException(String.format("azure.resourceGroups().getByName(%s) returned null"), model.resourceGroupNameCreateNew);
        }
        AzureModelController.addNewResourceGroup(model.subscriptionDetail, rg);
        AzureModelController.addNewWebAppToJustCreatedResourceGroup(rg, myWebApp);
        if (model.isAppServicePlanCreateNew) {
            AzureModelController.addNewAppServicePlanToJustCreatedResourceGroup(rg, appServicePlan);
        } else {
            // add empty list
            AzureModelController.addNewAppServicePlanToJustCreatedResourceGroup(rg, null);
        }
    } else {
        ResourceGroup rg = model.resourceGroup;
        AzureModelController.addNewWebAppToExistingResourceGroup(rg, myWebApp);
        if (model.isAppServicePlanCreateNew) {
            //AppServicePlan asp = azure.appServices().appServicePlans().getById(myWebApp.appServicePlanId());
            AzureModelController.addNewAppServicePlanToExistingResourceGroup(rg, appServicePlan);
        }
    }
    return myWebApp;
}
Also used : Azure(com.microsoft.azure.management.Azure) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup)

Example 98 with Azure

use of com.microsoft.azure.management.Azure 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();
                    }
                });
            }
        });
    }
}
Also used : KnownDockerVirtualMachineSizes(com.microsoft.azure.docker.model.KnownDockerVirtualMachineSizes) VirtualMachineSize(com.microsoft.azure.management.compute.VirtualMachineSize) Azure(com.microsoft.azure.management.Azure) PagedList(com.microsoft.azure.PagedList) Comparator(java.util.Comparator)

Example 99 with Azure

use of com.microsoft.azure.management.Azure in project azure-tools-for-java by Microsoft.

the class AzureSelectDockerWizard method createDockerContainerDeployTask.

public void createDockerContainerDeployTask(IProject project, AzureDockerImageInstance dockerImageInstance, AzureDockerHostsManager dockerManager) {
    String url = AzureDockerUtils.getUrl(dockerImageInstance);
    String deploymentName = url;
    String jobDescription = String.format("Publishing %s as Docker Container", new File(dockerImageInstance.artifactPath).getName());
    AzureDeploymentProgressNotification.createAzureDeploymentProgressNotification(deploymentName, jobDescription);
    Map<String, String> postEventProperties = new HashMap<String, String>();
    postEventProperties.put("DockerFileOption", dockerImageInstance.predefinedDockerfile);
    Job createDockerHostJob = new Job(jobDescription) {

        @Override
        protected IStatus run(IProgressMonitor progressMonitor) {
            try {
                // Setup Azure Console and Azure Activity Log Window notifications
                MessageConsole console = com.microsoft.azuretools.core.Activator.findConsole(com.microsoft.azuretools.core.Activator.CONSOLE_NAME);
                console.activate();
                final MessageConsoleStream azureConsoleOut = console.newMessageStream();
                progressMonitor.beginTask("start task", 100);
                //		            com.microsoft.azuretools.core.Activator.removeUnNecessaryListener();
                DeploymentEventListener undeployListnr = new DeploymentEventListener() {

                    @Override
                    public void onDeploymentStep(DeploymentEventArgs args) {
                        progressMonitor.subTask(args.getDeployMessage());
                        progressMonitor.worked(args.getDeployCompleteness());
                        azureConsoleOut.println(String.format("%s: %s", deploymentName, args.getDeployMessage()));
                    }
                };
                com.microsoft.azuretools.core.Activator.getDefault().addDeploymentEventListener(undeployListnr);
                com.microsoft.azuretools.core.Activator.depEveList.add(undeployListnr);
                // Start the real job here
                String msg = String.format("Publishing %s to Docker host %s ...", new File(dockerImageInstance.artifactPath).getName(), dockerImageInstance.host.name);
                AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 0, msg);
                msg = "Connecting to Azure...";
                AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 5, msg);
                AzureManager azureAuthManager = AuthMethodManager.getInstance().getAzureManager();
                // not signed in
                if (azureAuthManager == null) {
                    throw new RuntimeException("User not signed in");
                }
                AzureDockerHostsManager dockerManager = AzureDockerHostsManager.getAzureDockerHostsManagerEmpty(azureAuthManager);
                Azure azureClient = dockerManager.getSubscriptionsMap().get(dockerImageInstance.host.sid).azureClient;
                if (progressMonitor.isCanceled()) {
                    displayWarningOnCreateDockerContainerDeployTask(this, progressMonitor, deploymentName);
                    return Status.CANCEL_STATUS;
                }
                if (dockerImageInstance.hasNewDockerHost) {
                    msg = String.format("Creating new virtual machine %s ...", dockerImageInstance.host.name);
                    AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 20, msg);
                    AzureDockerUIResources.printDebugMessage(this, "Creating new virtual machine: " + new Date().toString());
                    AzureDockerVMOps.createDockerHostVM(azureClient, dockerImageInstance.host);
                    AzureDockerUIResources.printDebugMessage(this, "Done creating new virtual machine: " + new Date().toString());
                    if (progressMonitor.isCanceled()) {
                        displayWarningOnCreateDockerContainerDeployTask(this, progressMonitor, deploymentName);
                        return Status.CANCEL_STATUS;
                    }
                    msg = String.format("Updating Docker hosts ...");
                    AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 5, msg);
                    AzureDockerUIResources.printDebugMessage(this, "Getting the new docker host details: " + new Date().toString());
                    //			            dockerManager.refreshDockerHostDetails();
                    VirtualMachine vm = azureClient.virtualMachines().getByResourceGroup(dockerImageInstance.host.hostVM.resourceGroupName, dockerImageInstance.host.hostVM.name);
                    if (vm != null) {
                        DockerHost updatedHost = AzureDockerVMOps.getDockerHost(vm, dockerManager.getDockerVaultsMap());
                        if (updatedHost != null) {
                            dockerImageInstance.host.hostVM = updatedHost.hostVM;
                            dockerImageInstance.host.apiUrl = updatedHost.apiUrl;
                        }
                    }
                    AzureDockerUIResources.printDebugMessage(this, "Done getting new Docker host details: " + new Date().toString());
                    msg = String.format("Waiting for virtual machine to be up %s ...", dockerImageInstance.host.name);
                    AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 10, msg);
                    AzureDockerUIResources.printDebugMessage(this, "Waiting for virtual machine to be up: " + new Date().toString());
                    AzureDockerVMOps.waitForVirtualMachineStartup(azureClient, dockerImageInstance.host);
                    AzureDockerUIResources.printDebugMessage(this, "Done Waiting for virtual machine to be up: " + new Date().toString());
                    if (progressMonitor.isCanceled()) {
                        displayWarningOnCreateDockerContainerDeployTask(this, progressMonitor, deploymentName);
                        return Status.CANCEL_STATUS;
                    }
                    msg = String.format("Configuring Docker service for %s ...", dockerImageInstance.host.name);
                    AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 10, msg);
                    AzureDockerUIResources.printDebugMessage(this, "Configuring Docker host: " + new Date().toString());
                    AzureDockerVMOps.installDocker(dockerImageInstance.host);
                    AzureDockerUIResources.printDebugMessage(this, "Done configuring Docker host: " + new Date().toString());
                    msg = String.format("Updating Docker hosts ...");
                    AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 5, msg);
                    AzureDockerUIResources.printDebugMessage(this, "Refreshing docker hosts: " + new Date().toString());
                    //			            dockerManager.refreshDockerHostDetails();
                    vm = azureClient.virtualMachines().getByResourceGroup(dockerImageInstance.host.hostVM.resourceGroupName, dockerImageInstance.host.hostVM.name);
                    if (vm != null) {
                        DockerHost updatedHost = AzureDockerVMOps.getDockerHost(vm, dockerManager.getDockerVaultsMap());
                        if (updatedHost != null) {
                            updatedHost.sid = dockerImageInstance.host.sid;
                            updatedHost.hostVM.sid = dockerImageInstance.host.hostVM.sid;
                            if (updatedHost.certVault == null) {
                                updatedHost.certVault = dockerImageInstance.host.certVault;
                                updatedHost.hasPwdLogIn = dockerImageInstance.host.hasPwdLogIn;
                                updatedHost.hasSSHLogIn = dockerImageInstance.host.hasSSHLogIn;
                                updatedHost.isTLSSecured = dockerImageInstance.host.isTLSSecured;
                            }
                            dockerManager.addDockerHostDetails(updatedHost);
                            if (AzureUIRefreshCore.listeners != null) {
                                AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.ADD, updatedHost));
                            }
                        }
                    }
                    AzureDockerUIResources.printDebugMessage(this, "Done refreshing Docker hosts: " + new Date().toString());
                    AzureDockerUIResources.printDebugMessage(this, "Finished setting up Docker host");
                } else {
                    msg = String.format("Using virtual machine %s ...", dockerImageInstance.host.name);
                    AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 55, msg);
                }
                if (progressMonitor.isCanceled()) {
                    displayWarningOnCreateDockerContainerDeployTask(this, progressMonitor, deploymentName);
                    return Status.CANCEL_STATUS;
                }
                if (dockerImageInstance.host.session == null) {
                    AzureDockerUIResources.printDebugMessage(this, "Opening a remote connection to the Docker host: " + new Date().toString());
                    dockerImageInstance.host.session = AzureDockerSSHOps.createLoginInstance(dockerImageInstance.host);
                    AzureDockerUIResources.printDebugMessage(this, "Done opening a remote connection to the Docker host: " + new Date().toString());
                }
                if (dockerImageInstance.hasNewDockerHost) {
                    if (dockerImageInstance.host.certVault != null && dockerImageInstance.host.certVault.hostName != null) {
                        AzureDockerUIResources.createDockerKeyVault(dockerImageInstance.host, dockerManager);
                    }
                }
                msg = String.format("Uploading Dockerfile and artifact %s on %s ...", dockerImageInstance.artifactName, dockerImageInstance.host.name);
                AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 15, msg);
                AzureDockerUIResources.printDebugMessage(this, "Uploading Dockerfile and artifact: " + new Date().toString());
                AzureDockerVMOps.uploadDockerfileAndArtifact(dockerImageInstance, dockerImageInstance.host.session);
                AzureDockerUIResources.printDebugMessage(this, "Uploading Dockerfile and artifact: " + new Date().toString());
                if (progressMonitor.isCanceled()) {
                    displayWarningOnCreateDockerContainerDeployTask(this, progressMonitor, deploymentName);
                    return Status.CANCEL_STATUS;
                }
                msg = String.format("Creating Docker image %s on %s ...", dockerImageInstance.dockerImageName, dockerImageInstance.host.name);
                AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 15, msg);
                AzureDockerUIResources.printDebugMessage(this, "Creating a Docker image to the Docker host: " + new Date().toString());
                AzureDockerImageOps.create(dockerImageInstance, dockerImageInstance.host.session);
                AzureDockerUIResources.printDebugMessage(this, "Done creating a Docker image to the Docker host: " + new Date().toString());
                if (progressMonitor.isCanceled()) {
                    displayWarningOnCreateDockerContainerDeployTask(this, progressMonitor, deploymentName);
                    return Status.CANCEL_STATUS;
                }
                msg = String.format("Creating Docker container %s for image %s on %s ...", dockerImageInstance.dockerContainerName, dockerImageInstance.dockerImageName, dockerImageInstance.host.name);
                AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 5, msg);
                AzureDockerUIResources.printDebugMessage(this, "Creating a Docker container to the Docker host: " + new Date().toString());
                AzureDockerContainerOps.create(dockerImageInstance, dockerImageInstance.host.session);
                AzureDockerUIResources.printDebugMessage(this, "Done creating a Docker container to the Docker host: " + new Date().toString());
                if (progressMonitor.isCanceled()) {
                    displayWarningOnCreateDockerContainerDeployTask(this, progressMonitor, deploymentName);
                    return Status.CANCEL_STATUS;
                }
                msg = String.format("Starting Docker container %s for image %s on %s ...", dockerImageInstance.dockerContainerName, dockerImageInstance.dockerImageName, dockerImageInstance.host.name);
                AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 5, msg);
                AzureDockerUIResources.printDebugMessage(this, "Starting a Docker container to the Docker host: " + new Date().toString());
                AzureDockerContainerOps.start(dockerImageInstance, dockerImageInstance.host.session);
                AzureDockerUIResources.printDebugMessage(this, "Done starting a Docker container to the Docker host: " + new Date().toString());
                if (progressMonitor.isCanceled()) {
                    displayWarningOnCreateDockerContainerDeployTask(this, progressMonitor, deploymentName);
                    return Status.CANCEL_STATUS;
                }
                AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, url, 100, "");
                try {
                    com.microsoft.azuretools.core.Activator.depEveList.remove(undeployListnr);
                    com.microsoft.azuretools.core.Activator.removeDeploymentEventListener(undeployListnr);
                } catch (Exception ignored) {
                }
                progressMonitor.done();
                AppInsightsClient.create("Deploy as DockerContainer", "", postEventProperties);
                return Status.OK_STATUS;
            } catch (Exception e) {
                String msg = "An error occurred while attempting to publish a Docker container!" + "\n" + e.getMessage();
                log.log(Level.SEVERE, "createDockerContainerDeployTask: " + msg, e);
                e.printStackTrace();
                AzureDeploymentProgressNotification.notifyProgress(this, deploymentName, null, -1, "Error: " + e.getMessage());
                return Status.CANCEL_STATUS;
            }
        }
    };
    createDockerHostJob.schedule();
}
Also used : Azure(com.microsoft.azure.management.Azure) MessageConsole(org.eclipse.ui.console.MessageConsole) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) HashMap(java.util.HashMap) DeploymentEventArgs(com.microsoft.azuretools.azurecommons.deploy.DeploymentEventArgs) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) Date(java.util.Date) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) EditableDockerHost(com.microsoft.azure.docker.model.EditableDockerHost) DockerHost(com.microsoft.azure.docker.model.DockerHost) DeploymentEventListener(com.microsoft.azuretools.azurecommons.deploy.DeploymentEventListener) Job(org.eclipse.core.runtime.jobs.Job) AzureDockerHostsManager(com.microsoft.azure.docker.AzureDockerHostsManager) File(java.io.File) VirtualMachine(com.microsoft.azure.management.compute.VirtualMachine)

Example 100 with Azure

use of com.microsoft.azure.management.Azure in project azure-tools-for-java by Microsoft.

the class AzureDockerUIResources method createDockerKeyVault.

public static void createDockerKeyVault(DockerHost dockerHost, AzureDockerHostsManager dockerManager) {
    Job createDockerHostJob = new Job(String.format("Creating Azure Key Vault %s for %s", dockerHost.certVault.name, dockerHost.name)) {

        @Override
        protected IStatus run(IProgressMonitor progressMonitor) {
            progressMonitor.beginTask("start task", 100);
            try {
                progressMonitor.subTask(String.format("Reading subscription details for Docker host %s ...", dockerHost.apiUrl));
                progressMonitor.worked(5);
                Azure azureClient = dockerManager.getSubscriptionsMap().get(dockerHost.sid).azureClient;
                KeyVaultClient keyVaultClient = dockerManager.getSubscriptionsMap().get(dockerHost.sid).keyVaultClient;
                if (progressMonitor.isCanceled()) {
                    progressMonitor.done();
                    return Status.CANCEL_STATUS;
                }
                String retryMsg = "Create";
                int retries = 5;
                AzureDockerCertVault certVault = null;
                do {
                    progressMonitor.subTask(String.format("%s new key vault %s ...", retryMsg, dockerHost.certVault.name));
                    progressMonitor.worked(15 + 15 * retries);
                    if (AzureDockerUtils.DEBUG)
                        System.out.println(retryMsg + " new Docker key vault: " + new Date().toString());
                    AzureDockerCertVaultOps.createOrUpdateVault(azureClient, dockerHost.certVault, keyVaultClient);
                    if (AzureDockerUtils.DEBUG)
                        System.out.println("Done creating new key vault: " + new Date().toString());
                    if (progressMonitor.isCanceled()) {
                        progressMonitor.done();
                        return Status.CANCEL_STATUS;
                    }
                    certVault = AzureDockerCertVaultOps.getVault(azureClient, dockerHost.certVault.name, dockerHost.certVault.resourceGroupName, keyVaultClient);
                    retries++;
                    retryMsg = "Retry creating";
                } while (// Retry couple times
                retries < 5 && (certVault == null || certVault.vmUsername == null));
                progressMonitor.subTask("Updating key vaults ...");
                progressMonitor.worked(95);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Refreshing key vaults: " + new Date().toString());
                dockerManager.refreshDockerVaults();
                dockerManager.refreshDockerVaultDetails();
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done refreshing key vaults: " + new Date().toString());
                //					progressMonitor.subTask("");
                //					progressMonitor.worked(1);
                //					if (progressMonitor.isCanceled()) {
                //						if (displayWarningOnCreateKeyVaultCancelAction() == 0) {
                //							progressMonitor.done();
                //							return Status.CANCEL_STATUS;
                //						}
                //					}
                //
                progressMonitor.done();
                return Status.OK_STATUS;
            } catch (Exception e) {
                String msg = "An error occurred while attempting to create a new Azure Key Vault." + "\n" + e.getMessage();
                log.log(Level.SEVERE, "createDockerKeyVault: " + msg, e);
                e.printStackTrace();
                PluginUtil.displayErrorDialog(Display.getDefault().getActiveShell(), "Error Creating Azure Key Vault " + dockerHost.certVault.name, "An error occurred while attempting to create a new Azure Key Vault." + "\n" + e.getMessage());
                return Status.CANCEL_STATUS;
            }
        }
    };
    createDockerHostJob.schedule();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Azure(com.microsoft.azure.management.Azure) KeyVaultClient(com.microsoft.azure.keyvault.KeyVaultClient) AzureDockerCertVault(com.microsoft.azure.docker.model.AzureDockerCertVault) Job(org.eclipse.core.runtime.jobs.Job) Date(java.util.Date)

Aggregations

Azure (com.microsoft.azure.management.Azure)144 File (java.io.File)75 ArrayList (java.util.ArrayList)20 HashMap (java.util.HashMap)20 ExecutorService (java.util.concurrent.ExecutorService)17 ComputeService (com.vmware.photon.controller.model.resources.ComputeService)16 DiskService (com.vmware.photon.controller.model.resources.DiskService)16 ComputeEnumerateResourceRequest (com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest)15 EnumerationAction (com.vmware.photon.controller.model.adapterapi.EnumerationAction)15 AzureUriPaths (com.vmware.photon.controller.model.adapters.azure.AzureUriPaths)15 AzureConstants (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants)15 AzureResourceType (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AzureResourceType)15 AzureConstants.getQueryResultLimit (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.getQueryResultLimit)15 AzureDeferredResultServiceCallback (com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback)15 Default (com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback.Default)15 AzureSdkClients (com.vmware.photon.controller.model.adapters.azure.utils.AzureSdkClients)15 AzureUtils (com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils)15 AzureUtils.getResourceGroupName (com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.getResourceGroupName)15 AdapterUtils (com.vmware.photon.controller.model.adapters.util.AdapterUtils)15 ComputeEnumerateAdapterRequest (com.vmware.photon.controller.model.adapters.util.ComputeEnumerateAdapterRequest)15