Skip to content

Commit 641b4e5

Browse files
committed
Fix Pylint errors
Signed-off-by: Aravinda Vishwanathapura <[email protected]>
1 parent 096ae7b commit 641b4e5

15 files changed

+219
-176
lines changed

glustercli/cli/bitrot.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

3-
from glustercli.cli.utils import bitrot_execute, bitrot_execute_xml, GlusterCmdException
3+
from glustercli.cli.utils import bitrot_execute, bitrot_execute_xml, \
4+
GlusterCmdException
45
from glustercli.cli.parsers import parse_bitrot_scrub_status
56

67
THROTTLE_TYPES = ["lazy", "normal", "aggressive"]

glustercli/cli/bricks.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from glustercli.cli.parsers import parse_remove_brick_status
55

66

7-
def add(volname, bricks, stripe=None, replica=None, arbiter=None, force=False):
7+
def add(volname, bricks, stripe=None, replica=None,
8+
arbiter=None, force=False):
89
"""
910
Add Bricks
1011

glustercli/cli/georep.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# -*- coding: utf-8 -*-
22

3-
from glustercli.cli.utils import georep_execute, georep_execute_xml, gluster_system_execute
4-
from glustercli.cli.parsers import parse_georep_config, parse_georep_status
3+
from glustercli.cli.utils import georep_execute, georep_execute_xml, \
4+
gluster_system_execute
5+
from glustercli.cli.parsers import parse_georep_config, \
6+
parse_georep_status
57
from glustercli.cli import volume
68

79

@@ -20,6 +22,7 @@ def gsec_create(ssh_key_prefix=True):
2022
return gluster_system_execute(cmd)
2123

2224

25+
# noqa # pylint: disable=too-many-arguments
2326
def create(volname, slave_host, slave_vol, slave_user="root",
2427
push_pem=True, no_verify=False, force=False, ssh_port=22):
2528
"""

glustercli/cli/heal.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

3-
from glustercli.cli.utils import heal_execute, heal_execute_xml, GlusterCmdException
3+
from glustercli.cli.utils import heal_execute, heal_execute_xml, \
4+
GlusterCmdException
45
from glustercli.cli.parsers import parse_heal_statistics, parse_heal_info
56

67

glustercli/cli/parsers.py

+97-81
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@ def _parse_a_vol(volume_el):
3131
else:
3232
value['transport'] = 'TCP,RDMA'
3333

34-
for b in volume_el.findall('bricks/brick'):
35-
value['bricks'].append({"name": b.find("name").text,
36-
"uuid": b.find("hostUuid").text})
34+
for brick in volume_el.findall('bricks/brick'):
35+
value['bricks'].append({"name": brick.find("name").text,
36+
"uuid": brick.find("hostUuid").text})
3737

38-
for o in volume_el.findall('options/option'):
39-
value['options'].append({"name": o.find('name').text,
40-
"value": o.find('value').text})
38+
for opt in volume_el.findall('options/option'):
39+
value['options'].append({"name": opt.find('name').text,
40+
"value": opt.find('value').text})
4141

4242
return value
4343

4444

4545
def parse_volume_info(info):
4646
tree = etree.fromstring(info)
4747
volumes = []
48-
for el in tree.findall('volInfo/volumes/volume'):
48+
for volume_el in tree.findall('volInfo/volumes/volume'):
4949
try:
50-
volumes.append(_parse_a_vol(el))
51-
except (ParseError, AttributeError, ValueError) as e:
52-
raise GlusterCmdOutputParseError(e)
50+
volumes.append(_parse_a_vol(volume_el))
51+
except (ParseError, AttributeError, ValueError) as err:
52+
raise GlusterCmdOutputParseError(err)
5353

5454
return volumes
5555

@@ -88,11 +88,11 @@ def _parse_a_node(node_el):
8888
def _parse_volume_status(data):
8989
tree = etree.fromstring(data)
9090
nodes = []
91-
for el in tree.findall('volStatus/volumes/volume/node'):
91+
for node_el in tree.findall('volStatus/volumes/volume/node'):
9292
try:
93-
nodes.append(_parse_a_node(el))
94-
except (ParseError, AttributeError, ValueError) as e:
95-
raise GlusterCmdOutputParseError(e)
93+
nodes.append(_parse_a_node(node_el))
94+
except (ParseError, AttributeError, ValueError) as err:
95+
raise GlusterCmdOutputParseError(err)
9696

9797
return nodes
9898

@@ -104,17 +104,17 @@ def parse_volume_status(status_data, volinfo):
104104
tmp_brick_status[node["name"]] = node
105105

106106
volumes = []
107-
for v in volinfo:
108-
volumes.append(v.copy())
107+
for vol in volinfo:
108+
volumes.append(vol.copy())
109109
volumes[-1]["bricks"] = []
110110

111-
for b in v["bricks"]:
112-
brick_status_data = tmp_brick_status.get(b["name"], None)
111+
for brick in vol["bricks"]:
112+
brick_status_data = tmp_brick_status.get(brick["name"], None)
113113
if brick_status_data is None:
114114
# Default Status
115115
volumes[-1]["bricks"].append({
116-
"name": b["name"],
117-
"uuid": b["uuid"],
116+
"name": brick["name"],
117+
"uuid": brick["uuid"],
118118
"online": False,
119119
"ports": {"tcp": "N/A", "rdma": "N/A"},
120120
"pid": "N/A",
@@ -131,15 +131,15 @@ def parse_volume_status(status_data, volinfo):
131131
return volumes
132132

133133

134-
def _parse_profile_info_clear(el):
134+
def _parse_profile_info_clear(volume_el):
135135
clear = {
136-
'volname': el.find('volname').text,
136+
'volname': volume_el.find('volname').text,
137137
'bricks': []
138138
}
139139

140-
for b in el.findall('brick'):
141-
clear['bricks'].append({'brick_name': b.find('brickName').text,
142-
'clear_stats': b.find('clearStats').text})
140+
for brick_el in volume_el.findall('brick'):
141+
clear['bricks'].append({'brick_name': brick_el.find('brickName').text,
142+
'clear_stats': brick_el.find('clearStats').text})
143143

144144
return clear
145145

@@ -162,22 +162,27 @@ def _bytes_size(size):
162162

163163
def _parse_profile_block_stats(b_el):
164164
stats = []
165-
for b in b_el.findall('block'):
166-
size = _bytes_size(int(b.find('size').text))
167-
stats.append({size: {'reads': int(b.find('reads').text),
168-
'writes': int(b.find('writes').text)}})
165+
for block_el in b_el.findall('block'):
166+
size = _bytes_size(int(block_el.find('size').text))
167+
stats.append({size: {'reads': int(block_el.find('reads').text),
168+
'writes': int(block_el.find('writes').text)}})
169169
return stats
170170

171171

172172
def _parse_profile_fop_stats(fop_el):
173173
stats = []
174-
for f in fop_el.findall('fop'):
175-
name = f.find('name').text
176-
stats.append({name: {'hits': int(f.find('hits').text),
177-
'max_latency': float(f.find('maxLatency').text),
178-
'min_latency': float(f.find('minLatency').text),
179-
'avg_latency': float(f.find('avgLatency').text),
180-
}})
174+
for fop in fop_el.findall('fop'):
175+
name = fop.find('name').text
176+
stats.append(
177+
{
178+
name: {
179+
'hits': int(fop.find('hits').text),
180+
'max_latency': float(fop.find('maxLatency').text),
181+
'min_latency': float(fop.find('minLatency').text),
182+
'avg_latency': float(fop.find('avgLatency').text),
183+
}
184+
}
185+
)
181186
return stats
182187

183188

@@ -197,18 +202,28 @@ def _parse_profile_bricks(brick_el):
197202
brick_name = brick_el.find('brickName').text
198203

199204
if brick_el.find('cumulativeStats') is not None:
200-
cumulative_block_stats = _parse_profile_block_stats(brick_el.find('cumulativeStats/blockStats'))
201-
cumulative_fop_stats = _parse_profile_fop_stats(brick_el.find('cumulativeStats/fopStats'))
202-
cumulative_total_read_bytes = int(brick_el.find('cumulativeStats').find('totalRead').text)
203-
cumulative_total_write_bytes = int(brick_el.find('cumulativeStats').find('totalWrite').text)
204-
cumulative_total_duration = int(brick_el.find('cumulativeStats').find('duration').text)
205+
cumulative_block_stats = _parse_profile_block_stats(
206+
brick_el.find('cumulativeStats/blockStats'))
207+
cumulative_fop_stats = _parse_profile_fop_stats(
208+
brick_el.find('cumulativeStats/fopStats'))
209+
cumulative_total_read_bytes = int(
210+
brick_el.find('cumulativeStats').find('totalRead').text)
211+
cumulative_total_write_bytes = int(
212+
brick_el.find('cumulativeStats').find('totalWrite').text)
213+
cumulative_total_duration = int(
214+
brick_el.find('cumulativeStats').find('duration').text)
205215

206216
if brick_el.find('intervalStats') is not None:
207-
interval_block_stats = _parse_profile_block_stats(brick_el.find('intervalStats/blockStats'))
208-
interval_fop_stats = _parse_profile_fop_stats(brick_el.find('intervalStats/fopStats'))
209-
interval_total_read_bytes = int(brick_el.find('intervalStats').find('totalRead').text)
210-
interval_total_write_bytes = int(brick_el.find('intervalStats').find('totalWrite').text)
211-
interval_total_duration = int(brick_el.find('intervalStats').find('duration').text)
217+
interval_block_stats = _parse_profile_block_stats(
218+
brick_el.find('intervalStats/blockStats'))
219+
interval_fop_stats = _parse_profile_fop_stats(
220+
brick_el.find('intervalStats/fopStats'))
221+
interval_total_read_bytes = int(
222+
brick_el.find('intervalStats').find('totalRead').text)
223+
interval_total_write_bytes = int(
224+
brick_el.find('intervalStats').find('totalWrite').text)
225+
interval_total_duration = int(
226+
brick_el.find('intervalStats').find('duration').text)
212227

213228
profile_brick = {
214229
'brick_name': brick_name,
@@ -227,30 +242,30 @@ def _parse_profile_bricks(brick_el):
227242
return profile_brick
228243

229244

230-
def _parse_profile_info(el):
245+
def _parse_profile_info(volume_el):
231246
profile = {
232-
'volname': el.find('volname').text,
247+
'volname': volume_el.find('volname').text,
233248
'bricks': []
234249
}
235250

236-
for b in el.findall('brick'):
237-
profile['bricks'].append(_parse_profile_bricks(b))
251+
for brick_el in volume_el.findall('brick'):
252+
profile['bricks'].append(_parse_profile_bricks(brick_el))
238253

239254
return profile
240255

241256

242-
def parse_volume_profile_info(info, op):
257+
def parse_volume_profile_info(info, opt):
243258
xml = etree.fromstring(info)
244259
profiles = []
245-
for el in xml.findall('volProfile'):
260+
for prof_el in xml.findall('volProfile'):
246261
try:
247-
if op == "clear":
248-
profiles.append(_parse_profile_info_clear(el))
262+
if opt == "clear":
263+
profiles.append(_parse_profile_info_clear(prof_el))
249264
else:
250-
profiles.append(_parse_profile_info(el))
265+
profiles.append(_parse_profile_info(prof_el))
251266

252-
except (ParseError, AttributeError, ValueError) as e:
253-
raise GlusterCmdOutputParseError(e)
267+
except (ParseError, AttributeError, ValueError) as err:
268+
raise GlusterCmdOutputParseError(err)
254269

255270
return profiles
256271

@@ -310,13 +325,13 @@ def parse_georep_status(data, volinfo):
310325
"checkpoint_completion_time":
311326
pair.find("checkpoint_completion_time").text
312327
}
313-
except (ParseError, AttributeError, ValueError) as e:
314-
raise GlusterCmdOutputParseError(e)
328+
except (ParseError, AttributeError, ValueError) as err:
329+
raise GlusterCmdOutputParseError(err)
315330

316331
# Get List of Bricks for each Volume
317332
all_bricks = {}
318-
for vi in volinfo:
319-
all_bricks[vi["name"]] = vi["bricks"]
333+
for vol in volinfo:
334+
all_bricks[vol["name"]] = vol["bricks"]
320335

321336
# For Each session Get Bricks info for the Volume and Populate
322337
# Geo-rep status for that Brick
@@ -384,10 +399,11 @@ def parse_georep_config(data):
384399
def parse_remove_brick_status(status):
385400
tree = etree.fromstring(status)
386401

387-
result = {'nodes': [], 'aggregate': _parse_remove_aggregate(tree.find('volRemoveBrick/aggregate'))}
402+
result = {'nodes': [], 'aggregate': _parse_remove_aggregate(
403+
tree.find('volRemoveBrick/aggregate'))}
388404

389-
for el in tree.findall('volRemoveBrick/node'):
390-
result['nodes'].append(_parse_remove_node(el))
405+
for node_el in tree.findall('volRemoveBrick/node'):
406+
result['nodes'].append(_parse_remove_node(node_el))
391407

392408
return result
393409

@@ -435,20 +451,20 @@ def parse_tier_status(data):
435451
def parse_volume_list(data):
436452
xml = etree.fromstring(data)
437453
volumes = []
438-
for el in xml.findall('volList/volume'):
439-
volumes.append(el.text)
454+
for volume_el in xml.findall('volList/volume'):
455+
volumes.append(volume_el.text)
440456
return volumes
441457

442458

443459
def parse_heal_info(data):
444460
xml = etree.fromstring(data)
445461
healinfo = []
446-
for el in xml.findall('healInfo/bricks/brick'):
462+
for brick_el in xml.findall('healInfo/bricks/brick'):
447463
healinfo.append({
448-
'name': el.find('name').text,
449-
'status': el.find('status').text,
450-
'host_uuid': el.attrib['hostUuid'],
451-
'nr_entries': el.find('numberOfEntries').text
464+
'name': brick_el.find('name').text,
465+
'status': brick_el.find('status').text,
466+
'host_uuid': brick_el.attrib['hostUuid'],
467+
'nr_entries': brick_el.find('numberOfEntries').text
452468
})
453469
return healinfo
454470

@@ -468,8 +484,8 @@ def parse_snapshot_info(data):
468484
def parse_snapshot_list(data):
469485
xml = etree.fromstring(data)
470486
snapshots = []
471-
for el in xml.findall('snapList/snapshot'):
472-
snapshots.append(el.text)
487+
for snap_el in xml.findall('snapList/snapshot'):
488+
snapshots.append(snap_el.text)
473489
return snapshots
474490

475491

@@ -491,22 +507,22 @@ def _parse_a_peer(peer):
491507
def parse_peer_status(data):
492508
tree = etree.fromstring(data)
493509
peers = []
494-
for el in tree.findall('peerStatus/peer'):
510+
for peer_el in tree.findall('peerStatus/peer'):
495511
try:
496-
peers.append(_parse_a_peer(el))
497-
except (ParseError, AttributeError, ValueError) as e:
498-
raise GlusterCmdOutputParseError(e)
512+
peers.append(_parse_a_peer(peer_el))
513+
except (ParseError, AttributeError, ValueError) as err:
514+
raise GlusterCmdOutputParseError(err)
499515

500516
return peers
501517

502518

503519
def parse_pool_list(data):
504520
tree = etree.fromstring(data)
505521
pools = []
506-
for el in tree.findall('peerStatus/peer'):
522+
for peer_el in tree.findall('peerStatus/peer'):
507523
try:
508-
pools.append(_parse_a_peer(el))
509-
except (ParseError, AttributeError, ValueError) as e:
510-
raise GlusterCmdOutputParseError(e)
524+
pools.append(_parse_a_peer(peer_el))
525+
except (ParseError, AttributeError, ValueError) as err:
526+
raise GlusterCmdOutputParseError(err)
511527

512528
return pools

0 commit comments

Comments
 (0)