Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
moodle_rebase10.1.2
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
Dmitry Blinov
moodle_rebase10.1.2
Commits
0d3d672b
Commit
0d3d672b
authored
Jan 22, 2020
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stack/resilient: partial support for Python 3
parent
1fac44ad
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
32 deletions
+48
-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
+17
-12
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
+13
-6
stack/resilient/templates/notifier-feed-promise.py.in
stack/resilient/templates/notifier-feed-promise.py.in
+7
-3
No files found.
stack/resilient/buildout.hash.cfg
View file @
0d3d672b
...
...
@@ -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 = 6
0d4912fdf5e8dafaba9d9f333aa9e36
md5sum = 6
75ac9e1cf49ccc8f8eddb541a62d899
[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 =
fa6521daaa02fef4dd2ce06d29ef90be
[template-monitor-check-resilient-feed]
filename = templates/monitor-check-resilient-feed.in
md5sum =
19ee9055de961acf402e2dfe5b9581d2
md5sum =
af9787f8440fef19924b2e765372b20f
stack/resilient/resilient-web-takeover-cgi-script.py.in
View file @
0d3d672b
#!${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,11 @@ import atexit
import cgi
import cgitb
import datetime
import gdbm
try:
import dbm.gnu as gdbm
except ImportError:
import gdbm
import os
import shutil
import subprocess
...
...
@@ -39,11 +44,12 @@ 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).
if not db.keys():
db_keys = 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 +85,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 +105,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 @
0d3d672b
...
...
@@ -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 @
0d3d672b
#!{{ python_executable }}
from __future__ import print_function
import os
import urllib2
try:
from urllib2 import HTTPError, urlopen
except ImportError:
from urllib.error import HTTPError
from urllib.request import urlopen
import sys
input_feed_directory = '{{ input_feed_directory }}'
...
...
@@ -12,12 +17,14 @@ 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", 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:
with open(os.path.join(monitor_feed_directory, feed_file_name + '.rss'),
'wb') as f:
f.write(body)
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 @
0d3d672b
...
...
@@ -2,7 +2,11 @@
import csv
import os
import sys
import urllib2
try:
from urllib2 import HTTPError, urlopen
except ImportError:
from urllib.error import HTTPError
from urllib.request import urlopen
csv.field_size_limit(sys.maxsize)
...
...
@@ -15,9 +19,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