diff options
| -rw-r--r-- | geo-replication/syncdaemon/gsyncdconfig.py | 23 | ||||
| -rw-r--r-- | tests/00-geo-rep/georep-basic-dr-rsync.t | 3 | 
2 files changed, 21 insertions, 5 deletions
diff --git a/geo-replication/syncdaemon/gsyncdconfig.py b/geo-replication/syncdaemon/gsyncdconfig.py index 23a1c5769c7..26fb6a57318 100644 --- a/geo-replication/syncdaemon/gsyncdconfig.py +++ b/geo-replication/syncdaemon/gsyncdconfig.py @@ -313,6 +313,9 @@ class Gconf(object):          if item["validation"] == "unixtime":              return validate_unixtime(value) +        if item["validation"] == "int": +            return validate_int(value) +          return False      def _is_config_changed(self): @@ -326,6 +329,14 @@ class Gconf(object):          return False +def validate_int(value): +    try: +        _ = int(value) +        return True +    except ValueError: +        return False + +  def validate_unixtime(value):      try:          y = datetime.fromtimestamp(int(value)).strftime("%Y") @@ -338,11 +349,13 @@ def validate_unixtime(value):  def validate_minmax(value, minval, maxval): -    value = int(value) -    minval = int(minval) -    maxval = int(maxval) - -    return value >= minval and value <= maxval +    try: +        value = int(value) +        minval = int(minval) +        maxval = int(maxval) +        return value >= minval and value <= maxval +    except ValueError: +        return False  def validate_choice(value, allowed_values): diff --git a/tests/00-geo-rep/georep-basic-dr-rsync.t b/tests/00-geo-rep/georep-basic-dr-rsync.t index 4a03930efe2..062ca91760c 100644 --- a/tests/00-geo-rep/georep-basic-dr-rsync.t +++ b/tests/00-geo-rep/georep-basic-dr-rsync.t @@ -71,6 +71,9 @@ EXPECT_WITHIN $GEO_REP_TIMEOUT 4 check_status_num_rows "Created"  #Config gluster-command-dir  TEST $GEOREP_CLI $master $slave config gluster-command-dir ${GLUSTER_CMD_DIR} +#Config Set ssh-port to validate int validation +TEST $GEOREP_CLI $master $slave config ssh-port 22 +  #Config gluster-command-dir  TEST $GEOREP_CLI $master $slave config slave-gluster-command-dir ${GLUSTER_CMD_DIR}  | 
