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
Levin Zimmermann
slapos
Commits
5d4d4781
Commit
5d4d4781
authored
Aug 05, 2013
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create new SR for Openstack
parent
95eb1ab3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
612 additions
and
8 deletions
+612
-8
component/qemu-kvm/buildout.cfg
component/qemu-kvm/buildout.cfg
+34
-8
software/openstack/instance-main.cfg
software/openstack/instance-main.cfg
+263
-0
software/openstack/instance.cfg
software/openstack/instance.cfg
+20
-0
software/openstack/software.cfg
software/openstack/software.cfg
+203
-0
software/openstack/templates/kvm-controller-run.in
software/openstack/templates/kvm-controller-run.in
+32
-0
software/openstack/templates/kvm-run.in
software/openstack/templates/kvm-run.in
+60
-0
No files found.
component/qemu-kvm/buildout.cfg
View file @
5d4d4781
[buildout]
[buildout]
extends =
extends =
../../component/gnutls/buildout.cfg
../../component/gnutls/buildout.cfg
../../component/libpng/buildout.cfg
../../component/libpng/buildout.cfg
../../component/libuuid/buildout.cfg
../../component/libuuid/buildout.cfg
../../component/pkgconfig/buildout.cfg
../../component/xorg/buildout.cfg
../../component/xorg/buildout.cfg
../../component/zlib/buildout.cfg
../../component/zlib/buildout.cfg
[kvm]
# XXX Change all reference to kvm section to qemu section, then
# Backward compatibility
# use qemu as main name section.
<= qemu-kvm
[qemu]
<= kvm
[
qemu-
kvm]
[kvm]
recipe = slapos.recipe.cmmi
recipe = slapos.recipe.cmmi
# qemu-kvm and qemu are now the same since 1.3.
# qemu-kvm and qemu are now the same since 1.3.
url = http://wiki.qemu-project.org/download/qemu-1.
4
.1.tar.bz2
url = http://wiki.qemu-project.org/download/qemu-1.
5
.1.tar.bz2
md5sum =
eb2d696956324722b5ecfa46e41f9a75
md5sum =
b56e73bdcfdb214d5c68e13111aca96f
depends =
depends =
${libpng:so_version}
${libpng:so_version}
configure-options =
configure-options =
--target-list=""
--target-list=x86_64-softmmu
--enable-system
--with-system-pixman
--disable-sdl
--disable-sdl
--disable-xen
--disable-xen
--enable-vnc-tls
--enable-vnc-tls
...
@@ -36,4 +40,26 @@ configure-options =
...
@@ -36,4 +40,26 @@ configure-options =
environment =
environment =
PATH=${pkgconfig:location}/bin:%(PATH)s
PATH=${pkgconfig:location}/bin:%(PATH)s
PKG_CONFIG_PATH=${gnutls:location}/lib/pkgconfig:${glib:location}/lib/pkgconfig:${pixman:location}/lib/pkgconfig
PKG_CONFIG_PATH=${gnutls:location}/lib/pkgconfig:${glib:location}/lib/pkgconfig:${pixman:location}/lib/pkgconfig
LDFLAGS=-L${pixman:location}/lib -Wl,-rpath=${pixman:location}/lib
# The following is only available in buildout2, which we don't use yet.
[kvm-bits64]
configure-options =
--target-list=x86_64-softmmu
${kvm:configure-options}
[kvm-bits32]
configure-options =
--target-list=i386-softmmu
${kvm:configure-options}
[debian-amd64-netinst.iso]
# Download the installer of Debian 7 (Wheezy)
recipe = slapos.recipe.download
url = http://cdimage.debian.org/debian-cd/7.1.0/amd64/iso-cd/debian-7.1.0-amd64-netinst.iso
filename = ${:_buildout_section_name_}
md5sum = 80f498a1f9daa76bc911ae13692e4495
download-only = true
mode = 0644
location = ${buildout:parts-directory}/${:_buildout_section_name_}
software/openstack/instance-main.cfg
0 → 100644
View file @
5d4d4781
#############################
#
# Instanciate kvm
#
#############################
[buildout]
parts =
certificate-authority
kvm-instance
kvm-controller-instance
kvm-promise
tunnel-ipv6-ssh
tunnel-ipv6-http
tunnel-ipv6-https
tunnel-ipv6-keystone
tunnel-ipv6-keystone-admin
tunnel-ipv6-novnc
tunnel-ipv6-glance
tunnel-ipv6-s3api
tunnel-ipv6-spice
tunnel-ipv6-novadb
websockify-sighandler
novnc-promise
publish-kvm-connection-information
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[directory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc
bin = $${buildout:directory}/bin
srv = $${buildout:directory}/srv
var = $${buildout:directory}/var
scripts = $${:etc}/run
services = $${:etc}/service
promises = $${:etc}/promise
novnc-conf = $${:etc}/novnc
run = $${:var}/run
ca-dir = $${:srv}/ssl
[create-mac]
recipe = slapos.cookbook:generate.mac
storage-path = $${directory:srv}/mac
[gen-passwd]
recipe = slapos.cookbook:generate.password
storage-path = $${directory:srv}/passwd
bytes = 8
[gen-kvm-run]
recipe = slapos.recipe.template
url = ${kvm-run:location}/${kvm-run:filename}
output = $${directory:bin}/kvm_run_raw
mode = 0700
python_path = ${buildout:executable}
disk_path = $${directory:srv}/virtual.qcow2
qemu_img_path = ${kvm:location}/bin/qemu-img
disk_size = $${slap-parameter:disk-size}
vnc_ip = $${slap-network-information:local-ipv4}
qemu_path = ${kvm:location}/bin/qemu-system-x86_64
mac_address = $${create-mac:mac-address}
smp_count = $${slap-parameter:cpu-count}
ram_size = $${slap-parameter:ram-size}
disk_type = $${slap-parameter:disk-type}
boot_disk_path = $${directory:srv}/boot.qcow2
socket_path = $${directory:var}/qmp_socket
pid_file_path = $${directory:run}/kvm_run.pid
nbd_ip = $${slap-parameter:nbd-ip}
nbd_port = 1024
vnc_port = 5901
[gen-kvm-controller]
recipe = slapos.recipe.template
url = ${kvm-controller:location}/${kvm-controller:filename}
output = $${directory:bin}/kvm_controller_raw
mode = 0700
python_path = ${buildout:executable}
socket_path = $${directory:var}/qmp_socket
vnc_passwd = $${gen-passwd:passwd}
[kvm-controller-instance]
recipe = slapos.cookbook:wrapper
command-line = $${gen-kvm-controller:output}
wrapper-path = $${directory:scripts}/kvm_controller
[kvm-instance]
recipe = slapos.cookbook:wrapper
command-line = $${gen-kvm-run:output}
wrapper-path = $${directory:services}/kvm
[kvm-promise]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promises}/vnc_promise
hostname = $${gen-kvm-run:vnc_ip}
port = $${gen-kvm-run:vnc_port}
[tunnel-ipv6-base]
recipe = slapos.cookbook:ipv6toipv4
ipv6 = $${slap-network-information:global-ipv6}
ipv4 = $${slap-network-information:local-ipv4}
shell-path = ${dash:location}/bin/dash
6tunnel-path = ${6tunnel:location}/bin/6tunnel
[tunnel-ipv6-ssh]
<= tunnel-ipv6-base
ipv6-port = 22222
ipv4-port = 22222
runner-path = $${directory:services}/6tunnel-ssh
[tunnel-ipv6-http]
<= tunnel-ipv6-base
ipv6-port = 80
ipv4-port = 80
runner-path = $${directory:services}/6tunnel-http
[tunnel-ipv6-https]
<= tunnel-ipv6-base
ipv6-port = 443
ipv4-port = 443
runner-path = $${directory:services}/6tunnel-https
[tunnel-ipv6-keystone]
<= tunnel-ipv6-base
ipv6-port = 5000
ipv4-port = 5000
runner-path = $${directory:services}/6tunnel-keystone
[tunnel-ipv6-keystone-admin]
<= tunnel-ipv6-base
ipv6-port = 35357
ipv4-port = 35357
runner-path = $${directory:services}/6tunnel-keystone-admin
[tunnel-ipv6-novnc]
<= tunnel-ipv6-base
ipv6-port = 6080
ipv4-port = 6080
runner-path = $${directory:services}/6tunnel-novnc
[tunnel-ipv6-glance]
<= tunnel-ipv6-base
ipv6-port = 9292
ipv4-port = 9292
runner-path = $${directory:services}/6tunnel-glance
[tunnel-ipv6-spice]
<= tunnel-ipv6-base
ipv6-port = 6082
ipv4-port = 6082
runner-path = $${directory:services}/6tunnel-spice
#I don't know if this is really usefull!!
[tunnel-ipv6-s3api]
<= tunnel-ipv6-base
ipv6-port = 3333
ipv4-port = 3333
runner-path = $${directory:services}/6tunnel-s3api
[tunnel-ipv6-novadb]
<= tunnel-ipv6-base
ipv6-port = 3306
ipv4-port = 3306
runner-path = $${directory:services}/6tunnel-novadb
[novnc-instance]
recipe = slapos.cookbook:novnc
path = $${ca-novnc:executable}
ip = $${slap-network-information:global-ipv6}
port = 6081
vnc-ip = $${gen-kvm-run:vnc_ip}
vnc-port = $${gen-kvm-run:vnc_port}
novnc-location = ${noVNC:location}
websockify-path = ${buildout:directory}/bin/websockify
ssl-key-path = $${ca-novnc:key-file}
ssl-cert-path = $${ca-novnc:cert-file}
[websockify-sighandler]
recipe = slapos.cookbook:signalwrapper
wrapper-path = $${directory:services}/websockify
wrapped-path = $${novnc-instance:path}
[certificate-authority]
recipe = slapos.cookbook:certificate_authority
openssl-binary = ${openssl:location}/bin/openssl
ca-dir = $${directory:ca-dir}
requests-directory = $${cadirectory:requests}
wrapper = $${directory:services}/certificate_authority
ca-private = $${cadirectory:private}
ca-certs = $${cadirectory:certs}
ca-newcerts = $${cadirectory:newcerts}
ca-crl = $${cadirectory:crl}
[cadirectory]
recipe = slapos.cookbook:mkdirectory
requests = $${directory:ca-dir}/requests/
private = $${directory:ca-dir}/private/
certs = $${directory:ca-dir}/certs/
newcerts = $${directory:ca-dir}/newcerts/
crl = $${directory:ca-dir}/crl/
[ca-novnc]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
key-file = $${directory:novnc-conf}/novnc.key
cert-file = $${directory:novnc-conf}/novnc.crt
executable = $${directory:bin}/novnc
wrapper = $${directory:bin}/websockify
[novnc-promise]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promises}/novnc_promise
hostname = $${novnc-instance:ip}
port = $${novnc-instance:port}
[kvm-monitor]
recipe = slapos.cookbook:generic.slapmonitor
db-path = $${directory:srv}/slapmonitor_database
[request-slave-frontend]
recipe = slapos.cookbook:requestoptional
software-url = $${slap-parameter:frontend-software-url}
server-url = $${slap-connection:server-url}
key-file = $${slap-connection:key-file}
cert-file = $${slap-connection:cert-file}
computer-id = $${slap-connection:computer-id}
partition-id = $${slap-connection:partition-id}
name = VNC Frontend
software-type = $${slap-parameter:frontend-software-type}
slave = true
config = host port
config-host = $${novnc-instance:ip}
config-port = $${novnc-instance:port}
return = url resource port domainname
sla = instance_guid
sla-instance_guid = $${slap-parameter:frontend-instance-guid}
[publish-kvm-connection-information]
recipe = slapos.cookbook:publish
vnc-backend-url = https://[$${novnc-instance:ip}]:$${novnc-instance:port}/vnc_auto.html?host=[$${novnc-instance:ip}]&port=$${novnc-instance:port}&encrypt=1
vnc-password = $${gen-passwd:passwd}
vnc-url = $${request-slave-frontend:connection-url}/vnc_auto.html?host=$${request-slave-frontend:connection-domainname}&port=$${request-slave-frontend:connection-port}&encrypt=1&path=$${request-slave-frontend:connection-resource}
ssh = ssh stack@$${tunnel-ipv6-ssh:ipv6} -p $${tunnel-ipv6-ssh:ipv6-port}
ssh-defaul-passwd = openstack
[slap-parameter]
# Default values if not specified
frontend-instance-guid = SOFTINST-81
frontend-software-type = frontend
frontend-software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.92:/software/kvm/software.cfg
ram-size = 2048
disk-size = 20
disk-type = virtio
cpu-count = 4
nbd-ip = 2001:470:1f14:169:dd6b:3f84:9205:c750
domain =
software/openstack/instance.cfg
0 → 100644
View file @
5d4d4781
[buildout]
parts =
switch-softwaretype
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[switch-softwaretype]
recipe = slapos.cookbook:softwaretype
default = ${template-kvm:output}
[slap-connection]
# part to migrate to new - separated words
computer-id = $${slap_connection:computer_id}
partition-id = $${slap_connection:partition_id}
server-url = $${slap_connection:server_url}
software-release-url = $${slap_connection:software_release_url}
key-file = $${slap_connection:key_file}
cert-file = $${slap_connection:cert_file}
\ No newline at end of file
software/openstack/software.cfg
0 → 100644
View file @
5d4d4781
[buildout]
extends =
../../component/6tunnel/buildout.cfg
../../component/curl/buildout.cfg
../../component/dash/buildout.cfg
../../component/dcron/buildout.cfg
../../component/gzip/buildout.cfg
../../component/qemu-kvm/buildout.cfg
../../component/logrotate/buildout.cfg
../../component/noVNC/buildout.cfg
../../component/openssl/buildout.cfg
../../stack/slapos.cfg
parts =
template
eggs
[eggs]
recipe = z3c.recipe.scripts
eggs =
${lxml-python:egg}
websockify
slapos.cookbook
slapos.toolbox
[template-kvm]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-main.cfg
md5sum = 1ab7b31c6df203988c693cef80663d8d
output = ${buildout:directory}/template-openstack-main.cfg
mode = 0644
[template]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
md5sum = 5e426ac6182e30d651d53cf03abeef5d
output = ${buildout:directory}/template.cfg
mode = 0644
[template-download]
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/templates/${:filename}
mode = 0644
location = ${buildout:parts-directory}/${:_buildout_section_name_}
[kvm-controller]
<= template-download
filename = kvm-controller-run.in
md5sum = 04a94f04344a6169af242dea03b8c52d
[kvm-run]
<= template-download
filename = kvm-run.in
md5sum = 66d8385453de3c332a48052ecd2dbd2b
[networkcache]
# signature certificates of the following uploaders.
# Romain Courteaud
# Cedric de Saint Martin
# Test Agent
signature-certificate-list =
-----BEGIN CERTIFICATE-----
MIIB4DCCAUkCADANBgkqhkiG9w0BAQsFADA5MQswCQYDVQQGEwJGUjEZMBcGA1UE
CBMQRGVmYXVsdCBQcm92aW5jZTEPMA0GA1UEChMGTmV4ZWRpMB4XDTExMDkxNTA5
MDAwMloXDTEyMDkxNTA5MDAwMlowOTELMAkGA1UEBhMCRlIxGTAXBgNVBAgTEERl
ZmF1bHQgUHJvdmluY2UxDzANBgNVBAoTBk5leGVkaTCBnzANBgkqhkiG9w0BAQEF
AAOBjQAwgYkCgYEApYZv6OstoqNzxG1KI6iE5U4Ts2Xx9lgLeUGAMyfJLyMmRLhw
boKOyJ9Xke4dncoBAyNPokUR6iWOcnPHtMvNOsBFZ2f7VA28em3+E1JRYdeNUEtX
Z0s3HjcouaNAnPfjFTXHYj4um1wOw2cURSPuU5dpzKBbV+/QCb5DLheynisCAwEA
ATANBgkqhkiG9w0BAQsFAAOBgQBCZLbTVdrw3RZlVVMFezSHrhBYKAukTwZrNmJX
mHqi2tN8tNo6FX+wmxUUAf3e8R2Ymbdbn2bfbPpcKQ2fG7PuKGvhwMG3BlF9paEC
q7jdfWO18Zp/BG7tagz0jmmC4y/8akzHsVlruo2+2du2freE8dK746uoMlXlP93g
QUUGLQ==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIB9jCCAV+gAwIBAgIJAO4V/jiMoICoMA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV
BAMMCENPTVAtMjMyMCAXDTEyMDIxNjExMTAyM1oYDzIxMTIwMTIzMTExMDIzWjAT
MREwDwYDVQQDDAhDT01QLTIzMjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
wi/3Z8W9pUiegUXIk/AiFDQ0UJ4JFAwjqr+HSRUirlUsHHT+8DzH/hfcTDX1I5BB
D1ADk+ydXjMm3OZrQcXjn29OUfM5C+g+oqeMnYQImN0DDQIOcUyr7AJc4xhvuXQ1
P2pJ5NOd3tbd0kexETa1LVhR6EgBC25LyRBRae76qosCAwEAAaNQME4wHQYDVR0O
BBYEFMDmW9aFy1sKTfCpcRkYnP6zUd1cMB8GA1UdIwQYMBaAFMDmW9aFy1sKTfCp
cRkYnP6zUd1cMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAskbFizHr
b6d3iIyN+wffxz/V9epbKIZVEGJd/6LrTdLiUfJPec7FaxVCWNyKBlCpINBM7cEV
Gn9t8mdVQflNqOlAMkOlUv1ZugCt9rXYQOV7rrEYJBWirn43BOMn9Flp2nibblby
If1a2ZoqHRxoNo2yTmm7TSYRORWVS+vvfjY=
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIB9jCCAV+gAwIBAgIJAKRvzcy7OH0UMA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV
BAMMCENPTVAtNzcyMCAXDTEyMDgxMDE1NDI1MVoYDzIxMTIwNzE3MTU0MjUxWjAT
MREwDwYDVQQDDAhDT01QLTc3MjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
o7aipd6MbnuGDeR1UJUjuMLQUariAyQ2l2ZDS6TfOwjHiPw/mhzkielgk73kqN7A
sUREx41eTcYCXzTq3WP3xCLE4LxLg1eIhd4nwNHj8H18xR9aP0AGjo4UFl5BOMa1
mwoyBt3VtfGtUmb8whpeJgHhqrPPxLoON+i6fIbXDaUCAwEAAaNQME4wHQYDVR0O
BBYEFEfjy3OopT2lOksKmKBNHTJE2hFlMB8GA1UdIwQYMBaAFEfjy3OopT2lOksK
mKBNHTJE2hFlMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAaNRx6YN2
M/p3R8/xS6zvH1EqJ3FFD7XeAQ52WuQnKSREzuw0dsw12ClxjcHiQEFioyTiTtjs
5pW18Ry5Ie7iFK4cQMerZwWPxBodEbAteYlRsI6kePV7Gf735Y1RpuN8qZ2sYL6e
x2IMeSwJ82BpdEI5niXxB+iT0HxhmR+XaMI=
-----END CERTIFICATE-----
[versions]
Jinja2 = 2.7
MarkupSafe = 0.18
Werkzeug = 0.9.3
apache-libcloud = 0.13.0
async = 0.6.1
buildout-versions = 1.7
gitdb = 0.5.4
itsdangerous = 0.22
lxml = 3.2.3
meld3 = 0.6.10
pycrypto = 2.6
slapos.cookbook = 0.78.3
slapos.recipe.cmmi = 0.2
slapos.recipe.download = 1.0.dev-r4053
slapos.recipe.template = 2.4.2
slapos.toolbox = 0.35.0
smmap = 0.8.2
websockify = 0.5.1
z3c.recipe.scripts = 1.0.1
# Required by:
# slapos.core==0.35.1
# slapos.toolbox==0.35.0
Flask = 0.10.1
# Required by:
# slapos.toolbox==0.35.0
GitPython = 0.3.2.RC1
# Required by:
# slapos.toolbox==0.35.0
atomize = 0.1.1
# Required by:
# slapos.toolbox==0.35.0
feedparser = 5.1.3
# Required by:
# slapos.cookbook==0.78.3
inotifyx = 0.2.0-1
# Required by:
# slapos.cookbook==0.78.3
lock-file = 2.0
# Required by:
# slapos.cookbook==0.78.3
netaddr = 0.7.10
# Required by:
# slapos.core==0.35.1
netifaces = 0.8-1
# Required by:
# websockify==0.5.1
numpy = 1.7.1
# Required by:
# slapos.toolbox==0.35.0
paramiko = 1.11.0
# Required by:
# slapos.toolbox==0.35.0
psutil = 1.0.1
# Required by:
# slapos.core==0.35.1
pyflakes = 0.7.3
# Required by:
# slapos.cookbook==0.78.3
pytz = 2013b
# Required by:
# slapos.cookbook==0.78.3
# slapos.core==0.35.1
# slapos.toolbox==0.35.0
setuptools = 0.9.8
# Required by:
# slapos.cookbook==0.78.3
# slapos.toolbox==0.35.0
slapos.core = 0.35.1
# Required by:
# slapos.core==0.35.1
supervisor = 3.0
# Required by:
# slapos.core==0.35.1
unittest2 = 0.5.1
# Required by:
# slapos.cookbook==0.78.3
# slapos.toolbox==0.35.0
xml-marshaller = 0.9.7
# Required by:
# slapos.core==0.35.1
zope.interface = 4.0.5
\ No newline at end of file
software/openstack/templates/kvm-controller-run.in
0 → 100644
View file @
5d4d4781
#!${:python_path}
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
# Echo client program
import socket
import time
# Connect to KVM qmp socket
so = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
connected = False
while not connected:
try:
so.connect('${:socket_path}')
except socket.error:
time.sleep(1)
else:
connected = True
data = so.recv(1024)
# Enable qmp
so.send('{ "execute": "qmp_capabilities" }')
data = so.recv(1024)
# Set VNC password
so.send('{ "execute": "change", ' \
'"arguments": { "device": "vnc", "target": "password", ' \
' "arg": "${:vnc_passwd}" } }')
data = so.recv(1024)
# Finish
so.close()
\ No newline at end of file
software/openstack/templates/kvm-run.in
0 → 100644
View file @
5d4d4781
#!${:python_path}
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
# Echo client program
import os
import socket
import subprocess
def getSocketStatus(host, port):
s = None
for res in socket.getaddrinfo(host, port,
socket.AF_UNSPEC, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
s = socket.socket(af, socktype, proto)
except socket.error, msg:
s = None
continue
try:
s.connect(sa)
except socket.error, msg:
s.close()
s = None
continue
break
return s
# create disk if doesn't exist
disk_path = '${:disk_path}'
if not os.path.exists(disk_path):
subprocess.Popen(['${:qemu_img_path}', 'create' ,'-f', 'qcow2',
disk_path, '${:disk_size}G'])
# Generate NAT rules for ssh connexion
nat_rules = ",".join("hostfwd=tcp:${:vnc_ip}:%s-:%s" % (port, port) for port in [80, 443, 5000, 6080, 6082, 3333, 9292, 3306, 35357])
kvm_argument_list = ['${:qemu_path}',
'-enable-kvm', '-net', 'nic,macaddr=${:mac_address}',
'-net', 'user,hostfwd=tcp:${:vnc_ip}:22222-:22,%s' % nat_rules,
'-smp', '${:smp_count}',
'-m', '${:ram_size}',
'-drive', 'file=${:disk_path},if=${:disk_type}',
'-vnc', '${:vnc_ip}:1,ipv4,password',
'-boot', 'menu=on',
'-qmp', 'unix:${:socket_path},server',
'-pidfile', '${:pid_file_path}',
]
s = getSocketStatus('${:nbd_ip}', ${:nbd_port})
if s is None:
# NBD is not available : launch kvm without it
print 'Warning : Nbd is not available.'
else:
# NBD is available
kvm_argument_list.extend([
'-drive',
'file=nbd:[%s]:%s,media=cdrom' % ('${:nbd_ip}', ${:nbd_port})])
os.execv('${:qemu_path}', kvm_argument_list)
\ No newline at end of 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