Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tsm-orchestration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UFZ TSM
tsm-orchestration
Commits
889109e3
Commit
889109e3
authored
11 months ago
by
Bert Palm
Browse files
Options
Downloads
Patches
Plain Diff
use minio url from ENVVAR instead of from frontenddb
parent
ef36a909
No related branches found
Branches containing commit
No related tags found
1 merge request
!148
sftp sync script
Pipeline
#378642
passed
11 months ago
Stage: integration
Stage: end-to-end
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cron/scripts/sftp_sync/remote_fs.py
+1
-0
1 addition, 0 deletions
cron/scripts/sftp_sync/remote_fs.py
cron/scripts/sftp_sync/sftp_sync.py
+16
-10
16 additions, 10 deletions
cron/scripts/sftp_sync/sftp_sync.py
with
17 additions
and
10 deletions
cron/scripts/sftp_sync/remote_fs.py
+
1
−
0
View file @
889109e3
...
...
@@ -73,6 +73,7 @@ class MinioFS(RemoteFS):
bucket_name
:
str
|
None
=
None
,
secure
:
bool
=
True
,
):
logger
.
warning
(
str
(
locals
()))
cl
=
minio
.
Minio
(
endpoint
=
endpoint
,
access_key
=
access_key
,
...
...
This diff is collapsed.
Click to expand it.
cron/scripts/sftp_sync/sftp_sync.py
+
16
−
10
View file @
889109e3
...
...
@@ -12,22 +12,32 @@ from paramiko import WarningPolicy
def
get_minio_credentials
(
conn
,
thing_id
)
->
tuple
[
str
,
str
,
str
,
str
]:
"""
Returns (uri, access_key, secret_key, bucket_name)
"""
with
conn
.
cursor
()
as
cur
:
return
cur
.
execute
(
"
SELECT
r.fileserver_uri,
r.access_key, r.secret_key, r.bucket
"
a
,
s
,
b
=
cur
.
execute
(
"
SELECT r.access_key, r.secret_key, r.bucket
"
"
FROM tsm_thing t JOIN tsm_rawdatastorage r ON t.id = r.thing_id
"
"
WHERE t.thing_id = %s
"
,
[
thing_id
],
).
fetchone
()
if
not
a
:
raise
RuntimeError
(
"
No object storage credentials found in frontend database
"
)
return
os
.
environ
[
"
MINIO_URL
"
],
a
,
s
,
b
def
get_external_ftp_credentials
(
conn
,
thing_id
)
->
tuple
[
str
,
str
,
str
,
str
]:
"""
Returns (uri, username, password, path)
"""
with
conn
.
cursor
()
as
cur
:
return
cur
.
execute
(
ur
,
us
,
pw
,
pa
=
cur
.
execute
(
"
SELECT ext_sftp_uri, ext_sftp_username, ext_sftp_password, ext_sftp_path
"
"
FROM tsm_thing WHERE thing_id = %s
"
,
[
thing_id
],
).
fetchone
()
if
""
in
[
ur
,
us
]
or
None
in
[
ur
,
us
]:
raise
RuntimeError
(
"
No object external sftp credentials found in frontend database
"
)
return
ur
,
us
,
pw
,
pa
USAGE
=
"""
...
...
@@ -59,9 +69,9 @@ if __name__ == "__main__":
thing_id
=
sys
.
argv
[
1
]
ssh_priv_key
=
sys
.
argv
[
2
]
for
k
in
[
"
FTP_AUTH_DB_DSN
"
,
"
MINIO_SECURE
"
]:
if
(
os
.
environ
.
get
(
k
)
or
None
)
is
None
:
raise
EnvironmentError
(
"
Environment variable {k} must be set
"
)
for
k
in
[
"
FTP_AUTH_DB_DSN
"
,
"
MINIO_URL
"
,
"
MINIO_SECURE
"
]:
if
not
os
.
environ
.
get
(
k
):
raise
EnvironmentError
(
f
"
Environment variable
{
k
}
must be set
"
)
dsn
=
os
.
environ
[
"
FTP_AUTH_DB_DSN
"
]
minio_secure
=
(
# ensure True as default
False
if
os
.
environ
[
"
MINIO_SECURE
"
].
lower
()
in
[
"
false
"
,
"
0
"
]
else
True
...
...
@@ -71,10 +81,6 @@ if __name__ == "__main__":
ftp_ext
=
get_external_ftp_credentials
(
conn
,
thing_id
)
storage
=
get_minio_credentials
(
conn
,
thing_id
)
if
ftp_ext
[
0
]
is
None
:
raise
RuntimeError
(
"
Got no external SFTP server from database
"
)
if
storage
[
0
]
is
None
:
raise
RuntimeError
(
"
Got no object storage from database
"
)
target
=
MinioFS
.
from_credentials
(
*
storage
,
secure
=
minio_secure
)
source
=
FtpFS
.
from_credentials
(
*
ftp_ext
,
keyfile_path
=
ssh_priv_key
,
missing_host_key_policy
=
WarningPolicy
()
...
...
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