Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
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
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos
Commits
a23a1d2e
Commit
a23a1d2e
authored
Apr 14, 2021
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kvm: fix bootstrap-script-url with Python 3
parent
384a3cb9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
53 deletions
+15
-53
software/kvm/buildout.hash.cfg
software/kvm/buildout.hash.cfg
+2
-6
software/kvm/instance-kvm.cfg.jinja2
software/kvm/instance-kvm.cfg.jinja2
+13
-14
software/kvm/instance.cfg.in
software/kvm/instance.cfg.in
+0
-1
software/kvm/software.cfg
software/kvm/software.cfg
+0
-6
software/kvm/template/download_file.in
software/kvm/template/download_file.in
+0
-26
No files found.
software/kvm/buildout.hash.cfg
View file @
a23a1d2e
...
...
@@ -15,11 +15,11 @@
[template]
filename = instance.cfg.in
md5sum =
399b398a8eabfa6126d2a521dc779f9b
md5sum =
0d34ff81779115bf899f7bc752877b70
[template-kvm]
filename = instance-kvm.cfg.jinja2
md5sum =
704b6ac6bf42837bcd8f4582c5a746c0
md5sum =
4c5d8c723b6adb96fcac9690c0c900f7
[template-kvm-cluster]
filename = instance-kvm-cluster.cfg.jinja2.in
...
...
@@ -73,10 +73,6 @@ md5sum = 752c91a4a6b72f5cf8226d6b940015f8
filename = template/qemu-is-ready.in
md5sum = fb330a796fadb6cd5c85217f80a42af3
[file-download-script]
filename = template/download_file.in
md5sum = 599dbbbd438fe7801e3f8642ae9e9a78
[template-httpd]
filename = instance-kvm-http.cfg.in
md5sum = d657884d02105deffddee0edae4b50a6
...
...
software/kvm/instance-kvm.cfg.jinja2
View file @
a23a1d2e
...
...
@@ -19,19 +19,12 @@
{% set whitelist_domains = slapparameter_dict.get('whitelist-domains', '') -%}
{% set boot_image_url_list_enabled = 'boot-image-url-list' in slapparameter_dict %}
{% set boot_image_url_select_enabled = 'boot-image-url-select' in slapparameter_dict %}
{% set bootstrap_script_url = slapparameter_dict.get('bootstrap-script-url') -%}
{% set cpu_max_count = dumps(slapparameter_dict.get('cpu-max-count', int(slapparameter_dict.get('cpu-count', 1)) + 1)) %}
{% set ram_max_size = dumps(slapparameter_dict.get('ram-max-size', int(slapparameter_dict.get('ram-size', 1024)) + 512)) %}
{% set extends_list = [] -%}
{% set part_list = [] -%}
{% set bootstrap_url = '' -%}
{% set bootstrap_url_md5sum = '' -%}
{% if slapparameter_dict.get('bootstrap-script-url', '') -%}
{% set url_info_list = slapparameter_dict['bootstrap-script-url'].split('#') -%}
{% set bootstrap_url = url_info_list[0] -%}
{% set bootstrap_url_md5sum = url_info_list[1] -%}
{% endif -%}
{% if instance_type == 'cluster' -%}
{% set nat_rule_list = slapparameter_dict.get('nat-rules', '') %}
{% endif -%}
...
...
@@ -897,12 +890,18 @@ module = check_command_execute
name = ansible_{{ name }}.py
config-command = ${ansible-vm-bin:rendered}
{% if bootstrap_script_url -%}
[download-bootstrap-script]
recipe = plone.recipe.command
file-location = ${directory:public}/vm-bootstrap
command = {{ python_executable }} {{ file_download_script }} {{ bootstrap_url }} {{ bootstrap_url_md5sum }} ${:file-location}
update-command =
stop-on-error = true
recipe = slapos.recipe.build
location = ${directory:public}/vm-bootstrap
install =
from zc.buildout.download import check_md5sum, urlretrieve, ChecksumError
url, md5sum = {{ repr(bootstrap_script_url) }}.split('#')
urlretrieve(url, location)
if not check_md5sum(location, md5sum):
os.remove(location)
raise ChecksumError
{% endif -%}
[logrotate-vm-bootstrap]
< = logrotate-entry-base
...
...
@@ -1002,7 +1001,7 @@ keyboard-layout-language = fr
{% if slapparameter_dict.get('authorized-key', '') and slapparameter_dict.get('type', '') == 'cluster' %}
{% do part_list.append('get-authorized-key') -%}
{% endif -%}
{% if
slapparameter_dict.get('bootstrap-script-url', '')
-%}
{% if
bootstrap_script_url
-%}
{% do part_list.append('download-bootstrap-script') -%}
{% endif -%}
{% if slapparameter_dict.get('document-port', '') -%}
...
...
software/kvm/instance.cfg.in
View file @
a23a1d2e
...
...
@@ -83,7 +83,6 @@ extra-context =
raw dnsresolver_executable ${buildout:bin-directory}/dnsresolver
raw dcron_executable_location ${dcron:location}/sbin/crond
raw debian_amd64_netinst_location ${debian-amd64-netinst.iso:location}/${debian-amd64-netinst.iso:filename}
raw file_download_script ${file-download-script:location}/${file-download-script:filename}
raw whitelist_domains_default ${whitelist-domains-default:location}/${whitelist-domains-default:filename}
raw whitelist_firewall_download_controller ${whitelist-firewall-download-controller:target}
raw image_download_controller ${image-download-controller:target}
...
...
software/kvm/software.cfg
View file @
a23a1d2e
...
...
@@ -175,12 +175,6 @@ on-update = true
filename = qemu-is-ready.in
on-update = true
[file-download-script]
<= download-template-base
path = download_file.in
filename = download_file
on-update = true
[whitelist-domains-default]
<= download-template-base
filename = whitelist-domains-default
...
...
software/kvm/template/download_file.in
deleted
100644 → 0
View file @
384a3cb9
#!/usr/bin/env python
import
os
import
urllib
import
hashlib
import
sys
def
md5Checksum
(
file_path
):
with
open
(
file_path
,
'rb'
)
as
fh
:
m
=
hashlib
.
md5
()
while
True
:
data
=
fh
.
read
(
8192
)
if
not
data
:
break
m
.
update
(
data
)
return
m
.
hexdigest
()
if
__name__
==
"__main__"
:
url
,
md5sum
,
destination_path
=
sys
.
argv
[
1
:]
urllib
.
urlretrieve
(
url
,
destination_path
)
computed_md5sum
=
md5Checksum
(
destination_path
)
if
computed_md5sum
!=
md5sum
:
os
.
remove
(
destination_path
)
raise
Exception
(
'MD5 mismatch. MD5 of downloaded file is %s, Specified MD5 is %s.'
%
(
computed_md5sum
,
md5sum
))
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