diff options
Diffstat (limited to 'libs/globals')
-rw-r--r--[-rwxr-xr-x] | libs/globals/testenv.py | 104 |
1 files changed, 60 insertions, 44 deletions
diff --git a/libs/globals/testenv.py b/libs/globals/testenv.py index a73858b..e5d1b6b 100755..100644 --- 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 - - - - - - - |