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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Roque
slapos
Commits
92c3cb60
Commit
92c3cb60
authored
Jun 20, 2012
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/kvm'
parents
49c52013
7dfe15ec
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
148 additions
and
55 deletions
+148
-55
setup.py
setup.py
+3
-2
slapos/recipe/generatemac.py
slapos/recipe/generatemac.py
+15
-5
slapos/recipe/generatepassword.py
slapos/recipe/generatepassword.py
+50
-0
slapos/recipe/kvm/__init__.py
slapos/recipe/kvm/__init__.py
+0
-6
slapos/recipe/kvm/template/kvm_run.in
slapos/recipe/kvm/template/kvm_run.in
+1
-1
slapos/recipe/onetimeupload/__init__.py
slapos/recipe/onetimeupload/__init__.py
+0
-5
slapos/recipe/onetimeupload/template/onetimeupload_run.in
slapos/recipe/onetimeupload/template/onetimeupload_run.in
+0
-0
slapos/recipe/request.py
slapos/recipe/request.py
+2
-1
slapos/recipe/signal_wrapper.py
slapos/recipe/signal_wrapper.py
+37
-0
software/kvm/instance-frontend.cfg
software/kvm/instance-frontend.cfg
+1
-7
software/kvm/instance-kvm.cfg
software/kvm/instance-kvm.cfg
+29
-24
software/kvm/instance-nbd.cfg
software/kvm/instance-nbd.cfg
+7
-1
software/kvm/software.cfg
software/kvm/software.cfg
+3
-3
No files found.
setup.py
View file @
92c3cb60
...
...
@@ -60,10 +60,10 @@ setup(name=name,
'erp5scalabilitytestbed = slapos.recipe.erp5scalabilitytestbed:Recipe'
,
'equeue = slapos.recipe.equeue: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.password = slapos.recipe.generatepassword:Recipe'
,
'nbdserver = slapos.recipe.nbdserver:Recipe'
,
'
generic.onetimeupload = slapos.recipe.generic_
onetimeupload:Recipe'
,
'
onetimeupload = slapos.recipe.
onetimeupload:Recipe'
,
'helloworld = slapos.recipe.helloworld:Recipe'
,
'generic.cloudooo = slapos.recipe.generic_cloudooo:Recipe'
,
'firefox = slapos.recipe.firefox:Recipe'
,
...
...
@@ -134,6 +134,7 @@ setup(name=name,
'erp5.test = slapos.recipe.erp5_test:Recipe'
,
'generic.varnish = slapos.recipe.generic_varnish:Recipe'
,
'webchecker = slapos.recipe.web_checker:Recipe'
,
'signalwrapper= slapos.recipe.signal_wrapper:Recipe'
,
],
'slapos.recipe.nosqltestbed.plugin'
:
[
'kumo = slapos.recipe.nosqltestbed.kumo:KumoTestBed'
,
...
...
slapos/recipe/generatemac.py
View file @
92c3cb60
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
...
...
@@ -26,15 +25,26 @@
#
##############################################################################
import
random
import
os
from
slapos.recipe.librecipe
import
GenericBaseRecipe
class
Recipe
(
GenericBaseRecipe
):
def
__init__
(
self
,
buildout
,
name
,
options
):
# 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
])
if
os
.
path
.
exists
(
options
[
'storage-path'
]):
open_file
=
open
(
options
[
'storage-path'
],
'r'
)
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
):
return
[]
open_file
=
open
(
self
.
options
[
'storage-path'
],
'w'
)
open_file
.
write
(
self
.
options
[
'mac-address'
])
open_file
.
close
()
return
[
self
.
options
[
'storage-path'
]]
slapos/recipe/generate
_output_if_input_not_null
.py
→
slapos/recipe/generate
password
.py
View file @
92c3cb60
##############################################################################
#
# Copyright (c) 201
0
Vifib SARL and Contributors. All Rights Reserved.
# Copyright (c) 201
2
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
...
...
@@ -24,48 +24,27 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
random
import
os
import
binascii
from
slapos.recipe.librecipe
import
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
):
# Get all inputs
input_dict
=
{}
for
line
in
options
[
'input-list'
].
strip
().
split
(
'
\
n
'
):
key
,
buildout_parameter
=
line
.
split
(
' '
)
buildout_part
,
parameter_name
=
buildout_parameter
.
split
(
':'
)
parameter_value
=
buildout
[
buildout_part
].
get
(
parameter_name
)
# If any parameter is not defined, don't do anything
if
not
parameter_value
:
return
input_dict
[
key
]
=
parameter_value
# Generate output
options
[
'output'
]
=
options
[
'template'
]
%
input_dict
if
os
.
path
.
exists
(
options
[
'storage-path'
]):
open_file
=
open
(
options
[
'storage-path'
],
'r'
)
options
[
'passwd'
]
=
open_file
.
read
()
open_file
.
close
()
if
options
.
get
(
'passwd'
,
''
)
==
''
:
options
[
'passwd'
]
=
binascii
.
hexlify
(
os
.
urandom
(
int
(
options
.
get
(
'bytes'
,
'24'
))))
return
GenericBaseRecipe
.
__init__
(
self
,
buildout
,
name
,
options
)
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'
]]
slapos/recipe/kvm/__init__.py
View file @
92c3cb60
...
...
@@ -25,7 +25,6 @@
#
##############################################################################
from
slapos.recipe.librecipe
import
GenericBaseRecipe
import
binascii
import
os
import
sys
...
...
@@ -33,11 +32,6 @@ class Recipe(GenericBaseRecipe):
"""
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
):
config
=
dict
(
tap_interface
=
self
.
options
[
'tap'
],
...
...
slapos/recipe/kvm/template/kvm_run.in
View file @
92c3cb60
...
...
@@ -32,7 +32,7 @@ if not os.path.exists(disk_path):
subprocess.Popen(['%(qemu_img_path)s', 'create' ,'-f', 'qcow2',
'%(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',
'-smp', '%(smp_count)s',
'-m', '%(ram_size)s',
...
...
slapos/recipe/
generic_
onetimeupload/__init__.py
→
slapos/recipe/onetimeupload/__init__.py
View file @
92c3cb60
...
...
@@ -33,11 +33,6 @@ class Recipe(GenericBaseRecipe):
"""
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
):
config
=
dict
(
ip
=
self
.
options
[
'ip'
],
...
...
slapos/recipe/
generic_
onetimeupload/template/onetimeupload_run.in
→
slapos/recipe/onetimeupload/template/onetimeupload_run.in
View file @
92c3cb60
File moved
slapos/recipe/request.py
View file @
92c3cb60
...
...
@@ -36,6 +36,7 @@ class Recipe(object):
slap
=
slapmodule
.
slap
()
self
.
software_release_url
=
options
[
'software-url'
]
self
.
name
=
options
[
'name'
]
slap
.
initializeConnection
(
options
[
'server-url'
],
options
.
get
(
'key-file'
),
...
...
@@ -73,7 +74,7 @@ class Recipe(object):
options
[
'config-%s'
%
config_parameter
]
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
)
self
.
failed
=
None
...
...
slapos/recipe/signal_wrapper.py
0 → 100644
View file @
92c3cb60
##############################################################################
#
# 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'
]]
)
]
software/kvm/instance-frontend.cfg
View file @
92c3cb60
...
...
@@ -12,7 +12,6 @@ parts =
ca-frontend
certificate-authority
frontend-promise
publish-kvm-frontend-connection-information
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
...
...
@@ -48,7 +47,7 @@ logrotate-entries = $${rootdirectory:etc}/logrotate.d
recipe = slapos.cookbook:kvm.frontend
domain = $${ca-frontend:name}
# port = $${slap-parameter:port}
ip = $${slap-network-information:
global-ipv6
}
ip = $${slap-network-information:
local-ipv4
}
port = $${slap-parameter:port}
http-redirection = $${slap-parameter:http-redirection}
ssl-key-path = $${ca-frontend:key-file}
...
...
@@ -130,11 +129,6 @@ logrotate-entries = $${directory:logrotate-entries}
backup = $${directory:logrotate-backup}
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]
# Default value if no port is specified
port = 4443
...
...
software/kvm/instance-kvm.cfg
View file @
92c3cb60
...
...
@@ -5,12 +5,13 @@
#############################
[buildout]
parts =
request-slave-frontend
certificate-authority
publish-kvm-backend-connection-information
publish-kvm-frontend-connection-information
kvm-promise
websockify-sighandler
novnc-promise
frontend-promise
publish-kvm-connection-information
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
...
...
@@ -33,6 +34,12 @@ ca-dir = $${rootdirectory:srv}/ssl
[create-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]
recipe = slapos.cookbook:kvm
...
...
@@ -53,6 +60,7 @@ controller-path = $${basedirectory:services}/kvm_controller
shell-path = ${dash:location}/bin/dash
qemu-path = ${kvm:location}/bin/qemu-system-x86_64
qemu-img-path = ${kvm:location}/bin/qemu-img
passwd = $${gen-passwd:passwd}
[kvm-promise]
recipe = slapos.cookbook:check_port_listening
...
...
@@ -73,6 +81,11 @@ 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 = $${basedirectory:services}/websockify
wrapped-path = $${novnc-instance:path}
[certificate-authority]
recipe = slapos.cookbook:certificate_authority
openssl-binary = ${openssl:location}/bin/openssl
...
...
@@ -98,7 +111,7 @@ recipe = slapos.cookbook:certificate_authority.request
key-file = $${basedirectory:novnc-conf}/novnc.key
cert-file = $${basedirectory:novnc-conf}/novnc.crt
executable = $${rootdirectory:bin}/novnc
wrapper = $${
basedirectory:services
}/websockify
wrapper = $${
rootdirectory:bin
}/websockify
[novnc-promise]
recipe = slapos.cookbook:check_port_listening
...
...
@@ -114,41 +127,33 @@ db-path = $${rootdirectory:srv}/slapmonitor_database
[request-slave-frontend]
recipe = slapos.cookbook:request
software-url = $${slap-
connection:software-releas
e-url}
software-url = $${slap-
parameter:frontend-softwar
e-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 = SlaveFrontend
software-type =
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-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
[get-slave-connection-url]
recipe = slapos.cookbook:generate_output_if_input_not_null
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.
[publish-kvm-frontend-connection-information]
<= publish-kvm-backend-connection-information
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}
[frontend-promise]
recipe = slapos.cookbook:check_url_available
path = $${basedirectory:promises}/frontend_promise
url = $${
get-slave-connection-url:output
}
url = $${
publish-kvm-frontend-connection-information:url
}
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}
software/kvm/instance-nbd.cfg
View file @
92c3cb60
...
...
@@ -40,8 +40,13 @@ path = $${basedirectory:promises}/nbd_promise
hostname = $${nbd-instance:ip}
port = $${nbd-instance:port}
[gen-passwd]
recipe = slapos.cookbook:generate.password
storage-path = $${rootdirectory:srv}/passwd
bytes = 24
[onetimeupload-instance]
recipe = slapos.cookbook:
generic.
onetimeupload
recipe = slapos.cookbook:onetimeupload
ip = $${slap-network-information:global-ipv6}
port = 9999
image-path = $${rootdirectory:srv}/cdrom.iso
...
...
@@ -49,6 +54,7 @@ log-path = $${rootdirectory:log}/onetimeupload.log
shell-path = ${dash:location}/bin/dash
onetimeupload-path = ${buildout:bin-directory}/onetimeupload
path = $${basedirectory:services}/onetimeupload
key = $${gen-passwd:passwd}
[onetimeupload-promise]
recipe = slapos.cookbook:check_port_listening
...
...
software/kvm/software.cfg
View file @
92c3cb60
...
...
@@ -132,7 +132,7 @@ command =
[template-kvm]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-kvm.cfg
md5sum =
8d67a6cabe4fbce2bd44aa006a0d0cf8
md5sum =
334d26da3808e127a9751ebcc21d83bb
output = ${buildout:directory}/template-kvm.cfg
mode = 0644
...
...
@@ -146,14 +146,14 @@ mode = 0644
[template-nbd]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-nbd.cfg
md5sum =
7691fadfc8d4392c58ac1bf0ebd5aaf2
md5sum =
692b3da84473fbc962bea9b371b5355b
output = ${buildout:directory}/template-nbd.cfg
mode = 0644
[template-frontend]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-frontend.cfg
md5sum =
123bf4e5bea9e86c03b62e9afb8ca04b
md5sum =
73359b52013b1b65f75005e8698ed180
output = ${buildout:directory}/template-frontend.cfg
mode = 0644
...
...
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