Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
slapos
Commits
4c2a1939
Commit
4c2a1939
authored
Jul 01, 2011
by
Vivien Alger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polishing of kvm recipe and changes to websockify template
parent
4cae8f81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
26 deletions
+61
-26
slapos/recipe/kvm/__init__.py
slapos/recipe/kvm/__init__.py
+60
-25
slapos/recipe/kvm/template/websockify_run.in
slapos/recipe/kvm/template/websockify_run.in
+1
-1
No files found.
slapos/recipe/kvm/__init__.py
View file @
4c2a1939
...
@@ -30,33 +30,50 @@ from slapos.recipe.librecipe import BaseSlapRecipe
...
@@ -30,33 +30,50 @@ from slapos.recipe.librecipe import BaseSlapRecipe
import
subprocess
import
subprocess
import
binascii
import
binascii
import
random
import
random
import
zc.buildout
import
pkg_resources
import
pkg_resources
class
Recipe
(
BaseSlapRecipe
):
class
Recipe
(
BaseSlapRecipe
):
def
_install
(
self
):
def
_install
(
self
):
"""
Set the connection dictionnary for the computer partition and create a list
of paths to the different wrappers
Parameters : none
Returns : List path_list
"""
self
.
path_list
=
[]
self
.
path_list
=
[]
kvm_conf
=
self
.
installKvm
(
vnc_ip
=
self
.
getLocalIPv4Address
())
kvm_conf
=
self
.
installKvm
(
vnc_ip
=
self
.
getLocalIPv4Address
())
vnc_port
=
5900
+
kvm_conf
[
'vnc_display'
]
vnc_port
=
5900
+
kvm_conf
[
'vnc_display'
]
no
vnc_conf
=
self
.
installNovnc
(
source_ip
=
self
.
getGlobalIPv6Address
(),
no
VNC_conf
=
self
.
installNovnc
(
source_ip
=
self
.
getGlobalIPv6Address
(),
source_port
=
6080
,
source_port
=
6080
,
target_ip
=
kvm_conf
[
'vnc_ip'
],
target_ip
=
kvm_conf
[
'vnc_ip'
],
target_port
=
vnc_port
)
target_port
=
vnc_port
,
python_path
=
kvm_conf
[
'python_path'
])
self
.
linkBinary
()
self
.
linkBinary
()
self
.
computer_partition
.
setConnectionDict
(
dict
(
self
.
computer_partition
.
setConnectionDict
(
dict
(
vnc_connection_string
=
"
vnc://[%s]:%s"
%
(
vnc_port
[
'vnc
_ip'
],
vnc_connection_string
=
"
https://[%s]:%s"
%
(
noVNC_conf
[
'source
_ip'
],
vnc_port
)
,
noVNC_conf
[
'source_port'
]
,
vnc_password
=
vnc_passwd
,
)))
))
return
self
.
path_list
return
self
.
path_list
def
installKvm
(
self
,
vnc_ip
):
def
installKvm
(
self
,
vnc_ip
):
"""
Create kvm configuration dictionnary and instanciate a wrapper for kvm and
kvm controller
Parameters : IP the vnc server is listening on
Returns : Dictionnary kvm_conf
"""
kvm_conf
=
dict
(
vnc_ip
=
vnc_ip
)
kvm_conf
=
dict
(
vnc_ip
=
vnc_ip
)
connection_found
=
False
connection_found
=
False
...
@@ -88,7 +105,7 @@ class Recipe(BaseSlapRecipe):
...
@@ -88,7 +105,7 @@ class Recipe(BaseSlapRecipe):
# Create disk if needed
# Create disk if needed
if
not
os
.
path
.
exists
(
kvm_conf
[
'disk_path'
]):
if
not
os
.
path
.
exists
(
kvm_conf
[
'disk_path'
]):
retcode
=
subprocess
.
call
([
"%s create -f qcow2 %s %iG"
%
(
retcode
=
subprocess
.
call
([
"%s create -f qcow2 %s %iG"
%
(
self
.
options
[
'qemu_img_path'
],
disk_path
,
self
.
options
[
'qemu_img_path'
],
kvm_conf
[
'disk_path'
]
,
int
(
self
.
options
[
'disk_size'
]))],
shell
=
True
)
int
(
self
.
options
[
'disk_size'
]))],
shell
=
True
)
if
retcode
!=
0
:
if
retcode
!=
0
:
raise
OSError
,
"Disk creation failed!"
raise
OSError
,
"Disk creation failed!"
...
@@ -105,31 +122,51 @@ class Recipe(BaseSlapRecipe):
...
@@ -105,31 +122,51 @@ class Recipe(BaseSlapRecipe):
# Instanciate KVM
# Instanciate KVM
kvm_runner_path
=
self
.
instanciate
(
"kvm"
,
kvm_conf
)
kvm_runner_path
=
self
.
instanciate
_wrapper
(
"kvm"
,
kvm_conf
)
self
.
path_list
.
append
(
kvm_runner_path
)
self
.
path_list
.
append
(
kvm_runner_path
)
# Instanciate KVM controller
# Instanciate KVM controller
kvm_controller_runner_path
=
self
.
instanciate
(
"kvm_controller"
,
kvm_conf
)
kvm_controller_runner_path
=
self
.
instanciate_wrapper
(
"kvm_controller"
,
kvm_conf
)
self
.
path_list
.
append
(
kvm_controller_runner_path
)
self
.
path_list
.
append
(
kvm_controller_runner_path
)
# Instanciate Slapmonitor
# Instanciate Slapmonitor
##slapmonitor_runner_path = self.instanciate("slapmonitor",
##slapmonitor_runner_path = self.instanciate
_wrapper
("slapmonitor",
# [database_path, pid_file_path, python_path])
# [database_path, pid_file_path, python_path])
# Instanciate Slapreport
# Instanciate Slapreport
##slapreport_runner_path = self.instanciate("slapreport",
##slapreport_runner_path = self.instanciate
_wrapper
("slapreport",
# [database_path, python_path])
# [database_path, python_path])
kvm_conf
[
'vnc_display'
]
=
1
kvm_conf
[
'vnc_display'
]
=
1
return
kvm_conf
return
kvm_conf
def
installNoVnc
(
self
,
source_ip
,
source_port
,
target_ip
,
target_port
):
def
installNoVnc
(
self
,
source_ip
,
source_port
,
target_ip
,
target_port
,
# Instanciate Websockify
python_path
):
websockify_runner_path
=
self
.
instanciate
(
"websockify"
,
"""
[
python_path
,
vnc_ip
,
proxy_ip
,
vnc_port
,
proxy_port
])
Create noVNC configuration dictionnary and instanciate Websockify proxy
self
.
path_list
.
append
(
websockify_runner_path
)
Parameters : IP of the proxy, port on which is situated the proxy,
IP of the vnc server, port on which is situated the vnc server,
path to python binary
Returns : nothing
"""
noVNC_conf
=
{}
noVNC_conf
.
append
(
self
.
options
[
'websockify_path'
])
noVNC_conf
.
append
(
self
.
options
[
'noVNC_location'
])
noVNC_conf
[
'source_ip'
]
=
source_ip
noVNC_conf
[
'source_port'
]
=
source_port
noVNC_conf
[
'target_ip'
]
=
target_ip
noVNC_conf
[
'target_port'
]
=
target_port
noVNC_conf
[
'python_path'
]
=
python_path
# Instanciate Websockify
websockify_runner_path
=
self
.
instanciate_wrapper
(
"websockify"
,
noVNC_conf
)
self
.
path_list
.
append
(
websockify_runner_path
)
return
noVNC_conf
def
instanciate_Wrapper
(
self
,
name
,
config_dictionnary
):
def
instanciate_wrapper
(
self
,
name
,
config_dictionnary
):
"""
"""
Define the path to the wrapper of the thing you are instanciating
Define the path to the wrapper of the thing you are instanciating
...
@@ -143,14 +180,14 @@ class Recipe(BaseSlapRecipe):
...
@@ -143,14 +180,14 @@ class Recipe(BaseSlapRecipe):
config_dictionnary
.
update
(
self
.
options
)
config_dictionnary
.
update
(
self
.
options
)
wrapper_template_location
=
pkg_resources
.
resource_filename
(
wrapper_template_location
=
pkg_resources
.
resource_filename
(
__name__
,
os
.
path
.
join
(
__name__
,
os
.
path
.
join
(
'template'
,
'name_run.in'
))
'template'
,
'name_run.in'
))
runner_path
=
self
.
createRunningWrapper
(
name
,
runner_path
=
self
.
createRunningWrapper
(
name
,
self
.
substituteTemplate
(
wrapper_template_location
,
config_dictionnary
))
self
.
substituteTemplate
(
wrapper_template_location
,
config_dictionnary
))
return
name_
runner_path
return
runner_path
def
linkBinary
(
self
):
def
linkBinary
(
self
):
"""Links binaries to instance's bin directory for easier exposal"""
"""Links binaries to instance's bin directory for easier exposal"""
...
@@ -173,5 +210,3 @@ class Recipe(BaseSlapRecipe):
...
@@ -173,5 +210,3 @@ class Recipe(BaseSlapRecipe):
os
.
symlink
(
target
,
link
)
os
.
symlink
(
target
,
link
)
self
.
logger
.
debug
(
'Created link %r -> %r'
%
(
link
,
target
))
self
.
logger
.
debug
(
'Created link %r -> %r'
%
(
link
,
target
))
self
.
path_list
.
append
(
link
)
self
.
path_list
.
append
(
link
)
return
runner_path
slapos/recipe/kvm/template/websockify_run.in
View file @
4c2a1939
...
@@ -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
%
(
python_path
)
s %
(
websockify_path
)
s
--web
%
(
noVNC_location
)
s
--ssl-only
%
(
proxy_ip
)
s:%
(
proxy_port
)
s %
(
vnc_ip
)
s:%
(
vnc_port
)
s
%
(
python_path
)
s %
(
websockify_path
)
s
--web
%
(
noVNC_location
)
s
--ssl-only
%
(
source_ip
)
s:%
(
source_port
)
s %
(
target_ip
)
s:%
(
target_port
)
s
\ No newline at end of file
\ 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