From d01f7244e9d9f7e3ef84e0ba7b48ef1b1b09d809 Mon Sep 17 00:00:00 2001 From: Kinglong Mee Date: Mon, 12 Feb 2018 15:13:49 +0800 Subject: gfapi: return pre/post attributes from glfs_pread/pwrite As nfs-ganesha, a wcc data contains pre/post attributes is return in read/write rpc reply. nfs-ganesha get those attributes by two getattr between the real read/write right now. But, gluster has return pre/post attributes from glusterfsd, those attributes are skipped in syncop/gfapi, if gfapi return them, the upper user (nfs-ganesha) can use them directly without any duplicate getattr. Updates: #389 Change-Id: I7b643ae4241cfe2aeb17063de00192d81674024a Signed-off-by: Kinglong Mee --- tests/basic/gfapi/upcall-cache-invalidate.c | 2 +- tests/basic/gfapi/upcall-register-api.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/basic/gfapi') diff --git a/tests/basic/gfapi/upcall-cache-invalidate.c b/tests/basic/gfapi/upcall-cache-invalidate.c index 9add3381278..d1b421dff18 100644 --- a/tests/basic/gfapi/upcall-cache-invalidate.c +++ b/tests/basic/gfapi/upcall-cache-invalidate.c @@ -137,7 +137,7 @@ main (int argc, char *argv[]) LOG_ERR ("glfs_lseek", ret); memset (readbuf, 0, sizeof(readbuf)); - ret = glfs_pread (fd_tmp2, readbuf, 4, 0, 0); + ret = glfs_pread (fd_tmp2, readbuf, 4, 0, 0, NULL); if (ret <= 0) { ret = -1; diff --git a/tests/basic/gfapi/upcall-register-api.c b/tests/basic/gfapi/upcall-register-api.c index 56227a93d0a..cabd8be4f31 100644 --- a/tests/basic/gfapi/upcall-register-api.c +++ b/tests/basic/gfapi/upcall-register-api.c @@ -117,7 +117,7 @@ int perform_io (glfs_t *fs, glfs_t *fs2, int cnt) LOG_ERR ("glfs_lseek", ret); memset (readbuf, 0, sizeof(readbuf)); - ret = glfs_pread (fd_tmp2, readbuf, 4, 0, 0); + ret = glfs_pread (fd_tmp2, readbuf, 4, 0, 0, NULL); if (ret <= 0) { ret = -1; -- cgit nt'>
diff options
context:
space:
mode:
authorSelvasundaram <selvam@gluster.com>2011-08-10 21:24:22 +0530
committerSelvasundaram <selvam@gluster.com>2011-08-10 21:24:22 +0530
commit25dfeacd5d56923cbdeaefbb89281737e4030485 (patch)
tree0f8fe106adcd34166894d446974fc36a3f55a747 /src
parenta26edbc55a5f80fb0ec333f3a043b3cfc6068cef (diff)
parent457201bb104d84f74c9a27495834d9b730012210 (diff)
Merge branch 'master' of github.com:gluster/console
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/UsersClient.java17
-rw-r--r--src/com.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp2
-rw-r--r--src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.jpgbin44264 -> 0 bytes
-rw-r--r--src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.pngbin0 -> 160250 bytes
-rw-r--r--src/com.gluster.storage.management.console/icons/tango/32x32/migrate-brick-disabled.pngbin0 -> 2591 bytes
-rw-r--r--src/com.gluster.storage.management.console/icons/tango/32x32/migrate-brick.png (renamed from src/com.gluster.storage.management.console/icons/tango/32x32/replace-brick.png)bin2343 -> 2343 bytes
-rw-r--r--src/com.gluster.storage.management.console/plugin.properties2
-rw-r--r--src/com.gluster.storage.management.console/plugin.xml3
-rw-r--r--src/com.gluster.storage.management.console/splash.bmpbin398896 -> 398896 bytes
-rw-r--r--src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IImageKeys.java4
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java3
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/Common.py20
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/Globals.py131
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/Utils.py1086
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/backend/Commands.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/Commands.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/Disk.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/Disk.py)0
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/DiskUtils.py)0
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/FsTabUtils.py)0
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/backend/GetServerNetworkConfig.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/GetServerNetworkConfig.py)0
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/backend/GlusterdUtils.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/GlusterdUtils.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/NetworkUtils.py)0
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/backend/RRDUtils.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/RRDUtils.py)0
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/backend/ServerUtils.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/ServerUtils.py)0
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/VolumeUtils.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/add_user_cifs.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/add_user_cifs.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/clear_volume_directory.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/clear_volume_directory.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/create_volume_cifs.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/create_volume_cifs.py)16
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/create_volume_directory.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/create_volume_directory.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/delete_user_cifs.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/delete_user_cifs.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/delete_volume_cifs.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/delete_volume_cifs.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/disable-ssh-password-auth.sh (renamed from src/com.gluster.storage.management.gateway.scripts/src/disable-ssh-password-auth.sh)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/format_device.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/format_device.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_brick_status.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_disk_mount_point.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_disk_mount_point.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_disk_name_by_path.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_disk_name_by_path.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_file.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_file.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_format_device_status.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_format_device_status.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_cpu_details.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_rrd_cpu_details.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_memory_details.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_rrd_memory_details.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_net_details.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_rrd_net_details.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_server_details.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_server_status.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_server_status.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_volume_brick_log.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_volume_brick_log.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/get_volume_log.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/get_volume_log.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/gluster_provision_block_wrapper.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/gluster_provision_block_wrapper.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/modify_volume_cifs.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/modify_volume_cifs.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.init.d (renamed from src/com.gluster.storage.management.gateway.scripts/src/multicast-discoverd.init.d)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/multicast-discoverd.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/rrd_cpu.pl (renamed from src/com.gluster.storage.management.gateway.scripts/src/rrd_cpu.pl)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/rrd_mem.pl (renamed from src/com.gluster.storage.management.gateway.scripts/src/rrd_mem.pl)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/rrd_net.pl (renamed from src/com.gluster.storage.management.gateway.scripts/src/rrd_net.pl)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/rrd_update_cpu_details.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/rrd_update_cpu_details.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/rrd_update_memory_details.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/rrd_update_memory_details.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/setup_cifs_config.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/setup_cifs_config.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/start_volume_cifs.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/start_volume_cifs.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/stop_volume_cifs.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/stop_volume_cifs.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/update_volume_cifs.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/update_volume_cifs.py)0
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/common/Globals.py (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/Globals.py)4
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/common/Globals.pycbin0 -> 4718 bytes
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/common/Protocol.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/Protocol.py)0
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/common/Protocol.pycbin0 -> 16852 bytes
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py)17
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/common/Utils.pycbin0 -> 37088 bytes
-rw-r--r--src/com.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py (renamed from src/com.gluster.storage.management.gateway.scripts/src/XmlHandler.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py)23
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py)21
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/gateway/delete_user_cifs_all.py (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py)14
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/gateway/delete_volume_cifs_all.py (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py)12
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py)12
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/gmg-reset-password.sh)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/gateway/grun.py (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/grun.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/gateway/multicast-discover-servers.py (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/multicast-discover-servers.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/gateway/setup_cifs_config_all.py (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py)0
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py (renamed from src/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py)22
-rw-r--r--src/com.gluster.storage.management.gateway/WebContent/scripts/Protocol.py438
-rw-r--r--src/com.gluster.storage.management.gateway/WebContent/scripts/XmlHandler.py346
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/UsersResource.java18
77 files changed, 118 insertions, 2093 deletions
diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/UsersClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/UsersClient.java
index 6722708b..4e89e994 100644
--- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/UsersClient.java
+++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/UsersClient.java
@@ -18,16 +18,17 @@
*******************************************************************************/
package com.gluster.storage.management.client;
+import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_NEW_PASSWORD;
+import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_OLD_PASSWORD;
+
+import com.gluster.storage.management.core.constants.RESTConstants;
+import com.gluster.storage.management.core.exceptions.GlusterRuntimeException;
import com.gluster.storage.management.core.model.Status;
import com.sun.jersey.api.representation.Form;
import com.sun.jersey.core.util.Base64;
public class UsersClient extends AbstractClient {
- private static final String RESOURCE_NAME = "users";
- private static final String FORM_PARAM_OLD_PASSWORD = "oldpassword";
- private static final String FORM_PARAM_NEW_PASSWORD = "newpassword";
-
private String generateSecurityToken(String user, String password) {
return new String(Base64.encode(user + ":" + password));
}
@@ -42,7 +43,11 @@ public class UsersClient extends AbstractClient {
}
public void changePassword(String user, String oldPassword, String newPassword) {
- setSecurityToken(generateSecurityToken(user, oldPassword));
+ String oldSecurityToken = getSecurityToken();
+ String newSecurityToken = generateSecurityToken(user, oldPassword);
+ if(!oldSecurityToken.equals(newSecurityToken)) {
+ throw new GlusterRuntimeException("Invalid old password!");
+ }
Form form = new Form();
form.add(FORM_PARAM_OLD_PASSWORD, oldPassword);
@@ -76,7 +81,7 @@ public class UsersClient extends AbstractClient {
*/
@Override
public String getResourcePath() {
- return RESOURCE_NAME;
+ return RESTConstants.RESOURCE_USERS;
}
/*
diff --git a/src/com.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp b/src/com.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp
index 4d0dc72c..f87631df 100644
--- a/src/com.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp
+++ b/src/com.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp
@@ -5,7 +5,7 @@
<vendor>Gluster Inc.</vendor>
<homepage href="$$codebase" />
<description>Gluster Management Console</description>
- <icon kind="splash" href="splash.jpg"/>
+ <icon kind="splash" href="splash.png"/>
<shortcut online="true">
<desktop/>
diff --git a/src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.jpg b/src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.jpg
deleted file mode 100644
index de8b5219..00000000
--- a/src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.jpg
+++ /dev/null
Binary files differ
diff --git a/src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.png b/src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.png
new file mode 100644
index 00000000..293329da
--- /dev/null
+++ b/src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.png
Binary files differ
diff --git a/src/com.gluster.storage.management.console/icons/tango/32x32/migrate-brick-disabled.png b/src/com.gluster.storage.management.console/icons/tango/32x32/migrate-brick-disabled.png
new file mode 100644
index 00000000..8a1e82a7
--- /dev/null
+++ b/src/com.gluster.storage.management.console/icons/tango/32x32/migrate-brick-disabled.png
Binary files differ
diff --git a/src/com.gluster.storage.management.console/icons/tango/32x32/replace-brick.png b/src/com.gluster.storage.management.console/icons/tango/32x32/migrate-brick.png
index 999332a5..999332a5 100644
--- a/src/com.gluster.storage.management.console/icons/tango/32x32/replace-brick.png
+++ b/src/com.gluster.storage.management.console/icons/tango/32x32/migrate-brick.png
Binary files differ
diff --git a/src/com.gluster.storage.management.console/plugin.properties b/src/com.gluster.storage.management.console/plugin.properties
index 1efd6934..6a93e73d 100644
--- a/src/com.gluster.storage.management.console/plugin.properties
+++ b/src/com.gluster.storage.management.console/plugin.properties
@@ -1,6 +1,6 @@
aboutText=Gluster Management Console\n\
Version: 1.0.0\n\n\
-(c) Copyright Gluster, Inc. 2011. All rights reserved.\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
diff --git a/src/com.gluster.storage.management.console/plugin.xml b/src/com.gluster.storage.management.console/plugin.xml
index 9e799d49..60316263 100644
--- a/src/com.gluster.storage.management.console/plugin.xml
+++ b/src/com.gluster.storage.management.console/plugin.xml
@@ -506,7 +506,8 @@
allowLabelUpdate="false"
class="com.gluster.storage.management.console.actions.MigrateBrickAction"
definitionId="com.gluster.storage.management.console.commands.MigrateDisk"
- icon="icons/tango/32x32/replace-brick.png"
+ disabledIcon="icons/tango/32x32/migrate-brick-disabled.png"
+ icon="icons/tango/32x32/migrate-brick.png"
id="com.gluster.storage.management.console.actions.MigrateDiskAction"
label="&amp;Migrate Brick"
menubarPath="com.gluster.storage.management.console.menu.volume/volume"
diff --git a/src/com.gluster.storage.management.console/splash.bmp b/src/com.gluster.storage.management.console/splash.bmp
index c70f24c6..cb190cd4 100644
--- a/src/com.gluster.storage.management.console/splash.bmp
+++ b/src/com.gluster.storage.management.console/splash.bmp
Binary files differ
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IImageKeys.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IImageKeys.java
index 67590b27..2b20cb02 100644
--- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IImageKeys.java
+++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IImageKeys.java
@@ -34,8 +34,8 @@ public interface IImageKeys {
public static final String REMOVE_VOLUME_32x32 = "icons/tango/32x32/remove-volume.png";
public static final String VOLUME_REBALANCE_32x32 = "icons/tango/32x32/volume-rebalance.png";
public static final String VOLUME_REBALANCE_22x22 = "icons/tango/22x22/volume-rebalance.png";
- public static final String BRICK_MIGRATE_32x32 = "icons/tango/32x32/replace-brick.png";
- public static final String BRICK_MIGRATE_22x22 = "icons/tango/22x22/replace-brick.png";
+ public static final String BRICK_MIGRATE_32x32 = "icons/tango/32x32/migrate-brick.png";
+ public static final String BRICK_MIGRATE_22x22 = "icons/tango/22x22/migrate-brick.png";
public static final String ADD_BRICK_32x32 = "icons/tango/32x32/add-brick.png";
public static final String REMOVE_BRICK_32x32 = "icons/tango/32x32/remove-brick.png";
public static final String BRICK_OFFLINE_22x22 = "icons/tango/22x22/offline-brick.png";
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java
index 737f4d7b..97b83f70 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java
@@ -43,6 +43,7 @@ public class RESTConstants {
public static final String RESOURCE_TASKS = "tasks";
public static final String RESOURCE_KEYS = "keys";
public static final String RESOURCE_STATISTICS = "statistics";
+ public static final String RESOURCE_USERS = "users";
public static final String TASK_START = "start";
public static final String TASK_PAUSE = "pause";
@@ -81,6 +82,8 @@ public class RESTConstants {
public static final String FORM_PARAM_FIX_LAYOUT = "fix-layout";
public static final String FORM_PARAM_MIGRATE_DATA = "migrate-data";
public static final String FORM_PARAM_FORCED_DATA_MIGRATE = "forced-data-migrate";
+ public static final String FORM_PARAM_OLD_PASSWORD = "oldpassword";
+ public static final String FORM_PARAM_NEW_PASSWORD = "newpassword";
public static final String PATH_PARAM_FORMAT = "format";
public static final String PATH_PARAM_VOLUME_NAME = "volumeName";
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/Common.py b/src/com.gluster.storage.management.gateway.scripts/src/Common.py
deleted file mode 100644
index 70b2157a..00000000
--- a/src/com.gluster.storage.management.gateway.scripts/src/Common.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (c) 2009 Gluster, Inc. <http://www.gluster.com>
-# This file is part of GlusterSP.
-#
-# GlusterSP is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published
-# by the Free Software Foundation; either version 3 of the License,
-# or (at your option) any later version.
-#
-# GlusterSP 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
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see
-# <http://www.gnu.org/licenses/>.
-
-import sys
-import syslog
-
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/Globals.py b/src/com.gluster.storage.management.gateway.scripts/src/Globals.py
deleted file mode 100644
index d5cb1ae0..00000000
--- a/src/com.gluster.storage.management.gateway.scripts/src/Globals.py
+++ /dev/null
@@ -1,131 +0,0 @@
-# Copyright (C) 2010 Gluster, Inc. <http://www.gluster.com>
-# This file is part of Gluster Storage Platform.
-#
-# Gluster Storage Platform is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 3 of
-# the License, or (at your option) any later version.
-#
-# Gluster Storage Platform 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see
-# <http://www.gnu.org/licenses/>.
-
-MULTICAST_GROUP = '224.224.1.1'
-MULTICAST_PORT = 24729
-GLUSTER_PROBE_STRING = "GLUSTERPROBE"
-GLUSTER_PROBE_VERSION = "1.0.0"
-DEFAULT_BUFSIZE = 1024
-SERVER_PORT = 24731
-DEFAULT_BACKLOG = 5
-DEFAULT_TIMEOUT = 5
-DEFAULT_ID_LENGTH = 16
-
-GLUSTER_PLATFORM_VERSION = "3.2"
-
-## System configuration constants
-SYSCONFIG_NETWORK_DIR = "/etc/sysconfig/network-scripts"
-DNSMASQ_CONF_DIR = "/etc/dnsmasq.d"
-
-FSTAB_FILE = "/etc/fstab"
-NFS_EXPORTS_FILE = "/etc/exports"
-SAMBA_CONF_FILE = "/etc/samba/smb.conf"
-TIMEZONE_FILE = "/etc/timezone"
-ZONEINFO_DIR = "/usr/share/zoneinfo"
-LOCALTIME_FILE = "/etc/localtime"
-KERBEROS_CONF_FILE = "/etc/krb5.conf"
-NSSWITCH_CONF_FILE = "/etc/nsswitch.conf"
-NTP_CONF_FILE = "/etc/ntp.conf"
-MODPROBE_CONF_FILE = "/etc/modprobe.d/bonding.conf"
-SYSCONFIG_NETWORK_FILE = "/etc/sysconfig/network"
-RESOLV_CONF_FILE = "/etc/resolv.conf"
-DNSMASQ_LEASE_FILE = "/var/tmp/dnsmasq.leases"
-LIVE_MODE_FILE = "/etc/live"
-ADD_SERVER_COMPLETED_FILE = "/var/tmp/installation-completed"
-
-DNSMASQ_DNS_CONF_FILE = DNSMASQ_CONF_DIR + "/dns.conf"
-DNSMASQ_DHCP_CONF_FILE = DNSMASQ_CONF_DIR + "/dhcp.conf"
-##
-
-## Base constants
-MAX_PARTITION_SIZE = 16777216 # 16 TB
-OS_PARTITION_SIZE = 4000 # 4 GB
-SESSION_TIMEOUT = 1800 # 30 minutes
-SERVER_AGENT_PORT = 50000
-
-BOOT_PARTITION_LABEL = "GLUSTEROS"
-DATA_PARTITION_LABEL = "GLUSTERDATA"
-VOLUME_USER_DESCRIPTION = "Gluster Volume User"
-SERVER_AGENT_RUN_USERNAME = "gluster"
-INSTALLER_SERVER_NAME = "$installer$"
-
-GLUSTER_BASE_DIR = "/etc/glustermg"
-GLUSTER_LUN_DIR = "/data"
-REEXPORT_DIR = "/reexport"
-NFS_EXPORT_DIR = "/nfs"
-CIFS_EXPORT_DIR = "/cifs"
-WEBDAV_DOCUMENT_ROOT_DIR = "/var/www/html"
-UPDATES_DIR = "/UPDATES"
-TRANSPORT_HOME_DIR = "/transport"
-GLUSTERFS_LOG_DIR = "/var/log/glusterfs"
-LOG_DIR = "/var/log/glustermg"
-
-GLUSTER_UPDATES_FILE = "updates.xml"
-INSTALLER_STATUS_FILE = "/var/log/install-server-status.log"
-INSTALL_PLATFORM_LOCK_FILE = "/var/lock/install-gluster-platform.lock"
-LAST_ACCESSED_NETWORK_FILE = "last-accessed-network"
-PREPARE_DATA_DISK_LOCK_FILE = "/var/tmp/prepare-data-disk.lock"
-##
-
-## Derived constants
-GLUSTER_CONF_DIR = GLUSTER_BASE_DIR + "/conf"
-GLUSTER_TMP_DIR = GLUSTER_BASE_DIR + "/tmp"
-VOLUME_CONF_DIR = GLUSTER_BASE_DIR + "/volumes"
-SERVER_CONF_DIR = GLUSTER_BASE_DIR + "/servers"
-DNS_RECORDS_DIR = GLUSTER_BASE_DIR + "/dns-records"
-INSTALLER_CONF_DIR = SERVER_CONF_DIR + "/" + INSTALLER_SERVER_NAME
-
-GSN_USER_INFO_FILE = GLUSTER_BASE_DIR + "/gsn-user.info"
-GLUSTER_VERSION_FILE = GLUSTER_BASE_DIR + "/version"
-GLUSTER_UPDATE_SITE_FILE = GLUSTER_BASE_DIR + "/update-site"
-GLUSTER_DIRECTORY_SERVICE_CONF_FILE = GLUSTER_BASE_DIR + "/directory.xml"
-GLUSTER_TIME_CONF_FILE = GLUSTER_BASE_DIR + "/timeconfig.xml"
-TRANSACTION_KEY_FILE = GLUSTER_BASE_DIR + "/transaction.key"
-SERVER_COUNT_FILE = GLUSTER_BASE_DIR + "/server-count"
-SIGNATURE_FILE = GLUSTER_BASE_DIR + "/.signature"
-GLUSTER_SERVER_POOL_FILE = GLUSTER_BASE_DIR + "/pool"
-GLUSTER_ADMIN_FILE = GLUSTER_BASE_DIR + "/.password"
-
-VOLUME_SMBCONF_FILE = VOLUME_CONF_DIR + "/volumes.smbconf.list"
-
-GLOBAL_NETWORK_FILE = INSTALLER_CONF_DIR + "/network.xml"
-INSTALL_SERVER_CONF_FILE = INSTALLER_CONF_DIR + "/installer.xml"
-INSTALLER_INFO_FILE = INSTALLER_CONF_DIR + "/installer.info"
-INSTALLED_SERVER_COUNT_FILE = INSTALLER_CONF_DIR + "/installed-server-count"
-
-SESSION_FILE = GLUSTER_TMP_DIR + "/login.sessions"
-
-GENERAL_LOG_FILE = LOG_DIR + "/general.log"
-INSTALLER_LOG_FILE = LOG_DIR + "/installer.log"
-PEER_AGENT_LOG_FILE = LOG_DIR + "/peeragent.log"
-SERVER_AGENT_LOG_FILE = LOG_DIR + "/serveragent.log"
-TRANSPORT_AGENT_LOG_FILE = LOG_DIR + "/transport.log"
-##
-
-
-## Global variables
-## TODO: These should be removed
-DOWNLOAD_GLUSTER_UPDATE_PROCESS = None
-DOWNLOAD_GLUSTER_UPDATE_LEVEL = None
-DOWNLOAD_GLUSTER_CURRENT_UPDATE_LEVEL = None
-DOWNLOAD_GLUSTER_UPDATE_MD5SUM = None
-REQUEST_MAP = {}
-VERSION_DICTONARY = {}
-##
-
-AWS_WEB_SERVICE_URL = "http://169.254.169.254/latest"
-REAL_SAMBA_CONF_FILE = "/etc/samba/real.smb.conf"
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/Utils.py b/src/com.gluster.storage.management.gateway.scripts/src/Utils.py
deleted file mode 100644
index 82f8b7b6..00000000
--- a/src/com.gluster.storage.management.gateway.scripts/src/Utils.py
+++ /dev/null
@@ -1,1086 +0,0 @@
-# Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
-# This file is part of Gluster Storage Platform.
-#
-# Gluster Storage Platform is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 3 of
-# the License, or (at your option) any later version.
-#
-# Gluster Storage Platform 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see
-# <http://www.gnu.org/licenses/>.
-
-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 re
-import socket
-import struct
-import syslog
-import subprocess
-#import spwd
-import time
-#import uuid
-import tempfile
-import grp
-import pwd
-import inspect
-from datetime import datetime
-import urllib
-
-import Globals
-import Protocol
-
-RUN_COMMAND_ERROR = -1024
-LOG_SYSLOG = 1
-SYSLOG_REQUIRED = False
-LOG_FILE_NAME = None
-LOG_FILE_OBJ = None
-
-
-def _getLogCode(priority):
- if syslog.LOG_EMERG == priority:
- return "M"
- elif syslog.LOG_ALERT == priority:
- return "A"
- elif syslog.LOG_CRIT == priority:
- return "C"
- elif syslog.LOG_ERR == priority:
- return "E"
- elif syslog.LOG_WARNING == priority:
- return "W"
- elif syslog.LOG_NOTICE == priority:
- return "N"
- elif syslog.LOG_INFO == priority:
- return "I"
- elif syslog.LOG_DEBUG == priority:
- return "D"
- else: # UNKNOWN
- return "X"
-
-
-def setLogFile(fileName):
- global LOG_FILE_NAME
-
- if fileName:
- LOG_FILE_NAME = fileName
- return True
- return False
-
-
-def closeLog():
- global LOG_FILE_OBJ
- global SYSLOG_REQUIRED
-
- if SYSLOG_REQUIRED:
- syslog.closelog()
- SYSLOG_REQUIRED = False
- return True
-
- if LOG_FILE_OBJ:
- try:
- LOG_FILE_OBJ.close()
- LOG_FILE_OBJ = None
- except IOError, e:
- sys.stderr.write("Failed to close file: %s\n" % e)
- return False
- return True
-
-
-def openLog(fileName=None):
- global LOG_FILE_NAME
- global LOG_FILE_OBJ
- global SYSLOG_REQUIRED
-
- if fileName == LOG_SYSLOG:
- syslog.openlog(os.path.basename(sys.argv[0]))
- SYSLOG_REQUIRED = True
- return True
-
- if fileName:
- LOG_FILE_NAME = fileName
-
- if not LOG_FILE_NAME:
- return False
-
- closeLog()
-
- try:
- LOG_FILE_OBJ = open(LOG_FILE_NAME, "a")
- except IOError, e:
- sys.stderr.write("Failed to open file %s: %s\n" % (LOG_FILE_NAME, e))
- return False
- return True
-
-def record(priority, message=None):
- global LOG_FILE_OBJ
- global SYSLOG_REQUIRED
-
- stack = inspect.stack()[1]
- if stack[3] == "<module>":
- prefix = "%s:%s:%s" % (stack[1], stack[2], stack[3])
- else:
- prefix = "%s:%s:%s()" % (stack[1], stack[2], stack[3])
-
- if type(priority) == type("") or type(priority) == type(u""):
- logPriority = syslog.LOG_INFO
- logMessage = priority
- else:
- logPriority = priority
- logMessage = message
-
- if SYSLOG_REQUIRED:
- syslog.syslog(logPriority, "[%s]: %s" % (prefix, logMessage))
- return
-
- fp = sys.stderr
- if LOG_FILE_OBJ:
- fp = LOG_FILE_OBJ
-
- fp.write("[%s] %s [%s]: %s" % (str(datetime.now()), _getLogCode(logPriority), prefix, logMessage))
- if logMessage[-1] != '\n':
- fp.write("\n")
- fp.flush()
- return
-
-
-def trace(message):
- if message:
- log(syslog.LOG_DEBUG, message)
-
-
-def isString(value):
- return (type(value) == type("") or type(value) == type(u""))
-
-
-def getTempFileName():
- filedesc, filename = tempfile.mkstemp(prefix="GSP_")
- os.close(filedesc)
- return filename
-
-
-def runCommandBG(command, stdinFileObj=None, stdoutFileObj=None, stderrFileObj=None,
- shell=False, root=None):
- log("runCommandBG(): Trying to execute command [%s]" % command)
-
- if shell:
- if not isString(command):
- return None
- else:
- if isString(command):
- command = command.split()
-
- if root == True:
- if shell:
- command = "sudo " + command
- else:
- command = ['sudo'] + command
- elif isString(root):
- if shell:
- command = "sudo -u " + root + " " + command
- else:
- command = ['sudo', '-u', root] + command
-
- if not stdinFileObj:
- stdinFileObj=subprocess.PIPE
- if not stdoutFileObj:
- stdoutFileObj=subprocess.PIPE
- if not stderrFileObj:
- stderrFileObj=subprocess.PIPE
-
- try:
- process = subprocess.Popen(command,
- bufsize=-1,
- stdin=stdinFileObj,
- stdout=stdoutFileObj,
- stderr=stderrFileObj,
- shell=shell)
- return process
- except OSError, e:
- log("runCommandBG(): Failed to run command [%s]: %s" % (command, e))
- return None
-
-
-def runCommand(command,
- input='', output=False,
- shell=False, root=None):
- rv = {}
- rv["Status"] = RUN_COMMAND_ERROR
- rv["Stdout"] = None
- rv["Stderr"] = None
-
- try:
- stdinFileName = getTempFileName()
- stdinFileObj = open(stdinFileName, "w")
- stdinFileObj.write(input)
- stdinFileObj.close()
- stdinFileObj = open(stdinFileName, "r")
-
- stdoutFileName = getTempFileName()
- stdoutFileObj = open(stdoutFileName, "w")
-
- stderrFileName = getTempFileName()
- stderrFileObj = open(stderrFileName, "w")
- except IOError, e:
- log("Failed to create temporary file for executing command [%s]: %s" % (command, e))
- if output:
- return rv
- return rv["Status"]
-
- stdoutContent = None
- stderrContent = None
-
- process = runCommandBG(command,
- stdinFileObj=stdinFileObj,
- stdoutFileObj=stdoutFileObj,
- stderrFileObj=stderrFileObj,
- shell=shell, root=root)
- if process:
- rv['Status'] = process.wait()
- rv['Stdout'] = open(stdoutFileName).read()
- rv['Stderr'] = open(stderrFileName).read()
-
- os.remove(stdinFileName)
- os.remove(stdoutFileName)
- os.remove(stderrFileName)
-
- log("runCommand(): execution status of command [%s] = [%s]" % (command, rv))
-
- if output:
- return rv
- return rv["Status"]
-
-
-def runCommandFG(command, stdout=False, stderr=False,
- shell=False, root=None):
- if stdout or stderr:
- output = True
- else:
- output = False
- return runCommand(command, output=output, shell=shell, root=root)
-
-
-def IP2Number(ipString):
- try:
- return socket.htonl(struct.unpack("I", socket.inet_aton(ipString))[0])
- except socket.error:
- return None
- except TypeError:
- return None
- except struct.error:
- return None
-
-
-def Number2IP(number):
- try:
- return socket.inet_ntoa(struct.pack("I", socket.ntohl(number)))
- except socket.error:
- return None
- except AttributeError:
- return None
- except ValueError:
- return None
-
-
-def computeHostName(hostName):
- if not hostName:
- return False
-
- hostPrefix = ""
- for i in range(len(hostName), 0, -1):
- pos = i - 1
- if hostName[pos].isdigit():
- continue
- break
- hostPrefix = hostName[:pos+1]
- try:
- hostIndex = int(hostName[pos+1:])
- except ValueError:
- hostIndex = 0
- # TODO: Check the availablity of the (server) name
- return "%s%s" % (hostPrefix, hostIndex + 1)
-
-
-def daemonize():
- try:
- pid = os.fork()
- if pid > 0:
- # exit first parent
- sys.exit(0)
- except OSError, e:
- #sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror))
- return False
-
- # decouple from parent environment
- os.chdir("/")
- os.setsid()
- os.umask(0)
-
- # do second fork
- try:
- pid = os.fork()
- if pid > 0:
- # exit from second parent
- sys.exit(0)
- except OSError, e:
- #sys.stderr.write("fork #2 failed: %d (%s)\n" % (e.errno, e.strerror))
- return False
-
- # redirect standard file descriptors
- sys.stdout.flush()
- sys.stderr.flush()
- si = file("/dev/null", 'r')
- so = file("/dev/null", 'a+')
- se = file("/dev/null", 'a+', 0)
- os.dup2(si.fileno(), sys.stdin.fileno())
- os.dup2(so.fileno(), sys.stdout.fileno())
- os.dup2(se.fileno(), sys.stderr.fileno())
- return True
-
-
-def getDownloadStatus(fileName):
- try:
- lines = [line for line in open(fileName)
- if "saved" in line or "%" in line]
- except IOError:
- return 0
- if not lines:
- return 0
- if "saved" in lines[-1]:
- return 100
- return lines[-1].split("%")[0].split()[-1]
-
-
-def getMeminfo():
- """-> dict of data from meminfo (str:int).
- Values are in kilobytes.
- """
- import re
- re_parser = re.compile(r'^(?P<key>\S*):\s*(?P<value>\d*)\s*kB' )
- result = {}
- for line in open('/proc/meminfo'):
- match = re_parser.match(line)
- if not match:
- continue # skip lines that don't parse
- key, value = match.groups(['key', 'value'])
- result[key] = int(value)
- result['MemUsed'] = (result['MemTotal'] - result['MemFree'])
- return result
-
-
-def getCpuUsage():
- """-> dict of cpuid : (usertime, nicetime, systemtime, idletime)
- cpuid "cpu" means the total for all CPUs.
- cpuid "cpuN" means the value for CPU N.
- """
- wanted_records = [line for line in open('/proc/stat') if
- line.startswith('cpu')]
- result = {}
- for cpuline in wanted_records:
- fields = cpuline.split()[:5]
- data = map(int, fields[1:])
- result[fields[0]] = tuple(data)
- return result
-
-def _getCpuStatList():
- try:
- fp = open("/proc/stat")
- line = fp.readline()
- fp.close()
- return map(float, line.split()[1:5])
- except IOError, e:
- Utils.log("Failed to open /proc/stat: %s" % str(e))
- return None
-
-def getCpuUsageAvg():
- st1 = _getCpuStatList()
- #time1 = time.time()
- time.sleep(1)
- st2 = _getCpuStatList()
- #time2 = time.time()
- if not (st1 and st2):
- return None
- usageTime = (st2[0] - st1[0]) + (st2[1] - st1[1]) + (st2[2] - st1[2])
- try:
- return (100.0 * usageTime) / (usageTime + (st2[3] - st1[3]))
- except ZeroDivisionError, e:
- return 0
-
-def getLoadavg():
- try:
- loadavgstr = open('/proc/loadavg', 'r').readline().strip()
- except IOError:
- syslog.syslog(syslog.LOG_ERR, "failed to find cpu load")
- return None
-
- data = map(float, loadavgstr.split()[1:])
- # returns 1 minute load average
- return data[0]
-
-
-def getInfinibandPortStatus():
-
- """ Check for availability of infiniband port
- and return which port is active in a key pair value
- """
-
- # Check for existence of infiniband ports
- value = os.popen ("ls /sys/class/infiniband").readline().strip()
-
- if not value:
- return None
-
- portlist = os.popen ("echo /sys/class/infiniband/*/ports/*").readline().split()
-
- portkeys = {}
-
- for port in portlist:
- value = os.popen ("cat %s/state" %
- port.strip()).readline().split(':')[1].strip()
- portkeys[port.strip()] = value
-
- return portkeys
-
-
-def getServerFqdn():
- rv = runCommand("hostname --fqdn", output=True, root=True)
- if not rv["Stderr"]:
- return stripEmptyLines(rv["Stdout"])
- return socket.gethostname()
-
-
-def getServerCount():
- try:
- return int(open(Globals.SERVER_COUNT_FILE).read().strip())
- except IOError:
- log("failed to read file %s" % Globals.SERVER_COUNT_FILE)
- return 1
- except ValueError:
- log("invalid number format in file %s" % Globals.SERVER_COUNT_FILE)
- return 1
-
-
-def setServerCount(count):
- try:
- open(Globals.SERVER_COUNT_FILE, "w").write("%s\n" % count)
- return True
- except IOError:
- log("failed to write file %s" % Globals.SERVER_COUNT_FILE)
- return False
-
-
-def getInstalledServerCount():
- try:
- return int(open(Globals.INSTALLED_SERVER_COUNT_FILE).read().strip())
- except IOError:
- log("failed to read file %s" % Globals.INSTALLED_SERVER_COUNT_FILE)
- return 1
- except ValueError:
- log("invalid number format in file %s" % Globals.INSTALLED_SERVER_COUNT_FILE)
- return 1
-
-
-def setInstalledServerCount(count):
- try:
- open(Globals.INSTALLED_SERVER_COUNT_FILE, "w").write("%s\n" % count)
- return True
- except IOError:
- log("failed to write file %s" % Globals.INSTALLED_SERVER_COUNT_FILE)
- return False
-
-
-def getLastInstalledServerIpList():
- ipList = {}
- networkDom = Protocol.XDOM()
- if not networkDom.parseFile(Globals.GLOBAL_NETWORK_FILE):
- log("failed to parse file %s" % Globals.GLOBAL_NETWORK_FILE)
- for tagE in networkDom.getElementsByTagRoute("server.interface"):
- interfaceDom = Protocol.XDOM()
- interfaceDom.setDomObj(tagE)
- ipAddress = interfaceDom.getTextByTagRoute("ipaddr")
- if ipAddress:
- ipList[interfaceDom.getTextByTagRoute("device")] = ipAddress
- return ipList
-
-
-def getFreeIpAddress(device=None):
- serverCount = getServerCount()
- installedServerCount = getInstalledServerCount()
- if serverCount == installedServerCount:
- return None
-
- availableServerCount = serverCount - installedServerCount
- ipList = getLastInstalledServerIpList()
-
- if not ipList:
- return None
-
- if device:
- if device not in ipList.keys():
- return None
- deviceIpAddress = ipList[device]
- else:
- deviceIpAddress = ipList.values()[0]
- ipNumber = IP2Number(deviceIpAddress)
-
- for i in range((ipNumber + availableServerCount), ipNumber, -1):
- ipAddress = Number2IP(i)
- if runCommandFG(["ping", "-qnc", "1", ipAddress]) != 0:
- return ipAddress
- return None
-
-
-def getPasswordHash(userName):
- try:
- #return spwd.getspnam(userName).sp_pwd
- return "Not implimented"
- except KeyError:
- return None
-
-
-def getTransactionKey():
- try:
- tokens = open(Globals.TRANSACTION_KEY_FILE).read().split(',')
- except IOError:
- return None, None
- return tokens
-
-
-def generateSignature():
- #return str(uuid.uuid4()) + ('--%f' % time.time())
- return ('--%f' % time.time())
-
-
-def getSignature():
- try:
- return open(Globals.SIGNATURE_FILE).read().strip()
- except IOError:
- log(syslog.LOG_ERR, "unable to read signaure from %s file" % Globals.SIGNATURE_FILE)
- return False
-
-
-def storeSignature(signature, fileName=Globals.SIGNATURE_FILE):
- try:
- open(fileName, "w").write(signature + "\n")
- except IOError:
- log(syslog.LOG_ERR, "unable to write signature %s to %s file" % (signature, fileName))
- return False
- return True
-
-
-def isUserExist(userName):
- try:
- grp.getgrnam(userName).gr_gid
- return True
- except KeyError:
- pass
- try:
- pwd.getpwnam(userName).pw_uid
- return True
- except KeyError:
- pass
- return False
-
-
-def getGsnUserInfo(fileName=Globals.GSN_USER_INFO_FILE):
- userInfo = {}
- userInfo["UserId"] = None
- userInfo["Password"] = None
- try:
- for line in open(fileName):
- line = line.strip()
- k = line[:line.index("=")]
- v = line[line.index("=") + 1:]
- if v[0] == "'" or v[0] == '"':
- v = v[1:]
- if v[-1] == "'" or v[-1] == '"':
- v = v[:-1]
- if k.upper() == "GSN_ID":
- userInfo["UserId"] = v
<