diff options
author | sayaleeraut <saraut@redhat.com> | 2020-02-17 17:34:22 +0530 |
---|---|---|
committer | Bala Konda Reddy M <bala12352@gmail.com> | 2020-02-18 09:19:26 +0000 |
commit | 3fe9165451733890ddd4e6b913160c249ec6ecf2 (patch) | |
tree | f3904ce4d44a85a2f92a89f774f9d454d0cc9ffe /glustolibs-gluster | |
parent | 47bfa358b326c56854e4868084a000d17d0e6780 (diff) |
[LibFix] Add code to check brick
Earlier the method get_volume_type() passed when ran on interpreter.
But when the method was called in a TC, it failed at condition (Line:
2235) because :
e.g.
The value of brickdir_path is "dhcp47-3.lab.eng.blr.redhat.com:/bricks/
brick2/testvol_replicated_brick2/" and it is trying to find the value
in the list ['10.70.46.172:/bricks/brick2/testvol_replicated_brick0',
'10.70.46.195:/bricks/brick2/testvol_replicated_brick1',
'10.70.47.3:/bricks/brick2/testvol_replicated_brick2'] returned by
get_all_bricks(), which will fail.
Now, with fix, it will run successfully as it tries to check if for host
dhcp47-3.lab.eng.blr.redhat.com, the brick
/bricks/brick2/testvol_replicated_brick2 is present in the list
brick_paths[] which consists of only the paths and not the IP addresses
of the bricks present on that host.
Change-Id: Ie595faba1e92c559293ddd04f46b85065b23dfc5
Signed-off-by: sayaleeraut <saraut@redhat.com>
Diffstat (limited to 'glustolibs-gluster')
-rw-r--r-- | glustolibs-gluster/glustolibs/gluster/volume_libs.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/volume_libs.py b/glustolibs-gluster/glustolibs/gluster/volume_libs.py index 435ddcf43..b530f80a1 100644 --- a/glustolibs-gluster/glustolibs/gluster/volume_libs.py +++ b/glustolibs-gluster/glustolibs/gluster/volume_libs.py @@ -2222,7 +2222,7 @@ def get_volume_type(brickdir_path): Args: brickdir_path(str): The complete brick path. - (e.g., server1.example.com:/bricks/brick1) + (e.g., server1.example.com:/bricks/brick1/testvol_brick0/) Returns: volume type(str): The volume type in str. @@ -2230,9 +2230,12 @@ def get_volume_type(brickdir_path): """ # Adding import here to avoid cyclic imports from glustolibs.gluster.brick_libs import get_all_bricks - (host, _) = brickdir_path.split(':') + (host, brick_path_info) = brickdir_path.split(':') + path_info = brick_path_info[:-1] for volume in get_volume_list(host): - if brickdir_path in get_all_bricks(host, volume): + brick_paths = [brick.split(':')[1] for brick in get_all_bricks(host, + volume)] + if path_info in brick_paths: ret = get_volume_info(host, volume) if ret is None: g.log.error("Failed to get volume type for %s", volume) @@ -2247,5 +2250,5 @@ def get_volume_type(brickdir_path): else: return ret[volume].get('typeStr') else: - g.log.info("Failed to find brick-path %s for vol %s", + g.log.info("Failed to find brick-path %s for volume %s", brickdir_path, volume) |