diff options
| author | Shireesh Anjal <anjalshireesh@gmail.com> | 2011-03-28 06:58:51 -0700 |
|---|---|---|
| committer | Shireesh Anjal <anjalshireesh@gmail.com> | 2011-03-28 06:58:51 -0700 |
| commit | bf531d097bc99db08bda4d1a1dec541c57c7933c (patch) | |
| tree | 253a3fc82d5bac3755fc7e32f8456879b69b9979 /com.gluster.storage.management.server/src | |
| parent | b27c5d68d3ffa47c92e0fcd7d0873ac2d6b8fca8 (diff) | |
Preparing src for migration to github
Diffstat (limited to 'com.gluster.storage.management.server/src')
23 files changed, 0 insertions, 1548 deletions
diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/constants/VolumeOptionsDefaults.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/constants/VolumeOptionsDefaults.java deleted file mode 100644 index 384038f4..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/constants/VolumeOptionsDefaults.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * DefaultVolumeOptions.java - * - * 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.server.constants; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.VolumeOptionInfo; - -@XmlRootElement -public class VolumeOptionsDefaults { - @XmlElementWrapper(name = "volumeOptions") - @XmlElement(name = "volumeOption", type = VolumeOptionInfo.class) - public List<VolumeOptionInfo> options; - - public VolumeOptionsDefaults() { - } - - public VolumeOptionsDefaults getDefaults() { - options = getVolumeOptionsInfo(); - return this; - } - - /** - * Fetches the list of all volume options with their information from GlusterFS and returns the same - * - * @return List of volume option information objects - */ - private List<VolumeOptionInfo> getVolumeOptionsInfo() { - List<VolumeOptionInfo> volumeOptionsInfo = new ArrayList<VolumeOptionInfo>(); - - volumeOptionsInfo - .add(new VolumeOptionInfo( - "cluster.stripe-block-size", - "This could be used in case of a stripe setup. Specifies the size of the stripe unit that will read from or written to the striped servers. " - + CoreConstants.NEWLINE - + "Optionally different stripe unit sizes can be specified for different fies, with the following pattern <filename-pattern:blk-size>. ", - "*:128KB")); - volumeOptionsInfo - .add(new VolumeOptionInfo( - "cluster.self-heal-window-size", - "Specifies the number of maximum number blocks per file for which self-heal process would be applied simultaneously.", - "16")); - volumeOptionsInfo.add(new VolumeOptionInfo("cluster.data-self-heal-algorithm", - "cluster.data-self-heal-algorithm", "auto")); - volumeOptionsInfo - .add(new VolumeOptionInfo( - "network.frame-timeout", - "The time frame after which the operation has to be declared as dead, if the server does not respond for a particular operation.", - "1800")); - volumeOptionsInfo.add(new VolumeOptionInfo("network.ping-timeout", - "The time duration for which the client waits to check if the server is responsive.", "42")); - volumeOptionsInfo.add(new VolumeOptionInfo("auth.allow", - "'IP addresses/Host name' of the clients which should be allowed to access the the volume.", "*")); - volumeOptionsInfo.add(new VolumeOptionInfo("auth.reject", - "'IP addresses/Host name' of the clients which should be denied to access the volume.", "NONE")); - volumeOptionsInfo - .add(new VolumeOptionInfo( - "performance.cache-refresh-timeout", - "The cached data for a file will be retained till 'cache-refresh-timeout' seconds, after which data re-validation is performed.", - "1")); - volumeOptionsInfo.add(new VolumeOptionInfo("performance.cache-size", "Size of the read cache.", "32MB")); - volumeOptionsInfo.add(new VolumeOptionInfo("performance.write-behind-window-size", - "Size of the per-file write-behind buffer.", "1MB")); - volumeOptionsInfo.add(new VolumeOptionInfo("performance.cache-max-file-size", - "performance.cache-max-file-size", "-1")); - volumeOptionsInfo.add(new VolumeOptionInfo("performance.cache-min-file-size", - "performance.cache-min-file-size", "0")); - volumeOptionsInfo - .add(new VolumeOptionInfo( - "performance.io-thread-count", - " Number of threads in the thread-pool in the bricks to improve the concurrency in I/O s of server side.", - "16")); - volumeOptionsInfo - .add(new VolumeOptionInfo( - "diagnostics.latency-measurement", - "Statistics related to the latency of each operation would be tracked inside GlusterFS data-structures.", - "off")); - volumeOptionsInfo.add(new VolumeOptionInfo("diagnostics.dump-fd-stats", - "Statistics related to file-operations would be tracked inside GlusterFS data-structures.", "off")); - volumeOptionsInfo.add(new VolumeOptionInfo("diagnostics.brick-log-level", - "Changes the log-level of the bricks (servers).", "NORMAL")); - volumeOptionsInfo.add(new VolumeOptionInfo("diagnostics.client-log-level", - "Changes the log-level of the clients.", "NORMAL")); - volumeOptionsInfo.add(new VolumeOptionInfo("nfs.enable-ino32", - "Use this option from the CLI to make Gluster NFS return 32-bit inode numbers instead of 64-bit.", - "off")); - volumeOptionsInfo - .add(new VolumeOptionInfo( - "nfs.mem-factor", - "This option specifies a multiple that determines the total amount of memory used. Increases this increases the performance of NFS.", - "15")); - volumeOptionsInfo.add(new VolumeOptionInfo("transport.keepalive", "transport.keepalive", "on")); - - return volumeOptionsInfo; - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/data/GlusterDataSource.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/data/GlusterDataSource.java deleted file mode 100644 index e669a130..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/data/GlusterDataSource.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * GlusterDataSource.java - * - * 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.server.data; - -import javax.servlet.ServletContext; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.stereotype.Component; - -@Component -public class GlusterDataSource extends DriverManagerDataSource { - @Autowired - ServletContext servletContext; - - public GlusterDataSource() { - setDriverClassName(org.apache.derby.jdbc.EmbeddedDriver.class.getName()); - - setUsername("gluster"); - // TODO: change to a stronger (encrypted) password - setPassword("gluster"); - } - - public DriverManagerDataSource getDataSource() { - // Database directory = work/data relative to context root - setUrl("jdbc:derby:" + servletContext.getRealPath("data") + ";create=true"); - - return this; - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/AbstractServersResource.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/AbstractServersResource.java deleted file mode 100644 index 004160a7..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/AbstractServersResource.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * AbstractServersResource.java - * - * 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.server.resources; - -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.NetworkInterface; -import com.gluster.storage.management.core.model.Server; - -/** - * Abstract resource class for servers. Abstracts basic server related functionality like "get server details". - */ -public class AbstractServersResource { - // TODO: Used for generating dummy ip address. To be removed after implementing actual logic for fetching server - // details - private static int ipCount = 1; - - /** - * Fetch details of the given server. The server name must be populated in the object before calling this method. - * - * @param server - * Server whose details are to be fetched - */ - protected void fetchServerDetails(Server server) { - String serverName = server.getName(); - - // TODO: Fetch the server details and populate in the object. - // For now, populating dummy data. - populateDummyData(server); - } - - /** - * @param server - */ - private void populateDummyData(Server server) { - server.setNumOfCPUs((int) (Math.ceil(Math.random() * 8))); - server.setCpuUsage(Math.random() * 100); - server.setTotalMemory(Math.ceil(Math.random() * 8)); - server.setMemoryInUse(Math.random() * server.getTotalMemory()); - addDummyDisks(server); - addDummyNetworkInterfaces(server, (int) Math.ceil(Math.random() * 4)); - } - - private void addDummyNetworkInterfaces(Server server, int interfaceCount) { - for (int i = 0; i < interfaceCount; i++) { - server.addNetworkInterface(new NetworkInterface("eth" + i, server, "192.168.1." + ipCount++, - "255.255.255.0", "192.168.1.1")); - } - } - - /** - * @param server - */ - private void addDummyDisks(Server server) { - double dummyDiskSpace = Math.random() * 500; - server.addDisk(new Disk(server, "sda", dummyDiskSpace, Math.random() * dummyDiskSpace, Disk.DISK_STATUS.READY)); - dummyDiskSpace = Math.random() * 500; - server.addDisk(new Disk(server, "sdb", dummyDiskSpace, Math.random() * dummyDiskSpace, Disk.DISK_STATUS.READY)); - dummyDiskSpace = Math.random() * 500; - server.addDisk(new Disk(server, "sdc", dummyDiskSpace, Math.random() * dummyDiskSpace, Disk.DISK_STATUS.READY)); - } -} diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/DiscoveredServersResource.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/DiscoveredServersResource.java deleted file mode 100644 index 5987857a..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/DiscoveredServersResource.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * 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.server.resources; - -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.model.Response; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.ServerListResponse; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.StringListResponse; -import com.sun.jersey.spi.resource.Singleton; - -@Component -@Singleton -@Path("/discoveredservers") -public class DiscoveredServersResource extends AbstractServersResource { - private List<String> discoveredServerNames = new ArrayList<String>(); - - public List<String> getDiscoveredServerNames() { - return discoveredServerNames; - } - - @GET - @Produces(MediaType.TEXT_XML) - public Response getDiscoveredServers(@QueryParam("details") Boolean getDetails) { - if(getDetails != null && getDetails == true) { - return new ServerListResponse(Status.STATUS_SUCCESS, getDiscoveredServerDetails()); - } - return new StringListResponse(getDiscoveredServerNames()); - } - - private List<Server> getDiscoveredServerDetails() { - List<Server> discoveredServers = new ArrayList<Server>(); - List<String> serverNames = getDiscoveredServerNames(); - for (String serverName : serverNames) { - discoveredServers.add(getDiscoveredServer(serverName)); - } - return discoveredServers; - } - - public void setDiscoveredServerNames(List<String> discoveredServerNames) { - synchronized (discoveredServerNames) { - this.discoveredServerNames = discoveredServerNames; - } - } - - @Path("/{serverName}") - @GET - @Produces(MediaType.TEXT_XML) - public Server getDiscoveredServer(@PathParam("serverName") String serverName) { - Server server = new Server(serverName); - fetchServerDetails(server); - return server; - } - - public static void main(String[] args) { - StringListResponse listResponse = (StringListResponse)new DiscoveredServersResource().getDiscoveredServers(false); - for (String server : listResponse.getData()) { - System.out.println(server); - } - } -} diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/GlusterServersResource.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/GlusterServersResource.java deleted file mode 100644 index 6204bf9b..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/GlusterServersResource.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * 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.server.resources; - -import java.util.List; - -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.model.GenericResponse; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.GlusterServer.SERVER_STATUS; -import com.gluster.storage.management.core.model.GlusterServerListResponse; -import com.gluster.storage.management.core.model.GlusterServerResponse; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.utils.GlusterUtil; -import com.gluster.storage.management.core.utils.ProcessResult; -import com.sun.jersey.spi.resource.Singleton; - -@Component -@Singleton -@Path("/cluster/servers") -public class GlusterServersResource extends AbstractServersResource { - private GlusterUtil glusterUtil = new GlusterUtil(); - public static final String HOSTNAMETAG = "hostname:"; - - private List<GlusterServer> getServerDetails() { - List<GlusterServer> glusterServers = glusterUtil.getGlusterServers(); - for (GlusterServer server : glusterServers) { - if (server.getStatus() == SERVER_STATUS.ONLINE) { - fetchServerDetails(server); - // server.setPreferredNetworkInterface(server.getNetworkInterfaces().get(0)); - } - } - return glusterServers; - } - - @GET - @Produces(MediaType.TEXT_XML) - public GlusterServerListResponse getGlusterServers() { - return new GlusterServerListResponse(Status.STATUS_SUCCESS, getServerDetails()); - } - - @GET - @Path("{serverName}") - @Produces(MediaType.TEXT_XML) - public GlusterServer getGlusterServer(@PathParam("serverName") String serverName) { - GlusterServer server = new GlusterServer(serverName); - fetchServerDetails(server); - // server.setPreferredNetworkInterface(server.getNetworkInterfaces().get(0)); - server.setStatus(SERVER_STATUS.ONLINE); - return server; - } - - /* - * (non-Javadoc) - * - * @see - * com.gluster.storage.management.server.resources.AbstractServersResource#fetchServerDetails(com.gluster.storage - * .management.core.model.Server) - */ - @Override - protected void fetchServerDetails(Server server) { - // fetch standard server details like cpu, disk, memory details - super.fetchServerDetails(server); - - // TODO: Fetch gluster server details like status - } - - @POST - @Produces(MediaType.TEXT_XML) - public GlusterServerResponse addServer(@FormParam("serverName") String serverName) { - ProcessResult result = glusterUtil.addServer(serverName); - - if (!result.isSuccess()) { - Status failure = new Status(Status.STATUS_CODE_FAILURE, "Add server [" + serverName + "] failed: [" + result.getExitValue() - + "][" + result.getOutput() + "]"); - return new GlusterServerResponse(failure, null); - } - return new GlusterServerResponse(Status.STATUS_SUCCESS, getGlusterServer(serverName)); - } - - public static void main(String[] args) { - GlusterServersResource glusterServersResource = new GlusterServersResource(); - System.out.println(glusterServersResource.getServerDetails()); - - // To add a server - GlusterServerResponse response = glusterServersResource.addServer("my-server"); - System.out.println(response.getData().getName()); - } -} diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/Hello.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/Hello.java deleted file mode 100644 index 4e379199..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/Hello.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * 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.server.resources; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -//Sets the path to base URL + /hello -@Path("/hello") -public class Hello { - // This method is called if TEXT_PLAIN is request - @GET - @Produces(MediaType.TEXT_PLAIN) - public String sayPlainTextHello() { - return "Hello Jersey"; - } - - // This method is called if XMLis request - @GET - @Produces(MediaType.TEXT_XML) - public String sayXMLHello() { - return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>"; - } - - // This method is called if HTML is request - @GET - @Produces(MediaType.TEXT_HTML) - public String sayHtmlHello() { - return "<html> " + "<title>" + "Hello Jersey" + "</title>" - + "<body><h1>" + "Hello Jersey" + "</body></h1>" + "</html> "; - } -} diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/RunningTaskResource.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/RunningTaskResource.java deleted file mode 100644 index 2cec4c36..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/RunningTaskResource.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * 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.server.resources; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.springframework.stereotype.Component; - -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_RUNNING_TASKS; -import com.gluster.storage.management.core.model.Response; -import com.gluster.storage.management.core.model.RunningTask; -import com.gluster.storage.management.core.model.RunningTaskListResponse; -import com.gluster.storage.management.core.model.RunningTaskStatus; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.server.runningtasks.managers.RunningTaskManager; - -@Component -@Path(RESOURCE_PATH_RUNNING_TASKS) -public class RunningTaskResource { - - @GET - @Produces(MediaType.TEXT_XML) - public RunningTaskListResponse getRunningTasks() { - - RunningTaskStatus status = new RunningTaskStatus(); - List<RunningTask> runningTasks = new ArrayList<RunningTask>(); - - status.setCode(Status.STATUS_CODE_RUNNING); - status.setPercentageSupported(false); - - // Volume rebalance - RunningTask task = new RunningTask(); - task.setId("0001"); - task.setType("VolumeRebalance"); - task.setReference(""); - task.setDescription("Volume [Volume1] rebalance is running"); - task.setStatus(status); - runningTasks.add(task); - - task = new RunningTask(); - task.setId("0002"); - task.setType("VolumeRebalance"); - task.setReference(""); - task.setDescription("Volume [Volume2] rebalance is running"); - //task.setDescription("Error: volume rebalance operation failed at fd 0000 [/export/test-song-volume/mydirectory/test-video.avi"); - task.setStatus(status); - runningTasks.add(task); - - // MigrateDisk - task = new RunningTask(); - task.setId("0003"); - task.setType("MigrateDisk"); - task.setReference(""); - task.setDescription("Disk migration [Volume3/sda] is running"); - task.setStatus(status); - runningTasks.add(task); - - // FormatDisk - task = new RunningTask(); - task.setId("0004"); - task.setType("FormatDisk"); - task.setReference(""); - task.setDescription("Volume [vol1] rebalance is running"); - status.setPercentageSupported(true); - status.getPercentCompleted(45); - task.setStatus(status); - runningTasks.add(task); - return new RunningTaskListResponse(Status.STATUS_SUCCESS, runningTasks); - } - - @SuppressWarnings("rawtypes") - public Response startTask(@FormParam("taskType") String taskType) { - String managerClassName = "com.gluster.storage.management.server.runningtasks.managers." + taskType + "Manager"; - Class managerClass; - RunningTaskManager manager = null; - try { - managerClass = Class.forName(managerClassName); - manager = (RunningTaskManager) managerClass.newInstance(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - // TODO: set form params on the manager - Map params = null; - manager.setFormParams(params); - manager.start(); - return null; - } - - // TODO Remove the test script for production - public static void main(String[] args) { - RunningTaskResource rt = new RunningTaskResource(); - RunningTaskListResponse tasks = rt.getRunningTasks(); - List<RunningTask> runningTasks = tasks.getRunningTasks(); - for( RunningTask x : runningTasks) { - System.out.println( x.getId() + " : " + x.getType() + " : " + x.getDescription() ); - } - } -} - diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/ServerResource.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/ServerResource.java deleted file mode 100644 index 97b874e2..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/ServerResource.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * 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.server.resources;
-
-import java.io.File;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-import com.gluster.storage.management.core.utils.FileUtil;
-import com.gluster.storage.management.core.utils.MD5Crypt;
-import com.gluster.storage.management.core.utils.ProcessResult;
-import com.gluster.storage.management.core.utils.ProcessUtil;
-
-@Path("/server")
-public class ServerResource {
- // TODO: xml should be read from a "work" directory under the tomcat server.
- // Use relative path - do not hard code the absolute path.
- public static final String DISCOVERED_SERVERS_XML = "/GLUSTER/discovered-servers.xml";
-
- /**
- * Discover newly available servers
- *
- * @return list of discovered servers
- */
- private String GetDiscoveredServers() {
- File discoveredServersFile = new File(DISCOVERED_SERVERS_XML);
- String serverNames = new FileUtil().readFileAsString(discoveredServersFile);
- return serverNames;
- }
-
- @Path("/discover")
- @GET
- @Produces(MediaType.TEXT_XML)
- public String discoveredServers() {
- return GetDiscoveredServers();
- }
-
- private String GetDetails() {
- ProcessResult result = new ProcessUtil().executeCommand("get-server-details.py");
- if (!result.isSuccess()) {
- //TODO:Generate error message and return
- }
- return result.getOutput();
- }
-
- @Path("/details")
- @GET
- @Produces(MediaType.TEXT_XML)
- public String serverDetails() {
- return GetDetails();
- }
-
-}
diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/UsersResource.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/UsersResource.java deleted file mode 100644 index 51134317..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/UsersResource.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * 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.server.resources; - -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.authentication.encoding.PasswordEncoder; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.provisioning.JdbcUserDetailsManager; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.model.Status; -import com.sun.jersey.spi.resource.Singleton; - -@Singleton -@Component -@Path("/users") -public class UsersResource { - @Autowired - private JdbcUserDetailsManager jdbcUserService; - - @Autowired - private PasswordEncoder passwordEncoder; - - /** - * Authenticates given user with given password for login on current system - * - * @param user - * @param password - * @return true is user can be successfully authenticated using given password, else false - */ - /* - * NOTE: This method is no more required as user authentication is performed on every request by the spring security - * framework. Can be removed after testing. - */ - /* - * private boolean authenticate(String user, String password) { String tmpFileName = "tmp"; File saltFile = new - * File(tmpFileName); ProcessResult result = new ProcessUtil().executeCommand("get-user-password.py", user, - * tmpFileName); if (result.isSuccess()) { String salt = new FileUtil().readFileAsString(saltFile); String - * encryptedPassword = MD5Crypt.crypt(password, salt); return encryptedPassword.equals(salt); } - * - * return false; } - */ - - @Path("{user}") - @GET - @Produces(MediaType.TEXT_XML) - public Status login(@PathParam("user") String user) { - // success only if the user passed in query is same as the one passed in security header - return (SecurityContextHolder.getContext().getAuthentication().getName().equals(user) ? Status.STATUS_SUCCESS - : Status.STATUS_FAILURE); - } - - @Path("{user}") - @PUT - @Produces(MediaType.TEXT_XML) - public Status changePassword(@FormParam("oldpassword") String oldPassword, - @FormParam("newpassword") String newPassword) { - try { - jdbcUserService.changePassword(oldPassword, passwordEncoder.encodePassword(newPassword, null)); - } catch (AuthenticationException ex) { - ex.printStackTrace(); - return new Status(Status.STATUS_CODE_FAILURE, "Could not change password: [" + ex.getMessage() + "]"); - } - return Status.STATUS_SUCCESS; - } -} diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java deleted file mode 100644 index dfa5a5cc..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * VolumesResource.java - * - * 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.server.resources; - -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_OPERATION; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VALUE_START; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VALUE_STOP; -import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_VOLUME_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_VOLUMES; -import static com.gluster.storage.management.core.constants.RESTConstants.SUBRESOURCE_DEFAULT_OPTIONS; - -import java.util.Map; - -import javax.ws.rs.Consumes; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import com.gluster.storage.management.core.model.GenericResponse; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.utils.GlusterUtil; -import com.gluster.storage.management.core.utils.ProcessResult; -import com.gluster.storage.management.server.constants.VolumeOptionsDefaults; -import com.sun.jersey.spi.resource.Singleton; - -@Singleton -@Path(RESOURCE_PATH_VOLUMES) -public class VolumesResource { - private final GlusterUtil glusterUtil = new GlusterUtil(); - - @POST - @Consumes(MediaType.TEXT_XML) - @Produces(MediaType.TEXT_XML) - public GenericResponse<String> createVolume(Volume volume) { - ProcessResult response = glusterUtil.createVolume(volume); - if (!response.isSuccess()) { - return new GenericResponse<String>(Status.STATUS_FAILURE, "Volume creation failed: [" - + response.getOutput() + "]"); - } - - response = glusterUtil.setVolumeAccessControl(volume); - - return new GenericResponse<String>(Status.STATUS_SUCCESS, response.getOutput()); - } - - @PUT - @Path("{" + PATH_PARAM_VOLUME_NAME + "}") - @Produces(MediaType.TEXT_XML) - public Status performOperation(@FormParam(FORM_PARAM_OPERATION) String operation, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName) { - - if (operation.equals(FORM_PARAM_VALUE_START)) { - return new Status(glusterUtil.startVolume(volumeName)); - } - if (operation.equals(FORM_PARAM_VALUE_STOP)) { - return new Status(glusterUtil.stopVolume(volumeName)); - } - return new Status(Status.STATUS_CODE_FAILURE, "Invalid operation code [" + operation + "]"); - } - - @GET - @Path(SUBRESOURCE_DEFAULT_OPTIONS) - @Produces(MediaType.TEXT_XML) - public VolumeOptionsDefaults getDefaultOptions() { - // TODO: Fetch all volume options with their default values from GlusterFS - // whenever such a CLI command is made available in GlusterFS - return new VolumeOptionsDefaults().getDefaults(); - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/FormatDiskManager.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/FormatDiskManager.java deleted file mode 100644 index 37cc22f6..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/FormatDiskManager.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.server.runningtasks.managers; - -import java.util.Map; - -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.RunningTaskStatus; - -public class FormatDiskManager implements RunningTaskManager { - - - @Override - public String getId() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus start() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus stop() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus pause() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus resume() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setFormParams(Map params) { - // TODO Auto-generated method stub - - } - - @Override - public RunningTaskStatus getStatus() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/MigrateDiskManager.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/MigrateDiskManager.java deleted file mode 100644 index 97916abe..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/MigrateDiskManager.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.gluster.storage.management.server.runningtasks.managers; - -import java.util.Map; - -import com.gluster.storage.management.core.model.RunningTaskStatus; - -public class MigrateDiskManager implements RunningTaskManager { - - @Override - public String getId() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus start() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus stop() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus pause() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus resume() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setFormParams(Map params) { - // TODO Auto-generated method stub - - } - - @Override - public RunningTaskStatus getStatus() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/RunningTaskManager.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/RunningTaskManager.java deleted file mode 100755 index a21c6b81..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/RunningTaskManager.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * 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.server.runningtasks.managers; - -import java.util.Map; - -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.RunningTaskStatus; - -public interface RunningTaskManager { - - public String getId(); - - public RunningTaskStatus start(); - - public RunningTaskStatus stop(); - - public RunningTaskStatus pause(); - - public RunningTaskStatus resume(); - - public RunningTaskStatus getStatus(); - - @SuppressWarnings("rawtypes") - public void setFormParams(Map params); - -} diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/VolumeRebalanceManager.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/VolumeRebalanceManager.java deleted file mode 100644 index 01a5dc25..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/runningtasks/managers/VolumeRebalanceManager.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.gluster.storage.management.server.runningtasks.managers; - -import java.util.Map; - -import com.gluster.storage.management.core.model.RunningTaskStatus; - -public class VolumeRebalanceManager implements RunningTaskManager { - - @Override - public String getId() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus start() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus stop() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus pause() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RunningTaskStatus resume() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setFormParams(Map params) { - // TODO Auto-generated method stub - - } - - @Override - public RunningTaskStatus getStatus() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/security/GlusterUserDetailsService.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/security/GlusterUserDetailsService.java deleted file mode 100644 index 21c13a03..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/security/GlusterUserDetailsService.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * GlusterUserDetailsService.java - * - * 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.server.security; - -import org.springframework.security.core.userdetails.UserDetailsService; - -/** - * - */ -public interface GlusterUserDetailsService extends UserDetailsService { - void changePassword(String username, String password); -} - diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/security/UserAuthDao.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/security/UserAuthDao.java deleted file mode 100644 index cfc6e572..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/security/UserAuthDao.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * UserAuthDao.java - * - * 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.server.security; - -import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl; - -/** - * @author root - * - */ -public class UserAuthDao extends JdbcDaoImpl implements GlusterUserDetailsService { - - /* - * (non-Javadoc) - * - * @see com.gluster.storage.management.server.security.GlusterUserDetailsService#changePassword(java.lang.String, - * java.lang.String) - */ - @Override - public void changePassword(String username, String password) { - getJdbcTemplate().update("UPDATE USERS SET PASSWORD = ? WHERE USERNAME = ?", password, username); - } - -} diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/tasks/InitServerTask.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/tasks/InitServerTask.java deleted file mode 100644 index d96db6ca..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/tasks/InitServerTask.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * GlusterServerInitializer.java - * - * 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.server.tasks; - -import java.io.ByteArrayOutputStream; -import java.sql.ResultSet; -import java.sql.SQLException; - -import org.apache.derby.tools.ij; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.jdbc.core.RowCallbackHandler; -import org.springframework.jdbc.core.support.JdbcDaoSupport; -import org.springframework.security.authentication.encoding.PasswordEncoder; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.utils.FileUtil; - -/** - * Initializes the Gluster Management Server. - */ -public class InitServerTask extends JdbcDaoSupport { - @Autowired - private PasswordEncoder passwordEncoder; - - public void securePasswords() { - getJdbcTemplate().query("select username, password from users", new RowCallbackHandler() { - @Override - public void processRow(ResultSet rs) throws SQLException { - String username = rs.getString(1); - String password = rs.getString(2); - String encodedPassword = passwordEncoder.encodePassword(password, null); - getJdbcTemplate().update("update users set password = ? where username = ?", encodedPassword, username); - logger.debug("Updating password for username: " + username); - } - }); - } - - private void executeScript(String script) { - ByteArrayOutputStream sqlOut = new ByteArrayOutputStream(); - int numOfExceptions; - try { - numOfExceptions = ij.runScript(getJdbcTemplate().getDataSource().getConnection(), - new FileUtil().loadResource(script), CoreConstants.ENCODING_UTF8, sqlOut, - CoreConstants.ENCODING_UTF8); - String output = sqlOut.toString(); - sqlOut.close(); - logger.debug("Data script [" + script + "] returned with exit status [" + numOfExceptions - + "] and output [" + output + "]"); - if (numOfExceptions != 0) { - throw new GlusterRuntimeException("Server data initialization script [ " + script + "] failed with [" - + numOfExceptions + "] exceptions! [" + output + "]"); - } - } catch (Exception ex) { - ex.printStackTrace(); - throw new GlusterRuntimeException("Server data initialization script [" + script + "] failed!", ex); - } - } - - private void initDatabase() { - logger.debug("Initializing server data..."); - executeScript("data/scripts/security-schema.sql"); - executeScript("data/scripts/users-authorities-groups.sql"); - securePasswords(); // encrypt the passwords - } - - /** - * Initializes the server database, if running for the first time. - */ - public synchronized void initServer() { - try { - // Query to check whether the user table exists - getJdbcTemplate().queryForInt("select count(*) from users"); - logger.debug("Server data is already initialized!"); - } catch (DataAccessException ex) { - // Database not created yet. Create it! - initDatabase(); - } - } -} diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/tasks/ServerDiscoveryTask.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/tasks/ServerDiscoveryTask.java deleted file mode 100644 index 9fcb28e6..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/tasks/ServerDiscoveryTask.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * ServerDiscoveryTask.java - * - * 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.server.tasks; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.servlet.ServletContext; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.utils.ProcessResult; -import com.gluster.storage.management.server.resources.DiscoveredServersResource; -import com.gluster.storage.management.server.utils.ServerUtil; -import com.sun.jersey.spi.resource.Singleton; - -/** - * Task for auto-discovery of servers eligible to be added to the Gluster cluster. This task runs periodically and keeps - * the discovered server list at a common place. The server resource can then pick it and send to client whenever - * demanded. - */ -@Singleton -@Component -public class ServerDiscoveryTask { - private static final String ENV_AWS = "aws"; - private static final String ENV_VMWARE = "vmware"; - private static final String ENV_PHYCAL = "physical"; - private static final String SCRIPT_NAME_SFX = "-discover-servers.py"; - - @Autowired - private ServerUtil serverUtil; - - @Autowired - private ServletContext servletContext; - - @Autowired - private DiscoveredServersResource discoveredServersResource; - - @Autowired - private String environment; - - public void discoverServers() { - List<String> serverNameList = new ArrayList<String>(); - - ProcessResult result = serverUtil.executeGlusterScript(true, environment + SCRIPT_NAME_SFX, new ArrayList<String>()); - if(result.isSuccess()) { - String serverNames = result.getOutput(); - String[] parts = serverNames.split(CoreConstants.NEWLINE); - serverNameList = Arrays.asList(parts); - } - - discoveredServersResource.setDiscoveredServerNames(serverNameList); - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java b/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java deleted file mode 100644 index 1d237461..00000000 --- a/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * ServerUtil.java - * - * 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.server.utils; - -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.ServletContext; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.utils.ProcessResult; -import com.gluster.storage.management.core.utils.ProcessUtil; -import com.sun.jersey.spi.resource.Singleton; - -@Singleton -@Component -public class ServerUtil { - @Autowired - ServletContext servletContext; - - private static final String SCRIPT_DIR = "scripts"; - private static final String SCRIPT_COMMAND = "python"; - - public ProcessResult executeGlusterScript(boolean runInForeground, String scriptName, List<String> arguments) { - List<String> command = new ArrayList<String>(); - - command.add(SCRIPT_COMMAND); - command.add(getScriptPath(scriptName)); - command.addAll(arguments); - return new ProcessUtil().executeCommand(runInForeground, command); - } - - private String getScriptPath(String scriptName) { - String scriptPath = servletContext.getRealPath(SCRIPT_DIR) + CoreConstants.FILE_SEPARATOR + scriptName; - return scriptPath; - } -}
\ No newline at end of file diff --git a/com.gluster.storage.management.server/src/data/scripts/security-schema.sql b/com.gluster.storage.management.server/src/data/scripts/security-schema.sql deleted file mode 100644 index fdde5823..00000000 --- a/com.gluster.storage.management.server/src/data/scripts/security-schema.sql +++ /dev/null @@ -1,26 +0,0 @@ -create table users( - username varchar(50) not null primary key, - password varchar(50) not null, - enabled smallint not null - ); - - create table authorities ( - username varchar(50) not null, - authority varchar(50) not null, - constraint fk_authorities_users foreign key(username) references users(username)); - create unique index ix_auth_username on authorities (username,authority); - -create table groups ( - id bigint generated by default as identity(start with 0) primary key, - group_name varchar(50) not null); - -create table group_authorities ( - group_id bigint not null, - authority varchar(50) not null, - constraint fk_group_authorities_group foreign key(group_id) references groups(id)); - -create table group_members ( - id bigint generated by default as identity(start with 0) primary key, - username varchar(50) not null, - group_id bigint not null, - constraint fk_group_members_group foreign key(group_id) references groups(id)); diff --git a/com.gluster.storage.management.server/src/data/scripts/users-authorities-groups.sql b/com.gluster.storage.management.server/src/data/scripts/users-authorities-groups.sql deleted file mode 100644 index 35ccf965..00000000 --- a/com.gluster.storage.management.server/src/data/scripts/users-authorities-groups.sql +++ /dev/null @@ -1,21 +0,0 @@ --- Create users -insert into users(username, password, enabled) values ('gluster','gluster',1); -insert into users(username, password, enabled) values ('guest','guest',1); - --- Assign authorities to users (to be removed after implementing user group functionality) -insert into authorities(username,authority) values ('gluster','ROLE_USER'); -insert into authorities(username,authority) values ('gluster','ROLE_ADMIN'); -insert into authorities(username,authority) values ('guest','ROLE_USER'); - --- Create user groups -insert into groups(group_name) values ('Users'); -insert into groups(group_name) values ('Administrators'); - --- Add authorities to groups (functionality not yet implemented in code) -insert into group_authorities(group_id, authority) select id,'ROLE_USER' from groups where group_name='Users'; -insert into group_authorities(group_id, authority) select id,'ROLE_USER' from groups where group_name='Administrators'; -insert into group_authorities(group_id, authority) select id,'ROLE_ADMIN' from groups where group_name='Administrators'; - --- Assign group members -insert into group_members(group_id, username) select id,'guest' from groups where group_name='Users'; -insert into group_members(group_id, username) select id,'gluster' from groups where group_name='Administrators';
\ No newline at end of file diff --git a/com.gluster.storage.management.server/src/spring/gluster-server-base.xml b/com.gluster.storage.management.server/src/spring/gluster-server-base.xml deleted file mode 100644 index 86a8708f..00000000 --- a/com.gluster.storage.management.server/src/spring/gluster-server-base.xml +++ /dev/null @@ -1,50 +0,0 @@ - -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" - xmlns:task="http://www.springframework.org/schema/task" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"> - <context:component-scan base-package="com.gluster.storage.management.server" /> - <task:scheduler id="taskScheduler" /> - <task:executor id="taskExecutor" pool-size="1" /> - <task:annotation-driven executor="taskExecutor" - scheduler="taskScheduler" /> - - <task:scheduled-tasks> - <task:scheduled ref="serverDiscoveryTask" method="discoverServers" - fixed-delay="60000" /> - </task:scheduled-tasks> - - <bean id="environment" class="java.lang.String"> - <constructor-arg value="vmware" /> - </bean> - - <!-- Derby embedded data source --> - <!-- bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" - lazy-init="false"> <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" - /> <property name="url" value="jdbc:derby:work/data;create=true" /> <property - name="username" value="gluster" /> <property name="password" value="gluster" - /> </bean --> - - <bean id="dataSourceFactory" - class="com.gluster.storage.management.server.data.GlusterDataSource" /> - <bean id="dataSource" - class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> - <property name="targetObject"> - <ref local="dataSourceFactory" /> - </property> - <property name="targetMethod"> - <value>getDataSource</value> - </property> - </bean> - - <!-- bean id="dataSource" class="com.gluster.storage.management.server.data.GlusterDataSource" - lazy-init="false" autowire="byType" / --> - - <bean class="com.gluster.storage.management.server.tasks.InitServerTask" - init-method="initServer" depends-on="dataSource"> - <property name="dataSource" ref="dataSource" /> - </bean> -</beans>
\ No newline at end of file diff --git a/com.gluster.storage.management.server/src/spring/gluster-server-security.xml b/com.gluster.storage.management.server/src/spring/gluster-server-security.xml deleted file mode 100644 index 0de97761..00000000 --- a/com.gluster.storage.management.server/src/spring/gluster-server-security.xml +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans:beans xmlns="http://www.springframework.org/schema/security" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" - xmlns:jdbc="http://www.springframework.org/schema/jdbc" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd - http://www.springframework.org/schema/security - http://www.springframework.org/schema/security/spring-security-3.0.xsd - "> - - <http auto-config="true" use-expressions="true"> - <intercept-url pattern="/resources/*" - access="hasRole('ROLE_ADMIN') and fullyAuthenticated" /> - <intercept-url pattern="/*" access="permitAll" /> - <!-- SSL Protection --> - <!-- <intercept-url pattern="/resources/*" access="hasRole('ROLE_ADMIN') - and fullyAuthenticated" requires-channel="https"/> <intercept-url pattern="/*" - access="permitAll" requires-channel="any"/> --> - <port-mappings> - <port-mapping http="8080" https="8443" /> - </port-mappings> - - <!-- HTTP basic authentication --> - <http-basic /> - </http> - - <beans:bean - class="org.springframework.security.authentication.encoding.ShaPasswordEncoder" - id="passwordEncoder" /> - - <authentication-manager alias="authenticationManager"> - <authentication-provider user-service-ref="jdbcUserService"> - <!-- Passwords are SHA encrypted --> - <password-encoder hash="sha" /> - </authentication-provider> - </authentication-manager> - - <beans:bean id="jdbcUserService" - class="org.springframework.security.provisioning.JdbcUserDetailsManager" - lazy-init="false"> - <beans:property name="dataSource" ref="dataSource" /> - <beans:property name="authenticationManager" ref="authenticationManager" /> - </beans:bean> -</beans:beans>
\ No newline at end of file |
