Commit 92c3cb60 authored by Romain Courteaud's avatar Romain Courteaud

Merge remote-tracking branch 'origin/kvm'

parents 49c52013 7dfe15ec
...@@ -60,10 +60,10 @@ setup(name=name, ...@@ -60,10 +60,10 @@ setup(name=name,
'erp5scalabilitytestbed = slapos.recipe.erp5scalabilitytestbed:Recipe', 'erp5scalabilitytestbed = slapos.recipe.erp5scalabilitytestbed:Recipe',
'equeue = slapos.recipe.equeue:Recipe', 'equeue = slapos.recipe.equeue:Recipe',
'erp5testnode = slapos.recipe.erp5testnode:Recipe', 'erp5testnode = slapos.recipe.erp5testnode:Recipe',
'generate_output_if_input_not_null = slapos.recipe.generate_output_if_input_not_null:Recipe',
'generate.mac = slapos.recipe.generatemac:Recipe', 'generate.mac = slapos.recipe.generatemac:Recipe',
'generate.password = slapos.recipe.generatepassword:Recipe',
'nbdserver = slapos.recipe.nbdserver:Recipe', 'nbdserver = slapos.recipe.nbdserver:Recipe',
'generic.onetimeupload = slapos.recipe.generic_onetimeupload:Recipe', 'onetimeupload = slapos.recipe.onetimeupload:Recipe',
'helloworld = slapos.recipe.helloworld:Recipe', 'helloworld = slapos.recipe.helloworld:Recipe',
'generic.cloudooo = slapos.recipe.generic_cloudooo:Recipe', 'generic.cloudooo = slapos.recipe.generic_cloudooo:Recipe',
'firefox = slapos.recipe.firefox:Recipe', 'firefox = slapos.recipe.firefox:Recipe',
...@@ -134,6 +134,7 @@ setup(name=name, ...@@ -134,6 +134,7 @@ setup(name=name,
'erp5.test = slapos.recipe.erp5_test:Recipe', 'erp5.test = slapos.recipe.erp5_test:Recipe',
'generic.varnish = slapos.recipe.generic_varnish:Recipe', 'generic.varnish = slapos.recipe.generic_varnish:Recipe',
'webchecker = slapos.recipe.web_checker:Recipe', 'webchecker = slapos.recipe.web_checker:Recipe',
'signalwrapper= slapos.recipe.signal_wrapper:Recipe',
], ],
'slapos.recipe.nosqltestbed.plugin': [ 'slapos.recipe.nosqltestbed.plugin': [
'kumo = slapos.recipe.nosqltestbed.kumo:KumoTestBed', 'kumo = slapos.recipe.nosqltestbed.kumo:KumoTestBed',
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved. # Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
...@@ -26,15 +25,26 @@ ...@@ -26,15 +25,26 @@
# #
############################################################################## ##############################################################################
import random import random
import os
from slapos.recipe.librecipe import GenericBaseRecipe from slapos.recipe.librecipe import GenericBaseRecipe
class Recipe(GenericBaseRecipe): class Recipe(GenericBaseRecipe):
def __init__(self, buildout, name, options): def __init__(self, buildout, name, options):
# First octet has to represent a locally administered address if os.path.exists(options['storage-path']):
octet_list = [254] + [random.randint(0x00, 0xff) for x in range(5)] open_file = open(options['storage-path'], 'r')
options['mac-address'] = ':'.join(['%02x' % x for x in octet_list]) options['mac-address'] = open_file.read()
open_file.close()
if options.get('mac-address', '') == '':
# First octet has to represent a locally administered address
octet_list = [254] + [random.randint(0x00, 0xff) for x in range(5)]
options['mac-address'] = ':'.join(['%02x' % x for x in octet_list])
return GenericBaseRecipe.__init__(self, buildout, name, options)
def install(self): def install(self):
return [] open_file = open(self.options['storage-path'], 'w')
open_file.write(self.options['mac-address'])
open_file.close()
return [self.options['storage-path']]
############################################################################## ##############################################################################
# #
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved. # Copyright (c) 2012 Vifib SARL and Contributors. All Rights Reserved.
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential # programmers who take the whole responsibility of assessing all potential
...@@ -24,48 +24,27 @@ ...@@ -24,48 +24,27 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
import random
import os
import binascii
from slapos.recipe.librecipe import GenericBaseRecipe from slapos.recipe.librecipe import GenericBaseRecipe
class Recipe(GenericBaseRecipe): class Recipe(GenericBaseRecipe):
"""Generate an output from one or several input and a template.
Take "input-list" buildout parameter as input.
Each input of the list is separated by \n
Each input contains :
1/ The parameter to use (like mybuildoutpart:myparameter)
2/ The name of the input to use as key.
If all parameters in input are found, create an "output" parameter from a
"template" parameter. The "template" parameter is just a string containing
python parameters (like %(mykey)s).
Will produce nothing if one element of "input_list" doesn't exist.
Will raise if any input reference non-existent buildout part.
Example :
[get-output]
recipe = slapos.cookbook:generate_output_if_input_not_null
input-list =
firstkey mybuildoutpart:myparameter
otherkey myotherbuildoutpart:myotherparameter
template = I want to get %(key)s and %(otherkey)s
This example will produce an "output" parameter if myparameter and
myotherparameter are defined.
"""
def __init__(self, buildout, name, options): def __init__(self, buildout, name, options):
# Get all inputs if os.path.exists(options['storage-path']):
input_dict = {} open_file = open(options['storage-path'], 'r')
for line in options['input-list'].strip().split('\n'): options['passwd'] = open_file.read()
key, buildout_parameter = line.split(' ') open_file.close()
buildout_part, parameter_name = buildout_parameter.split(':')
parameter_value = buildout[buildout_part].get(parameter_name) if options.get('passwd', '') == '':
# If any parameter is not defined, don't do anything options['passwd'] = binascii.hexlify(os.urandom(
if not parameter_value: int(options.get('bytes', '24'))))
return return GenericBaseRecipe.__init__(self, buildout, name, options)
input_dict[key] = parameter_value
# Generate output
options['output'] = options['template'] % input_dict
def install(self): def install(self):
return [] open_file = open(self.options['storage-path'], 'w')
open_file.write(self.options['passwd'])
open_file.close()
return [self.options['storage-path']]
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
# #
############################################################################## ##############################################################################
from slapos.recipe.librecipe import GenericBaseRecipe from slapos.recipe.librecipe import GenericBaseRecipe
import binascii
import os import os
import sys import sys
...@@ -33,11 +32,6 @@ class Recipe(GenericBaseRecipe): ...@@ -33,11 +32,6 @@ class Recipe(GenericBaseRecipe):
""" """
kvm instance configuration. kvm instance configuration.
""" """
def __init__(self, buildout, name, options):
options['passwd'] = binascii.hexlify(os.urandom(4))
return GenericBaseRecipe.__init__(self, buildout, name, options)
def install(self): def install(self):
config = dict( config = dict(
tap_interface=self.options['tap'], tap_interface=self.options['tap'],
......
...@@ -32,7 +32,7 @@ if not os.path.exists(disk_path): ...@@ -32,7 +32,7 @@ if not os.path.exists(disk_path):
subprocess.Popen(['%(qemu_img_path)s', 'create' ,'-f', 'qcow2', subprocess.Popen(['%(qemu_img_path)s', 'create' ,'-f', 'qcow2',
'%(disk_path)s', '%(disk_size)sG']) '%(disk_path)s', '%(disk_size)sG'])
kvm_argument_list = ['kvm', '-net', 'nic,macaddr=%(mac_address)s', kvm_argument_list = ['%(qemu_path)s', '-enable-kvm', '-net', 'nic,macaddr=%(mac_address)s',
'-net', 'tap,ifname=%(tap_interface)s,script=no,downscript=no', '-net', 'tap,ifname=%(tap_interface)s,script=no,downscript=no',
'-smp', '%(smp_count)s', '-smp', '%(smp_count)s',
'-m', '%(ram_size)s', '-m', '%(ram_size)s',
......
...@@ -33,11 +33,6 @@ class Recipe(GenericBaseRecipe): ...@@ -33,11 +33,6 @@ class Recipe(GenericBaseRecipe):
""" """
kvm instance configuration. kvm instance configuration.
""" """
def __init__(self, buildout, name, options):
options['key'] = binascii.hexlify(os.urandom(24))
return GenericBaseRecipe.__init__(self, buildout, name, options)
def install(self): def install(self):
config = dict( config = dict(
ip=self.options['ip'], ip=self.options['ip'],
......
...@@ -36,6 +36,7 @@ class Recipe(object): ...@@ -36,6 +36,7 @@ class Recipe(object):
slap = slapmodule.slap() slap = slapmodule.slap()
self.software_release_url = options['software-url'] self.software_release_url = options['software-url']
self.name = options['name']
slap.initializeConnection(options['server-url'], slap.initializeConnection(options['server-url'],
options.get('key-file'), options.get('key-file'),
...@@ -73,7 +74,7 @@ class Recipe(object): ...@@ -73,7 +74,7 @@ class Recipe(object):
options['config-%s' % config_parameter] options['config-%s' % config_parameter]
self.instance = self.request(options['software-url'], software_type, self.instance = self.request(options['software-url'], software_type,
options['name'], partition_parameter_kw=partition_parameter_kw, self.name, partition_parameter_kw=partition_parameter_kw,
filter_kw=filter_kw, shared=self.isSlave) filter_kw=filter_kw, shared=self.isSlave)
self.failed = None self.failed = None
......
##############################################################################
#
# Copyright (c) 2012 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from slapos.recipe.librecipe import GenericBaseRecipe
class Recipe(GenericBaseRecipe):
def install(self):
return [
self.createPythonScript(
self.options['wrapper-path'],
'slapos.recipe.librecipe.execute.execute_with_signal_translation',
[self.options['wrapped-path']]
)
]
...@@ -12,7 +12,6 @@ parts = ...@@ -12,7 +12,6 @@ parts =
ca-frontend ca-frontend
certificate-authority certificate-authority
frontend-promise frontend-promise
publish-kvm-frontend-connection-information
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
...@@ -48,7 +47,7 @@ logrotate-entries = $${rootdirectory:etc}/logrotate.d ...@@ -48,7 +47,7 @@ logrotate-entries = $${rootdirectory:etc}/logrotate.d
recipe = slapos.cookbook:kvm.frontend recipe = slapos.cookbook:kvm.frontend
domain = $${ca-frontend:name} domain = $${ca-frontend:name}
# port = $${slap-parameter:port} # port = $${slap-parameter:port}
ip = $${slap-network-information:global-ipv6} ip = $${slap-network-information:local-ipv4}
port = $${slap-parameter:port} port = $${slap-parameter:port}
http-redirection = $${slap-parameter:http-redirection} http-redirection = $${slap-parameter:http-redirection}
ssl-key-path = $${ca-frontend:key-file} ssl-key-path = $${ca-frontend:key-file}
...@@ -130,11 +129,6 @@ logrotate-entries = $${directory:logrotate-entries} ...@@ -130,11 +129,6 @@ logrotate-entries = $${directory:logrotate-entries}
backup = $${directory:logrotate-backup} backup = $${directory:logrotate-backup}
state-file = $${rootdirectory:srv}/logrotate.status state-file = $${rootdirectory:srv}/logrotate.status
[publish-kvm-frontend-connection-information]
recipe = slapos.cookbook:publish
ip = $${frontend-instance:ip}
port = $${frontend-instance:port}
[slap-parameter] [slap-parameter]
# Default value if no port is specified # Default value if no port is specified
port = 4443 port = 4443
......
...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
############################# #############################
[buildout] [buildout]
parts = parts =
request-slave-frontend
certificate-authority certificate-authority
publish-kvm-backend-connection-information
publish-kvm-frontend-connection-information
kvm-promise kvm-promise
websockify-sighandler
novnc-promise novnc-promise
frontend-promise frontend-promise
publish-kvm-connection-information
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
...@@ -33,6 +34,12 @@ ca-dir = $${rootdirectory:srv}/ssl ...@@ -33,6 +34,12 @@ ca-dir = $${rootdirectory:srv}/ssl
[create-mac] [create-mac]
recipe = slapos.cookbook:generate.mac recipe = slapos.cookbook:generate.mac
storage-path = $${rootdirectory:srv}/mac
[gen-passwd]
recipe = slapos.cookbook:generate.password
storage-path = $${rootdirectory:srv}/passwd
bytes = 4
[kvm-instance] [kvm-instance]
recipe = slapos.cookbook:kvm recipe = slapos.cookbook:kvm
...@@ -53,6 +60,7 @@ controller-path = $${basedirectory:services}/kvm_controller ...@@ -53,6 +60,7 @@ controller-path = $${basedirectory:services}/kvm_controller
shell-path = ${dash:location}/bin/dash shell-path = ${dash:location}/bin/dash
qemu-path = ${kvm:location}/bin/qemu-system-x86_64 qemu-path = ${kvm:location}/bin/qemu-system-x86_64
qemu-img-path = ${kvm:location}/bin/qemu-img qemu-img-path = ${kvm:location}/bin/qemu-img
passwd = $${gen-passwd:passwd}
[kvm-promise] [kvm-promise]
recipe = slapos.cookbook:check_port_listening recipe = slapos.cookbook:check_port_listening
...@@ -73,6 +81,11 @@ websockify-path = ${buildout:directory}/bin/websockify ...@@ -73,6 +81,11 @@ websockify-path = ${buildout:directory}/bin/websockify
ssl-key-path = $${ca-novnc:key-file} ssl-key-path = $${ca-novnc:key-file}
ssl-cert-path = $${ca-novnc:cert-file} ssl-cert-path = $${ca-novnc:cert-file}
[websockify-sighandler]
recipe = slapos.cookbook:signalwrapper
wrapper-path = $${basedirectory:services}/websockify
wrapped-path = $${novnc-instance:path}
[certificate-authority] [certificate-authority]
recipe = slapos.cookbook:certificate_authority recipe = slapos.cookbook:certificate_authority
openssl-binary = ${openssl:location}/bin/openssl openssl-binary = ${openssl:location}/bin/openssl
...@@ -98,7 +111,7 @@ recipe = slapos.cookbook:certificate_authority.request ...@@ -98,7 +111,7 @@ recipe = slapos.cookbook:certificate_authority.request
key-file = $${basedirectory:novnc-conf}/novnc.key key-file = $${basedirectory:novnc-conf}/novnc.key
cert-file = $${basedirectory:novnc-conf}/novnc.crt cert-file = $${basedirectory:novnc-conf}/novnc.crt
executable = $${rootdirectory:bin}/novnc executable = $${rootdirectory:bin}/novnc
wrapper = $${basedirectory:services}/websockify wrapper = $${rootdirectory:bin}/websockify
[novnc-promise] [novnc-promise]
recipe = slapos.cookbook:check_port_listening recipe = slapos.cookbook:check_port_listening
...@@ -114,41 +127,33 @@ db-path = $${rootdirectory:srv}/slapmonitor_database ...@@ -114,41 +127,33 @@ db-path = $${rootdirectory:srv}/slapmonitor_database
[request-slave-frontend] [request-slave-frontend]
recipe = slapos.cookbook:request recipe = slapos.cookbook:request
software-url = $${slap-connection:software-release-url} software-url = $${slap-parameter:frontend-software-url}
server-url = $${slap-connection:server-url} server-url = $${slap-connection:server-url}
key-file = $${slap-connection:key-file} key-file = $${slap-connection:key-file}
cert-file = $${slap-connection:cert-file} cert-file = $${slap-connection:cert-file}
computer-id = $${slap-connection:computer-id} computer-id = $${slap-connection:computer-id}
partition-id = $${slap-connection:partition-id} partition-id = $${slap-connection:partition-id}
name = SlaveFrontend name = SlaveFrontend
software-type = frontend software-type = $${slap-parameter:frontend-software-type}
slave = true slave = true
config = host port config = host port
config-host = $${novnc-instance:ip} config-host = $${novnc-instance:ip}
config-port = $${novnc-instance:port} config-port = $${novnc-instance:port}
return = url resource port domainname return = url resource port domainname
sla = instance_guid
sla-instance_guid = $${slap-parameter:frontend-instance-guid}
[publish-kvm-backend-connection-information]
recipe = slapos.cookbook:publish
backend_url = https://[$${novnc-instance:ip}]:$${novnc-instance:port}/vnc_auto.html?host=[$${novnc-instance:ip}]&port=$${novnc-instance:port}&encrypt=1
password = $${kvm-instance:passwd}
# Will generate, if existing, URL to reach KVM using frontend [publish-kvm-frontend-connection-information]
[get-slave-connection-url] <= publish-kvm-backend-connection-information
recipe = slapos.cookbook:generate_output_if_input_not_null 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}
input-list =
frontend-url request-slave-frontend:connection-url
frontend-port request-slave-frontend:connection-port
frontend-resource request-slave-frontend:connection-resource
frontend-domainname request-slave-frontend:connection-domainname
template = %(frontend-url)s/vnc_auto.html?host=%(frontend-domainname)s&port=%(frontend-port)s&encrypt=1&path=%(frontend-resource)s
# This is default output, if slave is not ready yet
output = Not ready yet. Please use backend URL if possible or wait a few minutes.
[frontend-promise] [frontend-promise]
recipe = slapos.cookbook:check_url_available recipe = slapos.cookbook:check_url_available
path = $${basedirectory:promises}/frontend_promise path = $${basedirectory:promises}/frontend_promise
url = $${get-slave-connection-url:output} url = $${publish-kvm-frontend-connection-information:url}
dash_path = ${dash:location}/bin/dash dash_path = ${dash:location}/bin/dash
[publish-kvm-connection-information]
recipe = slapos.cookbook:publish
backend_url = https://[$${novnc-instance:ip}]:$${novnc-instance:port}/vnc_auto.html?host=[$${novnc-instance:ip}]&port=$${novnc-instance:port}&encrypt=1
url = $${get-slave-connection-url:output}
password = $${kvm-instance:passwd}
...@@ -40,8 +40,13 @@ path = $${basedirectory:promises}/nbd_promise ...@@ -40,8 +40,13 @@ path = $${basedirectory:promises}/nbd_promise
hostname = $${nbd-instance:ip} hostname = $${nbd-instance:ip}
port = $${nbd-instance:port} port = $${nbd-instance:port}
[gen-passwd]
recipe = slapos.cookbook:generate.password
storage-path = $${rootdirectory:srv}/passwd
bytes = 24
[onetimeupload-instance] [onetimeupload-instance]
recipe = slapos.cookbook:generic.onetimeupload recipe = slapos.cookbook:onetimeupload
ip = $${slap-network-information:global-ipv6} ip = $${slap-network-information:global-ipv6}
port = 9999 port = 9999
image-path = $${rootdirectory:srv}/cdrom.iso image-path = $${rootdirectory:srv}/cdrom.iso
...@@ -49,6 +54,7 @@ log-path = $${rootdirectory:log}/onetimeupload.log ...@@ -49,6 +54,7 @@ log-path = $${rootdirectory:log}/onetimeupload.log
shell-path = ${dash:location}/bin/dash shell-path = ${dash:location}/bin/dash
onetimeupload-path = ${buildout:bin-directory}/onetimeupload onetimeupload-path = ${buildout:bin-directory}/onetimeupload
path = $${basedirectory:services}/onetimeupload path = $${basedirectory:services}/onetimeupload
key = $${gen-passwd:passwd}
[onetimeupload-promise] [onetimeupload-promise]
recipe = slapos.cookbook:check_port_listening recipe = slapos.cookbook:check_port_listening
......
...@@ -132,7 +132,7 @@ command = ...@@ -132,7 +132,7 @@ command =
[template-kvm] [template-kvm]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-kvm.cfg url = ${:_profile_base_location_}/instance-kvm.cfg
md5sum = 8d67a6cabe4fbce2bd44aa006a0d0cf8 md5sum = 334d26da3808e127a9751ebcc21d83bb
output = ${buildout:directory}/template-kvm.cfg output = ${buildout:directory}/template-kvm.cfg
mode = 0644 mode = 0644
...@@ -146,14 +146,14 @@ mode = 0644 ...@@ -146,14 +146,14 @@ mode = 0644
[template-nbd] [template-nbd]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-nbd.cfg url = ${:_profile_base_location_}/instance-nbd.cfg
md5sum = 7691fadfc8d4392c58ac1bf0ebd5aaf2 md5sum = 692b3da84473fbc962bea9b371b5355b
output = ${buildout:directory}/template-nbd.cfg output = ${buildout:directory}/template-nbd.cfg
mode = 0644 mode = 0644
[template-frontend] [template-frontend]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-frontend.cfg url = ${:_profile_base_location_}/instance-frontend.cfg
md5sum = 123bf4e5bea9e86c03b62e9afb8ca04b md5sum = 73359b52013b1b65f75005e8698ed180
output = ${buildout:directory}/template-frontend.cfg output = ${buildout:directory}/template-frontend.cfg
mode = 0644 mode = 0644
......
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