Search in sources :

Example 1 with AzureUIRefreshEvent

use of com.microsoft.azuretools.utils.AzureUIRefreshEvent in project azure-tools-for-java by Microsoft.

the class AzureNewDockerWizard method createHost.

public void createHost() {
    AzureDockerPreferredSettings dockerPreferredSettings = dockerManager.getDockerPreferredSettings();
    if (dockerPreferredSettings == null) {
        dockerPreferredSettings = new AzureDockerPreferredSettings();
    }
    dockerPreferredSettings.dockerApiName = newHost.apiUrl;
    dockerPreferredSettings.region = newHost.hostVM.region;
    dockerPreferredSettings.vmSize = newHost.hostVM.vmSize;
    dockerPreferredSettings.vmOS = newHost.hostOSType.name();
    dockerManager.setDockerPreferredSettings(dockerPreferredSettings);
    Job createDockerHostJob = new Job("Creating Docker virtual machine " + newHost.name) {

        @Override
        protected IStatus run(IProgressMonitor progressMonitor) {
            progressMonitor.beginTask("start task", 100);
            try {
                DockerHost dockerHost = newHost;
                progressMonitor.subTask(String.format("Reading subscription details for Docker host %s ...", dockerHost.apiUrl));
                progressMonitor.worked(5);
                Azure azureClient = dockerManager.getSubscriptionsMap().get(dockerHost.sid).azureClient;
                if (progressMonitor.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 0) {
                        progressMonitor.done();
                        return Status.CANCEL_STATUS;
                    }
                }
                progressMonitor.subTask(String.format("Creating new virtual machine %s ...", dockerHost.name));
                progressMonitor.worked(10);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Creating new virtual machine: " + new Date().toString());
                AzureDockerVMOps.createDockerHostVM(azureClient, dockerHost);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done creating new virtual machine: " + new Date().toString());
                if (progressMonitor.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 0) {
                        progressMonitor.done();
                        return Status.CANCEL_STATUS;
                    }
                }
                progressMonitor.subTask("Getting the new Docker virtual machines details...");
                progressMonitor.worked(5);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Getting the new Docker hosts details: " + new Date().toString());
                VirtualMachine vm = azureClient.virtualMachines().getByResourceGroup(dockerHost.hostVM.resourceGroupName, dockerHost.hostVM.name);
                if (vm != null) {
                    DockerHost updatedHost = AzureDockerVMOps.getDockerHost(vm, dockerManager.getDockerVaultsMap());
                    if (updatedHost != null) {
                        dockerHost.hostVM = updatedHost.hostVM;
                        dockerHost.apiUrl = updatedHost.apiUrl;
                    }
                }
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done getting the new Docker hosts details: " + new Date().toString());
                if (progressMonitor.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 0) {
                        progressMonitor.done();
                        return Status.CANCEL_STATUS;
                    }
                }
                progressMonitor.subTask(String.format("Waiting for virtual machine %s to be up...", dockerHost.name));
                progressMonitor.worked(55);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Waiting for virtual machine to be up: " + new Date().toString());
                AzureDockerVMOps.waitForVirtualMachineStartup(azureClient, dockerHost);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done Waiting for virtual machine to be up: " + new Date().toString());
                if (progressMonitor.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 0) {
                        progressMonitor.done();
                        return Status.CANCEL_STATUS;
                    }
                }
                progressMonitor.subTask(String.format("Configuring Docker service for %s ...", dockerHost.apiUrl));
                progressMonitor.worked(15);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Configuring Docker host: " + new Date().toString());
                AzureDockerVMOps.installDocker(dockerHost);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done configuring Docker host: " + new Date().toString());
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Finished setting up Docker host");
                if (progressMonitor.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 0) {
                        progressMonitor.done();
                        return Status.CANCEL_STATUS;
                    }
                }
                if (dockerHost.certVault != null && dockerHost.certVault.hostName != null) {
                    AzureDockerUIResources.createDockerKeyVault(dockerHost, dockerManager);
                }
                progressMonitor.subTask("Refreshing the Docker virtual machines details...");
                progressMonitor.worked(5);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Refreshing Docker hosts details: " + new Date().toString());
                vm = azureClient.virtualMachines().getByResourceGroup(dockerHost.hostVM.resourceGroupName, dockerHost.hostVM.name);
                if (vm != null) {
                    DockerHost updatedHost = AzureDockerVMOps.getDockerHost(vm, dockerManager.getDockerVaultsMap());
                    if (updatedHost != null) {
                        updatedHost.sid = dockerHost.sid;
                        updatedHost.hostVM.sid = dockerHost.hostVM.sid;
                        if (updatedHost.certVault == null) {
                            updatedHost.certVault = dockerHost.certVault;
                            updatedHost.hasPwdLogIn = dockerHost.hasPwdLogIn;
                            updatedHost.hasSSHLogIn = dockerHost.hasSSHLogIn;
                            updatedHost.isTLSSecured = dockerHost.isTLSSecured;
                        }
                        dockerManager.addDockerHostDetails(updatedHost);
                        if (AzureUIRefreshCore.listeners != null) {
                            AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.ADD, updatedHost));
                        }
                    }
                }
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done refreshing Docker hosts details: " + new Date().toString());
                if (progressMonitor.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 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 Docker host." + "\n" + e.getMessage();
                log.log(Level.SEVERE, "createHost: " + msg, e);
                e.printStackTrace();
                return Status.CANCEL_STATUS;
            }
        //				progressMonitor.subTask("");
        //				progressMonitor.worked(1);
        //				if (progressMonitor.isCanceled()) {
        //					if (displayWarningOnCreateHostCancelAction() == 0) {
        //						progressMonitor.done();
        //						return Status.CANCEL_STATUS;
        //					}
        //				}
        //
        //				for (int i = 0; i < 10; i++) {
        //					try {
        //						Thread.sleep(3000);
        //						progressMonitor.subTask("doing " + i);
        //						// Report that 10 units are done
        //						progressMonitor.worked(10);
        //					} catch (InterruptedException e1) {
        //						e1.printStackTrace();
        //					}
        //				}
        }
    };
    createDockerHostJob.schedule();
