From 6530684f9f32ecf5c0af4547ec3666e5aaeef9d2 Mon Sep 17 00:00:00 2001 From: Vijaykumar Date: Thu, 19 Jan 2012 15:49:17 +0530 Subject: library functions: remove-brick, quota, profile top, log rotate, replace-brick and testenv function (removeBricksFromVolume). Change-Id: I6593f831e5002bd077eee0ce8bf6a8c5aca18ba5 Signed-off-by: Vijaykumar --- libs/globals/testenv.py | 104 +++++++----- libs/utils/glusterutils.py | 388 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 366 insertions(+), 126 deletions(-) mode change 100755 => 100644 libs/globals/testenv.py diff --git a/libs/globals/testenv.py b/libs/globals/testenv.py old mode 100755 new mode 100644 index a73858b..e5d1b6b --- a/libs/globals/testenv.py +++ b/libs/globals/testenv.py @@ -21,7 +21,7 @@ class TestEnv(): self._mounts = {} self._gluster_download_paths = [] self._active_volume = None - + self._exportdir_tuple = namedtuple('ExportDir', ['dir', 'fstype', 'device', 'options']) @@ -35,7 +35,7 @@ class TestEnv(): self._volume_tuple = namedtuple('Volume', ['volumename','replica', 'stripe', 'transporttype', 'bricks']) - + self._client_tuple = namedtuple('Client', ['hostname', 'user', 'password', 'glusterversion', 'installpath']) @@ -61,7 +61,7 @@ class TestEnv(): if (arguments.has_key('options') and arguments['options']): options = arguments['options'] - + exportdir_obj = self._exportdir_tuple(dir_, fstype, device, options) self._exportdirs[key] = exportdir_obj @@ -81,7 +81,7 @@ class TestEnv(): """ return self._exportdirs - + def addServer(self, key, hostname, user, password, glusterversion, **arguments): """ @@ -89,10 +89,10 @@ class TestEnv(): installpath = None if (arguments.has_key('installpath') and arguments['installpath']): installpath = arguments['installpath'] - + server_obj = self._server_tuple(hostname, user, password, glusterversion, installpath) - + self._servers[key] = server_obj def getServer(self, serverkey): @@ -101,7 +101,7 @@ class TestEnv(): server_obj = None if self._servers.has_key(serverkey): server_obj = self._servers[serverkey] - + return server_obj def getServers(self): @@ -111,7 +111,7 @@ class TestEnv(): for serverkey in self._servers.keys(): servers[serverkey] = self.getServer(serverkey) - + return servers def addClient(self, key, hostname, user, password, @@ -121,7 +121,7 @@ class TestEnv(): installpath = None if arguments.has_key('installpath') and arguments['installpath']: installpath = arguments['installpath'] - + client_obj = self._client_tuple(hostname, user, password, glusterversion, installpath) self._clients[key] = client_obj @@ -132,7 +132,7 @@ class TestEnv(): client_obj = None if self._clients.has_key(clientkey): client_obj = self._clients[clientkey] - + return client_obj def getClients(self): @@ -144,7 +144,7 @@ class TestEnv(): clients[clientkey] = self.getClient(clientkey) return clients - + def addBrick(self, key, hostname, path, **arguments): """ """ @@ -156,7 +156,7 @@ class TestEnv(): """ return_brick_obj = None newhostname = newpath = '' - + if self._bricks.has_key(brickkey): brick_obj = self._bricks[brickkey] else: @@ -169,7 +169,7 @@ class TestEnv(): newhostname = server_obj.hostname else: return return_brick_obj - + path_value = brick_obj.path if re.match("^\/", path_value): newpath = path_value @@ -183,7 +183,7 @@ class TestEnv(): return_brick_obj = brick_obj._replace(hostname=newhostname, path=newpath) - + return return_brick_obj def getBricks(self): @@ -193,7 +193,7 @@ class TestEnv(): for brickkey in self._bricks.keys(): return_bricks[brickkey] = self.getBrick(brickkey) - + return return_bricks def getRawBrick(self, brickkey): @@ -211,24 +211,47 @@ class TestEnv(): def addBricksToVolume(self, *bricks, **arguments): """ + Adds the added brick to volume object """ volume_obj = None - + if arguments.has_key("volumekey"): volumekey = arguments[volumekey] else: volumekey = self._active_volume - + if not (volumekey and self._volumes.has_key(volumekey)): - return 1 - + return 1 + volume_obj = self._volumes[volumekey] - + for brick in bricks: volume_obj.bricks.append(brick) - + return 0 + def removeBricksFromVolume(self, *bricks, **arguments): + """ + Removes the removed brick from volume object + """ + volume_obj = None + + if arguments.has_key("volumekey"): + volumekey = arguments['volumekay'] + else: + volumekey = self._active_volume + + if not (volumekey and self._volumes.has_key(volumekey)): + return 1 + + volume_obj = self._volumes[volumekey] + + for brick in bricks: + volume_obj.bricks.remove(brick) + + return 0 + + def replaceBrickInVolume(self, replace_brick, to_brick, volumekey="ActiveVolume"): """ @@ -237,7 +260,7 @@ class TestEnv(): replaced_status = False if volumekey == "ActiveVolume": volumekey = self._active_volume - + if not (volumekey and self._volumes.has_key(volumekey)): return 1 @@ -249,7 +272,7 @@ class TestEnv(): break else: continue - + if replaced_status: return 0 else: @@ -271,7 +294,7 @@ class TestEnv(): if not self._volumes.has_key(volumekey): return return_volume_obj - + volume_obj = self._volumes[volumekey] brickslist = [] for brickkey in volume_obj.bricks: @@ -282,7 +305,7 @@ class TestEnv(): brickslist.append(brick_obj) return_volume_obj = volume_obj._replace(bricks=brickslist) - + return return_volume_obj def getVolumes(self): @@ -309,13 +332,13 @@ class TestEnv(): """ returndevice_obj = None ip_pattern = re.compile('(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})') - + if not self._mountdevices.has_key(mountdevicekey): return returndevice_obj - + else: mountdevice_obj = self._mountdevices[mountdevicekey] - + hostname_value = mountdevice_obj.hostname if ip_pattern.match(hostname_value): newhostname = hostname_value @@ -334,7 +357,7 @@ class TestEnv(): newvolumename = volume_obj.volumename else: return returndevice_obj - + returndevice_obj = mountdevice_obj._replace(hostname=newhostname, volumename=newvolumename) @@ -348,8 +371,8 @@ class TestEnv(): for mountdevicekey in self._mountdevices.keys(): return_mount_devices[mountdevicekey] = self.getMountDevice(mountdevicekey) - return return_mount_devices - + return return_mount_devices + def addMount(self, key, client, dir_, device, **arguments): """ """ @@ -364,18 +387,18 @@ class TestEnv(): if (arguments.has_key("options") and arguments['options']): options = arguments['options'] - + mount_obj = self._mount_tuple(client, dir_, device, type_, logfile, options) self._mounts[key] = mount_obj - + def getMount(self, mountkey): """ """ return_mount_obj = None if not self._mounts.has_key(mountkey): return return_mount_obj - + mount_obj = self._mounts[mountkey] devicekey = mount_obj.device device_obj = self.getMountDevice(devicekey) @@ -402,16 +425,16 @@ class TestEnv(): mounts_keys = [] mounts_keys.extend(self._mounts.keys()) return mounts_keys - + def addDefaults(self, **arguments): """ """ downloadpaths = [] - + if (arguments.has_key('downloadpath') and arguments['downloadpath']): paths = arguments['downloadpath'] downloadpaths = [x.strip() for x in paths.split(",")] - + self._gluster_download_paths = downloadpaths def setActiveVolume(self, volumekey): @@ -461,10 +484,3 @@ class TestEnv(): else: host_obj = self.getClient(hostkey) return host_obj - - - - - - - diff --git a/libs/utils/glusterutils.py b/libs/utils/glusterutils.py index afd5db0..39f6a21 100644 --- a/libs/utils/glusterutils.py +++ b/libs/utils/glusterutils.py @@ -1,5 +1,4 @@ """glusterutils module contains wrappers for gluster commands. - *) glusterd_start *) glusterd_start_allservers *) glusterd_stop @@ -86,7 +85,7 @@ def glusterd_start(serverkey, force=False): else: logger.error("Unable to start glusterd") return 1 - + def glusterd_start_allservers(force=False): """ """ @@ -111,7 +110,7 @@ def glusterd_stop(serverkey): logger.error("SSH connection to host '%s' has not been established" % serverkey) return 1 - + gluster_pid_list = [] output = host_connection.executecommand("pidof glusterd") return_status = atfutils.assert_failure(output['exitstatus']) @@ -134,7 +133,7 @@ def glusterd_stop(serverkey): break return return_status - + def glusterd_stop_allservers(): """ """ @@ -156,7 +155,7 @@ def glusterd_restart(serverkey): else: return_status = glusterd_start(serverkey) return return_status - + def glusterd_remove_dir(serverkey): """ """ @@ -177,7 +176,7 @@ def glusterd_remove_dir(serverkey): logger.error("SSH connection to host '%s' has not been established" % serverkey) return 1 - + command = ' '.join([base_command, glusterd_dir]) logger.debug('%s: Executing Command: %s' % (serverkey, command)) output = server_connection.executecommand(command) @@ -193,7 +192,7 @@ def glusterd_remove_dir_allservers(): all_servers = env.getServers() for serverkey in all_servers.keys(): return_status = glusterd_remove_dir(serverkey) - + return 0 @@ -222,7 +221,7 @@ def glusterd_remove_logs(serverkey): if server_obj.installpath: prefix_path = server_obj.installpath - + for path in log_paths: absolute_path_list.append(prefix_path + path) @@ -235,7 +234,7 @@ def glusterd_remove_logs(serverkey): atfutils.print_stderr(output['stderrdata']) return 0 - + def glusterd_remove_logs_allservers(): """ """ @@ -243,7 +242,7 @@ def glusterd_remove_logs_allservers(): all_servers = env.getServers() for serverkey in all_servers.keys(): return_status = glusterd_remove_logs(serverkey) - + return 0 def volume_delete(serverkey): @@ -251,6 +250,7 @@ def volume_delete(serverkey): """ logger = GlobalObj.getLoggerObj() base_command = "gluster volume delete " + command = [base_command] env = GlobalObj.getTestenvObj() cm = GlobalObj.getConnectionsManagerObj() active_volume = env.getActiveVolume() @@ -258,8 +258,8 @@ def volume_delete(serverkey): logger.error("Invalid Volume.ActiveVolume not defined" + "for the TestEnvironment") return 1 - volumename = active_volume.volumename - command = base_command + volumename + command.extend([active_volume.volumename]) + command = ' '.join(command) host_connection = cm.getConnection(serverkey) if not host_connection: logger.error("SSH connection to host '%s' has not been established" @@ -285,7 +285,7 @@ def volume_create(serverkey): if not active_volume: logger.error("ActiveVolume not defined for the TestEnvironment") return 1 - command.extend([active_volume.volumename]) + command.extend([active_volume.volumename]) if active_volume.replica: command.extend(["replica", active_volume.replica]) @@ -295,12 +295,12 @@ def volume_create(serverkey): if active_volume.transporttype: command.extend(["transport", active_volume.transporttype]) - + command = ' '.join(command) for brick_obj in active_volume.bricks: brick_value = brick_obj.hostname + ":" + brick_obj.path command = ' '.join([command, brick_value]) - + host_connection = cm.getConnection(serverkey) if not host_connection: logger.error("SSH connection to host '%s' has not been established" @@ -321,18 +321,20 @@ def volume_start(serverkey, force=False): """ """ logger = GlobalObj.getLoggerObj() - base_command = "gluster volume start " + base_command = "gluster volume start" + command = [base_command] env = GlobalObj.getTestenvObj() cm = GlobalObj.getConnectionsManagerObj() active_volume = env.getActiveVolume() if not active_volume: logger.error("ActiveVolume not defined for the TestEnvironment") return 1 - volumename = active_volume.volumename - command = base_command + volumename + command.extend([active_volume.volumename]) + if force: - command = command + " force" - + command.extend(["force"]) + + command=' '.join(command) host_connection = cm.getConnection(serverkey) if not host_connection: logger.error("SSH connection to host '%s' has not been established" @@ -353,18 +355,20 @@ def volume_stop(serverkey, force=False): """ """ logger = GlobalObj.getLoggerObj() - base_command = "gluster volume stop " + base_command = "gluster volume stop" + command = [base_command] env = GlobalObj.getTestenvObj() cm = GlobalObj.getConnectionsManagerObj() active_volume = env.getActiveVolume() if not active_volume: logger.error("ActiveVolume not defined for the TestEnvironment") return 1 - volumename = active_volume.volumename - command = base_command + volumename + command.extend([active_volume.volumename]) + if force: - command = command + " force" - + command.extend(["force"]) + + command = ' '.join(command) host_connection = cm.getConnection(serverkey) if not host_connection: logger.error("SSH connection to host '%s' has not been established" @@ -378,7 +382,7 @@ def volume_stop(serverkey, force=False): atfutils.print_stderr(output['stderrdata']) return return_status -def volume_addbrick(serverkey, *bricks): +def volume_addbrick(serverkey, *bricks, **arguments): """ """ logger = GlobalObj.getLoggerObj() @@ -387,13 +391,22 @@ def volume_addbrick(serverkey, *bricks): cm = GlobalObj.getConnectionsManagerObj() active_volume = env.getActiveVolume() command = [base_command] - + if not active_volume: logger.error("ActiveVolume not defined for the TestEnvironment") return 1 volumename = active_volume.volumename - + command.extend([volumename]) + + """ + arguments can have key brick_type + brick_type=[ ] + """ + + if arguments.has_key('brick_type'): + command.extend([arguments['brick_type']]) + for brick in bricks: brick_obj = env.getBrick(brick) if not brick_obj: @@ -401,7 +414,7 @@ def volume_addbrick(serverkey, *bricks): return 1 brick_value = brick_obj.hostname + ":" + brick_obj.path command.extend([brick_value]) - + command = ' '.join(command) host_connection = cm.getConnection(serverkey) if not host_connection: @@ -419,7 +432,65 @@ def volume_addbrick(serverkey, *bricks): atfutils.print_stderr(output['stderrdata']) return return_status -def volume_replacebrick(serverkey, brick, newbrick, operation): +def volume_removebrick(serverkey, *bricks, **arguments): + """ + *bricks : list of bricks to be removed + **arguments(optional): It takes key:value pair + we are using optional keys + brick_type and operation + brick_type: [replica ] + operation:{start|pause|abort|status|commit|force} + """ + logger = GlobalObj.getLoggerObj() + base_command = "gluster volume remove-brick" + env = GlobalObj.getTestenvObj() + cm = GlobalObj.getConnectionsManagerObj() + active_volume = env.getActiveVolume() + command = [base_command] + + if not active_volume: + logger.error("ActiveVolume not defined in the TestEnvironment") + return 1 + command.extend([active_volume.volumename]) + """ + brick_type can have only [replica ] + """ + if arguments.has_key('brick_type'): + command.extend([arguments['brick_type']]) + + for brick in bricks: + brick_obj = env.getBrick(brick) + if not brick_obj: + logger.error("Invalid Brick. Brick not defined in TestEnviroment") + return 1 + brick_value = brick_obj.hostname +':'+ brick_obj.path + command.extend([brick_value]) + """ + operation can have {start|pause|abort|status|commit|force} + which is optional. + """ + + if arguments.has_key('operation'): + command.extend([arguments['operation']]) + + command = ' '.join(command) + host_connection = cm.getConnection(serverkey) + if not host_connection: + logger.error("SSH connection to host '%s' has not been established" + % serverkey) + return 1 + + logger.debug('%s:Executing Command: %s'% (serverkey, command)) + output = host_connection.executecommand(command, commandInput="y\n") + return_status = atfutils.assert_success(output['exitstatus']) + if not return_status: + if env.removeBricksFromVolume(*bricks): + return 1 + atfutils.print_stdout(output['stdoutdata']) + atfutils.print_stderr(output['stderrdata']) + return return_status + +def volume_replacebrick(serverkey, replace_brick, to_brick, operation): """ """ logger = GlobalObj.getLoggerObj() @@ -433,14 +504,20 @@ def volume_replacebrick(serverkey, brick, newbrick, operation): logger.error("ActiveVolume not defined for the TestEnvironment") return 1 volumename = active_volume.volumename - replace_brick = env.getbrick(replacebrick_key) - to_brick = env.getbrick(tobrick_key) - - if not (to_brick and replace_brick): + replace_brick_obj = env.getBrick(replace_brick) + to_brick_obj = env.getBrick(to_brick) + """ + checking if objects are none + """ + if not (replace_brick_obj and to_brick_obj): logger.error("Invalid Brick. Brick Not defined in TestEnvironment") return 1 - command.extend([volumename, brick, newbrick, operation]) + replace_brick_value = replace_brick_obj.hostname+':'+replace_brick_obj.path + to_brick_value = to_brick_obj.hostname+':'+to_brick_obj.path + + + command.extend([volumename, replace_brick_value, to_brick_value, operation]) command = ' '.join(command) host_connection = cm.getConnection(serverkey) if not host_connection: @@ -451,12 +528,12 @@ def volume_replacebrick(serverkey, brick, newbrick, operation): logger.debug('%s: Executing Command: %s' % (serverkey, command)) output = host_connection.executecommand(command, commandInput="y\n") return_status = atfutils.assert_success(output['exitstatus']) - if not return_status: + if (not return_status) and (operation == "commit"): if env.replaceBrickInVolume(brick, newbrick): return 1 atfutils.print_stdout(output['stdoutdata']) atfutils.print_stderr(output['stderrdata']) - return output + return return_status def volume_set(serverkey, key, value): """ @@ -466,16 +543,16 @@ def volume_set(serverkey, key, value): env = GlobalObj.getTestenvObj() cm = GlobalObj.getConnectionsManagerObj() command = [base_command] - + active_volume = env.getActiveVolume() if not active_volume: logger.error("ActiveVolume not defined for the TestEnvironment") return 1 volumename = active_volume.volumename - + command.extend([volumename, key, value]) command = ' '.join(command) - + host_connection = cm.getConnection(serverkey) if not host_connection: logger.error("SSH connection to host '%s' has not been established" @@ -489,6 +566,46 @@ def volume_set(serverkey, key, value): atfutils.print_stderr(output['stderrdata']) return return_status +def volume_log_rotate(serverkey, brick): + """ + brick is compulsory parameter + """ + logger = GlobalObj.getLoggerObj() + base_command = "gluster volume log rotate" + env = GlobalObj.getTestenvObj() + cm = GlobalObj.getConnectionsManagerObj() + command = [base_command] + + active_volume = env.getActiveVolume() + if not active_volume: + logger.error("ActiveVolume not defined for the Testenvironment") + return 1 + volumename = active_volume.volumename + + brick_obj = env.getBrick(brick) + if not brick_obj: + logger.error("Invalid Brick. Brick Not defined in TestEnvironment") + return 1 + + brick_value = brick_obj.hostname + ":" + brick_obj.path + + command.extend([volumename, brick_value]) + + command = ' '.join(command) + + host_connection = cm.getConnection(serverkey) + if not host_connection: + logger.error("SSH connection to host '%s' has not been established" + % serverkey) + return 1 + + logger.debug('%s: Executing Command: %s' %(serverkey, command)) + output = host_connection.executecommand(command) + return_status = atfutils.assert_success(output['exitstatus']) + atfutils.print_stdout(output['stdoutdata']) + atfutils.print_stderr(output['stderrdata']) + return return_status + def volume_reset(serverkey): """ """ @@ -515,39 +632,163 @@ def volume_reset(serverkey): atfutils.print_stderr(output['stderrdata']) return return_status -def peer_probe(fromserverkey): +def volume_profile(serverkey, operation): """ + operation:{start|info|stop} """ logger = GlobalObj.getLoggerObj() - base_command = "gluster peer probe " + base_command = "gluster volume profile" + env = GlobalObj.getTestenvObj() + cm = GlobalObj.getConnectionsManagerObj() command = [base_command] - all_servers = {} + + active_volume = env.getActiveVolume() + if not active_volume: + logger.error("ActiveVolume not defined for the TestEnvironment") + return 1 + volumename = active_volume.volumename + + command.extend([volumename, operation]) + command = ' '.join(command) + + host_connection = cm.getConnection(serverkey) + if not host_connection: + logger.error("SSH connection to the Host '%s' has not been established" + & serverkey) + return 1 + + logger.debug('%s: Execute Command: %s' %(serverkey, command)) + output = host_connection.executecommand(command) + return_status = atfutils.assert_success(output['exitstatus']) + atfutils.print_stdout(output['stdoutdata']) + atfutils.print_stderr(output['stderrdata']) + return return_status + +def volume_quota(serverkey, operation, **arguments): + """ + arguments can have two values + path: path can be '/' + ex: path='/' + value: value can be in GB or MB + ex: value=1GB + """ + logger = GlobalObj.getLoggerObj() + base_command = "gluster volume quota" env = GlobalObj.getTestenvObj() cm = GlobalObj.getConnectionsManagerObj() - all_servers = env.getServers() - all_servers.pop(fromserverkey) - - for key in all_servers.keys(): - if key is fromserverkey: - continue - else: - server_obj = all_servers[key] - command.extend([server_obj.hostname]) + command = [base_command] + active_volume = env.getActiveVolume() + if not active_volume: + logger.error("ActiveVolume not defined for the Testenvironment") + return 1 + volumename = active_volume.volumename + + command.extend([volumename, operation]) + + if arguments.has_key('path'): + command.extend([arguments['path']]) + + if arguments.has_key('value'): + command.extend([arguments['value']]) command = ' '.join(command) - host_connection = cm.getConnection(fromserverkey) + + host_connection = cm.getConnection(serverkey) if not host_connection: - logger.error("SSH connection to host '%s' has not been established" + logger.error("SSH connection to the host '%s' has not been established" % serverkey) return 1 - logger.debug('%s: Executing Command: %s' % (fromserverkey, command)) - output = host_connection.executecommand(command) + logger.debug('%s: Executing Command: %s' % (serverkey, command)) + output = host_connection.executecommand(command) + return_status = atfutils.assert_success(output['exitstatus']) + atfutils.print_stdout(output['stdoutdata']) + atfutils.print_stderr(output['stderrdata']) + return return_status + +def volume_top(serverkey, operation, **arguments): + """ + operation:{[open|read|write|opendir|readdir] |[read-perf|write-perf + bs count ]} + arguments(optional): Takes maximum two parameters + brick : brick1, brick2 etc + list-cnt: can take any number + + """ + logger = GlobalObj.getLoggerObj() + base_command = "gluster volume top" + env = GlobalObj.getTestenvObj() + cm = GlobalObj.getConnectionsManagerObj() + command = [base_command] + + active_volume = env.getActiveVolume() + if not active_volume: + logger.error("ActiveVolume not defines for the TestEnvironment") + return 1 + volumename = active_volume.volumename + + command.extend([volumename, operation]) + + if arguments.has_key('brick'): + brick_obj = env.getBrick(arguments['brick']) + if not brick_obj: + logger.error("Invalid Brick. Brick Not defined in TestEnvironment") + return 1 + brick_value = brick_obj.hostname+':'+brick_obj.path + command.extend(['brick',brick_value]) + + if arguments.has_key('list_cnt'): + command.extend(['list-cnt', arguments['list_cnt']]) + + command = ' '.join(command) + + host_connection = cm.getConnection(serverkey) + if not host_connection: + logger.error("SSH connection to host '%s' has not been established" + %serverkey) + return 1 + + logger.debug("%s: Executing command: %s" %(serverkey, command)) + output = host_connection.executecommand(command) return_status = atfutils.assert_success(output['exitstatus']) atfutils.print_stdout(output['stdoutdata']) atfutils.print_stderr(output['stderrdata']) return return_status +def peer_probe(fromserverkey): + """ + """ + logger = GlobalObj.getLoggerObj() + base_command = "gluster peer probe " + all_servers = {} + env = GlobalObj.getTestenvObj() + cm = GlobalObj.getConnectionsManagerObj() + all_servers = env.getServers() + all_servers.pop(fromserverkey) + host_connection = cm.getConnection(fromserverkey) + if not host_connection: + logger.error("SSH connection to host '%s' has not been established" + % serverkey) + return 1 + + for key in all_servers.keys(): + if not key is fromserverkey: + server_obj = all_servers[key] + """ + One hostname is being taken at a time while executing peer probe + """ + command = ' '.join([base_command, server_obj.hostname]) + logger.debug('%s: Executing Command: %s' % (fromserverkey, command)) + output = host_connection.executecommand(command) + return_status = atfutils.assert_success(output['exitstatus']) + atfutils.print_stdout(output['stdoutdata']) + atfutils.print_stderr(output['stderrdata']) + + if return_status: + return 1 + + return 0 + def create_brick(brickkey): """ """ @@ -555,7 +796,7 @@ def create_brick(brickkey): return_status = 1 env = GlobalObj.getTestenvObj() brick_obj = env.getRawBrick(brickkey) - + hostname_value = brick_obj.hostname serverkey = re.split("\.", hostname_value, maxsplit=1)[0] @@ -564,7 +805,7 @@ def create_brick(brickkey): """If the exportdir is not a mount point of a device: 1) Remove the existing exportdir 2) Create new exportdir""" - + if re.match("^\/", exportdir): dirpath = exportdir else: @@ -583,7 +824,7 @@ def create_brick(brickkey): if mount_exportdir(serverkey, device, fstype, options, dirpath): return return_status return 0 - + else: if hostutils.rmdir(serverkey, dirpath): return return_status @@ -598,13 +839,13 @@ def umount_device(serverkey, device): logger = GlobalObj.getLoggerObj() base_command = "umount " cm = GlobalObj.getConnectionsManagerObj() - + server_connection = cm.getConnection(serverkey) if not server_connection: logger.error("SSH connection to host '%s' has not been established" % serverkey) return 1 - + mountpoints = hostutils.find_mountpoints(serverkey, device) for mountpoint in mountpoints: @@ -631,7 +872,7 @@ def mount_exportdir(serverkey, device, fstype, options, dirpath): base_command = "mount " cm = GlobalObj.getConnectionsManagerObj() command = [base_command] - + server_connection = cm.getConnection(serverkey) if not server_connection: logger.error("SSH connection to host '%s' has not been established" @@ -641,10 +882,10 @@ def mount_exportdir(serverkey, device, fstype, options, dirpath): if fstype is None: fstype = "xfs" command.extend(["-t", fstype]) - + if options: command.extend([options]) - + command.extend([device, dirpath]) command = ' '.join(command) @@ -666,7 +907,7 @@ def create_brick_allservers(): return return_status return 0 - + __all__ = ['glusterd_start', 'glusterd_start_allservers', @@ -689,20 +930,3 @@ __all__ = ['glusterd_start', 'create_brick_allservers', 'mount_exportdir', 'umount_device'] - - - - - - - - - - - - - - - - - -- cgit