Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2015-11-19 11:32:53 -0500
committerRoland Grunberg2015-11-19 14:13:53 -0500
commit9741c6b29b6a2a97ca4cc7c1901632e9269dedf4 (patch)
tree15f6def17f3155d539498cbbcbe68f79052ffe84
parentd1dff6d88fba6ee7fc820306c918175b093602ce (diff)
downloadorg.eclipse.linuxtools-9741c6b29b6a2a97ca4cc7c1901632e9269dedf4.tar.gz
org.eclipse.linuxtools-9741c6b29b6a2a97ca4cc7c1901632e9269dedf4.tar.xz
org.eclipse.linuxtools-9741c6b29b6a2a97ca4cc7c1901632e9269dedf4.zip
Display error message when attempting to SSH into unconfigured VM.
Some VMs may not have an SSH daemon configured by default, so if a VM does not have an ip, port, or user, display an error message. Also change references for boxName, to boxRef. Change-Id: Ie960f323b5422feb69bde035c2f54d8061f78935 Reviewed-on: https://git.eclipse.org/r/60821 Tested-by: Hudson CI Reviewed-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/SSHVMCommandHandler.java11
-rw-r--r--vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/CreateVMPage.java44
-rw-r--r--vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/WizardMessages.properties8
3 files changed, 38 insertions, 25 deletions
diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/SSHVMCommandHandler.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/SSHVMCommandHandler.java
index 6a1eb81fff..2b8d18b664 100644
--- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/SSHVMCommandHandler.java
+++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/commands/SSHVMCommandHandler.java
@@ -17,8 +17,11 @@ import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.internal.vagrant.ui.wizards.WizardMessages;
import org.eclipse.linuxtools.vagrant.core.IVagrantVM;
import org.eclipse.linuxtools.vagrant.core.VagrantService;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.tm.terminal.connector.ssh.launcher.SshLauncherDelegate;
public class SSHVMCommandHandler extends BaseVMCommandHandler {
@@ -27,6 +30,14 @@ public class SSHVMCommandHandler extends BaseVMCommandHandler {
private static final String KEY = "PRIVATEKEY";
@Override
void executeInJob(final IVagrantVM vm, IProgressMonitor monitor) {
+ if (vm.ip() == null || vm.port() == 0 || vm.user() == null) {
+ Display.getDefault()
+ .syncExec(() -> MessageDialog.openError(Display.getCurrent()
+ .getActiveShell(),
+ WizardMessages.getString("SSHVMCommandHandler.sshError"), //$NON-NLS-1$
+ WizardMessages.getString("SSHVMCommandHandler.invalidCredentials"))); //$NON-NLS-1$
+ return;
+ }
// org.eclipse.tm.terminal.connector.ssh.controls.SshWizardConfigurationPanel
Map<String, Object> properties = new HashMap<>();
properties.put("ssh.keep_alive", 300);
diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/CreateVMPage.java b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/CreateVMPage.java
index 5e8c01ad39..f97093b914 100644
--- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/CreateVMPage.java
+++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/CreateVMPage.java
@@ -115,23 +115,23 @@ public class CreateVMPage extends WizardPage {
vmmNameObservable);
// Box name
- final Label boxNameLabel = new Label(container, SWT.NONE);
- boxNameLabel
- .setText(WizardMessages.getString("CreateVMPage.boxName.label")); //$NON-NLS-1$
+ final Label boxRefLabel = new Label(container, SWT.NONE);
+ boxRefLabel
+ .setText(WizardMessages.getString("CreateVMPage.boxRef.label")); //$NON-NLS-1$
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
- .grab(false, false).applyTo(boxNameLabel);
+ .grab(false, false).applyTo(boxRefLabel);
- final Text boxNameText = new Text(container, SWT.BORDER);
+ final Text boxRefText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
- .grab(true, false).applyTo(boxNameText);
- boxNameText.setToolTipText(
- WizardMessages.getString("CreateVMPage.boxName.tooltip")); //$NON-NLS-1$
+ .grab(true, false).applyTo(boxRefText);
+ boxRefText.setToolTipText(
+ WizardMessages.getString("CreateVMPage.boxRef.tooltip")); //$NON-NLS-1$
// Box Name binding
- final IObservableValue boxNameObservable = BeanProperties
+ final IObservableValue boxRefObservable = BeanProperties
.value(CreateVMPageModel.class, CreateVMPageModel.BOX_REF)
.observe(model);
- dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(boxNameText),
- boxNameObservable);
+ dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(boxRefText),
+ boxRefObservable);
// Box name search
final Button boxSearchButton = new Button(container, SWT.NONE);
@@ -189,10 +189,10 @@ public class CreateVMPage extends WizardPage {
vgFilesearchButton.addSelectionListener(onSearchImage());
customVMFileButton.addSelectionListener(
- onCheckCustomVMFile(vmNameText, boxNameText, boxLocText, vgFilesearchButton, boxSearchButton));
+ onCheckCustomVMFile(vmNameText, boxRefText, boxLocText, vgFilesearchButton, boxSearchButton));
dbc.addValidationStatusProvider(new CreateVMValidationStatusProvider(vmmNameObservable,
- boxNameObservable, boxLocObservable));
+ boxRefObservable, boxLocObservable));
advanced = new CreateVMAdvancedComposite(
container, model);
@@ -205,7 +205,7 @@ public class CreateVMPage extends WizardPage {
}
private SelectionListener onCheckCustomVMFile(Text vmNameText,
- Text boxNameText, Text boxLocText, Button searchButton,
+ Text boxRefText, Text boxLocText, Button searchButton,
Button boxSearchButton) {
return new SelectionAdapter() {
@@ -215,14 +215,14 @@ public class CreateVMPage extends WizardPage {
Button bt = (Button) e.widget;
if (bt.getSelection()) {
vmNameText.setEnabled(false);
- boxNameText.setEnabled(false);
+ boxRefText.setEnabled(false);
boxSearchButton.setEnabled(false);
searchButton.setEnabled(true);
boxLocText.setEnabled(true);
model.setVFileMode(true);
} else {
vmNameText.setEnabled(true);
- boxNameText.setEnabled(true);
+ boxRefText.setEnabled(true);
boxSearchButton.setEnabled(true);
searchButton.setEnabled(false);
boxLocText.setEnabled(false);
@@ -269,12 +269,12 @@ public class CreateVMPage extends WizardPage {
public class CreateVMValidationStatusProvider extends MultiValidator {
- private IObservableValue vmNameOb, boxNameOb, boxLocOb;
+ private IObservableValue vmNameOb, boxRefOb, boxLocOb;
public CreateVMValidationStatusProvider(IObservableValue vmNameOb,
- IObservableValue boxNameOb, IObservableValue boxLocOb) {
+ IObservableValue boxRefOb, IObservableValue boxLocOb) {
this.vmNameOb = vmNameOb;
- this.boxNameOb = boxNameOb;
+ this.boxRefOb = boxRefOb;
this.boxLocOb = boxLocOb;
}
@@ -287,15 +287,15 @@ public class CreateVMPage extends WizardPage {
@Override
protected IStatus validate() {
String vmName = (String) vmNameOb.getValue();
- String boxName = (String) boxNameOb.getValue();
+ String boxRef = (String) boxRefOb.getValue();
String boxLoc = (String) boxLocOb.getValue();
if (!model.getVFileMode()) {
if (vmName == null || vmName.isEmpty()) {
return ValidationStatus.error(WizardMessages
.getString("CreateVMPage.emptyVMName")); //$NON-NLS-1$
- } else if (boxName == null || boxName.isEmpty()) {
+ } else if (boxRef == null || boxRef.isEmpty()) {
return ValidationStatus.error(WizardMessages
- .getString("CreateVMPage.emptyBoxName")); //$NON-NLS-1$
+ .getString("CreateVMPage.emptyBoxRef")); //$NON-NLS-1$
}
} else {
if (boxLoc == null || boxLoc.isEmpty()) {
diff --git a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/WizardMessages.properties b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/WizardMessages.properties
index 85ebbc637d..58869a4dc8 100644
--- a/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/WizardMessages.properties
+++ b/vagrant/org.eclipse.linuxtools.vagrant.ui/src/org/eclipse/linuxtools/internal/vagrant/ui/wizards/WizardMessages.properties
@@ -26,9 +26,9 @@ CreateVMPage.File.CheckBox=Custom Vagrantfile
CreateVMPage.loc.label=Vagrantfile:
CreateVMPage.loc.tooltip=Enter a file path to an existing Vagrantfile
CreateVMPage.search.label=Search...
-CreateVMPage.boxName.label=Box Reference:
-CreateVMPage.boxName.tooltip=Enter the name or file path of the Box to use
-CreateVMPage.emptyBoxName=Please provide a Box name.
+CreateVMPage.boxRef.label=Box Reference:
+CreateVMPage.boxRef.tooltip=Enter the name or file path of the Box to use
+CreateVMPage.emptyBoxRef=Please provide a Box name or file.
CreateVMPage.emptyVagrantfile=Please provide a Vagrantfile.
CreateVMPage.emptyVMName=Please provide a VM name.
CreateVMPage.invalidVagrantfile=Vagrantfile no longer exists or cannot be read.
@@ -37,6 +37,8 @@ CreateVMAdvancedComposite.DefaultKey=New Environment Variable
CreateVMAdvancedComposite.DefaultValue=Default Environment Variable Value
CreateVMAdvancedComposite.Key=Key
CreateVMAdvancedComposite.Value=Value
+SSHVMCommandHandler.invalidCredentials=The SSH credentials for this VM are not properly defined. Please ensure that the VM has an SSH Service running.
+SSHVMCommandHandler.sshError=Unable to SSH into Virtual Machine
VagrantCommandNotFound.msg=The 'vagrant' command could not be found. Please make sure Vagrant is installed and configured to be on the system PATH
VagrantCommandNotFound.title=vagrant command not found

Back to the top