Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vincent Bechu
slapos
Commits
b0fda502
Commit
b0fda502
authored
Aug 31, 2016
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resilient: takeover CGI doesn't fail if no backup has been received yet.
Also makes the interface more readable
parent
6fcd18d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
stack/resilient/buildout.cfg
stack/resilient/buildout.cfg
+1
-1
stack/resilient/resilient-web-takeover-cgi-script.py.in
stack/resilient/resilient-web-takeover-cgi-script.py.in
+23
-10
No files found.
stack/resilient/buildout.cfg
View file @
b0fda502
...
...
@@ -95,7 +95,7 @@ output = ${buildout:directory}/instance-frozen.cfg
[resilient-web-takeover-cgi-script-download]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/resilient-web-takeover-cgi-script.py.in
md5sum = 3
aa7624af1196062d7d01946d4de9f0e
md5sum = 3
8a4f723924a674c4bc1be1b9ffd2c3c
mode = 0644
destination = ${buildout:directory}/resilient-web-takeover-cgi-script.py.in
...
...
stack/resilient/resilient-web-takeover-cgi-script.py.in
View file @
b0fda502
...
...
@@ -27,12 +27,18 @@ def getLatestBackupDate():
# Usually, there is only one callback (so only one key
# in the db), but if there are several:
# Take the "oldest" one (oldest value).
last_backup = db[db.keys()[0]]
for callback in db.keys():
timestamp = float(db[callback])
if timestamp
<
last
_backup:
last_backup =
timestamp
return
datetime
.
datetime
.
fromtimestamp
(
last_backup
)
if not db.keys():
result = False
else:
last_backup = db[db.keys()[0]]
for callback in db.keys():
timestamp = float(db[callback])
if timestamp
<
last
_backup:
last_backup =
timestamp
result =
datetime.datetime.fromtimestamp(last_backup)
db
.
close
()
shutil
.
rmtree
(
temporary_directory
)
return
result
def
isBackupInProgress
()
:
"""
...
...
@@ -42,6 +48,12 @@ def isBackupInProgress():
#
XXX:
check
if
file
is
valid
return
os
.
path
.
exists
(
equeue_lockfile
)
latest_backup_date =
getLatestBackupDate()
if
latest_backup_date =
=
False:
latest_backup_message =
"No backup downloaded yet, takeover should not happen now."
else:
latest_backup_message =
latest_backup_date.strftime('%Y-%m-%d
%
H:
%
M:
%
S
')
print
"
Content-Type:
text
/
html
"
print
...
...
@@ -51,16 +63,17 @@ if "password" not in form:
<body>
<h1>
This is takeover web interface.
</h1>
<p>
Calling takeover will stop and freeze the current main instance, and make this clone instance the new main instance, replacing the old one.
</p>
<p><
b>
Warning: submit the form only if you understand what you are doing.
</b
></p>
<p><
font
size=
\"+2\"
><b>
Warning: submit the form only if you understand what you are doing.
</b></font
></p>
<p>
Note: the password asked here can be found within the parameters of your SlapOS instance page.
</p>
<p>
Last valid backup: %s
</p>
<p>
Importer script(s) of backup in progress: %s
</p>
<hr
/>
<p><b>
Last valid backup:
</b>
%s
</p>
<p><b>
Importer script(s) of backup in progress:
</b>
%s
</p>
<form
action=
"/"
>
Password:
<input
type=
"text"
name=
"password"
>
<input
type=
"submit"
value=
"Take over"
style=
"background: red;"
>
</form>
</body>
</html>
""" % (
getLatestBackupDate().strftime('%Y-%m-%d %H:%M:%S')
, isBackupInProgress())
</html>
""" % (
latest_backup_message
, isBackupInProgress())
sys.exit(0)
if form['password'].value != '${:password}':
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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