//    	DefaultLoader.getIdeHelper().runInBackground(null, "Creating Docker virtual machine " + newHost.name + "...", false, true, "Creating Docker virtual machine " + newHost.name + "...", new Runnable() {
//            @Override
//            public void run() {
//                DefaultLoader.getIdeHelper().invokeLater(new Runnable() {
//                    @Override
//                    public void run() {
//                    	
//                    }
//                });
//            }
//        });
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Azure(com.microsoft.azure.management.Azure) DockerHost(com.microsoft.azure.docker.model.DockerHost) Job(org.eclipse.core.runtime.jobs.Job) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) AzureDockerPreferredSettings(com.microsoft.azure.docker.model.AzureDockerPreferredSettings) Date(java.util.Date) VirtualMachine(com.microsoft.azure.management.compute.VirtualMachine)

Example 2 with AzureUIRefreshEvent

use of com.microsoft.azuretools.utils.AzureUIRefreshEvent in project azure-tools-for-java by Microsoft.

the class AzureNewDockerWizardDialog method create.

public void create() {
    DockerHost dockerHost = model.getDockerHost();
    AzureDockerPreferredSettings dockerPreferredSettings = model.getDockerManager().getDockerPreferredSettings();
    if (dockerPreferredSettings == null) {
        dockerPreferredSettings = new AzureDockerPreferredSettings();
    }
    dockerPreferredSettings.dockerApiName = dockerHost.apiUrl;
    dockerPreferredSettings.region = dockerHost.hostVM.region;
    dockerPreferredSettings.vmSize = dockerHost.hostVM.vmSize;
    dockerPreferredSettings.vmOS = dockerHost.hostOSType.name();
    model.getDockerManager().setDockerPreferredSettings(dockerPreferredSettings);
    ProgressManager.getInstance().run(new Task.Backgroundable(model.getProject(), "Creating Docker Host on Azure...", true) {

        @Override
        public void run(ProgressIndicator progressIndicator) {
            try {
                progressIndicator.setFraction(.05);
                progressIndicator.setText2(String.format("Reading subscription details for Docker host %s ...", dockerHost.apiUrl));
                AzureDockerHostsManager dockerManager = model.getDockerManager();
                Azure azureClient = dockerManager.getSubscriptionsMap().get(dockerHost.sid).azureClient;
                if (progressIndicator.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 1) {
                        return;
                    }
                }
                progressIndicator.setFraction(.10);
                progressIndicator.setText2(String.format("Creating new virtual machine %s ...", dockerHost.name));
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Creating new virtual machine: " + new Date().toString());
                AzureDockerVMOps.createDockerHostVM(azureClient, dockerHost);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done creating new virtual machine: " + new Date().toString());
                if (progressIndicator.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 1) {
                        return;
                    }
                }
                progressIndicator.setFraction(.60);
                progressIndicator.setIndeterminate(true);
                progressIndicator.setText2("Getting the new Docker virtual machines details...");
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Getting the new Docker virtual machines details: " + new Date().toString());
                // dockerManager.refreshDockerHostDetails();
                VirtualMachine vm = azureClient.virtualMachines().getByResourceGroup(dockerHost.hostVM.resourceGroupName, dockerHost.hostVM.name);
                if (vm != null) {
                    DockerHost updatedHost = AzureDockerVMOps.getDockerHost(vm, dockerManager.getDockerVaultsMap());
                    if (updatedHost != null) {
                        dockerHost.hostVM = updatedHost.hostVM;
                        dockerHost.apiUrl = updatedHost.apiUrl;
                    }
                }
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done getting the new Docker virtual machines details: " + new Date().toString());
                if (progressIndicator.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 1) {
                        return;
                    }
                }
                progressIndicator.setFraction(.65);
                progressIndicator.setText2(String.format("Waiting for virtual machine %s to be up...", dockerHost.name));
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Waiting for virtual machine to be up: " + new Date().toString());
                AzureDockerVMOps.waitForVirtualMachineStartup(azureClient, dockerHost);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done Waiting for virtual machine to be up: " + new Date().toString());
                if (progressIndicator.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 1) {
                        return;
                    }
                }
                progressIndicator.setFraction(.75);
                progressIndicator.setText2(String.format("Configuring Docker service for %s ...", dockerHost.apiUrl));
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Configuring Docker host: " + new Date().toString());
                AzureDockerVMOps.installDocker(dockerHost);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done configuring Docker host: " + new Date().toString());
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Finished setting up Docker host");
                if (progressIndicator.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 1) {
                        return;
                    }
                }
                if (dockerHost.certVault != null && dockerHost.certVault.hostName != null) {
                    AzureDockerUIResources.createDockerKeyVault(model.getProject(), dockerHost, dockerManager);
                }
                progressIndicator.setFraction(.90);
                progressIndicator.setIndeterminate(true);
                progressIndicator.setText2("Refreshing the Docker virtual machines details...");
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Refreshing Docker hosts details: " + new Date().toString());
                // dockerManager.refreshDockerHostDetails();
                vm = azureClient.virtualMachines().getByResourceGroup(dockerHost.hostVM.resourceGroupName, dockerHost.hostVM.name);
                if (vm != null) {
                    DockerHost updatedHost = AzureDockerVMOps.getDockerHost(vm, dockerManager.getDockerVaultsMap());
                    if (updatedHost != null) {
                        updatedHost.sid = dockerHost.sid;
                        updatedHost.hostVM.sid = dockerHost.hostVM.sid;
                        if (updatedHost.certVault == null) {
                            updatedHost.certVault = dockerHost.certVault;
                            updatedHost.hasPwdLogIn = dockerHost.hasPwdLogIn;
                            updatedHost.hasSSHLogIn = dockerHost.hasSSHLogIn;
                            updatedHost.isTLSSecured = dockerHost.isTLSSecured;
                        }
                        dockerManager.addDockerHostDetails(updatedHost);
                        if (AzureUIRefreshCore.listeners != null) {
                            AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.ADD, updatedHost));
                        }
                    }
                }
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done refreshing Docker hosts details: " + new Date().toString());
                if (progressIndicator.isCanceled()) {
                    if (displayWarningOnCreateHostCancelAction() == 1) {
                        return;
                    }
                }
                progressIndicator.setFraction(1);
                progressIndicator.setIndeterminate(true);
            } catch (Exception e) {
                String msg = "An error occurred while attempting to create Docker host." + "\n" + e.getMessage();
                LOGGER.error("Failed to Create Docker Host", e);
                PluginUtil.displayErrorDialogInAWTAndLog("Failed to Create Docker Host", msg, e);
            }
        }
    });
}
Also used : Task(com.intellij.openapi.progress.Task) Azure(com.microsoft.azure.management.Azure) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) AzureDockerPreferredSettings(com.microsoft.azure.docker.model.AzureDockerPreferredSettings) Date(java.util.Date) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) DockerHost(com.microsoft.azure.docker.model.DockerHost) AzureDockerHostsManager(com.microsoft.azure.docker.AzureDockerHostsManager) VirtualMachine(com.microsoft.azure.management.compute.VirtualMachine)

