diff options
Diffstat (limited to 'src/com.gluster.storage.management.gui')
| -rw-r--r-- | src/com.gluster.storage.management.gui/plugin.xml | 16 | ||||
| -rw-r--r-- | src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DownloadVolumeLogsAction.java | 86 |
2 files changed, 102 insertions, 0 deletions
diff --git a/src/com.gluster.storage.management.gui/plugin.xml b/src/com.gluster.storage.management.gui/plugin.xml index b208fc24..6c6983a3 100644 --- a/src/com.gluster.storage.management.gui/plugin.xml +++ b/src/com.gluster.storage.management.gui/plugin.xml @@ -526,6 +526,22 @@ </action> <action allowLabelUpdate="false" + class="com.gluster.storage.management.gui.actions.DownloadVolumeLogsAction" + definitionId="com.gluster.storage.management.gui.commands.DownloadVolumeLogs" + icon="icons/logs.png" + id="com.gluster.storage.management.gui.actions.DownloadVolumeLogsAction" + label="Download &Logs" + menubarPath="com.gluster.storage.management.gui.menu.volume/volume" + mode="FORCE_TEXT" + pulldown="false" + retarget="false" + state="false" + style="push" + toolbarPath="Normal" + tooltip="Download all logs of the volume"> + </action> + <action + allowLabelUpdate="false" class="com.gluster.storage.management.gui.actions.ResetVolumeOptionsAction" definitionId="com.gluster.storage.management.gui.commands.ResetVolumeOptions" icon="icons/reset-options.png" diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DownloadVolumeLogsAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DownloadVolumeLogsAction.java new file mode 100644 index 00000000..9a75355f --- /dev/null +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DownloadVolumeLogsAction.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com> + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * <http://www.gnu.org/licenses/>. + *******************************************************************************/ +package com.gluster.storage.management.gui.actions; + +import java.io.File; + +import org.eclipse.jface.action.IAction; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; + +import com.gluster.storage.management.client.GlusterDataModelManager; +import com.gluster.storage.management.client.VolumesClient; +import com.gluster.storage.management.core.model.Volume; + +/** + * + */ +public class DownloadVolumeLogsAction extends AbstractActionDelegate { + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + @Override + public void dispose() { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see com.gluster.storage.management.gui.actions.AbstractActionDelegate#performAction(org.eclipse.jface.action.IAction) + */ + @Override + protected void performAction(IAction action) { + final Volume volume = (Volume)selectedEntity; + final VolumesClient client = new VolumesClient(GlusterDataModelManager.getInstance().getSecurityToken()); + + final Runnable downloadLogsThread = new Runnable() { + + @Override + public void run() { + FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); + dialog.setFilterNames(new String[] {"GZipped Tar (*.tar.gz)"}); + dialog.setFilterExtensions(new String[] {"*.tar.gz"}); + dialog.open(); + + String title = "Download Volume Logs [" + volume.getName() + "]"; + String filePath = dialog.getFilterPath() + File.separator + dialog.getFileName(); + if(!filePath.endsWith(".tar.gz")) { + filePath += ".tar.gz"; + } + try { + client.downloadLogs(volume.getName(), filePath); + showInfoDialog(title, "Volume logs downloaded successfully to [" + filePath + "]"); + } catch(Exception e) { + showErrorDialog(title, e.getMessage()); + } + } + }; + + BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + + @Override + public void run() { + Display.getDefault().asyncExec(downloadLogsThread); + } + }); + } +} |
