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
Cédric Le Ninivin
slapos
Commits
c44aff58
Commit
c44aff58
authored
Nov 05, 2012
by
Cédric de Saint Martin
Committed by
Marco Mariani
Nov 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement support for second NBD
parent
ecd4b0c6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
17 deletions
+28
-17
slapos/recipe/kvm/__init__.py
slapos/recipe/kvm/__init__.py
+3
-2
slapos/recipe/kvm/template/kvm_run.in
slapos/recipe/kvm/template/kvm_run.in
+19
-13
software/kvm/instance-kvm.cfg.in
software/kvm/instance-kvm.cfg.in
+5
-1
software/kvm/software.cfg
software/kvm/software.cfg
+1
-1
No files found.
slapos/recipe/kvm/__init__.py
View file @
c44aff58
...
...
@@ -45,8 +45,10 @@ class Recipe(GenericBaseRecipe):
tap_interface
=
self
.
options
[
'tap'
],
vnc_ip
=
self
.
options
[
'vnc-ip'
],
vnc_port
=
self
.
options
[
'vnc-port'
],
nbd_ip
=
self
.
options
[
'nbd-
ip
'
],
nbd_ip
=
self
.
options
[
'nbd-
host
'
],
nbd_port
=
self
.
options
[
'nbd-port'
],
nbd2_ip
=
self
.
options
.
get
(
'nbd2-host'
,
''
),
nbd2_port
=
self
.
options
.
get
(
'nbd2-port'
,
1024
),
disk_path
=
self
.
options
[
'disk-path'
],
disk_size
=
self
.
options
[
'disk-size'
],
disk_type
=
self
.
options
[
'disk-type'
],
...
...
@@ -75,4 +77,3 @@ class Recipe(GenericBaseRecipe):
return
[
runner_path
,
controller_path
]
slapos/recipe/kvm/template/kvm_run.in
View file @
c44aff58
...
...
@@ -30,26 +30,32 @@ def getSocketStatus(host, port):
disk_path = '%(disk_path)s'
if not os.path.exists(disk_path):
subprocess.Popen(['%(qemu_img_path)s', 'create' ,'-f', 'qcow2',
'%(disk_path)s'
, '%(disk_size)sG'])
disk_path
, '%(disk_size)sG'])
kvm_argument_list = ['%(qemu_path)s', '-enable-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',
'-drive', 'file=%(disk_path)s,if=%(disk_type)s
,boot=on
',
'-drive', 'file=%(disk_path)s,if=%(disk_type)s',
'-vnc', '%(vnc_ip)s:1,ipv4,password',
'-boot', 'menu=on',
'-qmp', 'unix:%(socket_path)s,server',
'-pidfile', '%(pid_file_path)s',
]
# Try to connect to NBD server
s = getSocketStatus('%(nbd_ip)s', %(nbd_port)s)
if s is None:
# NBD is not available : launch kvm without it
print 'Warning : Nbd is not available.'
os.execv('%(qemu_path)s', kvm_argument_list)
else:
# NBD is available
kvm_argument_list.extend(['-cdrom', 'nbd:[%(nbd_ip)s]:%(nbd_port)s'])
os.execv('%(qemu_path)s', kvm_argument_list)
# Try to connect to NBD server (and second nbd if defined)
for nbd_ip, nbd_port in (
('%(nbd_ip)s', %(nbd_port)s), ('%(nbd2_ip)s', %(nbd2_port)s)):
if nbd_ip and nbd_port:
s = getSocketStatus(nbd_ip, nbd_port)
if s is None:
# NBD is not available : launch kvm without it
print 'Warning : Nbd is not available.'
else:
# NBD is available
kvm_argument_list.extend([
'-drive',
'file=nbd:[%%s]:%%s,media=cdrom' %% (nbd_ip, nbd_port)])
os.execv('%(qemu_path)s', kvm_argument_list)
software/kvm/instance-kvm.cfg.in
View file @
c44aff58
...
...
@@ -45,8 +45,10 @@ bytes = 4
recipe = slapos.cookbook:kvm
vnc-ip = $${slap-network-information:local-ipv4}
vnc-port = 5901
nbd-
ip
= $${slap-parameter:nbd-host}
nbd-
host
= $${slap-parameter:nbd-host}
nbd-port = $${slap-parameter:nbd-port}
nbd2-host = $${slap-parameter:nbd2-host}
nbd2-port = $${slap-parameter:nbd2-port}
tap = $${slap-network-information:network-interface}
disk-path = $${directory:srv}/virtual.qcow2
disk-size = $${slap-parameter:disk-size}
...
...
@@ -168,6 +170,8 @@ frontend-software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/ta
nbd-port = 1024
nbd-host = debian.nbd.vifib.net
nbd2-port = 1024
nbd2-host =
ram-size = 1024
disk-size = 10
...
...
software/kvm/software.cfg
View file @
c44aff58
...
...
@@ -119,7 +119,7 @@ command =
[template-kvm]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-kvm.cfg.in
md5sum =
aefed0723c79f4d4b9ed977b73e4bac5
md5sum =
5607cb6b6af58694d55b87411880d368
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