use of org.eclipse.linuxtools.vagrant.core.IVagrantConnection in project linuxtools by eclipse.
the class DestroyVMCommandHandler method executeInJob.
@Override
void executeInJob(IVagrantVM vm, IProgressMonitor monitor) {
IVagrantConnection connection = VagrantService.getInstance();
try {
connection.destroyVM(vm);
String stateLoc = Activator.getDefault().getStateLocation().toOSString();
File vagrantDir = Paths.get(stateLoc, vm.name()).toFile();
CommandUtils.delete(vagrantDir);
} catch (VagrantException | InterruptedException e) {
final String errorMessage = Messages.DestroyVMCommandHandler_error + vm.id();
openError(errorMessage, e);
} finally {
// always get images as we sometimes get errors on intermediate
// images
// being removed but we will remove some top ones successfully
connection.getVMs(true);
}
}
use of org.eclipse.linuxtools.vagrant.core.IVagrantConnection in project linuxtools by eclipse.
the class RefreshVMCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
final IVagrantConnection connection = VagrantService.getInstance();
if (connection == null) {
return null;
}
final Job job = new Job(DVMessages.getString(VM_REFRESH_MSG)) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
monitor.beginTask(DVMessages.getString(VM_REFRESH_MSG), 1);
connection.getVMs(true);
monitor.worked(1);
monitor.done();
return Status.OK_STATUS;
}
};
job.setPriority(Job.LONG);
job.schedule();
return null;
}
use of org.eclipse.linuxtools.vagrant.core.IVagrantConnection in project linuxtools by eclipse.
the class VagrantVMContentProvider method getElements.
@Override
public Object[] getElements(final Object inputElement) {
if (inputElement instanceof IVagrantConnection) {
final IVagrantConnection connection = (IVagrantConnection) inputElement;
if (connection.isVMsLoaded()) {
return connection.getVMs().toArray();
}
loadContainers(connection);
return EMPTY;
}
return EMPTY;
}
use of org.eclipse.linuxtools.vagrant.core.IVagrantConnection in project linuxtools by eclipse.
the class AddBoxCommandHandler method performPullImage.
private void performPullImage(final String boxName, final String boxLoc) {
final Job pullImageJob = new Job(DVMessages.getFormattedString(PULL_IMAGE_JOB_TITLE, boxName)) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
monitor.beginTask(DVMessages.getString(PULL_IMAGE_JOB_TASK), IProgressMonitor.UNKNOWN);
// handler refresh the images when done
try {
IVagrantConnection connection = VagrantService.getInstance();
boolean isValidURL = true;
try {
new URL(boxLoc);
} catch (MalformedURLException e) {
isValidURL = false;
}
connection.addBox(boxName, boxLoc, isValidURL);
connection.getBoxes(true);
} catch (final VagrantException e) {
Display.getDefault().syncExec(() -> MessageDialog.openError(Display.getCurrent().getActiveShell(), DVMessages.getFormattedString(ERROR_PULLING_IMAGE, boxName), e.getMessage()));
// for now
} catch (InterruptedException e) {
// do nothing
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
pullImageJob.schedule();
}
Aggregations