Skip to content

Commit 345445a

Browse files
authored
Fix parsing issue when the fields are absent
Fixed issue where some systems did not return inodes_free and inodes_total, which cause an exception, now if values do not exist a default value will be inserted. Fixes: #49 Signed-off-by: PROJX<https://github.com/projx>
1 parent ae7b666 commit 345445a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

glustercli/cli/parsers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ def parse_volume_info(info, group_subvols=False):
229229

230230
return volumes
231231

232+
def _check_node_value(node_el, key, type, default_value):
233+
value = node_el.find(key)
234+
if value is not None:
235+
return type(value.text)
236+
return type(default_value)
232237

233238
def _parse_a_node(node_el):
234239
name = (node_el.find('hostname').text + ":" + node_el.find('path').text)
@@ -247,8 +252,8 @@ def _parse_a_node(node_el):
247252
'pid': node_el.find('pid').text,
248253
'size_total': int(node_el.find('sizeTotal').text),
249254
'size_free': int(node_el.find('sizeFree').text),
250-
'inodes_total': int(node_el.find('inodesTotal').text),
251-
'inodes_free': int(node_el.find('inodesFree').text),
255+
'inodes_total': _check_node_value(node_el, 'inodesTotal', int, 0),
256+
'inodes_free': _check_node_value(node_el, 'inodesFree', int, 0),
252257
'device': node_el.find('device').text,
253258
'block_size': node_el.find('blockSize').text,
254259
'mnt_options': node_el.find('mntOptions').text,

0 commit comments

Comments
 (0)