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
b3a54ad4
Commit
b3a54ad4
authored
Nov 05, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement support for second NBD
parent
6e8f0861
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 @
b3a54ad4
...
@@ -45,8 +45,10 @@ class Recipe(GenericBaseRecipe):
...
@@ -45,8 +45,10 @@ class Recipe(GenericBaseRecipe):
tap_interface
=
self
.
options
[
'tap'
],
tap_interface
=
self
.
options
[
'tap'
],
vnc_ip
=
self
.
options
[
'vnc-ip'
],
vnc_ip
=
self
.
options
[
'vnc-ip'
],
vnc_port
=
self
.
options
[
'vnc-port'
],
vnc_port
=
self
.
options
[
'vnc-port'
],
nbd_ip
=
self
.
options
[
'nbd-
ip
'
],
nbd_ip
=
self
.
options
[
'nbd-
host
'
],
nbd_port
=
self
.
options
[
'nbd-port'
],
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_path
=
self
.
options
[
'disk-path'
],
disk_size
=
self
.
options
[
'disk-size'
],
disk_size
=
self
.
options
[
'disk-size'
],
disk_type
=
self
.
options
[
'disk-type'
],
disk_type
=
self
.
options
[
'disk-type'
],
...
@@ -75,4 +77,3 @@ class Recipe(GenericBaseRecipe):
...
@@ -75,4 +77,3 @@ class Recipe(GenericBaseRecipe):
return
[
runner_path
,
controller_path
]
return
[
runner_path
,
controller_path
]
slapos/recipe/kvm/template/kvm_run.in
View file @
b3a54ad4
...
@@ -30,26 +30,32 @@ def getSocketStatus(host, port):
...
@@ -30,26 +30,32 @@ def getSocketStatus(host, port):
disk_path = '%(disk_path)s'
disk_path = '%(disk_path)s'
if not os.path.exists(disk_path):
if not os.path.exists(disk_path):
subprocess.Popen(['%(qemu_img_path)s', 'create' ,'-f', 'qcow2',
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',
'-net', 'tap,ifname=%(tap_interface)s,script=no,downscript=no',
'-smp', '%(smp_count)s',
'-smp', '%(smp_count)s',
'-m', '%(ram_size)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',
'-vnc', '%(vnc_ip)s:1,ipv4,password',
'-boot', 'menu=on',
'-boot', 'menu=on',
'-qmp', 'unix:%(socket_path)s,server',
'-qmp', 'unix:%(socket_path)s,server',
'-pidfile', '%(pid_file_path)s',
'-pidfile', '%(pid_file_path)s',
]
]
# Try to connect to NBD server
# Try to connect to NBD server (and second nbd if defined)
s = getSocketStatus('%(nbd_ip)s', %(nbd_port)s)
for nbd_ip, nbd_port in (
if s is None:
('%(nbd_ip)s', %(nbd_port)s), ('%(nbd2_ip)s', %(nbd2_port)s)):
# NBD is not available : launch kvm without it
if nbd_ip and nbd_port:
print 'Warning : Nbd is not available.'
s = getSocketStatus(nbd_ip, nbd_port)
os.execv('%(qemu_path)s', kvm_argument_list)
if s is None:
else:
# NBD is not available : launch kvm without it
# NBD is available
print 'Warning : Nbd is not available.'
kvm_argument_list.extend(['-cdrom', 'nbd:[%(nbd_ip)s]:%(nbd_port)s'])
else:
os.execv('%(qemu_path)s', kvm_argument_list)
# 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 @
b3a54ad4
...
@@ -45,8 +45,10 @@ bytes = 4
...
@@ -45,8 +45,10 @@ bytes = 4
recipe = slapos.cookbook:kvm
recipe = slapos.cookbook:kvm
vnc-ip = $${slap-network-information:local-ipv4}
vnc-ip = $${slap-network-information:local-ipv4}
vnc-port = 5901
vnc-port = 5901
nbd-
ip
= $${slap-parameter:nbd-host}
nbd-
host
= $${slap-parameter:nbd-host}
nbd-port = $${slap-parameter:nbd-port}
nbd-port = $${slap-parameter:nbd-port}
nbd2-host = $${slap-parameter:nbd2-host}
nbd2-port = $${slap-parameter:nbd2-port}
tap = $${slap-network-information:network-interface}
tap = $${slap-network-information:network-interface}
disk-path = $${directory:srv}/virtual.qcow2
disk-path = $${directory:srv}/virtual.qcow2
disk-size = $${slap-parameter:disk-size}
disk-size = $${slap-parameter:disk-size}
...
@@ -168,6 +170,8 @@ frontend-software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/ta
...
@@ -168,6 +170,8 @@ frontend-software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/ta
nbd-port = 1024
nbd-port = 1024
nbd-host = debian.nbd.vifib.net
nbd-host = debian.nbd.vifib.net
nbd2-port = 1024
nbd2-host =
ram-size = 1024
ram-size = 1024
disk-size = 10
disk-size = 10
...
...
software/kvm/software.cfg
View file @
b3a54ad4
...
@@ -119,7 +119,7 @@ command =
...
@@ -119,7 +119,7 @@ command =
[template-kvm]
[template-kvm]
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-kvm.cfg.in
url = ${:_profile_base_location_}/instance-kvm.cfg.in
md5sum =
aefed0723c79f4d4b9ed977b73e4bac5
md5sum =
5607cb6b6af58694d55b87411880d368
output = ${buildout:directory}/template-kvm.cfg
output = ${buildout:directory}/template-kvm.cfg
mode = 0644
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