Commit bc1d0db9 authored by Alain Takoudjou's avatar Alain Takoudjou

kvm: add promise to check if qemu is correctly started

parent 287685eb
...@@ -92,7 +92,7 @@ command = ...@@ -92,7 +92,7 @@ command =
[template] [template]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg.in url = ${:_profile_base_location_}/instance.cfg.in
md5sum = 92c62e050aac47097f5ca81cb7f2acec md5sum = 110df709a7c8a5c749f93663f6ab0d28
output = ${buildout:directory}/template.cfg output = ${buildout:directory}/template.cfg
mode = 0644 mode = 0644
...@@ -101,7 +101,7 @@ recipe = hexagonit.recipe.download ...@@ -101,7 +101,7 @@ recipe = hexagonit.recipe.download
ignore-existing = true ignore-existing = true
url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2 url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2
mode = 644 mode = 644
md5sum = f53c55c6a12c58baf650828c14ca171f md5sum = d09d37dc3bcf34da8d31b11215866b27
download-only = true download-only = true
on-update = true on-update = true
...@@ -207,7 +207,7 @@ ignore-existing = true ...@@ -207,7 +207,7 @@ ignore-existing = true
url = ${:_profile_base_location_}/template/kvm-controller-run.in url = ${:_profile_base_location_}/template/kvm-controller-run.in
mode = 644 mode = 644
filename = kvm-controller-run.in filename = kvm-controller-run.in
md5sum = b61ef9c54d912fdbfed3899fa985f79c md5sum = 71afd2d13f6e56993ae413a168e012d7
download-only = true download-only = true
on-update = true on-update = true
...@@ -231,6 +231,16 @@ md5sum = 822737e483864bf255ad1259237bef2a ...@@ -231,6 +231,16 @@ md5sum = 822737e483864bf255ad1259237bef2a
download-only = true download-only = true
on-update = true on-update = true
[template-qemu-ready]
recipe = hexagonit.recipe.download
ignore-existing = true
url = ${:_profile_base_location_}/template/qemu-is-ready.in
mode = 644
filename = qemu-is-ready.in
md5sum = 0066fa0f5f3dd47bded5e5924df2550d
download-only = true
on-update = true
[file-download-script] [file-download-script]
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
ignore-existing = true ignore-existing = true
......
...@@ -63,6 +63,7 @@ context = ...@@ -63,6 +63,7 @@ context =
raw python_executable ${buildout:executable} raw python_executable ${buildout:executable}
raw qemu_executable_location ${kvm:location}/bin/qemu-system-x86_64 raw qemu_executable_location ${kvm:location}/bin/qemu-system-x86_64
raw qemu_img_executable_location ${kvm:location}/bin/qemu-img raw qemu_img_executable_location ${kvm:location}/bin/qemu-img
raw qemu_start_promise_tpl ${template-qemu-ready:location}/${template-qemu-ready:filename}
raw sixtunnel_executable_location ${6tunnel:location}/bin/6tunnel raw sixtunnel_executable_location ${6tunnel:location}/bin/6tunnel
raw template_httpd_cfg ${template-httpd:rendered} raw template_httpd_cfg ${template-httpd:rendered}
raw template_content ${template-content:location}/${template-content:filename} raw template_content ${template-content:location}/${template-content:filename}
......
...@@ -65,6 +65,7 @@ bytes = 8 ...@@ -65,6 +65,7 @@ bytes = 8
python-path = {{ python_executable }} python-path = {{ python_executable }}
vnc-passwd = ${gen-passwd:passwd} vnc-passwd = ${gen-passwd:passwd}
socket-path = ${directory:var}/qmp_socket socket-path = ${directory:var}/qmp_socket
kvm-status-path = ${directory:var}/qemu-vm-is-ready
[kvm-parameter-dict] [kvm-parameter-dict]
python-path = {{ python_executable }} python-path = {{ python_executable }}
...@@ -212,6 +213,15 @@ input = inline:#!/bin/sh ...@@ -212,6 +213,15 @@ input = inline:#!/bin/sh
output = ${directory:promises}/kvm-disk-image-corruption output = ${directory:promises}/kvm-disk-image-corruption
mode = 700 mode = 700
[kvm-started-promise]
recipe = slapos.recipe.template:jinja2
template = {{ qemu_start_promise_tpl }}
rendered = ${directory:promises}/qemu-virtual-machine-is-ready
mode = 700
context =
raw dash {{ dash_executable_location }}
raw qemu_ready_path ${kvm-controller-parameter-dict:kvm-status-path}
raw qemu_service_log_file ${buildout:directory}/.${slap-connection:partition-id}_kvm.log
[novnc-instance] [novnc-instance]
recipe = slapos.cookbook:novnc recipe = slapos.cookbook:novnc
...@@ -624,7 +634,7 @@ parts = ...@@ -624,7 +634,7 @@ parts =
kvm-disk-image-corruption-promise kvm-disk-image-corruption-promise
websockify-sighandler websockify-sighandler
novnc-promise novnc-promise
# kvm-monitor kvm-started-promise
cron cron
cron-entry-logrotate cron-entry-logrotate
frontend-promise frontend-promise
......
...@@ -96,6 +96,7 @@ context = ...@@ -96,6 +96,7 @@ context =
raw python_executable ${buildout:executable} raw python_executable ${buildout:executable}
raw qemu_executable_location ${kvm:location}/bin/qemu-system-x86_64 raw qemu_executable_location ${kvm:location}/bin/qemu-system-x86_64
raw qemu_img_executable_location ${kvm:location}/bin/qemu-img raw qemu_img_executable_location ${kvm:location}/bin/qemu-img
raw qemu_start_promise_tpl ${template-qemu-ready:location}/${template-qemu-ready:filename}
raw sixtunnel_executable_location ${6tunnel:location}/bin/6tunnel raw sixtunnel_executable_location ${6tunnel:location}/bin/6tunnel
raw template_httpd_cfg ${template-httpd:rendered} raw template_httpd_cfg ${template-httpd:rendered}
raw template_content ${template-content:location}/${template-content:filename} raw template_content ${template-content:location}/${template-content:filename}
......
...@@ -5,6 +5,6 @@ extends = development.cfg ...@@ -5,6 +5,6 @@ extends = development.cfg
[template] [template]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-for-erp5testnode.cfg.in url = ${:_profile_base_location_}/instance-for-erp5testnode.cfg.in
md5sum = 71b730997a6e3ce7f0579901401eab9c md5sum = 61414eefb6641f74d5f2b4ffc23af393
output = ${buildout:directory}/template.cfg output = ${buildout:directory}/template.cfg
mode = 0644 mode = 0644
\ No newline at end of file
...@@ -5,11 +5,16 @@ ...@@ -5,11 +5,16 @@
# Echo client program # Echo client program
import socket import socket
import time import time
import os
# XXX: to be factored with slapos.toolbox qemu qmp wrapper. # XXX: to be factored with slapos.toolbox qemu qmp wrapper.
socket_path = '{{ parameter_dict.get("socket-path") }}' socket_path = '{{ parameter_dict.get("socket-path") }}'
vnc_password = '{{ parameter_dict.get("vnc-passwd") }}' vnc_password = '{{ parameter_dict.get("vnc-passwd") }}'
status_path = '{{ parameter_dict.get("kvm-status-path") }}'
if os.path.exists(status_path):
os.unlink(status_path)
# Connect to KVM qmp socket # Connect to KVM qmp socket
so = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) so = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
...@@ -35,3 +40,6 @@ data = so.recv(1024) ...@@ -35,3 +40,6 @@ data = so.recv(1024)
# Finish # Finish
so.close() so.close()
with open(status_path, 'w') as status_file:
status_file.write("OK")
#!{{ dash }}
if [ -f "{{ qemu_ready_path }}" ]; then
echo "VM correctly started."
else
log_file="{{ qemu_service_log_file }}"
>&2 echo "Qemu process is not correctly started."
if [ -f "$log_file" ]; then
>&2 echo "** Latest ouput logs **"
>&2 echo
>&2 echo "$(tail $log_file)"
exit 1
fi
fi
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment