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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ekaterina
slapos
Commits
7a20831d
Commit
7a20831d
authored
Jan 22, 2020
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stack/resilient: add support for Python 3
parent
603eca2f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
32 deletions
+36
-32
stack/resilient/buildout.hash.cfg
stack/resilient/buildout.hash.cfg
+4
-4
stack/resilient/resilient-web-takeover-cgi-script.py.in
stack/resilient/resilient-web-takeover-cgi-script.py.in
+14
-13
stack/resilient/template-replicated.cfg.in
stack/resilient/template-replicated.cfg.in
+7
-7
stack/resilient/templates/monitor-check-resilient-feed.in
stack/resilient/templates/monitor-check-resilient-feed.in
+7
-5
stack/resilient/templates/notifier-feed-promise.py.in
stack/resilient/templates/notifier-feed-promise.py.in
+4
-3
No files found.
stack/resilient/buildout.hash.cfg
View file @
7a20831d
...
...
@@ -30,7 +30,7 @@ md5sum = 0bbe16f3d805afd880a251a4f40ecaf1
[template-replicated]
filename = template-replicated.cfg.in
md5sum =
290b380fe3da8736642bc10a8b1163d1
md5sum =
815fd8f7c42b9cf59b286b0fe77fa76d
[template-parts]
filename = template-parts.cfg.in
...
...
@@ -46,7 +46,7 @@ md5sum = d21472f0e58f928fb827f2cbf22c4d4a
[resilient-web-takeover-cgi-script-download]
filename = resilient-web-takeover-cgi-script.py.in
md5sum =
60d4912fdf5e8dafaba9d9f333aa9e36
md5sum =
f5f1443330cd55210e9dbfd6b4ff5c8a
[template-wrapper]
filename = templates/wrapper.in
...
...
@@ -54,9 +54,9 @@ md5sum = 8cde04bfd0c0e9bd56744b988275cfd8
[notifier-feed-promise-template]
filename = templates/notifier-feed-promise.py.in
md5sum =
d75346911dbc4cfcdb39a21e56cd5016
md5sum =
8e7496e3c0e2b3b151afd7a340433d2e
[template-monitor-check-resilient-feed]
filename = templates/monitor-check-resilient-feed.in
md5sum =
19ee9055de961acf402e2dfe5b9581d2
md5sum =
618b0b46b37eaad2f3f5b22c86e2b24d
stack/resilient/resilient-web-takeover-cgi-script.py.in
View file @
7a20831d
#!${buildout:executable}
from __future__ import print_function
equeue_database = '${equeue:database}'
equeue_lockfile = '${equeue:lockfile}'
takeover_script = '${resiliency-takeover-script:wrapper-takeover}'
...
...
@@ -8,7 +9,7 @@ import atexit
import cgi
import cgitb
import datetime
import
gdbm
import
six.moves.dbm_gnu as dbm_gnu
import os
import shutil
import subprocess
...
...
@@ -35,15 +36,16 @@ def getLatestBackupDate():
atexit.register(deleteTemporaryDirectory, temporary_directory)
equeue_database_copy = os.path.join(temporary_directory, 'equeue.db')
shutil.copyfile(equeue_database, equeue_database_copy)
db =
gdbm
.open(equeue_database_copy)
db =
dbm_gnu
.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).
if not db.keys():
db_keys = list(db.keys())
if not db_keys:
result = False
else:
last_backup = db[db
.keys()
[-1]]
for callback in db
.keys()
:
last_backup = db[db
_keys
[-1]]
for callback in db
_keys
:
timestamp = float(db[callback])
if timestamp
<
last
_backup:
last_backup =
timestamp
...
...
@@ -79,12 +81,11 @@ if latest_backup_date == False:
else:
latest_backup_message = latest_backup_date.strftime('%Y-%m-%d %H:%M:%S')
print "Content-Type: text/html"
print
print("Content-Type: text/html\n")
form = cgi.FieldStorage()
if "password" not in form:
print
"""
<html>
print
(
"""
<html>
<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>
...
...
@@ -100,15 +101,15 @@ if "password" not in form:
<input
type=
"submit"
value=
"Take over"
style=
"background: red;"
>
</form>
</body>
</html>
""" % (latest_backup_message, isBackupInProgress(), getSoftwareReleaseInformationFormatted())
</html>
""" % (latest_backup_message, isBackupInProgress(), getSoftwareReleaseInformationFormatted())
)
sys.exit(0)
if form['password'].value != '${:password}':
print
"
<H1>
Error
</H1>
"
print
"Password is invalid."
print
("
<H1>
Error
</H1>
")
print
("Password is invalid.")
sys.exit(1)
# XXX hardcoded location
result = subprocess.check_output([takeover_script], stderr=subprocess.STDOUT)
print
'Success.'
print
'
<pre>
%s
</pre>
' % result
print
('Success.')
print
('
<pre>
%s
</pre>
' % result)
stack/resilient/template-replicated.cfg.in
View file @
7a20831d
...
...
@@ -41,7 +41,7 @@ config-notify = {% for id in range(1,nbbackup|int) %} ${request-pbs-{{namebase}}
config-name = {{namebase}}0
# Bubble up all the instance parameters to the requested export instance.
{% if slapparameter_dict is defined %}
{% for parameter_name, parameter_value in s
lapparameter_dict.items(
) %}
{% for parameter_name, parameter_value in s
ix.iteritems(slapparameter_dict
) %}
{% if parameter_value is string %}
config-{{parameter_name}} = {{ parameter_value.split('\n') | join('\n ') }}
{% else %}
...
...
@@ -49,7 +49,7 @@ config-{{parameter_name}} = {{ parameter_value }}
{% endif %}
{% endfor %}
{% endif %}
{% for key, value in
monitor_dict.iteritems(
) -%}
{% for key, value in
six.iteritems(monitor_dict
) -%}
config-{{ key }} = {{ value }}
{% endfor -%}
{% if sla_parameter_dict == {} -%}
...
...
@@ -67,7 +67,7 @@ sla-mode = unique_by_network
{% do sla_dict.__setitem__(key[sla_key_secondary_length:], sla_parameter_dict.get(key)) -%}
{% endif -%}
{% endfor -%}
{% for key, value in s
la_dict.iteritems(
) -%}
{% for key, value in s
ix.iteritems(sla_dict
) -%}
sla-{{ key }} = {{ value }}
{% endfor -%}
{% endif -%}
...
...
@@ -101,7 +101,7 @@ config-number = {{id}}
config-name = {{namebase}}{{id}}
config-authorized-key = ${request-pbs-{{namebase}}-{{id}}:connection-ssh-key}
config-on-notification = ${request-pbs-{{namebase}}-{{id}}:connection-feeds-url}${:pbs-notification-id}
{% for key, value in
monitor_dict.iteritems(
) -%}
{% for key, value in
six.iteritems(monitor_dict
) -%}
config-{{ key }} = {{ value }}
{% endfor -%}
{% if sla_parameter_dict == {} -%}
...
...
@@ -119,7 +119,7 @@ sla-mode = unique_by_network
{% do sla_dict.__setitem__(key[sla_key_secondary_length:], sla_parameter_dict.get(key)) -%}
{% endif -%}
{% endfor -%}
{% for key, value in s
la_dict.iteritems(
) -%}
{% for key, value in s
ix.iteritems(sla_dict
) -%}
sla-{{ key }} = {{ value }}
{% endfor -%}
{% endif %}
...
...
@@ -202,7 +202,7 @@ software-type = pull-backup
name = PBS ({{namebase}} / {{id}})
config-ignore-known-hosts-file = ${slap-parameter:ignore-known-hosts-file}
config-monitor-title = PBS ${slap-connection:computer-id}-{{namebase}}-{{id}}
{% for key, value in
monitor_dict.iteritems(
) -%}
{% for key, value in
six.iteritems(monitor_dict
) -%}
config-{{ key }} = {{ value }}
{% endfor -%}
return = ssh-key notification-url feeds-url {{ monitor_return }}
...
...
@@ -222,7 +222,7 @@ sla-mode = unique_by_network
{% do sla_dict.__setitem__(key[sla_key_secondary_length:], sla_parameter_dict.get(key)) -%}
{% endif -%}
{% endfor -%}
{% for key, value in s
la_dict.iteritems(
) -%}
{% for key, value in s
ix.iteritems(sla_dict
) -%}
sla-{{ key }} = {{ value }}
{% endfor %}
{% endif %}
...
...
stack/resilient/templates/monitor-check-resilient-feed.in
View file @
7a20831d
#!{{ python_executable }}
from __future__ import print_function
import os
import urllib2
from six.moves.urllib.error import HTTPError
from six.moves.urllib.request import urlopen
import sys
input_feed_directory = '{{ input_feed_directory }}'
...
...
@@ -12,12 +14,12 @@ feed_file_list = os.listdir(input_feed_directory)
rss_ok = True
for feed_file_name in feed_file_list:
print
"Getting %s" % feed_file_name
print
("Getting %s" % feed_file_name)
url = base_url + feed_file_name
try:
feed = url
lib2.url
open(url)
feed = urlopen(url)
body = feed.read()
open(os.path.join(monitor_feed_directory, feed_file_name + '.rss'), 'w').write(body)
print
"FEED is ok"
except
urllib2.
HTTPError as e:
print
("FEED is ok")
except HTTPError as e:
sys.exit("%s is unvailable: %s" % (feed_file_name, e))
stack/resilient/templates/notifier-feed-promise.py.in
View file @
7a20831d
...
...
@@ -2,7 +2,8 @@
import csv
import os
import sys
import urllib2
from six.moves.urllib.error import HTTPError
from six.moves.urllib.request import urlopen
csv.field_size_limit(sys.maxsize)
...
...
@@ -15,9 +16,9 @@ for feed_file_name in feed_file_list:
url = base_url + feed_file_name
# Try feed consistency
try:
feed = url
lib2.url
open(url)
feed = urlopen(url)
body = feed.read()
except
urllib2.
HTTPError as e:
except HTTPError as e:
sys.exit("%s is unavailable: %s" % (feed_file_name, e))
with open(os.path.join(notifier_feed_directory, feed_file_name)) as feed_file:
reader = csv.reader(feed_file)
...
...
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