Example 3 with AzureUIRefreshEvent

use of com.microsoft.azuretools.utils.AzureUIRefreshEvent in project azure-tools-for-java by Microsoft.

the class PublishWebAppOnLinuxDialog method execute.

private void execute() {
    Operation operation = TelemetryManager.createOperation(WEBAPP, DEPLOY_WEBAPP_CONTAINER);
    Observable.fromCallable(() -> {
        ConsoleLogger.info("Starting job ...  ");
        operation.start();
        if (basePath == null) {
            ConsoleLogger.error("Project base path is null.");
            throw new FileNotFoundException("Project base path is null.");
        }
        // locate artifact to specified location
        String targetFilePath = model.getTargetPath();
        ConsoleLogger.info(String.format("Locating artifact ... [%s]", targetFilePath));
        // validate dockerfile
        Path targetDockerfile = Paths.get(model.getDockerFilePath());
        ConsoleLogger.info(String.format("Validating dockerfile ... [%s]", targetDockerfile));
        if (!targetDockerfile.toFile().exists()) {
            throw new FileNotFoundException("Dockerfile not found.");
        }
        // replace placeholder if exists
        String content = new String(Files.readAllBytes(targetDockerfile));
        content = content.replaceAll(Constant.DOCKERFILE_ARTIFACT_PLACEHOLDER, Paths.get(basePath).toUri().relativize(Paths.get(targetFilePath).toUri()).getPath());
        Files.write(targetDockerfile, content.getBytes());
        // build image
        PrivateRegistryImageSetting acrInfo = model.getPrivateRegistryImageSetting();
        ConsoleLogger.info(String.format("Building image ...  [%s]", acrInfo.getImageTagWithServerUrl()));
        DockerClient docker = DefaultDockerClient.fromEnv().build();
        DockerUtil.ping(docker);
        DockerUtil.buildImage(docker, acrInfo.getImageTagWithServerUrl(), targetDockerfile.getParent(), targetDockerfile.getFileName().toString(), new DockerProgressHandler());
        // push to ACR
        ConsoleLogger.info(String.format("Pushing to ACR ... [%s] ", acrInfo.getServerUrl()));
        DockerUtil.pushImage(docker, acrInfo.getServerUrl(), acrInfo.getUsername(), acrInfo.getPassword(), acrInfo.getImageTagWithServerUrl(), new DockerProgressHandler());
        // deploy
        if (model.isCreatingNewWebAppOnLinux()) {
            // create new WebApp
            ConsoleLogger.info(String.format("Creating new WebApp ... [%s]", model.getWebAppName()));
            IWebApp app = AzureWebAppMvpModel.getInstance().createAzureWebAppWithPrivateRegistryImage(model);
            if (app != null && app.name() != null) {
                ConsoleLogger.info(String.format("URL:  http://%s.azurewebsites.net/", app.name()));
                AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.REFRESH, null));
            }
        } else {
            // update WebApp
            ConsoleLogger.info(String.format("Updating WebApp ... [%s]", model.getWebAppName()));
            IWebApp app = AzureWebAppMvpModel.getInstance().updateWebAppOnDocker(model.getWebAppId(), acrInfo);
            if (app != null && app.name() != null) {
                ConsoleLogger.info(String.format("URL:  http://%s.azurewebsites.net/", app.name()));
            }
        }
        return null;
    }).subscribeOn(SchedulerProviderFactory.getInstance().getSchedulerProvider().io()).subscribe(ret -> {
        ConsoleLogger.info("Job done");
        if (model.isCreatingNewWebAppOnLinux() && AzureUIRefreshCore.listeners != null) {
            AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.REFRESH, null));
        }
        sendTelemetry(true, null);
        operation.complete();
    }, err -> {
        err.printStackTrace();
        ConsoleLogger.error(err.getMessage());
        EventUtil.logError(operation, ErrorType.systemError, new Exception(err), null, null);
        operation.complete();
        sendTelemetry(false, err.getMessage());
    });
}
Also used : Path(java.nio.file.Path) PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) DockerProgressHandler(com.microsoft.azuretools.container.DockerProgressHandler) DockerClient(com.spotify.docker.client.DockerClient) DefaultDockerClient(com.spotify.docker.client.DefaultDockerClient) FileNotFoundException(java.io.FileNotFoundException) Operation(com.microsoft.azuretools.telemetrywrapper.Operation) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) InvalidFormDataException(com.microsoft.azuretools.azurecommons.exceptions.InvalidFormDataException) FileNotFoundException(java.io.FileNotFoundException) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)

