|
|
9f5ccc |
From 8b5b3b247a00515d3188453c27b0ba749e93d325 Mon Sep 17 00:00:00 2001
|
|
|
9f5ccc |
From: Aravinda VK <avishwan@redhat.com>
|
|
|
9f5ccc |
Date: Tue, 26 Mar 2019 13:20:13 +0530
|
|
|
9f5ccc |
Subject: [PATCH 339/344] geo-rep: fix integer config validation
|
|
|
9f5ccc |
|
|
|
9f5ccc |
ssh-port validation is mentioned as `validation=int` in template
|
|
|
9f5ccc |
`gsyncd.conf`, but not handled this during geo-rep config set.
|
|
|
9f5ccc |
|
|
|
9f5ccc |
upstream patch:
|
|
|
9f5ccc |
https://review.gluster.org/#/c/glusterfs/+/22418/
|
|
|
9f5ccc |
Backport of:
|
|
|
9f5ccc |
|
|
|
9f5ccc |
>Fixes: bz#1692666
|
|
|
9f5ccc |
>Change-Id: I3f19d9b471b0a3327e4d094dfbefcc58ed2c34f6
|
|
|
9f5ccc |
>Signed-off-by: Aravinda VK <avishwan@redhat.com>
|
|
|
9f5ccc |
>Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
|
|
|
9f5ccc |
|
|
|
9f5ccc |
BUG: 1782162
|
|
|
9f5ccc |
Change-Id: I3f19d9b471b0a3327e4d094dfbefcc58ed2c34f6
|
|
|
9f5ccc |
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
|
|
|
9f5ccc |
Reviewed-on: https://code.engineering.redhat.com/gerrit/187533
|
|
|
9f5ccc |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
9f5ccc |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
9f5ccc |
---
|
|
|
9f5ccc |
geo-replication/syncdaemon/gsyncdconfig.py | 23 ++++++++++++++++++-----
|
|
|
9f5ccc |
tests/00-geo-rep/georep-basic-dr-rsync.t | 3 +++
|
|
|
9f5ccc |
2 files changed, 21 insertions(+), 5 deletions(-)
|
|
|
9f5ccc |
|
|
|
9f5ccc |
diff --git a/geo-replication/syncdaemon/gsyncdconfig.py b/geo-replication/syncdaemon/gsyncdconfig.py
|
|
|
9f5ccc |
index f823311..8848071 100644
|
|
|
9f5ccc |
--- a/geo-replication/syncdaemon/gsyncdconfig.py
|
|
|
9f5ccc |
+++ b/geo-replication/syncdaemon/gsyncdconfig.py
|
|
|
9f5ccc |
@@ -329,6 +329,9 @@ class Gconf(object):
|
|
|
9f5ccc |
if item["validation"] == "unixtime":
|
|
|
9f5ccc |
return validate_unixtime(value)
|
|
|
9f5ccc |
|
|
|
9f5ccc |
+ if item["validation"] == "int":
|
|
|
9f5ccc |
+ return validate_int(value)
|
|
|
9f5ccc |
+
|
|
|
9f5ccc |
return False
|
|
|
9f5ccc |
|
|
|
9f5ccc |
def _is_config_changed(self):
|
|
|
9f5ccc |
@@ -381,6 +384,14 @@ def config_upgrade(config_file, ret):
|
|
|
9f5ccc |
config.write(configfile)
|
|
|
9f5ccc |
|
|
|
9f5ccc |
|
|
|
9f5ccc |
+def validate_int(value):
|
|
|
9f5ccc |
+ try:
|
|
|
9f5ccc |
+ _ = int(value)
|
|
|
9f5ccc |
+ return True
|
|
|
9f5ccc |
+ except ValueError:
|
|
|
9f5ccc |
+ return False
|
|
|
9f5ccc |
+
|
|
|
9f5ccc |
+
|
|
|
9f5ccc |
def validate_unixtime(value):
|
|
|
9f5ccc |
try:
|
|
|
9f5ccc |
y = datetime.fromtimestamp(int(value)).strftime("%Y")
|
|
|
9f5ccc |
@@ -393,11 +404,13 @@ def validate_unixtime(value):
|
|
|
9f5ccc |
|
|
|
9f5ccc |
|
|
|
9f5ccc |
def validate_minmax(value, minval, maxval):
|
|
|
9f5ccc |
- value = int(value)
|
|
|
9f5ccc |
- minval = int(minval)
|
|
|
9f5ccc |
- maxval = int(maxval)
|
|
|
9f5ccc |
-
|
|
|
9f5ccc |
- return value >= minval and value <= maxval
|
|
|
9f5ccc |
+ try:
|
|
|
9f5ccc |
+ value = int(value)
|
|
|
9f5ccc |
+ minval = int(minval)
|
|
|
9f5ccc |
+ maxval = int(maxval)
|
|
|
9f5ccc |
+ return value >= minval and value <= maxval
|
|
|
9f5ccc |
+ except ValueError:
|
|
|
9f5ccc |
+ return False
|
|
|
9f5ccc |
|
|
|
9f5ccc |
|
|
|
9f5ccc |
def validate_choice(value, allowed_values):
|
|
|
9f5ccc |
diff --git a/tests/00-geo-rep/georep-basic-dr-rsync.t b/tests/00-geo-rep/georep-basic-dr-rsync.t
|
|
|
9f5ccc |
index b432635..b6fbf18 100644
|
|
|
9f5ccc |
--- a/tests/00-geo-rep/georep-basic-dr-rsync.t
|
|
|
9f5ccc |
+++ b/tests/00-geo-rep/georep-basic-dr-rsync.t
|
|
|
9f5ccc |
@@ -71,6 +71,9 @@ EXPECT_WITHIN $GEO_REP_TIMEOUT 4 check_status_num_rows "Created"
|
|
|
9f5ccc |
#Config gluster-command-dir
|
|
|
9f5ccc |
TEST $GEOREP_CLI $master $slave config gluster-command-dir ${GLUSTER_CMD_DIR}
|
|
|
9f5ccc |
|
|
|
9f5ccc |
+#Config Set ssh-port to validate int validation
|
|
|
9f5ccc |
+TEST $GEOREP_CLI $master $slave config ssh-port 22
|
|
|
9f5ccc |
+
|
|
|
9f5ccc |
#Config gluster-command-dir
|
|
|
9f5ccc |
TEST $GEOREP_CLI $master $slave config slave-gluster-command-dir ${GLUSTER_CMD_DIR}
|
|
|
9f5ccc |
|
|
|
9f5ccc |
--
|
|
|
9f5ccc |
1.8.3.1
|
|
|
9f5ccc |
|