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
Dmitry Blinov
slapos
Commits
024f9e12
Commit
024f9e12
authored
Feb 13, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup : delete kvm recipe, move generic_kvm to kvm
parent
ccc5b5ec
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
42 additions
and
638 deletions
+42
-638
setup.py
setup.py
+0
-1
slapos/recipe/generic_kvm/__init__.py
slapos/recipe/generic_kvm/__init__.py
+0
-76
slapos/recipe/kvm/__init__.py
slapos/recipe/kvm/__init__.py
+40
-87
slapos/recipe/kvm/certificate_authority.py
slapos/recipe/kvm/certificate_authority.py
+0
-114
slapos/recipe/kvm/template/kvm_controller_run.in
slapos/recipe/kvm/template/kvm_controller_run.in
+0
-0
slapos/recipe/kvm/template/kvm_run.in
slapos/recipe/kvm/template/kvm_run.in
+0
-0
slapos/recipe/kvm/template/openssl.cnf.ca.in
slapos/recipe/kvm/template/openssl.cnf.ca.in
+0
-350
slapos/recipe/kvm/template/slapmonitor_run.in
slapos/recipe/kvm/template/slapmonitor_run.in
+0
-4
slapos/recipe/kvm/template/slapreport_run.in
slapos/recipe/kvm/template/slapreport_run.in
+0
-4
software/kvm/instance-kvm.cfg
software/kvm/instance-kvm.cfg
+1
-1
software/kvm/software.cfg
software/kvm/software.cfg
+1
-1
No files found.
setup.py
View file @
024f9e12
...
...
@@ -57,7 +57,6 @@ setup(name=name,
'equeue = slapos.recipe.equeue:Recipe'
,
'erp5testnode = slapos.recipe.erp5testnode:Recipe'
,
'generate.mac = slapos.recipe.generatemac:Recipe'
,
'generic.kvm = slapos.recipe.generic_kvm:Recipe'
,
'generic.kvm.frontend = slapos.recipe.generic_kvm_frontend:Recipe'
,
'generic.nbdserver = slapos.recipe.generic_nbdserver:Recipe'
,
'generic.novnc = slapos.recipe.generic_novnc:Recipe'
,
...
...
slapos/recipe/generic_kvm/__init__.py
deleted
100644 → 0
View file @
ccc5b5ec
##############################################################################
#
# Copyright (c) 2011 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
import
binascii
import
os
import
sys
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'
],
vnc_ip
=
self
.
options
[
'vnc-ip'
],
vnc_port
=
self
.
options
[
'vnc-port'
],
nbd_ip
=
self
.
options
[
'nbd-ip'
],
nbd_port
=
self
.
options
[
'nbd-port'
],
disk_path
=
self
.
options
[
'disk-path'
],
disk_size
=
self
.
options
[
'disk-size'
],
mac_address
=
self
.
options
[
'mac-address'
],
smp_count
=
self
.
options
[
'smp-count'
],
ram_size
=
self
.
options
[
'ram-size'
],
socket_path
=
self
.
options
[
'socket-path'
],
pid_file_path
=
self
.
options
[
'pid-path'
],
python_path
=
sys
.
executable
,
shell_path
=
self
.
options
[
'shell-path'
],
qemu_path
=
self
.
options
[
'qemu-path'
],
qemu_img_path
=
self
.
options
[
'qemu-img-path'
],
# XXX Weak password
vnc_passwd
=
self
.
options
[
'passwd'
]
)
# Runners
runner_path
=
self
.
createExecutable
(
self
.
options
[
'runner-path'
],
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'kvm_run.in'
),
config
))
controller_path
=
self
.
createExecutable
(
self
.
options
[
'controller-path'
],
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'kvm_controller_run.in'
),
config
))
return
[
runner_path
,
controller_path
]
slapos/recipe/kvm/__init__.py
View file @
024f9e12
##############################################################################
#
# Copyright (c) 201
0
Vifib SARL and Contributors. All Rights Reserved.
# Copyright (c) 201
1
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,100 +24,53 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
slapos.recipe.librecipe
import
GenericBaseRecipe
import
binascii
import
os
import
sys
from
slapos.recipe.librecipe
import
BaseSlapRecipe
import
subprocess
import
binascii
import
random
import
zc.buildout
import
pkg_resources
import
ConfigParser
import
hashlib
FALSE_VALUE_LIST
=
[
'n'
,
'no'
,
'0'
,
'false'
]
class
Recipe
(
BaseSlapRecipe
):
# # To avoid magic numbers
# VNC_BASE_PORT = 5900
def
_install
(
self
):
class
Recipe
(
GenericBaseRecipe
):
"""
Set the connection dictionnary for the computer partition and create a list
of paths to the different wrappers
Parameters : none
Returns : List path_list
kvm instance configuration.
"""
self
.
path_list
=
[]
self
.
requirements
,
self
.
ws
=
self
.
egg
.
working_set
()
self
.
cron_d
=
self
.
installCrond
()
self
.
ca_conf
=
self
.
installCertificateAuthority
()
self
.
key_path
,
self
.
certificate_path
=
self
.
requestCertificate
(
'noVNC'
)
def
__init__
(
self
,
buildout
,
name
,
options
):
options
[
'passwd'
]
=
binascii
.
hexlify
(
os
.
urandom
(
4
))
return
GenericBaseRecipe
.
__init__
(
self
,
buildout
,
name
,
options
)
# Install the socket_connection_attempt script
catcher
=
zc
.
buildout
.
easy_install
.
scripts
(
[(
'check_port_listening'
,
'slapos.recipe.kvm.socket_connection_attempt'
,
'connection_attempt'
)],
self
.
ws
,
sys
.
executable
,
self
.
bin_directory
,
)
# Save the check_port_listening script path
check_port_listening_script
=
catcher
[
0
]
# Get the port_listening_promise template path, and save it
self
.
port_listening_promise_path
=
pkg_resources
.
resource_filename
(
__name__
,
'template/port_listening_promise.in'
)
self
.
port_listening_promise_conf
=
dict
(
check_port_listening_script
=
check_port_listening_script
,
def
install
(
self
):
config
=
dict
(
tap_interface
=
self
.
options
[
'tap'
],
vnc_ip
=
self
.
options
[
'vnc-ip'
],
vnc_port
=
self
.
options
[
'vnc-port'
],
nbd_ip
=
self
.
options
[
'nbd-ip'
],
nbd_port
=
self
.
options
[
'nbd-port'
],
disk_path
=
self
.
options
[
'disk-path'
],
disk_size
=
self
.
options
[
'disk-size'
],
mac_address
=
self
.
options
[
'mac-address'
],
smp_count
=
self
.
options
[
'smp-count'
],
ram_size
=
self
.
options
[
'ram-size'
],
socket_path
=
self
.
options
[
'socket-path'
],
pid_file_path
=
self
.
options
[
'pid-path'
],
python_path
=
sys
.
executable
,
shell_path
=
self
.
options
[
'shell-path'
],
qemu_path
=
self
.
options
[
'qemu-path'
],
qemu_img_path
=
self
.
options
[
'qemu-img-path'
],
# XXX Weak password
vnc_passwd
=
self
.
options
[
'passwd'
]
)
vnc_port
=
Recipe
.
VNC_BASE_PORT
+
kvm_conf
[
'vnc_display'
]
# Runners
runner_path
=
self
.
createExecutable
(
self
.
options
[
'runner-path'
],
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'kvm_run.in'
),
config
))
noVNC_conf
=
self
.
installNoVnc
(
source_ip
=
self
.
getGlobalIPv6Address
(),
source_port
=
6080
,
target_ip
=
kvm_conf
[
'vnc_ip'
]
,
target_port
=
vnc_port
)
controller_path
=
self
.
createExecutable
(
self
.
options
[
'controller-path'
]
,
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'kvm_controller_run.in'
)
,
config
)
)
ipv6_url
=
'https://[%s]:%s/vnc_auto.html?host=[%s]&port=%s&encrypt=1'
%
(
noVNC_conf
[
'source_ip'
],
noVNC_conf
[
'source_port'
],
noVNC_conf
[
'source_ip'
],
noVNC_conf
[
'source_port'
])
# Request frontend slave instance, unless contrary is specified
# XXX-Cedric : HARDCODE : during dev, request is OPT-IN
request_frontend
=
self
.
parameter_dict
.
get
(
'frontend'
,
'false'
)
#request_frontend = self.parameter_dict.get('frontend', True)
if
not
request_frontend
in
FALSE_VALUE_LIST
:
slave_frontend
=
self
.
request
(
# XXX-Cedric : Use KVM Software Type to instantiate kvmfrontend.
# kvmfrontend should be in KVM recipe but using different
# software type.
software_release
=
'/opt/slapdev/software/kvm-frontend/software.cfg'
,
software_type
=
'RootSoftwareInstance'
,
partition_reference
=
'frontend'
,
shared
=
True
,
partition_parameter_kw
=
{
"host"
:
noVNC_conf
[
'source_ip'
],
"port"
:
noVNC_conf
[
'source_port'
]}
)
url
=
'%s/vnc_auto.html?host=%s&port=%s&encrypt=1&path=%s'
%
(
slave_frontend
.
getConnectionParameter
(
'site_url'
),
slave_frontend
.
getConnectionParameter
(
'domainname'
),
slave_frontend
.
getConnectionParameter
(
'port'
),
slave_frontend
.
getConnectionParameter
(
'resource'
))
connection_dict
=
dict
(
url
=
url
,
backend_url
=
ipv6_url
,
password
=
kvm_conf
[
'vnc_passwd'
])
else
:
# No frontend : just set raw IPv6
connection_dict
=
dict
(
url
=
ipv6_url
,
password
=
kvm_conf
[
'vnc_passwd'
])
self
.
computer_partition
.
setConnectionDict
(
connection_dict
)
return
[
runner_path
,
controller_path
]
return
self
.
path_list
slapos/recipe/kvm/certificate_authority.py
deleted
100755 → 0
View file @
ccc5b5ec
import
os
import
subprocess
import
time
import
ConfigParser
import
uuid
def
popenCommunicate
(
command_list
,
input
=
None
):
subprocess_kw
=
dict
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
if
input
is
not
None
:
subprocess_kw
.
update
(
stdin
=
subprocess
.
PIPE
)
popen
=
subprocess
.
Popen
(
command_list
,
**
subprocess_kw
)
result
=
popen
.
communicate
(
input
)[
0
]
if
popen
.
returncode
is
None
:
popen
.
kill
()
if
popen
.
returncode
!=
0
:
raise
ValueError
(
'Issue during calling %r, result was:
\
n
%s'
%
(
command_list
,
result
))
return
result
class
CertificateAuthority
:
def
__init__
(
self
,
key
,
certificate
,
openssl_binary
,
openssl_configuration
,
request_dir
):
self
.
key
=
key
self
.
certificate
=
certificate
self
.
openssl_binary
=
openssl_binary
self
.
openssl_configuration
=
openssl_configuration
self
.
request_dir
=
request_dir
def
checkAuthority
(
self
):
file_list
=
[
self
.
key
,
self
.
certificate
]
ca_ready
=
True
for
f
in
file_list
:
if
not
os
.
path
.
exists
(
f
):
ca_ready
=
False
break
if
ca_ready
:
return
for
f
in
file_list
:
if
os
.
path
.
exists
(
f
):
os
.
unlink
(
f
)
try
:
# no CA, let us create new one
popenCommunicate
([
self
.
openssl_binary
,
'req'
,
'-nodes'
,
'-config'
,
self
.
openssl_configuration
,
'-new'
,
'-x509'
,
'-extensions'
,
'v3_ca'
,
'-keyout'
,
self
.
key
,
'-out'
,
self
.
certificate
,
'-days'
,
'10950'
],
# Authority name will be random, so no instance has the same issuer
'Certificate Authority %s
\
n
'
%
uuid
.
uuid1
())
except
:
try
:
for
f
in
file_list
:
if
os
.
path
.
exists
(
f
):
os
.
unlink
(
f
)
except
:
# do not raise during cleanup
pass
raise
def
_checkCertificate
(
self
,
common_name
,
key
,
certificate
):
file_list
=
[
key
,
certificate
]
ready
=
True
for
f
in
file_list
:
if
not
os
.
path
.
exists
(
f
):
ready
=
False
break
if
ready
:
return
False
for
f
in
file_list
:
if
os
.
path
.
exists
(
f
):
os
.
unlink
(
f
)
csr
=
certificate
+
'.csr'
try
:
popenCommunicate
([
self
.
openssl_binary
,
'req'
,
'-config'
,
self
.
openssl_configuration
,
'-nodes'
,
'-new'
,
'-keyout'
,
key
,
'-out'
,
csr
,
'-days'
,
'3650'
],
common_name
+
'
\
n
'
)
try
:
popenCommunicate
([
self
.
openssl_binary
,
'ca'
,
'-batch'
,
'-config'
,
self
.
openssl_configuration
,
'-out'
,
certificate
,
'-infiles'
,
csr
])
finally
:
if
os
.
path
.
exists
(
csr
):
os
.
unlink
(
csr
)
except
:
try
:
for
f
in
file_list
:
if
os
.
path
.
exists
(
f
):
os
.
unlink
(
f
)
except
:
# do not raise during cleanup
pass
raise
else
:
return
True
def
checkRequestDir
(
self
):
for
request_file
in
os
.
listdir
(
self
.
request_dir
):
parser
=
ConfigParser
.
RawConfigParser
()
parser
.
readfp
(
open
(
os
.
path
.
join
(
self
.
request_dir
,
request_file
),
'r'
))
if
self
.
_checkCertificate
(
parser
.
get
(
'certificate'
,
'name'
),
parser
.
get
(
'certificate'
,
'key_file'
),
parser
.
get
(
'certificate'
,
'certificate_file'
)):
print
'Created certificate %r'
%
parser
.
get
(
'certificate'
,
'name'
)
def
runCertificateAuthority
(
args
):
ca_conf
=
args
[
0
]
ca
=
CertificateAuthority
(
ca_conf
[
'key'
],
ca_conf
[
'certificate'
],
ca_conf
[
'openssl_binary'
],
ca_conf
[
'openssl_configuration'
],
ca_conf
[
'request_dir'
])
while
True
:
ca
.
checkAuthority
()
ca
.
checkRequestDir
()
time
.
sleep
(
60
)
slapos/recipe/
generic_
kvm/template/kvm_controller_run.in
→
slapos/recipe/kvm/template/kvm_controller_run.in
View file @
024f9e12
File moved
slapos/recipe/
generic_
kvm/template/kvm_run.in
→
slapos/recipe/kvm/template/kvm_run.in
View file @
024f9e12
File moved
slapos/recipe/kvm/template/openssl.cnf.ca.in
deleted
100644 → 0
View file @
ccc5b5ec
This diff is collapsed.
Click to expand it.
slapos/recipe/kvm/template/slapmonitor_run.in
deleted
100644 → 0
View file @
ccc5b5ec
#!/bin/sh
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
exec
%
(
python_path
)
s %
(
slapmonitor_path
)
s %
(
pid_file_path
)
s %
(
database_path
)
s
slapos/recipe/kvm/template/slapreport_run.in
deleted
100644 → 0
View file @
ccc5b5ec
#!/bin/sh
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
exec
%
(
python_path
)
s %
(
slapreport_path
)
s
$1
%
(
database_path
)
s
software/kvm/instance-kvm.cfg
View file @
024f9e12
...
...
@@ -34,7 +34,7 @@ ca-dir = $${rootdirectory:srv}/ssl
recipe = slapos.cookbook:generate.mac
[kvm-instance]
recipe = slapos.cookbook:
generic.
kvm
recipe = slapos.cookbook:kvm
vnc-ip = $${slap-network-information:local-ipv4}
vnc-port = 5901
nbd-ip = $${slap-parameter:nbd_ip}
...
...
software/kvm/software.cfg
View file @
024f9e12
...
...
@@ -170,7 +170,7 @@ command =
[template-kvm]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-kvm.cfg
md5sum =
351d611fc7c1b210e14e14832c21752c
md5sum =
ce62abe1edabc78a4baa574a39d7faa0
output = ${buildout:directory}/template-kvm.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