Skip to content

Commit

Permalink
Update parse_lquota to work on lquota --no-pretty-print output
Browse files Browse the repository at this point in the history
  • Loading branch information
Dale Roberts committed Jul 18, 2023
1 parent f3d4d8f commit c581e28
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
11 changes: 10 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
CHANGES
=======

0.3.4
-----

* Fix automatically generated change log things
* Add archive step back in
* Have tests properly handle cases where gid exists or not
* Modify test to handle non-existent groups
* Handle uids and gids that do not correspond to users/groups on the system
* Use nci-files-report --json.
* Use nci-files-report --json. Actually add test data to repo
* Use nci\_account --json instead of API directly
* Update parse\_user\_storage\_data to use backend NCI API
* Update README info
* Remove travis CI config. Add Github Actions status badge

Expand Down
36 changes: 21 additions & 15 deletions ncigrafana/parse_lquota.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

databases = {}
dbfileprefix = '.'
nfields = 12
nfields = 7

def parse_lquota(filename, verbose, db=None, dburl=None):

Expand Down Expand Up @@ -74,20 +74,26 @@ def parse_lquota(filename, verbose, db=None, dburl=None):
parsing_usage = False
continue

array = line.strip(os.linesep).split(maxsplit=nfields)
project = array[0]
storagepoint = array[1]
size = parse_size((array[2]+array[3]), b=1024, u='iB')
size_quota = parse_size((array[4]+array[5]), b=1024, u='iB')
size_limit = parse_size((array[6]+array[7]), b=1024, u='iB')
inodes = int(array[8])
inodes_quota = int(array[9])
inodes_limit = int(array[10])

if len(array) == nfields:
msg = array[nfields-1]
else:
msg = None
project,storagepoint,size,size_quota,_,inodes,inodes_quota,_ = line.strip(os.linesep).split(maxsplit=nfields)
size=float(size)
size_quota=float(size_quota)
inodes=int(inodes)
inodes_quota=int(inodes_quota)
#array = line.strip(os.linesep).split(maxsplit=nfields)
#project = array[0]
#storagepoint = array[1]
#size=array[2]
#size = parse_size((array[2]+array[3]), b=1024, u='iB')
#size_quota = parse_size((array[4]+array[5]), b=1024, u='iB')
#size_limit = parse_size((array[6]+array[7]), b=1024, u='iB')
#inodes = int(array[8])
#inodes_quota = int(array[9])
#inodes_limit = int(array[10])

#if len(array) == nfields:
# msg = array[nfields-1]
#else:
# msg = None

system = 'gadi'
scheme = 'Combined'
Expand Down
16 changes: 8 additions & 8 deletions test/lquota.log
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ Thu Jun 27 08:30:03 AEST 2019
--------------------------------------------------------------------------
fs Usage Quota Limit iUsage iQuota iLimit
--------------------------------------------------------------------------
vv5 scratch 19.56 MiB 109.0 MiB 218.0 MiB 9107665 44223147 88446294
fs0 scratch 7.19 TiB 10.99 TiB 21.97 TiB 703700 1097000 2194000
vv5 gdata 158.04 KiB 158.95 KiB 166.89 KiB 7156412 8468000 8891400
fs0 gdata 76.21 TiB 80.0 TiB 84.0 TiB 1805324 5465000 5738250
vv5 scratch 20510146 109000000 218000000 9107665 44223147 88446294
fs0 scratch 7905488603709 10990000000000 21970000000000 703700 1097000 2194000
vv5 gdata 161832 158950 166890 7156412 8468000 8891400
fs0 gdata 83793781152808 80000000000000 84000000000000 1805324 5465000 5738250
--------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%
Fri Jun 28 08:30:03 AEST 2019
--------------------------------------------------------------------------
fs Usage Quota Limit iUsage iQuota iLimit
--------------------------------------------------------------------------
vv5 scratch 19.56 MiB 109.0 MiB 218.0 MiB 9107665 44223147 88446294
fs0 scratch 7.19 TiB 10.99 TiB 21.97 TiB 703700 1097000 2194000
vv5 gdata 158.04 KiB 158.95 KiB 166.89 KiB 7156412 8468000 8891400
fs0 gdata 76.21 TiB 80.0 TiB 84.0 TiB 1805324 5465000 5738250
vv5 scratch 19560000 109000000 218000000 9107665 44223147 88446294
fs0 scratch 7190000000000 10990000000000 21970000000000 703700 1097000 2194000
vv5 gdata 158040 158950 166890 7156412 8468000 8891400
fs0 gdata 7621000000000 8000000000000 8400000000000 1805324 5465000 5738250
--------------------------------------------------------------------------
8 changes: 4 additions & 4 deletions test/test_parse_lquota.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ def test_getstorage(db):
system = 'gadi'
project = 'vv5'
dp = db.getprojectstorage(project, system, 'scratch')
assert dp == (20510146.56, 9107665.0)
assert dp == (20510146.0, 9107665.0)
dp = db.getprojectstorage(project, system, 'gdata')
assert dp == (161832.96, 7156412.0)
assert dp == (161832.0, 7156412.0)

project = 'fs0'
dp = db.getprojectstorage(project, system, 'scratch')
assert dp == (7905488603709.44, 703700.0)
assert dp == (7905488603709.0, 703700.0)
dp = db.getprojectstorage(project, system, 'gdata')
assert dp == (83793781152808.95, 1805324.0)
assert dp == (83793781152808.0, 1805324.0)

0 comments on commit c581e28

Please sign in to comment.