summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/dht_test_utils.py')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/dht_test_utils.py46
1 files changed, 42 insertions, 4 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py b/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
index 55dcce5c7..11f2eda62 100644
--- a/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
+++ b/glustolibs-gluster/glustolibs/gluster/dht_test_utils.py
@@ -29,7 +29,6 @@ import glustolibs.gluster.constants as k
import glustolibs.gluster.exceptions as gex
from glustolibs.gluster.brickdir import BrickDir
from glustolibs.gluster.volume_libs import get_subvols, get_volume_type
-from glustolibs.gluster.gluster_init import get_gluster_version
from glustolibs.misc.misc_libs import upload_scripts
@@ -39,9 +38,8 @@ def run_layout_tests(mnode, fqpath, layout, test_type):
brick_path_list = ret.get('brickdir_paths')
for brickdir_path in brick_path_list:
(server_ip, _) = brickdir_path.split(':')
- if (get_gluster_version(server_ip) >= 6.0 and
- get_volume_type(brickdir_path) in ('Replicate', 'Disperse',
- 'Arbiter')):
+ if get_volume_type(brickdir_path) in ('Replicate', 'Disperse',
+ 'Arbiter'):
g.log.info("Cannot check for layout completeness as"
" volume under test is Replicate/Disperse/Arbiter")
else:
@@ -342,6 +340,44 @@ def find_new_hashed(subvols, parent_path, oldname):
return None
+def find_specific_hashed(subvols, parent_path, subvol, existing_names=None):
+ """ Finds filename that hashes to a specific subvol.
+
+ Args:
+ subvols(list): list of subvols
+ parent_path(str): parent path (relative to mount) of "oldname"
+ subvol(str): The subvol to which the new name has to be hashed
+ existing_names(int|list): The name(s) already hashed to subvol
+
+ Returns:
+ (Class Object): For success returns an object of type NewHashed
+ holding information pertaining to new name.
+ None, otherwise
+ Note: The new hash will be searched under the same parent
+ """
+ # pylint: disable=protected-access
+ if not isinstance(existing_names, list):
+ existing_names = [existing_names]
+ brickobject = create_brickobjectlist(subvols, parent_path)
+ if brickobject is None:
+ g.log.error("could not form brickobject list")
+ return None
+ count = -1
+ for item in range(1, 5000, 1):
+ newhash = calculate_hash(brickobject[0]._host, str(item))
+ for brickdir in brickobject:
+ count += 1
+ if (subvol._fqpath == brickdir._fqpath and
+ item not in existing_names):
+ ret = brickdir.hashrange_contains_hash(newhash)
+ if ret:
+ g.log.debug("oldhashed %s new %s count %s",
+ subvol, brickdir._host, str(count))
+ return NewHashed(item, brickdir, count)
+ count = -1
+ return None
+
+
class NewHashed(object):
'''
Helper Class to hold new hashed info
@@ -420,3 +456,5 @@ def is_layout_complete(mnode, volname, dirpath):
return False
elif hash_difference < 1:
g.log.error("Layout has overlaps")
+
+ return True