Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
strudel2_backend
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hpc-team
strudel2_backend
Commits
0a689972
Commit
0a689972
authored
6 years ago
by
Ubuntu
Browse files
Options
Downloads
Patches
Plain Diff
changes to log info
parent
2ccbb25a
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
tes/__init__.py
+3
-5
3 additions, 5 deletions
tes/__init__.py
tes/apiendpoints.py
+8
-0
8 additions, 0 deletions
tes/apiendpoints.py
with
11 additions
and
5 deletions
tes/__init__.py
+
3
−
5
View file @
0a689972
...
...
@@ -5,11 +5,11 @@ from flask_cors import CORS, cross_origin
from
.tunnelstat
import
SSHSession
app
=
Flask
(
__name__
)
app
.
config
[
'
LOCAL_DEV
'
]
=
Tru
e
app
.
config
[
'
LOCAL_DEV
'
]
=
Fals
e
app
.
config
[
'
DEBUG
'
]
=
True
app
.
config
[
'
SECRET_KEY
'
]
=
'
asdasfdfj
'
import
datetime
app
.
config
[
'
PERMANENT_SESSION_LIFETIME
'
]
=
datetime
.
timedelta
(
seconds
=
30
)
app
.
config
[
'
PERMANENT_SESSION_LIFETIME
'
]
=
datetime
.
timedelta
(
seconds
=
30
0
)
app
.
config
[
'
SESSION_REFRESH_EACH_REQUEST
'
]
=
True
app
.
config
[
'
SESSION_COOKIE_NAME
'
]
=
'
tessession
'
app
.
config
[
'
TWSPROXY
'
]
=
'
http://localhost:4000/
'
...
...
@@ -27,9 +27,7 @@ from . import apiendpoints
def
after_cleanup_sessions
(
response
):
import
logging
logger
=
logging
.
getLogger
()
logger
.
debug
(
"
in after_cleanup_sessions
"
)
sshsessid
=
session
.
get
(
'
sshsessid
'
,
None
)
print
(
"
the sshsessid for this request was {}
"
.
format
(
sshsessid
))
# kvsessionextension.cleanup_sessions(app)
_ttl
=
app
.
config
[
'
PERMANENT_SESSION_LIFETIME
'
]
...
...
@@ -39,7 +37,7 @@ def after_cleanup_sessions(response):
ttl
=
_ttl
for
k
,
sshsess
in
list
(
sshsessions
.
items
()):
if
datetime
.
datetime
.
now
()
>
sshsess
.
last
+
ttl
:
print
(
"
session last seen at {} now {}
"
.
format
(
sshsess
.
last
,
datetime
.
datetime
.
now
()))
logger
.
debug
(
"
session last seen at {} now {}
"
.
format
(
sshsess
.
last
,
datetime
.
datetime
.
now
()))
sshsess
.
kill
()
del
sshsessions
[
k
]
return
response
...
...
This diff is collapsed.
Click to expand it.
tes/apiendpoints.py
+
8
−
0
View file @
0a689972
...
...
@@ -45,6 +45,9 @@ class GetCert(Resource):
resp
=
sess
.
post
(
url
,
json
=
data
,
headers
=
headers
,
verify
=
False
)
print
(
"
get_cert returned from its external call
"
)
data
=
resp
.
json
()
import
logging
logger
=
logging
.
getLogger
()
logger
.
debug
(
'
attempted get_cert {}
'
.
format
(
data
))
return
data
[
'
certificate
'
]
class
TestAuth
(
Resource
):
...
...
@@ -224,13 +227,18 @@ class JobSubmit(Resource):
"""
def
post
(
self
):
"""
starting a job is a post, since it changes the state of the backend
"""
import
logging
logger
=
logging
.
getLogger
()
params
=
get_conn_params
()
logger
.
debug
(
'
submitting with parameters {}
'
.
format
(
params
))
sshsess
=
SSHSession
.
get_sshsession
()
res
=
Ssh
.
execute
(
sshsess
,
host
=
params
[
'
identity
'
][
'
site
'
][
'
host
'
],
user
=
params
[
'
identity
'
][
'
username
'
],
cmd
=
params
[
'
interface
'
][
'
submitcmd
'
],
stdin
=
params
[
'
app
'
][
'
startscript
'
])
if
not
(
res
[
'
stderr
'
]
==
''
or
res
[
'
stderr
'
]
is
None
or
res
[
'
stderr
'
]
==
b
''
):
print
(
res
[
'
stderr
'
])
logger
.
debug
(
res
[
'
stderr
'
])
flask_restful
.
abort
(
400
,
message
=
res
[
'
stderr
'
].
decode
())
logger
.
debug
(
res
[
'
stdout
'
])
return
res
[
'
stdout
'
].
decode
()
def
gen_authtok
():
...
...
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