Example 4 with AzureUIRefreshEvent

use of com.microsoft.azuretools.utils.AzureUIRefreshEvent in project azure-tools-for-java by Microsoft.

the class WebAppRunState method onSuccess.

@Override
@AzureOperation(name = "webapp.complete_starting.state", type = AzureOperation.Type.ACTION)
protected void onSuccess(IAppService result, @NotNull RunProcessHandler processHandler) {
    if (webAppSettingModel.isCreatingNew() && AzureUIRefreshCore.listeners != null) {
        AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.REFRESH, result));
    }
    updateConfigurationDataModel(result);
    int indexOfDot = webAppSettingModel.getTargetName().lastIndexOf(".");
    final String fileName = webAppSettingModel.getTargetName().substring(0, indexOfDot);
    final String fileType = webAppSettingModel.getTargetName().substring(indexOfDot + 1);
    final String url = getUrl(result, fileName, fileType);
    processHandler.setText(message("appService.deploy.hint.succeed"));
    processHandler.setText("URL: " + url);
    if (webAppSettingModel.isOpenBrowserAfterDeployment()) {
        openWebAppInBrowser(url, processHandler);
    }
    processHandler.notifyComplete();
}
Also used : AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 5 with AzureUIRefreshEvent

use of com.microsoft.azuretools.utils.AzureUIRefreshEvent in project azure-tools-for-java by Microsoft.

