Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
528e9abb
Commit
528e9abb
authored
6 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
SW-285
: insert known lta site quota
parent
21c3b882
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
LTA/ltastorageoverview/lib/scraper.py
+41
-7
41 additions, 7 deletions
LTA/ltastorageoverview/lib/scraper.py
LTA/ltastorageoverview/lib/store.py
+18
-0
18 additions, 0 deletions
LTA/ltastorageoverview/lib/store.py
with
59 additions
and
7 deletions
LTA/ltastorageoverview/lib/scraper.py
+
41
−
7
View file @
528e9abb
...
@@ -40,7 +40,7 @@ from random import random, randint
...
@@ -40,7 +40,7 @@ from random import random, randint
logger
=
logging
.
getLogger
()
logger
=
logging
.
getLogger
()
VISIT_INTERVAL
=
datetime
.
timedelta
(
days
=
3
)
VISIT_INTERVAL
=
datetime
.
timedelta
(
days
=
3
)
LEXAR_HOST
=
'
ingest@lexar004
'
LEXAR_HOST
=
'
ingest@lexar004
.offline.lofar
'
class
FileInfo
:
class
FileInfo
:
'''
Simple struct to hold filename and size
'''
'''
Simple struct to hold filename and size
'''
...
@@ -388,20 +388,54 @@ class ResultGetterThread(threading.Thread):
...
@@ -388,20 +388,54 @@ class ResultGetterThread(threading.Thread):
db
.
updateDirectoryLastVisitTime
(
self
.
dir_id
,
datetime
.
datetime
.
utcnow
()
-
VISIT_INTERVAL
)
db
.
updateDirectoryLastVisitTime
(
self
.
dir_id
,
datetime
.
datetime
.
utcnow
()
-
VISIT_INTERVAL
)
def
populateDbWithLTASitesAndRootDirs
(
db
):
def
populateDbWithLTASitesAndRootDirs
(
db
):
"""
Helper method to fill empty database with (hardcoded) information about our LTA partners/sites/quotas
"""
if
not
db
.
sites
():
if
not
db
.
sites
():
#db.insertSite('nikhef', 'srm://tbn18.nikhef.nl:8446')
#db.insertSite('nikhef', 'srm://tbn18.nikhef.nl:8446')
sara_id
=
db
.
insertSiteIfNotExists
(
'
sara
'
,
'
srm://srm.grid.sara.nl:8443
'
)
sara_id
=
db
.
insertSiteIfNotExists
(
'
sara
'
,
'
srm://srm.grid.sara.nl:8443
'
)
juelich_id
=
db
.
insertSiteIfNotExists
(
'
juelich
'
,
'
srm://lofar-srm.fz-juelich.de:8443
'
)
juelich_id
=
db
.
insertSiteIfNotExists
(
'
juelich
'
,
'
srm://lofar-srm.fz-juelich.de:8443
'
)
poznan_id
=
db
.
insertSiteIfNotExists
(
'
poznan
'
,
'
srm://lta-head.lofar.psnc.pl:8443
'
)
poznan_id
=
db
.
insertSiteIfNotExists
(
'
poznan
'
,
'
srm://lta-head.lofar.psnc.pl:8443
'
)
for
site_id
in
[
sara_id
,
juelich_id
,
poznan_id
]:
# insert the LTA site root dir(s)
for
i
in
range
(
1
,
8
):
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar/software
'
)
db
.
executeQuery
(
'
insert into lta.site_quota(site_id, quota, valid_until_date) values (%s, %s, %s);
'
,
(
site_id
,
long
(
i
*
1e15
),
'
201%d-12-31 23:59:59
'
%
i
))
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar/ops
'
)
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar/storage
'
)
#db.insertRootDirectory('nikhef', '/dpm/nikhef.nl/home/lofar')
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar/eor
'
)
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar
'
)
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar/pulsar
'
)
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar/cosmics
'
)
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar/surveys
'
)
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar/user
'
)
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar/proc
'
)
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar/trans
'
)
db
.
insertRootDirectory
(
'
sara
'
,
'
/pnfs/grid.sara.nl/data/lofar/lotest
'
)
db
.
insertRootDirectory
(
'
juelich
'
,
'
/pnfs/fz-juelich.de/data/lofar/ops
'
)
db
.
insertRootDirectory
(
'
juelich
'
,
'
/pnfs/fz-juelich.de/data/lofar/ops
'
)
db
.
insertRootDirectory
(
'
poznan
'
,
'
/lofar/ops
'
)
db
.
insertRootDirectory
(
'
poznan
'
,
'
/lofar/ops
'
)
#db.insertRootDirectory('nikhef', '/dpm/nikhef.nl/home/lofar')
def
end_of_year
(
year
):
'''
little helper function which returns a datetime timestamp for the end of the given year
'''
return
datetime
.
datetime
(
year
,
12
,
31
,
23
,
59
,
59
)
# insert quota as given by our LTA partners
db
.
insertSiteQuota
(
sara_id
,
5e15
,
end_of_year
(
2012
))
db
.
insertSiteQuota
(
sara_id
,
8e15
,
end_of_year
(
2013
))
db
.
insertSiteQuota
(
sara_id
,
11e15
,
end_of_year
(
2014
))
db
.
insertSiteQuota
(
sara_id
,
14e15
,
end_of_year
(
2015
))
db
.
insertSiteQuota
(
sara_id
,
17e15
,
end_of_year
(
2016
))
db
.
insertSiteQuota
(
sara_id
,
20e15
,
end_of_year
(
2017
))
db
.
insertSiteQuota
(
sara_id
,
23e15
,
end_of_year
(
2018
))
db
.
insertSiteQuota
(
juelich_id
,
2.5e15
,
end_of_year
(
2013
))
db
.
insertSiteQuota
(
juelich_id
,
4.5e15
,
end_of_year
(
2014
))
db
.
insertSiteQuota
(
juelich_id
,
6.5e15
,
end_of_year
(
2015
))
db
.
insertSiteQuota
(
juelich_id
,
8.5e15
,
end_of_year
(
2016
))
db
.
insertSiteQuota
(
juelich_id
,
10.5e15
,
end_of_year
(
2017
))
db
.
insertSiteQuota
(
juelich_id
,
12.5e15
,
end_of_year
(
2018
))
db
.
insertSiteQuota
(
poznan_id
,
0.5e15
,
end_of_year
(
2016
))
db
.
insertSiteQuota
(
poznan_id
,
3.5e15
,
end_of_year
(
2017
))
db
.
insertSiteQuota
(
poznan_id
,
5.5e15
,
end_of_year
(
2018
))
def
main
():
def
main
():
...
...
This diff is collapsed.
Click to expand it.
LTA/ltastorageoverview/lib/store.py
+
18
−
0
View file @
528e9abb
...
@@ -238,6 +238,24 @@ class LTAStorageDb(PostgresDatabaseConnection):
...
@@ -238,6 +238,24 @@ class LTAStorageDb(PostgresDatabaseConnection):
'''
returns list of quota tuples (site_id, site_name, quota, valid_until_date)
'''
'''
returns list of quota tuples (site_id, site_name, quota, valid_until_date)
'''
return
self
.
executeQuery
(
'
SELECT * FROM lta.site_quota;
'
,
FETCH_All
)
return
self
.
executeQuery
(
'
SELECT * FROM lta.site_quota;
'
,
FETCH_All
)
def
insertSiteQuota
(
self
,
site_id
,
quota
,
valid_until_date
,
commit
=
True
):
"""
insert the quota for a given site with a date until which this quota is valid.
:param int site_id: the id of the site for which you want to set the quota.
:param int quota: the quota in number of bytes.
:param datetime valid_until_date: the timestamp until which this given quota is valid.
:param bool commit: do/don
'
t commit immediately.
:return: the id of the new quota
"""
id
=
self
.
executeQuery
(
'
INSERT INTO lta.site_quota(site_id, quota, valid_until_date) values (%s, %s, %s) RETURNING id;
'
,
(
site_id
,
quota
,
valid_until_date
))
if
commit
:
self
.
commit
()
return
id
'''
returns list of quota tuples (site_id, site_name, quota, valid_until_date)
'''
return
self
.
executeQuery
(
'
SELECT * FROM lta.site_quota;
'
,
FETCH_All
)
def
directory
(
self
,
dir_id
):
def
directory
(
self
,
dir_id
):
'''
returns lta.directory (id, name, site_id, site_name) for the given dir_id
'''
'''
returns lta.directory (id, name, site_id, site_name) for the given dir_id
'''
return
self
.
executeQuery
(
'''
SELECT dir.id as dir_id, dir.name as dir_name, site.id as site_id, site.name as site_name
return
self
.
executeQuery
(
'''
SELECT dir.id as dir_id, dir.name as dir_name, site.id as site_id, site.name as site_name
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment