use of com.microsoft.tasks.DockerContainerDeployTask 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);
}
Aggregations