summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNigel Babu <nigelb@redhat.com>2016-11-16 17:36:15 +0530
committerJonathan Holloway <jholloway@redhat.com>2016-12-12 08:01:33 -0800
commit3070312c13e02cace3041d3429b0c31fc10b73ee (patch)
tree15b202c91c00fd93ab5559bced17b2e7fa27127f
parentb7aea27f6662fd5b0344c6dbffcf2b9a86c1f8cc (diff)
Clean up pyflakes and pep8 errors
Change-Id: Ibdd092118d3bb912716c46fd278ef3c680a6e742 Signed-off-by: Nigel Babu <nigelb@redhat.com>
-rw-r--r--glustolibs-gluster/glustolibs/gluster/bitrot_ops.py11
-rw-r--r--glustolibs-gluster/glustolibs/gluster/brick_libs.py4
-rw-r--r--glustolibs-gluster/glustolibs/gluster/brick_ops.py1
-rw-r--r--glustolibs-gluster/glustolibs/gluster/gluster_base_class.py10
-rw-r--r--glustolibs-gluster/glustolibs/gluster/gluster_init.py10
-rw-r--r--glustolibs-gluster/glustolibs/gluster/heal_libs.py3
-rw-r--r--glustolibs-gluster/glustolibs/gluster/heal_ops.py3
-rw-r--r--glustolibs-gluster/glustolibs/gluster/lib_utils.py61
-rw-r--r--glustolibs-gluster/glustolibs/gluster/peer_ops.py1
-rw-r--r--glustolibs-gluster/glustolibs/gluster/quota_ops.py2
-rw-r--r--glustolibs-gluster/glustolibs/gluster/rebalance_ops.py1
-rw-r--r--glustolibs-gluster/glustolibs/gluster/samba_ops.py3
-rw-r--r--glustolibs-gluster/glustolibs/gluster/snap_ops.py2
-rw-r--r--glustolibs-gluster/glustolibs/gluster/tiering_ops.py1
-rw-r--r--glustolibs-gluster/glustolibs/gluster/uss_ops.py1
-rw-r--r--glustolibs-gluster/glustolibs/gluster/volume_libs.py28
-rw-r--r--glustolibs-gluster/glustolibs/gluster/volume_ops.py12
-rwxr-xr-xglustolibs-io/shared_files/scripts/fd_writes.py4
-rwxr-xr-xglustolibs-io/shared_files/scripts/file_dir_ops.py11
-rw-r--r--tests/bvt/test_bvt_lite_and_plus.py8
-rw-r--r--tox.ini6
21 files changed, 82 insertions, 101 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/bitrot_ops.py b/glustolibs-gluster/glustolibs/gluster/bitrot_ops.py
index 6eed10e..cab205c 100644
--- a/glustolibs-gluster/glustolibs/gluster/bitrot_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/bitrot_ops.py
@@ -27,11 +27,6 @@ from glustolibs.gluster.lib_utils import (get_pathinfo,
import time
import re
-try:
- import xml.etree.cElementTree as etree
-except ImportError:
- import xml.etree.ElementTree as etree
-
# Global variables
SCRUBBER_TIMEOUT = 100
@@ -174,7 +169,7 @@ def is_file_signed(mnode, filename, volname, expected_file_version=None):
g.log.error("File version mismatch in signature.Filename: %s ."
"Expected file version: %s.Actual file version: %s"
% (filename, expected_file_version,
- actual_signature_file_version))
+ actual_signature_file_version))
return False
actual_file_signature = ''.join(re.findall('.{16}',
@@ -185,7 +180,7 @@ def is_file_signed(mnode, filename, volname, expected_file_version=None):
g.log.error("File signature mismatch. File name: %s . Expected "
"file signature: %s. Actual file signature: %s"
% (filename, expected_file_signature,
- actual_file_signature))
+ actual_file_signature))
return False
return True
@@ -572,7 +567,7 @@ def get_scrub_status(mnode, volname):
corrupt_list = []
for node in temp_list:
tmp_reg = ('Node: (\S+)\n.*Error count.*'
- + 'Corrupted object.*?:(.*)\n=.*')
+ 'Corrupted object.*?:(.*)\n=.*')
m = re.search(tmp_reg, node, re.S)
if m is None:
g.log.error("Mismatch in cli output when bad file"
diff --git a/glustolibs-gluster/glustolibs/gluster/brick_libs.py b/glustolibs-gluster/glustolibs/gluster/brick_libs.py
index 617419d..508eae6 100644
--- a/glustolibs-gluster/glustolibs/gluster/brick_libs.py
+++ b/glustolibs-gluster/glustolibs/gluster/brick_libs.py
@@ -22,7 +22,6 @@
import random
from glusto.core import Glusto as g
from glustolibs.gluster.volume_ops import (get_volume_info, get_volume_status)
-from glustolibs.gluster.volume_libs import get_subvols
def get_all_bricks(mnode, volname):
@@ -232,7 +231,7 @@ def bring_bricks_online(mnode, volname, bricks_list,
False otherwise
"""
rc = True
- failed_to_brick_online_list = []
+ failed_to_bring_online_list = []
for brick in bricks_list:
bring_brick_online_method = random.choice(bring_bricks_online_methods)
if bring_brick_online_method == 'glusterd_restart':
@@ -337,6 +336,7 @@ def are_bricks_online(mnode, volname, bricks_list):
g.log.info("All the bricks %s are online" % bricks_list)
return True
+
def get_offline_bricks_list(mnode, volname):
"""Get list of bricks which are offline.
diff --git a/glustolibs-gluster/glustolibs/gluster/brick_ops.py b/glustolibs-gluster/glustolibs/gluster/brick_ops.py
index ae55b68..61c86fa 100644
--- a/glustolibs-gluster/glustolibs/gluster/brick_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/brick_ops.py
@@ -21,6 +21,7 @@
from glusto.core import Glusto as g
+
def add_brick(mnode, volname, bricks_list, replica=None):
"""Add Bricks specified in the bricks_list to the volume.
diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
index 276e51d..c179462 100644
--- a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
+++ b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
@@ -297,7 +297,7 @@ class GlusterVolumeBaseClass(GlusterBaseClass):
# Validate if peer is connected from all the servers
for server in cls.servers:
ret = is_peer_connected(server, cls.servers)
- assert (ret == True), "Validating Peers to be in Cluster Failed"
+ assert (ret is True), "Validating Peers to be in Cluster Failed"
# Print Peer Status from mnode
_, _, _ = peer_status(cls.mnode)
@@ -306,7 +306,7 @@ class GlusterVolumeBaseClass(GlusterBaseClass):
ret = setup_volume(mnode=cls.mnode,
all_servers_info=cls.all_servers_info,
volume_config=cls.volume, force=True)
- assert (ret == True), "Setup volume %s failed" % cls.volname
+ assert (ret is True), "Setup volume %s failed" % cls.volname
time.sleep(10)
# Print Volume Info and Status
@@ -342,7 +342,7 @@ class GlusterVolumeBaseClass(GlusterBaseClass):
(mount_obj.server_system, mount_obj.volname,
mount_obj.client_system, mount_obj.mountpoint))
rc = False
- assert (rc == True), ("Mounting volume %s on few clients failed" %
+ assert (rc is True), ("Mounting volume %s on few clients failed" %
cls.volname)
@classmethod
@@ -359,9 +359,9 @@ class GlusterVolumeBaseClass(GlusterBaseClass):
mount_obj.client_system, mount_obj.mountpoint)
)
rc = False
- assert (rc == True), ("Unmount of all mounts are not successful")
+ assert (rc is True), ("Unmount of all mounts are not successful")
# Cleanup volume
if cleanup_vol:
ret = cleanup_volume(mnode=cls.mnode, volname=cls.volname)
- assert (ret == True), ("cleanup volume %s failed" % cls.volname)
+ assert (ret is True), ("cleanup volume %s failed" % cls.volname)
diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_init.py b/glustolibs-gluster/glustolibs/gluster/gluster_init.py
index 1820807..371e187 100644
--- a/glustolibs-gluster/glustolibs/gluster/gluster_init.py
+++ b/glustolibs-gluster/glustolibs/gluster/gluster_init.py
@@ -21,6 +21,7 @@
"""
from glusto.core import Glusto as g
+
def start_glusterd(servers):
"""Starts glusterd on specified servers if they are not running.
@@ -46,6 +47,7 @@ def start_glusterd(servers):
return True
+
def stop_glusterd(servers):
"""Stops the glusterd on specified servers.
@@ -97,6 +99,7 @@ def restart_glusterd(servers):
return True
+
def is_glusterd_running(servers):
"""Checks the glusterd status on specified servers.
@@ -122,13 +125,14 @@ def is_glusterd_running(servers):
g.log.error("glusterd is not running on the server %s", server)
rc = 1
if cmd2_results[server][0] == 0:
- g.log.error("PID of glusterd is alive and status is not running")
+ g.log.error("PID of glusterd is alive and status is not "
+ "running")
rc = -1
return rc
-#TODO: THIS IS NOT IMPLEMENTED YET. PLEASE DO THIS MANUALLY
-# TILL WE IMPLEMENT THIS PART
+# TODO: THIS IS NOT IMPLEMENTED YET. PLEASE DO THIS MANUALLY
+# TILL WE IMPLEMENT THIS
def env_setup_servers(servers):
"""Set up environment on all the specified servers.
diff --git a/glustolibs-gluster/glustolibs/gluster/heal_libs.py b/glustolibs-gluster/glustolibs/gluster/heal_libs.py
index 2ad408c..4d5594a 100644
--- a/glustolibs-gluster/glustolibs/gluster/heal_libs.py
+++ b/glustolibs-gluster/glustolibs/gluster/heal_libs.py
@@ -20,10 +20,9 @@
Description: Module for gluster heal related helper functions.
"""
-import os
import time
from glusto.core import Glusto as g
-from glustolibs.gluster.volume_ops import (get_volume_info, get_volume_status)
+from glustolibs.gluster.volume_ops import get_volume_status
try:
import xml.etree.cElementTree as etree
except ImportError:
diff --git a/glustolibs-gluster/glustolibs/gluster/heal_ops.py b/glustolibs-gluster/glustolibs/gluster/heal_ops.py
index 1bf8d2f..8c0b6c8 100644
--- a/glustolibs-gluster/glustolibs/gluster/heal_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/heal_ops.py
@@ -19,10 +19,7 @@
Description: Module for gluster heal operations.
"""
-import os
-import time
from glusto.core import Glusto as g
-from glustolibs.gluster.volume_ops import (get_volume_info, get_volume_status)
try:
import xml.etree.cElementTree as etree
except ImportError:
diff --git a/glustolibs-gluster/glustolibs/gluster/lib_utils.py b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
index 1958789..d1329d6 100644
--- a/glustolibs-gluster/glustolibs/gluster/lib_utils.py
+++ b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
@@ -31,11 +31,6 @@ import random
ONE_GB_BYTES = 1073741824.0
-try:
- import xml.etree.cElementTree as etree
-except ImportError:
- import xml.etree.ElementTree as etree
-
def append_string_to_file(mnode, filename, str_to_add_in_file,
user="root"):
@@ -364,7 +359,7 @@ def get_servers_used_bricks_dict(mnode, servers):
for item in list1:
x = re.search(':(.*)/(.*)', item)
list2 = x.group(1).strip().split(':')
- if servers_used_bricks_dict.has_key(list2[0]):
+ if list2[0] in servers_used_bricks_dict:
value = servers_used_bricks_dict[list2[0]]
value.append(list2[1])
else:
@@ -400,7 +395,7 @@ def get_servers_unused_bricks_dict(mnode, servers, servers_info):
dict2 = get_servers_used_bricks_dict(mnode, servers)
servers_unused_bricks_dict = OrderedDict()
for key, value in dict1.items():
- if dict2.has_key(key):
+ if key in dict2:
unused_bricks = list(set(value) - set(dict2[key]))
servers_unused_bricks_dict[key] = unused_bricks
else:
@@ -457,8 +452,9 @@ def form_bricks_list(mnode, volname, number_of_bricks, servers, servers_info):
for num in range(brick_index, brick_index + number_of_bricks):
# current_server is the server from which brick path will be created
current_server = servers_unused_bricks_dict.keys()[dict_index]
- current_server_unused_bricks_list = (servers_unused_bricks_dict.values()
- [dict_index])
+ current_server_unused_bricks_list = (
+ servers_unused_bricks_dict.values()[dict_index]
+ )
brick_path = ''
if current_server_unused_bricks_list:
brick_path = ("%s:%s/%s_brick%s" %
@@ -476,6 +472,7 @@ def form_bricks_list(mnode, volname, number_of_bricks, servers, servers_info):
return bricks_list
+
def is_rhel6(servers):
"""Function to get whether the server is RHEL-6
@@ -491,10 +488,11 @@ def is_rhel6(servers):
for server, ret_values in results.iteritems():
retcode, out, err = ret_values
if retcode != 0:
- g.log.error("Unable to get the RHEL version on server %s" %(server,))
+ g.log.error("Unable to get the RHEL version on server %s" %
+ (server))
rc = False
- if retcode == 0 and not "release 6" in out:
- g.log.error("Server %s is not RHEL-6" %(server,))
+ if retcode == 0 and "release 6" not in out:
+ g.log.error("Server %s is not RHEL-6" % (server))
rc = False
return rc
@@ -514,10 +512,11 @@ def is_rhel7(servers):
for server, ret_values in results.iteritems():
retcode, out, err = ret_values
if retcode != 0:
- g.log.error("Unable to get the RHEL version on server %s" %(server,))
+ g.log.error("Unable to get the RHEL version on server %s" %
+ (server))
rc = False
- if retcode == 0 and not "release 7" in out:
- g.log.error("Server %s is not RHEL-7" %(server,))
+ if retcode == 0 and "release 7" not in out:
+ g.log.error("Server %s is not RHEL-7" % (server))
rc = False
return rc
@@ -541,12 +540,12 @@ def get_disk_usage(mnode, path, user="root"):
get_disk_usage("abc.com", "/mnt/glusterfs")
"""
- inst = random.randint(10,100)
+ inst = random.randint(10, 100)
conn = g.rpyc_get_connection(mnode, user=user, instance=inst)
if conn is None:
g.log.error("Failed to get rpyc connection")
return None
- cmd = 'stat -f '+ path
+ cmd = 'stat -f ' + path
p = conn.modules.subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = p.communicate()
@@ -568,19 +567,20 @@ def get_disk_usage(mnode, path, user="root"):
keys = ['b_size', 'b_total', 'b_free', 'b_avail', 'i_total', 'i_free']
val = list(match.groups())
info = dict(zip(keys, val))
- usage_info['total'] = ((int(info['b_total']) * int(info['b_size']))
- / ONE_GB_BYTES)
- usage_info['free'] = ((int(info['b_free']) * int(info['b_size']))
- / ONE_GB_BYTES)
- usage_info['used_percent'] = (100 - (100.0 * usage_info['free']
- / usage_info['total']))
+ usage_info['total'] = ((int(info['b_total']) * int(info['b_size'])) /
+ ONE_GB_BYTES)
+ usage_info['free'] = ((int(info['b_free']) * int(info['b_size'])) /
+ ONE_GB_BYTES)
+ usage_info['used_percent'] = (100 - (100.0 * usage_info['free'] /
+ usage_info['total']))
usage_info['total_inode'] = int(info['i_total'])
usage_info['free_inode'] = int(info['i_free'])
- usage_info['used_percent_inode'] = (100 - (100.0 * usage_info['free_inode']
- / usage_info['total_inode']))
+ usage_info['used_percent_inode'] = (100 - (100.0 *
+ usage_info['free_inode'] /
+ usage_info['total_inode']))
usage_info['used'] = usage_info['total'] - usage_info['free']
usage_info['used_inode'] = (usage_info['total_inode'] -
- usage_info['free_inode'])
+ usage_info['free_inode'])
return usage_info
@@ -636,11 +636,9 @@ def check_if_dir_is_filled(mnode, dirname, percent_to_fill,
used = output['used_percent']
if int(percent_to_fill) > int(used):
- remaining_to_fill = int(percent_to_fill) - int(used)
-
g.log.info("Directory %s used percent: %s"
- %(dirname, used))
- if int(percent_to_fill) <= int(used):
+ % (dirname, used))
+ if int(percent_to_fill) <= int(used):
flag = 1
g.rpyc_close_connection(host=mnode)
break
@@ -657,6 +655,7 @@ def check_if_dir_is_filled(mnode, dirname, percent_to_fill,
g.log.info("Directory is filled with given percentage")
return True
else:
- g.log.info("Timeout reached before filling directory with given percentage")
+ g.log.info("Timeout reached before filling directory with given"
+ " percentage")
return True
return False
diff --git a/glustolibs-gluster/glustolibs/gluster/peer_ops.py b/glustolibs-gluster/glustolibs/gluster/peer_ops.py
index 9f74bb7..e4d3e6e 100644
--- a/glustolibs-gluster/glustolibs/gluster/peer_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/peer_ops.py
@@ -375,7 +375,6 @@ def is_peer_connected(mnode, servers):
if mnode in servers:
servers.remove(mnode)
- peer_connected = True
peer_status_list = get_peer_status(mnode)
if peer_status_list is None:
g.log.error("Failed to parse the peer status. Hence failed to "
diff --git a/glustolibs-gluster/glustolibs/gluster/quota_ops.py b/glustolibs-gluster/glustolibs/gluster/quota_ops.py
index f7121b0..5a7f50f 100644
--- a/glustolibs-gluster/glustolibs/gluster/quota_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/quota_ops.py
@@ -20,8 +20,6 @@
"""
from glusto.core import Glusto as g
-import re
-import time
try:
import xml.etree.cElementTree as etree
diff --git a/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py b/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py
index 108a246..a4cd57e 100644
--- a/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py
@@ -20,7 +20,6 @@
"""
from glusto.core import Glusto as g
-import re
import time
try:
diff --git a/glustolibs-gluster/glustolibs/gluster/samba_ops.py b/glustolibs-gluster/glustolibs/gluster/samba_ops.py
index e4f5b01..ec158b0 100644
--- a/glustolibs-gluster/glustolibs/gluster/samba_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/samba_ops.py
@@ -133,9 +133,6 @@ def create_smb_users(servers, smb_users_info, start_uid=50000):
for smb_user in smb_users_info.keys():
if smb_user == 'root':
continue
- user_add_command = ("getent passwd %d | grep %s &> /dev/null || "
- "useradd -u %d %s" % (uid, smb_user,
- uid, smb_user))
for server in servers:
# Check if user already exist with same uid
cmd = ("getent passwd %d" % uid)
diff --git a/glustolibs-gluster/glustolibs/gluster/snap_ops.py b/glustolibs-gluster/glustolibs/gluster/snap_ops.py
index 5d58f23..2ca5688 100644
--- a/glustolibs-gluster/glustolibs/gluster/snap_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/snap_ops.py
@@ -21,8 +21,6 @@
from glusto.core import Glusto as g
from glustolibs.gluster.volume_ops import volume_start, volume_stop
-import re
-import time
try:
import xml.etree.cElementTree as etree
diff --git a/glustolibs-gluster/glustolibs/gluster/tiering_ops.py b/glustolibs-gluster/glustolibs/gluster/tiering_ops.py
index 38890f5..755ca27 100644
--- a/glustolibs-gluster/glustolibs/gluster/tiering_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/tiering_ops.py
@@ -20,6 +20,7 @@
"""
import re
+import time
from glusto.core import Glusto as g
from glustolibs.gluster.peer_ops import peer_probe_servers
from glustolibs.gluster.gluster_init import start_glusterd
diff --git a/glustolibs-gluster/glustolibs/gluster/uss_ops.py b/glustolibs-gluster/glustolibs/gluster/uss_ops.py
index 3275a6e..4a48a2c 100644
--- a/glustolibs-gluster/glustolibs/gluster/uss_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/uss_ops.py
@@ -43,6 +43,7 @@ def enable_uss(mnode, volname):
cmd = "gluster volume set %s features.uss enable" % volname
return g.run(mnode, cmd)
+
def disable_uss(mnode, volname):
"""Disables uss on the specified volume
diff --git a/glustolibs-gluster/glustolibs/gluster/volume_libs.py b/glustolibs-gluster/glustolibs/gluster/volume_libs.py
index 24aac82..520e8af 100644
--- a/glustolibs-gluster/glustolibs/gluster/volume_libs.py
+++ b/glustolibs-gluster/glustolibs/gluster/volume_libs.py
@@ -192,12 +192,6 @@ def setup_volume(mnode, all_servers_info, volume_config, force=False):
g.log.error("Invalid volume type defined in config")
return False
- # Get transport type
- if 'transport' in volume_config['voltype']:
- transpor_type = volume_config['voltype']['transport']
- else:
- transport_type = 'tcp'
-
# get bricks_list
bricks_list = form_bricks_list(mnode=mnode, volname=volname,
number_of_bricks=number_of_bricks,
@@ -335,14 +329,14 @@ def setup_volume(mnode, all_servers_info, volume_config, force=False):
return False
# Enable Ganesha
-## if ('nfs_ganesha' in volume_config and
-## 'enable' in volume_config['nfs_ganesha'] and
-## volume_config['nfs_ganesha']['enable']):
-## from glustolibs.gluster.ganesha import vol_set_ganesha
-## ret = vol_set_ganesha(mnode=mnode, volname=volname, option=True)
-## if not ret:
-## g.log.error("failed to set the ganesha option for %s" % volname)
-## return False
+# if ('nfs_ganesha' in volume_config and
+# 'enable' in volume_config['nfs_ganesha'] and
+# volume_config['nfs_ganesha']['enable']):
+# from glustolibs.gluster.ganesha import vol_set_ganesha
+# ret = vol_set_ganesha(mnode=mnode, volname=volname, option=True)
+# if not ret:
+# g.log.error("failed to set the ganesha option for %s" % volname)
+# return False
# Enable Samba
if ('smb' in volume_config and 'enable' in volume_config['smb'] and
@@ -479,7 +473,7 @@ def get_subvols(mnode, volname):
# Disperse or Distribute-Disperse volume
elif (cold_tier_type == 'Disperse' or
- cold_tier_type == 'Distributed-Disperse'):
+ cold_tier_type == 'Distributed-Disperse'):
disp_count = sum([int(nums) for nums in
((volinfo[volname]["bricks"]['coldBricks']
['numberOfBricks']).split("x", 1)[1].
@@ -641,8 +635,8 @@ def get_volume_type_info(mnode, volname):
if key in volinfo[volname]:
non_tiered_volume_type_info[key] = volinfo[volname][key]
else:
- g.log.error("Unable to find key '%s' in the volume info for the "
- "volume %s" % (key, volname))
+ g.log.error("Unable to find key '%s' in the volume info for "
+ "the volume %s" % (key, volname))
non_tiered_volume_type_info[key] = None
volume_type_info['volume_type_info'] = non_tiered_volume_type_info
diff --git a/glustolibs-gluster/glustolibs/gluster/volume_ops.py b/glustolibs-gluster/glustolibs/gluster/volume_ops.py
index f7a9473..6770b1d 100644
--- a/glustolibs-gluster/glustolibs/gluster/volume_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/volume_ops.py
@@ -17,17 +17,12 @@
import re
-import time
from glusto.core import Glusto as g
from pprint import pformat
try:
import xml.etree.cElementTree as etree
except ImportError:
import xml.etree.ElementTree as etree
-from glustolibs.gluster.mount_ops import mount_volume
-from glustolibs.gluster.gluster_init import env_setup_servers, start_glusterd
-from glustolibs.gluster.peer_ops import (peer_probe_servers,
- nodes_from_pool_list)
"""
This file contains the gluster volume operations like create volume,
@@ -80,7 +75,7 @@ def volume_create(mnode, volname, bricks_list, force=False, **kwargs):
volume_create(mnode, volname, bricks_list)
"""
replica_count = arbiter_count = stripe_count = None
- disperse_count = disperse_data_count = redundancy_count = None
+ disperse_count = disperse_data_count = redundancy_count = None
transport_type = None
if 'replica_count' in kwargs:
@@ -137,6 +132,7 @@ def volume_create(mnode, volname, bricks_list, force=False, **kwargs):
return g.run(mnode, cmd)
+
def volume_start(mnode, volname, force=False):
"""Starts the gluster volume
@@ -235,7 +231,7 @@ def volume_delete(mnode, volname):
bricks = [x["name"] for x in volinfo[volname]["bricks"]["brick"]
if "name" in x]
ret, _, _ = g.run(mnode, "gluster volume delete %s --mode=script"
- % volname)
+ % volname)
if ret != 0:
return False
@@ -658,7 +654,7 @@ def get_volume_info(mnode, volname='all'):
(volinfo[volname]["bricks"][el.tag]["brick"].
append(brick_info_dict))
else:
- volinfo[volname]["bricks"][el.tag][elmt.tag] = elmt.text
+ volinfo[volname]["bricks"][el.tag][elmt.tag] = elmt.text # noqa: E501
elif elem.tag == "options":
volinfo[volname]["options"] = {}
for option in elem.findall("option"):
diff --git a/glustolibs-io/shared_files/scripts/fd_writes.py b/glustolibs-io/shared_files/scripts/fd_writes.py
index 0eaf513..ba46a5f 100755
--- a/glustolibs-io/shared_files/scripts/fd_writes.py
+++ b/glustolibs-io/shared_files/scripts/fd_writes.py
@@ -17,7 +17,6 @@
import argparse
import random
-import subprocess
import os
import time
import string
@@ -72,7 +71,7 @@ def create_dir(dir_path):
if not path_exists(dir_abs_path):
try:
os.makedirs(dir_abs_path)
- except (OSError, IOError) as e:
+ except (OSError, IOError):
print "Unable to create dir: %s" % dir_abs_path
return 1
return 0
@@ -190,6 +189,7 @@ def fd_writes(args):
each_process.join()
return 0
+
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Program to perfrom fd based writes on files for time t",
diff --git a/glustolibs-io/shared_files/scripts/file_dir_ops.py b/glustolibs-io/shared_files/scripts/file_dir_ops.py
index e98a660..4216033 100755
--- a/glustolibs-io/shared_files/scripts/file_dir_ops.py
+++ b/glustolibs-io/shared_files/scripts/file_dir_ops.py
@@ -22,7 +22,6 @@
import os
import argparse
import sys
-import time
import random
import string
import datetime
@@ -99,7 +98,7 @@ def create_dir(dir_path):
if not path_exists(dir_abs_path):
try:
os.makedirs(dir_abs_path)
- except (OSError, IOError) as e:
+ except (OSError, IOError):
print "Unable to create dir: %s" % dir_abs_path
return 1
return 0
@@ -208,7 +207,7 @@ def create_deep_dirs_with_files(args):
file_types = args.file_types
try:
fixed_file_size = args.fixed_file_size
- except AttributeError as e:
+ except AttributeError:
fixed_file_size = None
base_file_name = args.base_file_name
dirname_start_num = args.dirname_start_num
@@ -298,7 +297,7 @@ def _create_files(dir_path, num_of_files, fixed_file_size=None,
str_to_write = string.ascii_letters + string.digits
file_str = (''.join(random.choice(str_to_write)
for x in range(file_size)))
- p = document.add_paragraph(file_str)
+ document.add_paragraph(file_str)
document.save(fname_abs_path)
except:
print ("Unable to write to file '%s' : %s" %
@@ -323,7 +322,7 @@ def create_files(args):
num_of_files = args.num_of_files
try:
fixed_file_size = args.fixed_file_size
- except AttributeError as e:
+ except AttributeError:
fixed_file_size = None
base_file_name = args.base_file_name
file_types = args.file_types
@@ -448,7 +447,7 @@ def _get_path_stats(path):
'inode': stat.st_ino,
'stat': stat
})
- except Exception as e:
+ except Exception:
rc = 1
err = "Unable to get the stat of path %s" % path
diff --git a/tests/bvt/test_bvt_lite_and_plus.py b/tests/bvt/test_bvt_lite_and_plus.py
index a77b6be..55db725 100644
--- a/tests/bvt/test_bvt_lite_and_plus.py
+++ b/tests/bvt/test_bvt_lite_and_plus.py
@@ -15,12 +15,10 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-import pytest
import os
from glusto.core import Glusto as g
from glustolibs.gluster.gluster_base_class import (GlusterVolumeBaseClass,
runs_on)
-import time
@runs_on([['replicated', 'distributed', 'distributed-replicated',
@@ -47,7 +45,7 @@ class BvtTestsClass(GlusterVolumeBaseClass):
"scripts/file_dir_ops.py")
cls.script_upload_path = "/tmp/file_dir_ops.py"
ret = os.path.exists(cls.script_local_path)
- assert (ret == True), ("Unable to find the io scripts")
+ assert (ret is True), ("Unable to find the io scripts")
for client in cls.clients:
g.upload(client, cls.script_local_path, cls.script_upload_path)
@@ -100,7 +98,7 @@ class BvtTestsClass(GlusterVolumeBaseClass):
(self.mounts[i].client_system,
self.mounts[i].mountpoint))
rc = False
- assert (rc == True), "IO failed on some of the clients"
+ assert (rc is True), "IO failed on some of the clients"
# Get stat of all the files/dirs created.
all_mounts_procs = []
@@ -118,7 +116,7 @@ class BvtTestsClass(GlusterVolumeBaseClass):
(self.mounts[i].client_system,
self.mounts[i].mountpoint))
rc = False
- assert (rc == True), "Stat failed on some of the clients"
+ assert (rc is True), "Stat failed on some of the clients"
def tearDown(self):
pass
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..53eca7c
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,6 @@
+[flake8]
+exclude =
+ .git,
+ docs,
+ glustolibs-io/setup.py,
+ glustolibs-gluster/setup.py