Search in sources :

Example 6 with EditableDockerHost

use of com.microsoft.azure.docker.model.EditableDockerHost in project azure-tools-for-java by Microsoft.

the class ViewDockerHostAction method actionPerformed.

@Override
public void actionPerformed(NodeActionEvent e) {
    dockerHost = dockerManager.getDockerHostForURL(dockerHost.apiUrl);
    AzureViewDockerDialog viewDockerDialog = new AzureViewDockerDialog(project, dockerHost, dockerManager);
    viewDockerDialog.show();
    if (viewDockerDialog.getInternalExitCode() == AzureViewDockerDialog.UPDATE_EXIT_CODE) {
        AzureDockerUIResources.updateDockerHost(project, new EditableDockerHost(dockerHost), dockerManager, true);
    }
}
Also used : AzureViewDockerDialog(com.microsoft.intellij.docker.dialogs.AzureViewDockerDialog) EditableDockerHost(com.microsoft.azure.docker.model.EditableDockerHost)

Example 7 with EditableDockerHost

use of com.microsoft.azure.docker.model.EditableDockerHost in project azure-tools-for-java by Microsoft.

the class AzureSelectDockerHostStep method onEditDockerHostAction.

private void onEditDockerHostAction() {
    try {
        DefaultTableModel tableModel = (DefaultTableModel) dockerHostsTable.getModel();
        String apiURL = (String) tableModel.getValueAt(dockerHostsTable.getSelectedRow(), 4);
        DockerHost updateHost = dockerManager.getDockerHostForURL(apiURL);
        if (updateHost != null && !updateHost.isUpdating) {
            AzureDockerUIResources.updateDockerHost(model.getProject(), new EditableDockerHost(updateHost), model.getDockerHostsManager(), true);
        } else {
            PluginUtil.displayErrorDialog("Error: Invalid Edit Selection", "The selected Docker host can not be edited at this time!");
        }
    } catch (Exception e) {
        setDialogButtonsState(false);
        String msg = "An error occurred while attempting to edit the selected Docker host.\n" + e.getMessage();
        if (AzureDockerUtils.DEBUG)
            e.printStackTrace();
        LOGGER.error("onEditDockerHostAction", e);
        PluginUtil.displayErrorDialog("Update Docker Hosts Error", msg);
    }
}
Also used : EditableDockerHost(com.microsoft.azure.docker.model.EditableDockerHost) DefaultTableModel(javax.swing.table.DefaultTableModel) DockerHost(com.microsoft.azure.docker.model.DockerHost) EditableDockerHost(com.microsoft.azure.docker.model.EditableDockerHost)

Example 8 with EditableDockerHost

use of com.microsoft.azure.docker.model.EditableDockerHost in project azure-tools-for-java by Microsoft.

the class AzureSelectDockerWizardDialog method deploy.

