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
Stephane VAROQUI
slapos
Commits
aa3e52de
Commit
aa3e52de
authored
Jul 13, 2011
by
Vivien Alger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished refactoring of recipe
parent
35f02dd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
40 deletions
+40
-40
slapos/recipe/kvm/__init__.py
slapos/recipe/kvm/__init__.py
+40
-40
No files found.
slapos/recipe/kvm/__init__.py
View file @
aa3e52de
...
@@ -67,9 +67,12 @@ class Recipe(BaseSlapRecipe):
...
@@ -67,9 +67,12 @@ class Recipe(BaseSlapRecipe):
self
.
linkBinary
()
self
.
linkBinary
()
self
.
computer_partition
.
setConnectionDict
(
dict
(
self
.
computer_partition
.
setConnectionDict
(
dict
(
url
=
"https://[%s]:%s/vnc.html?host=[%s]&port=%s"
%
(
noVNC_conf
[
'source_ip'
],
url
=
"https://[%s]:%s/vnc.html?host=[%s]&port=%s"
%
(
noVNC_conf
[
'source_ip'
],
noVNC_conf
[
'source_port'
],
noVNC_conf
[
'source_ip'
],
noVNC_conf
[
'source_port'
],
noVNC_conf
[
'source_ip'
],
noVNC_conf
[
'source_port'
]
noVNC_conf
[
'source_port'
]
),
password
=
kvm_conf
[
'vnc_passwd'
]))
),
password
=
kvm_conf
[
'vnc_passwd'
]))
return
self
.
path_list
return
self
.
path_list
def
installKvm
(
self
,
vnc_ip
):
def
installKvm
(
self
,
vnc_ip
):
...
@@ -123,7 +126,7 @@ class Recipe(BaseSlapRecipe):
...
@@ -123,7 +126,7 @@ class Recipe(BaseSlapRecipe):
kvm_conf
[
'nbd_port'
]
=
self
.
parameter_dict
[
'nbd_port'
]
kvm_conf
[
'nbd_port'
]
=
self
.
parameter_dict
[
'nbd_port'
]
# First octet has to represent a locally administered address
# First octet has to represent a locally administered address
octet_list
=
[
254
]
+
[
random
.
randint
(
0x00
,
0xff
)
for
x
in
range
(
5
)]
octet_list
=
[
254
]
+
[
random
.
randint
(
0x00
,
0xff
)
for
x
in
range
(
5
)]
kvm_conf
[
'mac_address'
]
=
':'
.
join
([
'%02x'
%
x
for
x
in
octet_list
])
kvm_conf
[
'mac_address'
]
=
':'
.
join
([
'%02x'
%
x
for
x
in
octet_list
])
kvm_conf
[
'hostname'
]
=
"slaposkvm"
kvm_conf
[
'hostname'
]
=
"slaposkvm"
...
@@ -131,14 +134,30 @@ class Recipe(BaseSlapRecipe):
...
@@ -131,14 +134,30 @@ class Recipe(BaseSlapRecipe):
kvm_conf
[
'ram_size'
]
=
self
.
options
[
'ram_size'
]
kvm_conf
[
'ram_size'
]
=
self
.
options
[
'ram_size'
]
kvm_conf
[
'vnc_display'
]
=
1
kvm_conf
[
'vnc_display'
]
=
1
# Instanciate KVM
# Instanciate KVM
kvm_template_location
=
pkg_resources
.
resource_filename
(
kvm_runner_path
=
self
.
instanciate_wrapper
(
"kvm"
,
kvm_conf
)
__name__
,
os
.
path
.
join
(
'template'
,
'kvm_run.in'
))
kvm_runner_path
=
self
.
createRunningWrapper
(
kvm
,
self
.
substituteTemplate
(
wrapper_template_location
,
config_dictionnary
))
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_wrapper
(
"kvm_controller"
,
kvm_controller_template_location
=
pkg_resources
.
resource_filename
(
kvm_conf
)
__name__
,
os
.
path
.
join
(
'template'
,
'kvm_controller_run.in'
))
kvm_controller_runner_path
=
self
.
createRunningWrapper
(
name
,
self
.
substituteTemplate
(
wrapper_template_location
,
config_dictionnary
))
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_wrapper("slapmonitor",
##slapmonitor_runner_path = self.instanciate_wrapper("slapmonitor",
# [database_path, pid_file_path, python_path])
# [database_path, pid_file_path, python_path])
...
@@ -161,49 +180,30 @@ class Recipe(BaseSlapRecipe):
...
@@ -161,49 +180,30 @@ class Recipe(BaseSlapRecipe):
"""
"""
noVNC_conf
=
{}
noVNC_conf
=
{}
noVNC_conf
[
'websockify_path'
]
=
self
.
options
[
'websockify_path'
]
noVNC_conf
[
'noVNC_location'
]
=
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
noVNC_conf
[
'ca_conf'
]
=
self
.
ca_conf
noVNC_conf
[
'key_path'
]
=
self
.
key_path
noVNC_conf
[
'certificate_path'
]
=
self
.
certificate_path
noVNC_conf
[
'source_ip'
]
=
source_ip
noVNC_conf
[
'source_port'
]
=
source_port
# Instanciate Websockify
# Instanciate Websockify
websockify_runner_path
=
zc
.
buildout
.
easy_install
.
scripts
([(
'stunnel'
,
websockify_runner_path
=
zc
.
buildout
.
easy_install
.
scripts
([(
'stunnel'
,
'slapos.recipe.librecipe.execute'
,
'execute_wait'
)],
self
.
ws
,
'slapos.recipe.librecipe.execute'
,
'execute_wait'
)],
self
.
ws
,
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
[
noVNC_conf
[
'python_path'
].
strip
(),
'self.options['
websockify_path
']'
,
'--web'
,
'self.options['
noVNC_location
']'
,
'--key=%s'
%
(
noVNC_conf
[
'key_path'
]),
'--cert=%r'
%
(
noVNC_conf
[
'certificate_path'
]),
'--ssl-only'
,
noVNC_conf
[
'source_ip'
]:
noVNC_conf
[
'source_port'
],
noVNC_conf
[
'target_ip'
]:
noVNC_conf
[
'target_port'
]],
[
python_path
.
strip
(),
self
.
options
[
'websockify_path'
],
'--web'
,
self
.
options
[
'noVNC_location'
],
'--key=%s'
%
(
self
.
key_path
),
'--cert=%s'
%
(
self
.
certificate_path
),
'--ssl-only'
,
'%s:%s'
%
(
source_ip
,
source_port
),
'%s:%s'
%
(
target_ip
,
target_port
)],
[
self
.
certificate_path
,
self
.
key_path
]]
[
self
.
certificate_path
,
self
.
key_path
]]
)[
0
]
)[
0
]
self
.
path_list
.
append
(
websockify_runner_path
)
self
.
path_list
.
append
(
websockify_runner_path
)
return
noVNC_conf
return
noVNC_conf
def
instanciate_wrapper
(
self
,
name
,
config_dictionnary
):
"""
Define the path to the wrapper of the thing you are instanciating
Parameters : name of what you are instanciating, list of arguments for the
configuration dictionnary of the wrapper
Returns : path to the running wrapper
"""
wrapper_template_location
=
pkg_resources
.
resource_filename
(
__name__
,
os
.
path
.
join
(
'template'
,
'%s_run.in'
%
name
))
runner_path
=
self
.
createRunningWrapper
(
name
,
self
.
substituteTemplate
(
wrapper_template_location
,
config_dictionnary
))
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"""
for
linkline
in
self
.
options
.
get
(
'link_binary_list'
,
''
).
splitlines
():
for
linkline
in
self
.
options
.
get
(
'link_binary_list'
,
''
).
splitlines
():
...
...
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