Commit 5067f9af authored by Cédric de Saint Martin's avatar Cédric de Saint Martin

Merge branch 'kvm'

parents 9411bfb0 a817f39d
...@@ -11,8 +11,9 @@ extends = ...@@ -11,8 +11,9 @@ extends =
[qemu-kvm] [qemu-kvm]
recipe = slapos.recipe.cmmi recipe = slapos.recipe.cmmi
url = http://downloads.sourceforge.net/project/kvm/qemu-kvm/1.2.0/qemu-kvm-1.2.0.tar.gz # qemu-kvm and qemu are now the same since 1.3.
md5sum = d7b18b673c48abfee65a9c0245df0415 url = http://wiki.qemu-project.org/download/qemu-1.4.1.tar.bz2
md5sum = eb2d696956324722b5ecfa46e41f9a75
configure-options = configure-options =
--disable-sdl --disable-sdl
--disable-xen --disable-xen
......
...@@ -107,7 +107,8 @@ class Recipe(GenericSlapRecipe): ...@@ -107,7 +107,8 @@ class Recipe(GenericSlapRecipe):
http_redirect_server = '' http_redirect_server = ''
config = dict( config = dict(
ip=self.options['ip'], ipv6=self.options['ipv6'],
ipv4=self.options['ipv4'],
port=self.options['port'], port=self.options['port'],
key=self.options['ssl-key-path'], key=self.options['ssl-key-path'],
certificate=self.options['ssl-cert-path'], certificate=self.options['ssl-cert-path'],
......
...@@ -37,12 +37,13 @@ var fs = require('fs'), ...@@ -37,12 +37,13 @@ var fs = require('fs'),
httpProxy = require('http-proxy'), httpProxy = require('http-proxy'),
proxyByUrl = require('proxy-by-url'); proxyByUrl = require('proxy-by-url');
var listenInterface = process.argv[2], var listenInterfacev6 = process.argv[2],
port = process.argv[3], listenInterfacev4 = process.argv[3],
sslKeyFile = process.argv[4], port = process.argv[4],
sslCertFile = process.argv[5], sslKeyFile = process.argv[5],
proxyTable = process.argv[6], sslCertFile = process.argv[6],
redirect = process.argv[7] || false, proxyTable = process.argv[7],
redirect = process.argv[8] || false,
isRawIPv6; isRawIPv6;
if (process.argv.length < 7) { if (process.argv.length < 7) {
...@@ -50,11 +51,6 @@ if (process.argv.length < 7) { ...@@ -50,11 +51,6 @@ if (process.argv.length < 7) {
process.exit(1); process.exit(1);
} }
isRawIPv6 = function checkipv6(str) {
// Inspired by http://forums.intermapper.com/viewtopic.php?t=452
return (/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/.test(str));
}(listenInterface);
/** /**
* Dummy middleware that throws 404 not found. Does not contain websocket * Dummy middleware that throws 404 not found. Does not contain websocket
* middleware. * middleware.
...@@ -69,7 +65,7 @@ var middlewareNotFound = function(req, res, proxy) { ...@@ -69,7 +65,7 @@ var middlewareNotFound = function(req, res, proxy) {
/** /**
* Create server * Create server
*/ */
var proxyServer = httpProxy.createServer( var proxyServerv6 = httpProxy.createServer(
// We declare our proxyByUrl middleware // We declare our proxyByUrl middleware
proxyByUrl(proxyTable), proxyByUrl(proxyTable),
// Then we add your dummy middleware, called when proxyByUrl doesn't find url. // Then we add your dummy middleware, called when proxyByUrl doesn't find url.
...@@ -87,42 +83,70 @@ var proxyServer = httpProxy.createServer( ...@@ -87,42 +83,70 @@ var proxyServer = httpProxy.createServer(
) )
}, },
source: { source: {
host: listenInterface, host: listenInterfacev6,
port: port port: port
}} }}
); );
var proxyServerv4 = httpProxy.createServer(
// We declare our proxyByUrl middleware
proxyByUrl(proxyTable),
// Then we add your dummy middleware, called when proxyByUrl doesn't find url.
middlewareNotFound,
// And we set HTTPS options for server. HTTP will be forbidden.
{
https: {
key: fs.readFileSync(
sslKeyFile,
'utf8'
),
cert: fs.readFileSync(
sslCertFile,
'utf8'
)
},
source: {
host: listenInterfacev4,
port: port
}}
);
console.log('HTTPS server starting and trying to listen on ' + console.log('HTTPS server starting and trying to listen on ' +
listenInterface + ':' + port); listenInterfacev4 + ':' + port);
// Release the beast. // Release the beast.
proxyServer.listen(port, listenInterface); proxyServerv6.listen(port, listenInterfacev6);
proxyServerv4.listen(port, listenInterfacev4);
// Dummy HTTP server redirecting to HTTPS. Only has sense if we can use port 80 // Dummy HTTP server redirecting to HTTPS. Only has sense if we can use port 80
if (redirect === '1') { if (redirect === '1') {
console.log('HTTP redirect server starting and trying to listen on ' + console.log('HTTP redirect server starting and trying to listen on ' +
listenInterface + ':' + httpPort); listenInterface + ':' + httpPort);
try { /*
var httpPort = 80; *try {
http.createServer(function(req, res) { * var httpPort = 80;
var url; * http.createServer(function(req, res) {
if (isRawIPv6 === true) { * var url;
url = 'https://[' + listenInterface + ']'; * if (isRawIPv6 === true) {
} else { * url = 'https://[' + listenInterface + ']';
url = 'https://' + listenInterface; * } else {
} * url = 'https://' + listenInterface;
// If non standard port : need to specify it * }
if (port !== 443) { * // If non standard port : need to specify it
url = url + ':' + port; * if (port !== 443) {
} * url = url + ':' + port;
// Add last part of URL * }
url = url + req.url; * // Add last part of URL
console.log(url); * url = url + req.url;
// Anwser "permanently redirected" * console.log(url);
res.statusCode = 301; * // Anwser "permanently redirected"
res.setHeader('Location', url); * res.statusCode = 301;
res.end(); * res.setHeader('Location', url);
}).listen(httpPort, listenInterface); * res.end();
} catch (error) { * }).listen(httpPort, listenInterface);
console.log('Couldn\'t start plain HTTP redirection server : ' + error) * } catch (error) {
} * console.log('Couldn\'t start plain HTTP redirection server : ' + error)
* }
*/
} }
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
# BEWARE: This file is operated by slapgrid # BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically # BEWARE: It will be overwritten automatically
export NODE_PATH=%(node_env)s export NODE_PATH=%(node_env)s
exec %(node_path)s %(conf_path)s %(ip)s %(port)s %(key)s %(certificate)s %(map_path)s %(plain_http)s exec %(node_path)s %(conf_path)s %(ipv6)s %(ipv4)s %(port)s %(key)s %(certificate)s %(map_path)s %(plain_http)s
...@@ -56,6 +56,7 @@ recipe = plone.recipe.command ...@@ -56,6 +56,7 @@ recipe = plone.recipe.command
destination = ${buildout:parts-directory}/${:_buildout_section_name_} destination = ${buildout:parts-directory}/${:_buildout_section_name_}
location = ${buildout:parts-directory}/${:_buildout_section_name_} location = ${buildout:parts-directory}/${:_buildout_section_name_}
command = command =
export HOME=${:location};
rm -fr ${:destination} && rm -fr ${:destination} &&
mkdir -p ${:destination} && mkdir -p ${:destination} &&
cd ${:destination} && cd ${:destination} &&
...@@ -69,17 +70,10 @@ command = ...@@ -69,17 +70,10 @@ command =
[template-kvm] [template-kvm]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-kvm.cfg.in url = ${:_profile_base_location_}/instance-kvm.cfg.in
md5sum = c0320447308299ec9caaeece4187bc1f md5sum = 87197471aa93863c310204e8865b5ac1
output = ${buildout:directory}/template-kvm.cfg output = ${buildout:directory}/template-kvm.cfg
mode = 0644 mode = 0644
[template-kvmplus]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-kvmplus.cfg.in
md5sum = c8e92237eeda93caca1132b5202c3a02
output = ${buildout:directory}/template-kvmplus.cfg
mode = 0644
[template-nbd] [template-nbd]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-nbd.cfg.in url = ${:_profile_base_location_}/instance-nbd.cfg.in
...@@ -90,13 +84,13 @@ mode = 0644 ...@@ -90,13 +84,13 @@ mode = 0644
[template-frontend] [template-frontend]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-frontend.cfg.in url = ${:_profile_base_location_}/instance-frontend.cfg.in
md5sum = 73359b52013b1b65f75005e8698ed180 md5sum = cdb690495e9eb007d2b7d2f8e12f5c59
output = ${buildout:directory}/template-frontend.cfg output = ${buildout:directory}/template-frontend.cfg
mode = 0644 mode = 0644
[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 = 68788763d23f70f24b9e575871c903a8 md5sum = 0a98e34aaec7097a84066c0665e3a49a
output = ${buildout:directory}/template.cfg output = ${buildout:directory}/template.cfg
mode = 0644 mode = 0644
[buildout] [buildout]
extends = extends =
../../git/buildout.cfg ../../component/git/buildout.cfg
common.cfg common.cfg
parts += parts +=
slapos.cookbook-repository slapos.cookbook-repository
slapos.core-repository
slapos.toolbox-repository slapos.toolbox-repository
check-recipe check-recipe
develop = develop =
${:parts-directory}/slapos.cookbook-repository ${:parts-directory}/slapos.cookbook-repository
${:parts-directory}/slapos.toolbox-repository
[slapos.cookbook-repository] [slapos.cookbook-repository]
recipe = slapos.recipe.build:gitclone recipe = slapos.recipe.build:gitclone
repository = http://git.erp5.org/repos/slapos.git repository = http://git.erp5.org/repos/slapos.git
branch = slaprunner branch = kvm
git-executable = ${git:location}/bin/git
[slapos.toolbox-repository]
recipe = slapos.recipe.build:gitclone
repository = http://git.erp5.org/repos/slapos.toolbox.git
branch = master
git-executable = ${git:location}/bin/git git-executable = ${git:location}/bin/git
[check-recipe] [check-recipe]
...@@ -24,3 +30,4 @@ stop-on-error = true ...@@ -24,3 +30,4 @@ stop-on-error = true
update-command = ${:command} update-command = ${:command}
command = command =
grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link && grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link &&
grep parts ${buildout:develop-eggs-directory}/slapos.toolbox.egg-link
...@@ -11,7 +11,8 @@ parts = ...@@ -11,7 +11,8 @@ parts =
cron-entry-logrotate cron-entry-logrotate
ca-frontend ca-frontend
certificate-authority certificate-authority
frontend-promise frontend-promise-ipv6
frontend-promise-ipv4
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
...@@ -47,7 +48,8 @@ logrotate-entries = $${rootdirectory:etc}/logrotate.d ...@@ -47,7 +48,8 @@ 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:local-ipv4} ipv6 = $${slap-network-information:global-ipv6}
ipv4 = $${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}
...@@ -60,10 +62,16 @@ node-binary = ${nodejs:location}/bin/node ...@@ -60,10 +62,16 @@ node-binary = ${nodejs:location}/bin/node
node-env = ${buildout:parts-directory}:${npm-modules:location}/node_modules node-env = ${buildout:parts-directory}:${npm-modules:location}/node_modules
shell-path = ${dash:location}/bin/dash shell-path = ${dash:location}/bin/dash
[frontend-promise] [frontend-promise-ipv6]
recipe = slapos.cookbook:check_port_listening recipe = slapos.cookbook:check_port_listening
path = $${basedirectory:promises}/frontend_promise path = $${basedirectory:promises}/frontend_promise
hostname = $${frontend-instance:ip} hostname = $${frontend-instance:ipv6}
port = $${frontend-instance:port}
[frontend-promise-ipv4]
recipe = slapos.cookbook:check_port_listening
path = $${basedirectory:promises}/frontend_promise
hostname = $${frontend-instance:ipv4}
port = $${frontend-instance:port} port = $${frontend-instance:port}
[certificate-authority] [certificate-authority]
...@@ -133,6 +141,7 @@ state-file = $${rootdirectory:srv}/logrotate.status ...@@ -133,6 +141,7 @@ state-file = $${rootdirectory:srv}/logrotate.status
# Default value if no port is specified # Default value if no port is specified
port = 4443 port = 4443
http-redirection = 0 http-redirection = 0
slave_instance_list =
# [logrotate-entry-frontend] # [logrotate-entry-frontend]
# <= logrotate # <= logrotate
......
...@@ -36,7 +36,7 @@ storage-path = $${directory:srv}/mac ...@@ -36,7 +36,7 @@ storage-path = $${directory:srv}/mac
[gen-passwd] [gen-passwd]
recipe = slapos.cookbook:generate.password recipe = slapos.cookbook:generate.password
storage-path = $${directory:srv}/passwd storage-path = $${directory:srv}/passwd
bytes = 4 bytes = 8
[kvm-instance] [kvm-instance]
# XXX-Cedric: change "KVM" recipe to simple "create wrappers". No need for this # XXX-Cedric: change "KVM" recipe to simple "create wrappers". No need for this
...@@ -135,7 +135,7 @@ key-file = $${slap-connection:key-file} ...@@ -135,7 +135,7 @@ 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 = VNC Frontend
software-type = $${slap-parameter:frontend-software-type} software-type = $${slap-parameter:frontend-software-type}
slave = true slave = true
config = host port config = host port
...@@ -162,7 +162,6 @@ curl_path = ${curl:location}/bin/curl ...@@ -162,7 +162,6 @@ curl_path = ${curl:location}/bin/curl
[slap-parameter] [slap-parameter]
# Default values if not specified # Default values if not specified
frontend-instance-guid = SOFTINST-11031
frontend-software-type = frontend 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 frontend-software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.92:/software/kvm/software.cfg
......
#############################
#
# Instanciate kvm+
#
#############################
# Deprecated. Just specify amount of RAM / disk you want in instance parameter.
[buildout]
extends = ${template-kvm:output}
[slap-parameter]
ram-size = 2048
disk-size = 20
\ No newline at end of file
...@@ -10,7 +10,6 @@ offline = true ...@@ -10,7 +10,6 @@ offline = true
recipe = slapos.cookbook:softwaretype recipe = slapos.cookbook:softwaretype
default = ${template-kvm:output} default = ${template-kvm:output}
kvm = ${template-kvm:output} kvm = ${template-kvm:output}
kvm+ = ${template-kvmplus:output}
nbd = ${template-nbd:output} nbd = ${template-nbd:output}
frontend = ${template-frontend:output} frontend = ${template-frontend:output}
......
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