Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
noc
tower
Commits
27bfe2c8
Commit
27bfe2c8
authored
Nov 13, 2020
by
EKbfh
🐼
Browse files
Merge branch 'add-39-change-value-login-timeout' into 'master'
Add 39 change value login timeout See merge request
!69
parents
105fd991
36123a77
Pipeline
#28536
passed with stages
in 5 minutes and 30 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
tower/migrations/039_change_login_session_timeout.py
0 → 100644
View file @
27bfe2c8
# Third-party modules
import
yaml
import
json
from
peewee
import
(
Model
,
CharField
,
TextField
,
ForeignKeyField
)
def
migrate
(
migrator
):
class
Environment
(
Model
):
class
Meta
(
object
):
database
=
migrator
.
db
db_table
=
"environment"
name
=
CharField
(
unique
=
True
)
class
Node
(
Model
):
class
Meta
(
object
):
database
=
migrator
.
db
db_table
=
"node"
name
=
CharField
()
environment
=
ForeignKeyField
(
Environment
,
on_delete
=
"RESTRICT"
)
class
Pool
(
Model
):
class
Meta
(
object
):
database
=
migrator
.
db
db_table
=
"pool"
environment
=
ForeignKeyField
(
Environment
,
on_delete
=
"RESTRICT"
)
name
=
CharField
()
class
Service
(
Model
):
class
Meta
(
object
):
database
=
migrator
.
db
db_table
=
"service"
environment
=
ForeignKeyField
(
Environment
,
on_delete
=
"RESTRICT"
)
service
=
CharField
()
config
=
TextField
()
pool
=
ForeignKeyField
(
Pool
,
null
=
True
)
node
=
ForeignKeyField
(
Node
)
if
len
(
Environment
.
select
())
!=
0
:
for
env
in
Environment
.
select
():
print
(
"Migrating %s"
%
env
.
name
)
for
s
in
Service
.
select
().
where
(
Service
.
environment
==
env
.
id
):
if
s
.
service
==
"login"
:
conf
=
yaml
.
full_load
(
s
.
config
)
if
"session_ttl"
in
conf
:
if
"d"
not
in
str
(
conf
[
"session_ttl"
]):
conf
[
"session_ttl"
]
=
str
(
conf
[
"session_ttl"
])
+
"d"
s
.
config
=
json
.
dumps
(
conf
,
sort_keys
=
True
)
s
.
save
()
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment