1 ##############################################################################
3 # Copyright (c) 2011 Vifib SARL and Contributors. All Rights Reserved.
5 # WARNING: This program as such is intended to be used by professional
6 # programmers who take the whole responsibility of assessing all potential
7 # consequences resulting from its eventual inadequacies and bugs
8 # End users who are looking for a ready-to-use solution with commercial
9 # guarantees and support are strongly adviced to contract a Free Software
12 # This program is Free Software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 3
15 # of the License, or (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ##############################################################################
27 from slapos
.recipe
.librecipe
import GenericBaseRecipe
31 class Recipe(GenericBaseRecipe
):
33 kvm instance configuration.
36 # Sanitize drive type parameter
37 self
.options
.setdefault('disk-type', 'virtio')
38 if not self
.options
.get('disk-type') in ['ide', 'scsi', 'sd',
39 'mtd', 'floppy', 'pflash', 'virtio']:
40 print 'Warning: "disk-type" parameter is not in allowed values. Using ' \
42 self
.options
['disk-type'] = 'virtio'
44 self
.options
['python-path'] = sys
.executable
48 if not self
.isTrueValue(self
.options
.get('use-tap')):
49 # XXX This could be done using Jinja.
50 for port
in self
.options
['nat-rules'].split():
51 ipv6_port
= int(port
) + 10000
52 tunnel_path
= self
.createExecutable(
53 '%s-%sto%s' %
(self
.options
['6tunnel-wrapper-path'], port
, ipv6_port
),
54 self
.substituteTemplate(
55 self
.getTemplateFilename('6to4.in'),
57 'ipv6': self
.options
['ipv6'],
58 'ipv6_port': ipv6_port
,
59 'ipv4': self
.options
['ipv4'],
61 'shell_path': self
.options
['shell-path'],
62 '6tunnel_path': self
.options
['6tunnel-path'],
66 path_list
.append(tunnel_path
)
68 runner_path
= self
.createExecutable(
69 self
.options
['runner-path'],
70 self
.substituteTemplate(self
.getTemplateFilename('kvm_run.in'),
72 path_list
.append(runner_path
)
74 controller_path
= self
.createExecutable(
75 self
.options
['controller-path'],
76 self
.substituteTemplate(self
.getTemplateFilename('kvm_controller_run.in'),