From f02f719cf28dea27923ad04dd7c1c50ea49933ff Mon Sep 17 00:00:00 2001 From: Dhandapani Date: Wed, 17 Aug 2011 16:09:00 +0530 Subject: conflict fixes --- .../client/constants/ClientConstants.java | 2 +- .../plugin.properties | 3 +- .../plugin.xml | 11 +-- .../management/console/ConsoleConstants.java | 26 +++++++ .../console/dialogs/CreateVolumePage1.java | 1 - .../console/dialogs/CreateVolumeWizard.java | 14 +++- .../management/console/utils/GUIHelper.java | 5 +- .../console/views/GlusterViewsManager.java | 9 ++- .../management/console/views/TerminalView.java | 26 ------- .../console/views/VolumeSummaryView.java | 39 +++++++--- .../storage/management/core/model/Volume.java | 1 + .../gateway/remove_server_volume_cifs_config.py | 83 ++++++++++++++++++++++ .../WebContent/WEB-INF/web.xml | 2 +- .../gateway/constants/VolumeOptionsDefaults.java | 1 - 14 files changed, 164 insertions(+), 59 deletions(-) create mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ConsoleConstants.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/TerminalView.java create mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py (limited to 'src') diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/constants/ClientConstants.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/constants/ClientConstants.java index 765735fb..e253dfa5 100644 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/constants/ClientConstants.java +++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/constants/ClientConstants.java @@ -27,7 +27,7 @@ public class ClientConstants { public static final String SYS_PROP_SERVER_URL = "gluster.server.url"; public static final String DEFAULT_SERVER_URL = "https://localhost:8443/glustermg/linux.gtk.x86_64"; public static final String CONTEXT_ROOT = "glustermg"; - public static final String REST_API_VERSION = "1.0"; + public static final String REST_API_VERSION = "1.0.0"; // SSL related public static final String TRUSTED_KEYSTORE = "gmc-trusted.keystore"; diff --git a/src/com.gluster.storage.management.console/plugin.properties b/src/com.gluster.storage.management.console/plugin.properties index 6a93e73d..4ef7da70 100644 --- a/src/com.gluster.storage.management.console/plugin.properties +++ b/src/com.gluster.storage.management.console/plugin.properties @@ -3,4 +3,5 @@ Version: 1.0.0\n\n\ Copyright (c) 2011 Gluster, Inc.\n\ Visit http://www.gluster.com/\n\n\ This product includes software developed by the\n\ -Eclipse Foundation http://eclipse.org/ \ No newline at end of file +Eclipse Foundation http://eclipse.org/\n\ +RichClientGUI http://www.richclientgui.com/ \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/plugin.xml b/src/com.gluster.storage.management.console/plugin.xml index 675b7e52..9cadd537 100644 --- a/src/com.gluster.storage.management.console/plugin.xml +++ b/src/com.gluster.storage.management.console/plugin.xml @@ -175,15 +175,6 @@ name="Tasks" restorable="true"> - - @@ -1419,7 +1410,7 @@ + * 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 + * . + *******************************************************************************/ +package com.gluster.storage.management.console; + +/** + * + */ +public class ConsoleConstants { + public static final String TERMINAL_VIEW_ID = "org.eclipse.tm.terminal.view.TerminalView"; +} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumePage1.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumePage1.java index 8fa27087..d7d98d24 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumePage1.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumePage1.java @@ -362,7 +362,6 @@ public class CreateVolumePage1 extends WizardPage { } addVolumeBricks(); - return volume; } diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java index bfb29ee1..498723d9 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java @@ -28,6 +28,7 @@ import com.gluster.storage.management.console.utils.GlusterLogger; import com.gluster.storage.management.core.constants.CoreConstants; import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; public class CreateVolumeWizard extends Wizard { private static final String title = "Gluster Management Console - Create Volume"; @@ -51,8 +52,17 @@ public class CreateVolumeWizard extends Wizard { try { volumesClient.createVolume(newVolume); + + // Set proper volume type before assign to model + VOLUME_TYPE volumetype = newVolume.getVolumeType(); + if (volumetype == VOLUME_TYPE.REPLICATE && newVolume.getBricks().size() > newVolume.getReplicaCount()) { + newVolume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_REPLICATE); + } else if (volumetype == VOLUME_TYPE.STRIPE && newVolume.getBricks().size() > newVolume.getStripeCount()) { + newVolume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_STRIPE); + } + handleSuccess(newVolume, volumesClient); - } catch(Exception e) { + } catch (Exception e) { String errMsg = e.getMessage(); // the error could be in to post-volume-create processing. check if this is the case. if (volumesClient.volumeExists(newVolume.getName())) { @@ -62,7 +72,7 @@ public class CreateVolumeWizard extends Wizard { return false; } } - + return true; } diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java index 841d5a9d..f46f9ddf 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java @@ -80,11 +80,11 @@ import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.progress.IProgressConstants; import com.gluster.storage.management.console.Application; +import com.gluster.storage.management.console.ConsoleConstants; import com.gluster.storage.management.console.GlusterDataModelManager; import com.gluster.storage.management.console.IImageKeys; import com.gluster.storage.management.console.views.NavigationView; import com.gluster.storage.management.console.views.TasksView; -import com.gluster.storage.management.console.views.TerminalView; import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.Disk; import com.gluster.storage.management.core.utils.JavaUtil; @@ -460,8 +460,7 @@ public class GUIHelper { } public void showTerminalView() { - //showView("org.eclipse.tm.terminal.view.TerminalView"); - showView(TerminalView.ID); + showView(ConsoleConstants.TERMINAL_VIEW_ID); } public void showProgressView() { diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterViewsManager.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterViewsManager.java index 928bc7fc..05c30626 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterViewsManager.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterViewsManager.java @@ -24,6 +24,7 @@ import org.eclipse.ui.IViewReference; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; +import com.gluster.storage.management.console.ConsoleConstants; import com.gluster.storage.management.core.model.Cluster; import com.gluster.storage.management.core.model.Entity; import com.gluster.storage.management.core.model.EntityGroup; @@ -44,6 +45,7 @@ public class GlusterViewsManager implements ViewsManager { /* (non-Javadoc) * @see com.gluster.storage.management.console.views.ViewsManager#updateViews(com.gluster.storage.management.core.model.Entity) */ + @SuppressWarnings("rawtypes") @Override public void updateViews(Entity entity) { closeAllViews(); @@ -65,13 +67,11 @@ public class GlusterViewsManager implements ViewsManager { } } - /** - * - */ private void closeAllViews() { IViewReference[] viewReferences = page.getViewReferences(); for (final IViewReference viewReference : viewReferences) { - if (!(viewReference.getId().equals(NavigationView.ID) || viewReference.getId().equals(TerminalView.ID))) { + if (!(viewReference.getId().equals(NavigationView.ID) || viewReference.getId().equals( + ConsoleConstants.TERMINAL_VIEW_ID))) { page.hideView(viewReference); } } @@ -80,7 +80,6 @@ public class GlusterViewsManager implements ViewsManager { private void showViewsForCluster(Cluster cluster) throws PartInitException { page.showView(ClusterSummaryView.ID); page.showView(TasksView.ID, null, IWorkbenchPage.VIEW_CREATE); - //page.showView("org.eclipse.tm.terminal.view.TerminalView", null, IWorkbenchPage.VIEW_CREATE); } private void showViewsForVolume(Volume volume) throws PartInitException { diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/TerminalView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/TerminalView.java deleted file mode 100644 index d99ac513..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/TerminalView.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * 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 - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views; - -/** - * - */ -public class TerminalView extends org.eclipse.tm.internal.terminal.view.TerminalView { - public static final String ID = TerminalView.class.getName(); -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java index 5de35000..dfd0c669 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java @@ -3,6 +3,7 @@ package com.gluster.storage.management.console.views; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.eclipse.jface.dialogs.MessageDialog; @@ -403,8 +404,6 @@ public class VolumeSummaryView extends ViewPart { guiHelper.setStatusMessage("Setting Cifs Configuration..."); parent.update(); - final String cifsUsers = cifsUsersText.getText().trim(); - // To check if no changes in the users list if (!isvalidCifsUser()) { MessageDialog.openError(Display.getDefault().getActiveShell(), "Cifs Configuration", @@ -419,6 +418,7 @@ public class VolumeSummaryView extends ViewPart { public void run() { VolumesClient vc = new VolumesClient(); Volume newVolume = new Volume(); + String cifsUsers = cifsUsersText.getText().trim(); try { vc.setCifsConfig(volume.getName(), cifsCheckbox.getSelection(), cifsUsers); enableCifsUsersControls(false); @@ -665,7 +665,7 @@ public class VolumeSummaryView extends ViewPart { || volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { replicaCount = (double) volume.getReplicaCount(); } - totalDiskSpace.setText("" + NumberUtil.formatNumber((getTotalDiskSpace() / 1024) / replicaCount)); + totalDiskSpace.setText("" + NumberUtil.formatNumber(getTotalDiskSpace() / 1024)); } private double getDiskSize(String serverName, String deviceName) { @@ -692,16 +692,39 @@ public class VolumeSummaryView extends ViewPart { } private double getTotalDiskSpace() { + List diskSizes = getVolumeDiskSizes(); + VOLUME_TYPE volumeType = volume.getVolumeType(); double diskSize = 0d; + if (volumeType == VOLUME_TYPE.DISTRIBUTE || volumeType == VOLUME_TYPE.STRIPE + || volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { + for (Double size : diskSizes) { + diskSize += size; + } + } else { // Replicate or distributed replicate + int replicaCount = volume.getReplicaCount(); + if (replicaCount == 0) { + replicaCount = Volume.DEFAULT_REPLICA_COUNT; + } + int startIndex = 0; + for (int i = 0; i < (diskSizes.size() / replicaCount); i++) { + startIndex = i * replicaCount; + diskSize += Collections.min(diskSizes.subList(startIndex, startIndex + replicaCount)); + } + } + return diskSize; + } + + private List getVolumeDiskSizes() { + List diskSizes = new ArrayList(); Device device; for (Brick brick : volume.getBricks()) { device = modelManager.getDeviceForBrickDir(brick); - if (device != null) { // In case of off line server, device becomes null - diskSize += getDiskSize(brick.getServerName(), device.getName()); - } + diskSizes.add( (device == null) ? 0d : getDiskSize(brick.getServerName(), device.getName()) ); } - return diskSize; + return diskSizes; } + + private void createDiskSpaceField(Composite section) { Label diskSpaceLabel = toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); @@ -713,7 +736,7 @@ public class VolumeSummaryView extends ViewPart { replicaCount = (double) Volume.DEFAULT_REPLICA_COUNT; } totalDiskSpace = toolkit.createLabel(section, - "" + NumberUtil.formatNumber((getTotalDiskSpace() / 1024) / replicaCount), SWT.NONE); + "" + NumberUtil.formatNumber(getTotalDiskSpace() / 1024), SWT.NONE); toolkit.createLabel(section, "", SWT.NONE); // dummy } diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java index 2ce1ea44..65bec003 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java @@ -353,6 +353,7 @@ public class Volume extends Entity { setReplicaCount(newVolume.getReplicaCount()); setStripeCount(newVolume.getStripeCount()); setNASProtocols(newVolume.getNASProtocols()); + setCifsUsers(newVolume.getCifsUsers()); getOptions().copyFrom(newVolume.getOptions()); } } \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py new file mode 100755 index 00000000..efdb9b1c --- /dev/null +++ b/src/com.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py @@ -0,0 +1,83 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils + + +def main(): + if len(sys.argv) < 3: + sys.stderr.write("usage: %s SERVER_NAME VOLUME_FILE\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + serverName = sys.argv[1] + volumeFile = sys.argv[2] + + try: + fp = open(volumeFile) + lines = fp.readlines() + fp.close() + except IOError, e: + Utils.log("Failed to read volume file %s: %s" % (volumeFile, str(e))) + sys.stderr.write("Failed to read volume file %s: %s\n" % (volumeFile, str(e))) + sys.exit(1) + + volumeNameList = [line.strip() for line in lines] + if not volumeNameList: + sys.exit(0) + + try: + fp = open(Globals.CIFS_VOLUME_FILE) + content = fp.read() + fp.close() + except IOError, e: + Utils.log("failed to read file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) + sys.stderr.write("failed to read file %s: %s\n" % (Globals.CIFS_VOLUME_FILE, str(e))) + sys.exit(2) + + cifsVolumeList = [line.split(":")[0] for line in content.split()] + runningCifsVolumeList = set(cifsVolumeList).intersection(set(volumeNameList)) + + if not runningCifsVolumeList: + sys.exit(0) + + tempFileName = Utils.getTempFileName() + try: + fp = open(tempFileName, "w") + fp.write("%s\n" % serverName) + except IOError: + Utils.log("Failed to write server name to file %s" % tempFileName) + sys.stderr.write("Failed to write server name to file\n") + sys.exit(3) + + status = True + for volumeName in runningCifsVolumeList: + if Utils.runCommand(["grun.py", tempFileName, "stop_volume_cifs.py", volumeName.strip()]) != 0: + status = False + if Utils.runCommand(["grun.py", tempFileName, "delete_volume_cifs.py", volumeName.strip()]) ! 0: + status = False + + try: + os.remove(tempFileName) + except OSError, e: + Utils.log("Failed to remove temporary file %s" % tempFileName) + sys.stderr.write("Failed to remove temporary file %s\n" % tempFileName) + pass + + if status: + sys.exit(0) + else: + sys.exit(2) + +if __name__ == "__main__": + main() diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml index 631788ff..54872639 100644 --- a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml +++ b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml @@ -37,7 +37,7 @@ gluster-resources-1.0 - /1.0/* + /1.0.0/* JnlpDownloadServlet diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/constants/VolumeOptionsDefaults.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/constants/VolumeOptionsDefaults.java index 892ebf11..508a3029 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/constants/VolumeOptionsDefaults.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/constants/VolumeOptionsDefaults.java @@ -30,7 +30,6 @@ import com.gluster.storage.management.core.constants.CoreConstants; import com.gluster.storage.management.core.exceptions.ConnectionException; import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.VolumeOptionInfo; import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; import com.gluster.storage.management.gateway.services.ClusterService; -- cgit