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
Kasra Jamshidi
slapos
Commits
6646c2e7
Commit
6646c2e7
authored
Jan 12, 2015
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resilient stack: takeover: display date of last backup.
parent
4e914795
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
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
+29
-2
No files found.
stack/resilient/buildout.cfg
View file @
6646c2e7
...
@@ -92,7 +92,7 @@ output = ${buildout:directory}/instance-frozen.cfg
...
@@ -92,7 +92,7 @@ output = ${buildout:directory}/instance-frozen.cfg
[resilient-web-takeover-cgi-script-download]
[resilient-web-takeover-cgi-script-download]
recipe = slapos.recipe.download
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/resilient-web-takeover-cgi-script.py.in
url = ${:_profile_base_location_}/resilient-web-takeover-cgi-script.py.in
md5sum =
e6262c5cf9b1c4d1ea4d959fdcbe3070
md5sum =
4e9599736dbbba9eb466cd0e4d78368d
mode = 0644
mode = 0644
destination = ${buildout:directory}/resilient-web-takeover-cgi-script.py.in
destination = ${buildout:directory}/resilient-web-takeover-cgi-script.py.in
...
...
stack/resilient/resilient-web-takeover-cgi-script.py.in
View file @
6646c2e7
#!${buildout:executable}
#!${buildout:executable}
equeue_database = '${equeue:database}'
import cgi
import cgi
import cgitb
import cgitb
import datetime
import gdbm
import os
import os
import shutil
import subprocess
import subprocess
import sys
import sys
import tempfile
cgitb.enable()
cgitb.enable()
def getLatestBackupDate():
"""
Get the date of the latest successful backup.
"""
# Create a copy of the db (locked by equeue process)
temporary_directory = tempfile.mkdtemp()
equeue_database_copy = os.path.join(temporary_directory, 'equeue.db')
shutil.copyfile(equeue_database, equeue_database_copy)
db = gdbm.open(equeue_database_copy)
# 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
)
print
"
Content-Type:
text
/
html
"
print
"
Content-Type:
text
/
html
"
print
print
...
@@ -17,12 +43,13 @@ if "password" not in form:
...
@@ -17,12 +43,13 @@ if "password" not in form:
<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>
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><b>
Warning: submit the form only if you understand what you are doing.
</b></p>
<p>
Note: the password asked here can be found within the parameters of your SlapOS instance page.
</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>
<form
action=
"/"
>
<form
action=
"/"
>
Password:
<input
type=
"text"
name=
"password"
>
Password:
<input
type=
"text"
name=
"password"
>
<input
type=
"submit"
value=
"Take over"
style=
"background: red;"
>
<input
type=
"submit"
value=
"Take over"
style=
"background: red;"
>
</form>
</form>
</body>
</body>
</html>
"""
</html>
"""
% getLatestBackupDate().strftime('%Y-%m-%d %H:%M:%S')
sys.exit(0)
sys.exit(0)
if form['password'].value != '${:password}':
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