public String deploy() {
    AzureDockerImageInstance dockerImageInstance = model.getDockerImageDescription();
    AzureDockerPreferredSettings dockerPreferredSettings = model.getDockerHostsManager().getDockerPreferredSettings();
    if (dockerPreferredSettings == null) {
        dockerPreferredSettings = new AzureDockerPreferredSettings();
    }
    dockerPreferredSettings.dockerApiName = dockerImageInstance.host.apiUrl;
    dockerPreferredSettings.dockerfileOption = dockerImageInstance.predefinedDockerfile;
    dockerPreferredSettings.region = dockerImageInstance.host.hostVM.region;
    dockerPreferredSettings.vmSize = dockerImageInstance.host.hostVM.vmSize;
    dockerPreferredSettings.vmOS = dockerImageInstance.host.hostOSType.name();
    model.getDockerHostsManager().setDockerPreferredSettings(dockerPreferredSettings);
    DefaultLoader.getIdeHelper().runInBackground(model.getProject(), "Deploying Docker Container on Azure", false, true, "Deploying Web app to a Docker host on Azure...", new Runnable() {

        @Override
        public void run() {
            try {
                DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        AzureDockerImageInstance dockerImageInstance = model.getDockerImageDescription();
                        if (!dockerImageInstance.hasNewDockerHost) {
                            Session session = null;
                            do {
                                try {
                                    // check if the Docker host is accessible
                                    session = AzureDockerSSHOps.createLoginInstance(dockerImageInstance.host);
                                } catch (Exception e) {
                                    session = null;
                                }
                                if (session == null) {
                                    EditableDockerHost editableDockerHost = new EditableDockerHost(dockerImageInstance.host);
                                    AzureInputDockerLoginCredsDialog loginCredsDialog = new AzureInputDockerLoginCredsDialog(model.getProject(), editableDockerHost, model.getDockerHostsManager(), false);
                                    loginCredsDialog.show();
                                    if (loginCredsDialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
                                        // Update Docker host log in credentials
                                        DockerHost dockerHost = model.getDockerHostsManager().getDockerHostForURL(dockerImageInstance.host.apiUrl);
                                        dockerHost.certVault = editableDockerHost.updatedDockerHost.certVault;
                                        dockerHost.hasPwdLogIn = editableDockerHost.updatedDockerHost.hasPwdLogIn;
                                        dockerHost.hasSSHLogIn = editableDockerHost.updatedDockerHost.hasSSHLogIn;
                                        dockerImageInstance.host = dockerHost;
                                    //                    AzureDockerVMOps.updateDockerHostVM(model.getDockerHostsManager().getSubscriptionsMap().get(model.getDockerImageDescription().sid).azureClient, editableDockerHost.updatedDockerHost);
                                    } else {
                                        return;
                                    }
                                }
                            } while (session == null);
                        }
                        Azure azureClient = model.getDockerHostsManager().getSubscriptionsMap().get(model.getDockerImageDescription().sid).azureClient;
                        DockerContainerDeployTask task = new DockerContainerDeployTask(model.getProject(), azureClient, model.getDockerImageDescription());
                        task.queue();
                        // Update caches here
                        if (onCreate != null) {
                            onCreate.run();
                        }
                    }
                });
            } catch (Exception e) {
                String msg = "An error occurred while attempting to deploy to the selected Docker host." + "\n" + e.getMessage();
                PluginUtil.displayErrorDialogInAWTAndLog("Failed to Deploy Web App as Docker Container", msg, e);
            }
        }
    });
    return AzureDockerUtils.getUrl(dockerImageInstance);
}
Also used : AzureInputDockerLoginCredsDialog(com.microsoft.intellij.docker.dialogs.AzureInputDockerLoginCredsDialog) AzureDockerImageInstance(com.microsoft.azure.docker.model.AzureDockerImageInstance) Azure(com.microsoft.azure.management.Azure) EditableDockerHost(com.microsoft.azure.docker.model.EditableDockerHost) DockerHost(com.microsoft.azure.docker.model.DockerHost) EditableDockerHost(com.microsoft.azure.docker.model.EditableDockerHost) DockerContainerDeployTask(com.microsoft.tasks.DockerContainerDeployTask) AzureDockerPreferredSettings(com.microsoft.azure.docker.model.AzureDockerPreferredSettings) Session(com.jcraft.jsch.Session)

Aggregations

EditableDockerHost (com.microsoft.azure.docker.model.EditableDockerHost)8 DockerHost (com.microsoft.azure.docker.model.DockerHost)5 Session (com.jcraft.jsch.Session)4 AzureDockerPreferredSettings (com.microsoft.azure.docker.model.AzureDockerPreferredSettings)3 Azure (com.microsoft.azure.management.Azure)2 AzureInputDockerLoginCredsDialog (com.microsoft.azuretools.docker.ui.dialogs.AzureInputDockerLoginCredsDialog)2 AzureViewDockerDialog (com.microsoft.azuretools.docker.ui.dialogs.AzureViewDockerDialog)2 AzureInputDockerLoginCredsDialog (com.microsoft.intellij.docker.dialogs.AzureInputDockerLoginCredsDialog)2 AzureDockerImageInstance (com.microsoft.azure.docker.model.AzureDockerImageInstance)1 AzureWizardDialog (com.microsoft.azuretools.core.components.AzureWizardDialog)1 AzureNewDockerWizard (com.microsoft.azuretools.docker.ui.wizards.createhost.AzureNewDockerWizard)1 AzureViewDockerDialog (com.microsoft.intellij.docker.dialogs.AzureViewDockerDialog)1 DockerContainerDeployTask (com.microsoft.tasks.DockerContainerDeployTask)1 File (java.io.File)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1 IProject (org.eclipse.core.resources.IProject)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1