the class WebAppOnLinuxDeployState method executeSteps.

@Override
@AzureOperation(name = "docker.deploy_image.state", type = AzureOperation.Type.ACTION)
public IAppService executeSteps(@NotNull RunProcessHandler processHandler, @NotNull Operation operation) throws Exception {
    processHandler.setText("Starting job ...  ");
    final String basePath = project.getBasePath();
    if (basePath == null) {
        processHandler.println("Project base path is null.", ProcessOutputTypes.STDERR);
        throw new FileNotFoundException("Project base path is null.");
    }
    // locate artifact to specified location
    final String targetFilePath = deployModel.getTargetPath();
    processHandler.setText(String.format("Locating artifact ... [%s]", targetFilePath));
    // validate dockerfile
    final Path targetDockerfile = Paths.get(deployModel.getDockerFilePath());
    processHandler.setText(String.format("Validating dockerfile ... [%s]", targetDockerfile));
    if (!targetDockerfile.toFile().exists()) {
        throw new FileNotFoundException("Dockerfile not found.");
    }
    // replace placeholder if exists
    String content = new String(Files.readAllBytes(targetDockerfile));
    content = content.replaceAll(Constant.DOCKERFILE_ARTIFACT_PLACEHOLDER, Paths.get(basePath).toUri().relativize(Paths.get(targetFilePath).toUri()).getPath());
    Files.write(targetDockerfile, content.getBytes());
    // build image
    final PrivateRegistryImageSetting acrInfo = deployModel.getPrivateRegistryImageSetting();
    processHandler.setText(String.format("Building image ...  [%s]", acrInfo.getImageTagWithServerUrl()));
    final DockerClient docker = DefaultDockerClient.fromEnv().build();
    DockerUtil.ping(docker);
    DockerUtil.buildImage(docker, acrInfo.getImageTagWithServerUrl(), targetDockerfile.getParent(), targetDockerfile.getFileName().toString(), new DockerProgressHandler(processHandler));
    // push to ACR
    processHandler.setText(String.format("Pushing to ACR ... [%s] ", acrInfo.getServerUrl()));
    DockerUtil.pushImage(docker, acrInfo.getServerUrl(), acrInfo.getUsername(), acrInfo.getPassword(), acrInfo.getImageTagWithServerUrl(), new DockerProgressHandler(processHandler));
    // deploy
    if (deployModel.isCreatingNewWebAppOnLinux()) {
        // create new WebApp
        processHandler.setText(String.format("Creating new WebApp ... [%s]", deployModel.getWebAppName()));
        final IWebApp app = AzureWebAppMvpModel.getInstance().createAzureWebAppWithPrivateRegistryImage(deployModel);
        if (app != null && app.name() != null) {
            processHandler.setText(String.format("URL:  http://%s.azurewebsites.net/", app.name()));
            updateConfigurationDataModel(app);
            AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.REFRESH, null));
        }
        return app;
    } else {
        // update WebApp
        processHandler.setText(String.format("Updating WebApp ... [%s]", deployModel.getWebAppName()));
        final IWebApp app = AzureWebAppMvpModel.getInstance().updateWebAppOnDocker(deployModel.getWebAppId(), acrInfo);
        if (app != null && app.name() != null) {
            processHandler.setText(String.format("URL:  http://%s.azurewebsites.net/", app.name()));
        }
        return app;
    }
}
Also used : Path(java.nio.file.Path) PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) DockerProgressHandler(com.microsoft.azure.toolkit.intellij.webapp.docker.utils.DockerProgressHandler) DockerClient(com.spotify.docker.client.DockerClient) DefaultDockerClient(com.spotify.docker.client.DefaultDockerClient) FileNotFoundException(java.io.FileNotFoundException) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

AzureUIRefreshEvent (com.microsoft.azuretools.utils.AzureUIRefreshEvent)9 DockerHost (com.microsoft.azure.docker.model.DockerHost)4 Azure (com.microsoft.azure.management.Azure)4 VirtualMachine (com.microsoft.azure.management.compute.VirtualMachine)4 Date (java.util.Date)4 AzureDockerHostsManager (com.microsoft.azure.docker.AzureDockerHostsManager)3 AzureDockerPreferredSettings (com.microsoft.azure.docker.model.AzureDockerPreferredSettings)2 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)2 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 PrivateRegistryImageSetting (com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting)2 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)2 DefaultDockerClient (com.spotify.docker.client.DefaultDockerClient)2 DockerClient (com.spotify.docker.client.DockerClient)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 MalformedURLException (java.net.MalformedURLException)2 Path (java.nio.file.Path)2 HashMap (java.util.HashMap)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Job (org.eclipse.core.runtime.jobs.Job)2