Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tzis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
data-infrastructure-services
tzis
Commits
279a1b0e
Commit
279a1b0e
authored
2 years ago
by
Fabian Wachsmann
Browse files
Options
Downloads
Patches
Plain Diff
Tried to include JSC os
parent
983d76da
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
tzis/catalog.py
+2
-1
2 additions, 1 deletion
tzis/catalog.py
tzis/swifthandling.py
+13
-8
13 additions, 8 deletions
tzis/swifthandling.py
with
15 additions
and
9 deletions
tzis/catalog.py
+
2
−
1
View file @
279a1b0e
...
...
@@ -4,10 +4,11 @@ from zarrswift import SwiftStore
from
datetime
import
datetime
import
requests
import
json
import
copy
def
write_index_file
(
store
,
pattern
=
None
,
contact
=
None
):
prefix
=
store
.
prefix
prefix
=
copy
.
deepcopy
(
store
.
prefix
)
store
.
prefix
=
""
index_name
=
"
INDEX.csv
"
header
=
[
...
...
This diff is collapsed.
Click to expand it.
tzis/swifthandling.py
+
13
−
8
View file @
279a1b0e
...
...
@@ -35,10 +35,15 @@ def get_fsspec_url(os_url, os_container):
return
os_url
def
_check_connection
(
account
,
user
,
password
=
None
):
SWIFT_BASE
=
"
https://swift.dkrz.de/
"
def
_check_connection
(
swift_base
,
account
,
user
,
password
=
None
):
SWIFT_BASE
=
"
https://swift.dkrz.de/
"
SWIFT_VERS
=
"
v1.0
"
if
swift_base
==
"
jsc
"
:
SWIFT_BASE
=
"
https://just-keystone.fz-juelich.de:8080/
"
SWIFT_VERS
=
"
v1.0
"
elif
swift_base
!=
"
DKRZ
"
:
raise
Exception
(
"
You have to provide either dkrz
'
or
'
jsc
'
for swift_base
"
)
headers
=
{
"
X-Auth-User
"
:
f
"
{
account
}
:
{
user
}
"
}
if
password
:
...
...
@@ -109,14 +114,14 @@ def _get_envtoken(token_file="~/.swiftenv", **kwargs):
return
env
,
expires
def
create_token
(
account
,
user
,
**
kwargs
):
def
create_token
(
swift_base
,
account
,
user
name
,
**
kwargs
):
"""
Create a new swift token for a given account.
"""
user
=
user
or
getpass
.
getuser
()
user
=
user
name
or
getpass
.
getuser
()
password
=
getpass
.
getpass
(
(
f
"
Creating new swift-token
"
f
"
\n
Give password for
{
user
}
on
{
account
}
:
"
)
)
resp
=
_check_connection
(
account
,
user
,
password
)
resp
=
_check_connection
(
swift_base
,
account
,
user
,
password
)
tz
=
time
.
tzname
[
-
1
]
expires
=
token
=
storage_url
=
None
token
=
resp
.
headers
[
"
x-auth-token
"
]
...
...
@@ -127,7 +132,7 @@ def create_token(account, user, **kwargs):
_write_token
(
token
,
storage_url
,
expires
,
**
kwargs
)
def
get_token
(
account
,
username
=
None
,
**
kwargs
):
def
get_token
(
swift_base
,
account
,
username
=
None
,
**
kwargs
):
"""
Check if a swift token for a given account is still valid.
This method checks if a token for a swift container can be used
...
...
@@ -158,7 +163,7 @@ def get_token(account, username=None, **kwargs):
and
valid
):
return
env
create_token
(
account
,
username
or
None
)
create_token
(
swift_base
,
account
,
username
or
None
)
return
_get_envtoken
(
**
kwargs
)
...
...
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