@@ -31,25 +31,25 @@ def _parse_a_vol(volume_el):
31
31
else :
32
32
value ['transport' ] = 'TCP,RDMA'
33
33
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 })
37
37
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 })
41
41
42
42
return value
43
43
44
44
45
45
def parse_volume_info (info ):
46
46
tree = etree .fromstring (info )
47
47
volumes = []
48
- for el in tree .findall ('volInfo/volumes/volume' ):
48
+ for volume_el in tree .findall ('volInfo/volumes/volume' ):
49
49
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 )
53
53
54
54
return volumes
55
55
@@ -88,11 +88,11 @@ def _parse_a_node(node_el):
88
88
def _parse_volume_status (data ):
89
89
tree = etree .fromstring (data )
90
90
nodes = []
91
- for el in tree .findall ('volStatus/volumes/volume/node' ):
91
+ for node_el in tree .findall ('volStatus/volumes/volume/node' ):
92
92
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 )
96
96
97
97
return nodes
98
98
@@ -104,17 +104,17 @@ def parse_volume_status(status_data, volinfo):
104
104
tmp_brick_status [node ["name" ]] = node
105
105
106
106
volumes = []
107
- for v in volinfo :
108
- volumes .append (v .copy ())
107
+ for vol in volinfo :
108
+ volumes .append (vol .copy ())
109
109
volumes [- 1 ]["bricks" ] = []
110
110
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 )
113
113
if brick_status_data is None :
114
114
# Default Status
115
115
volumes [- 1 ]["bricks" ].append ({
116
- "name" : b ["name" ],
117
- "uuid" : b ["uuid" ],
116
+ "name" : brick ["name" ],
117
+ "uuid" : brick ["uuid" ],
118
118
"online" : False ,
119
119
"ports" : {"tcp" : "N/A" , "rdma" : "N/A" },
120
120
"pid" : "N/A" ,
@@ -131,15 +131,15 @@ def parse_volume_status(status_data, volinfo):
131
131
return volumes
132
132
133
133
134
- def _parse_profile_info_clear (el ):
134
+ def _parse_profile_info_clear (volume_el ):
135
135
clear = {
136
- 'volname' : el .find ('volname' ).text ,
136
+ 'volname' : volume_el .find ('volname' ).text ,
137
137
'bricks' : []
138
138
}
139
139
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 })
143
143
144
144
return clear
145
145
@@ -162,22 +162,27 @@ def _bytes_size(size):
162
162
163
163
def _parse_profile_block_stats (b_el ):
164
164
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 )}})
169
169
return stats
170
170
171
171
172
172
def _parse_profile_fop_stats (fop_el ):
173
173
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
+ )
181
186
return stats
182
187
183
188
@@ -197,18 +202,28 @@ def _parse_profile_bricks(brick_el):
197
202
brick_name = brick_el .find ('brickName' ).text
198
203
199
204
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 )
205
215
206
216
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 )
212
227
213
228
profile_brick = {
214
229
'brick_name' : brick_name ,
@@ -227,30 +242,30 @@ def _parse_profile_bricks(brick_el):
227
242
return profile_brick
228
243
229
244
230
- def _parse_profile_info (el ):
245
+ def _parse_profile_info (volume_el ):
231
246
profile = {
232
- 'volname' : el .find ('volname' ).text ,
247
+ 'volname' : volume_el .find ('volname' ).text ,
233
248
'bricks' : []
234
249
}
235
250
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 ))
238
253
239
254
return profile
240
255
241
256
242
- def parse_volume_profile_info (info , op ):
257
+ def parse_volume_profile_info (info , opt ):
243
258
xml = etree .fromstring (info )
244
259
profiles = []
245
- for el in xml .findall ('volProfile' ):
260
+ for prof_el in xml .findall ('volProfile' ):
246
261
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 ))
249
264
else :
250
- profiles .append (_parse_profile_info (el ))
265
+ profiles .append (_parse_profile_info (prof_el ))
251
266
252
- except (ParseError , AttributeError , ValueError ) as e :
253
- raise GlusterCmdOutputParseError (e )
267
+ except (ParseError , AttributeError , ValueError ) as err :
268
+ raise GlusterCmdOutputParseError (err )
254
269
255
270
return profiles
256
271
@@ -310,13 +325,13 @@ def parse_georep_status(data, volinfo):
310
325
"checkpoint_completion_time" :
311
326
pair .find ("checkpoint_completion_time" ).text
312
327
}
313
- except (ParseError , AttributeError , ValueError ) as e :
314
- raise GlusterCmdOutputParseError (e )
328
+ except (ParseError , AttributeError , ValueError ) as err :
329
+ raise GlusterCmdOutputParseError (err )
315
330
316
331
# Get List of Bricks for each Volume
317
332
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" ]
320
335
321
336
# For Each session Get Bricks info for the Volume and Populate
322
337
# Geo-rep status for that Brick
@@ -384,10 +399,11 @@ def parse_georep_config(data):
384
399
def parse_remove_brick_status (status ):
385
400
tree = etree .fromstring (status )
386
401
387
- result = {'nodes' : [], 'aggregate' : _parse_remove_aggregate (tree .find ('volRemoveBrick/aggregate' ))}
402
+ result = {'nodes' : [], 'aggregate' : _parse_remove_aggregate (
403
+ tree .find ('volRemoveBrick/aggregate' ))}
388
404
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 ))
391
407
392
408
return result
393
409
@@ -435,20 +451,20 @@ def parse_tier_status(data):
435
451
def parse_volume_list (data ):
436
452
xml = etree .fromstring (data )
437
453
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 )
440
456
return volumes
441
457
442
458
443
459
def parse_heal_info (data ):
444
460
xml = etree .fromstring (data )
445
461
healinfo = []
446
- for el in xml .findall ('healInfo/bricks/brick' ):
462
+ for brick_el in xml .findall ('healInfo/bricks/brick' ):
447
463
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
452
468
})
453
469
return healinfo
454
470
@@ -468,8 +484,8 @@ def parse_snapshot_info(data):
468
484
def parse_snapshot_list (data ):
469
485
xml = etree .fromstring (data )
470
486
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 )
473
489
return snapshots
474
490
475
491
@@ -491,22 +507,22 @@ def _parse_a_peer(peer):
491
507
def parse_peer_status (data ):
492
508
tree = etree .fromstring (data )
493
509
peers = []
494
- for el in tree .findall ('peerStatus/peer' ):
510
+ for peer_el in tree .findall ('peerStatus/peer' ):
495
511
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 )
499
515
500
516
return peers
501
517
502
518
503
519
def parse_pool_list (data ):
504
520
tree = etree .fromstring (data )
505
521
pools = []
506
- for el in tree .findall ('peerStatus/peer' ):
522
+ for peer_el in tree .findall ('peerStatus/peer' ):
507
523
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 )
511
527
512
528
return pools
0 commit comments