Merge lp:~nuclearbob/utah/config-changes into lp:utah
- config-changes
- Merge into dev
Status: | Merged |
---|---|
Merged at revision: | 739 |
Proposed branch: | lp:~nuclearbob/utah/config-changes |
Merge into: | lp:utah |
Diff against target: |
560 lines (+185/-64) 11 files modified
conf/utah/uqt-vm-tools.conf (+1/-1) examples/run_install_test.py (+2/-2) examples/run_test_bamboo_feeder.py (+1/-2) examples/run_test_cobbler.py (+1/-2) examples/run_test_vm.py (+1/-2) examples/run_utah_tests.py (+8/-4) utah/config.py (+122/-12) utah/provisioning/baremetal/bamboofeeder.py (+3/-3) utah/provisioning/baremetal/cobbler.py (+3/-4) utah/provisioning/provisioning.py (+30/-11) utah/provisioning/vm/libvirtvm.py (+13/-21) |
To merge this branch: | bzr merge lp:~nuclearbob/utah/config-changes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Joe Talbott (community) | Approve | ||
Max Brustkern (community) | Needs Resubmitting | ||
Review via email: mp+133347@code.launchpad.net |
Commit message
Description of the change
This branch implements several changes to the config interface.
Config directories are now supported, and all files within those (with size > 0) will be processed as json files. If a file that is a file (according to os.path.isfile) and has size > 0 doesn't parse as JSON, an exception will be raised with the filename. Files/directories are processed in this order:
/etc/utah/config
/etc/utah/conf.d
~/.utah/config
~/.utah/conf.d
$UTAH_CONFIF_FILE
$UTAH_CONFIF_DIR
Currently, files that are actually directories will be processed correctly, and vice versa. I'm not sure if we should support that or not.
Additionally, most options available via the command line interface can now be supplied via the config file. These include:
machinetype
emulator
image
kernel
initrd
preseed
boot
xml
gigabytes (supported as disksizes, which should be a list)
series
type
arch
debug (by setting the default log level or the debug log file)
diskbus
Currently unsupported options are:
variant (nothing actually uses this yet)
no-destroy (we've talked about reworking this anyway, so I'd rather support it then)
json (this will be changed or removed soon anyway, and didn't affect the actual provisioner, just the test runner)
name (not all provisioning types currently support this, so I'd prefer to add this support later)
One current caveat is that the "which provisioning method do I run?" stuff hasn't been updated to detect whether preseed, image, etc. was passed in a config file and hand off to CustomVM instead of VMToolsVM appropriately. If that's important immediately, I can add it now, otherwise, I'm already working on the "automatically download an image and install it using CustomVM" branch, at which point CustomVM would be the default for all VM installations. Since vm-tools is probably not going to be maintained now that uvt exists, I think depracating the VMTools provisioner would be wise once we have auto-downloading in place. If we want to add a new one for uvt, we can do that.
Javier Collado (javier.collado) wrote : | # |
It would be really nice to have some documentation in config.py for each configuration variable.
Looking at them, isn't really obvious what they're supposed to be used for.
I also agree with Joe's comment. However, since uqt-vm-tools.conf isn't a python file, we can still keep that as it is for now. Adding a comment wherever SERIES_CHOICES is defined to remind us to keep vm_release_list in sync would be nice to have though.
- 752. By Max Brustkern
-
Implemented serieschoices and cleaned up long lines
- 753. By Max Brustkern
-
Changed default install type to mini to save download time/disk space
- 754. By Max Brustkern
-
Added comments
Max Brustkern (nuclearbob) wrote : | # |
I pushed a new branch that should address those, and also change the default install type to mini to save download time and disk space for people who don't care what type of install they're using.
As far as vm_release_list is concerned, I'd like to deprecate the vmtools integration soon. I'm testing the automatic iso downloading stuff now, and I'll propose a merge once it all looks good, probably later today.
Joe Talbott (joetalbott) wrote : | # |
Looks good to me. Merge away.
Preview Diff
1 | === modified file 'conf/utah/uqt-vm-tools.conf' |
2 | --- conf/utah/uqt-vm-tools.conf 2012-07-11 17:43:36 +0000 |
3 | +++ conf/utah/uqt-vm-tools.conf 2012-11-08 15:07:21 +0000 |
4 | @@ -1,5 +1,5 @@ |
5 | # list of all active releases (included devel) |
6 | -vm_release_list="hardy lucid natty oneiric precise quantal" |
7 | +vm_release_list="hardy lucid oneiric precise quantal raring" |
8 | |
9 | # used by vm-repo (ie 'umt repo' puts stuff in /var/www/debs/testing/..., so |
10 | # vm_repo_url should be the URL to those files. The IP of the host is by |
11 | |
12 | === modified file 'examples/run_install_test.py' |
13 | --- examples/run_install_test.py 2012-10-19 21:57:01 +0000 |
14 | +++ examples/run_install_test.py 2012-11-08 15:07:21 +0000 |
15 | @@ -3,6 +3,7 @@ |
16 | import argparse |
17 | import sys |
18 | |
19 | +from utah import config |
20 | from utah.exceptions import UTAHException |
21 | from utah.url import url_argument |
22 | from utah.group import check_user_group, print_group_error_message |
23 | @@ -46,8 +47,7 @@ |
24 | help=('Size in gigabytes of virtual disk, ' |
25 | 'specify more than once for multiple disks')) |
26 | parser.add_argument('-s', '--series', metavar='SERIES', |
27 | - choices=('hardy', 'lucid', 'natty', |
28 | - 'oneiric', 'precise', 'quantal'), |
29 | + choices=config.serieschoices, |
30 | help='Series to use for installation (%(choices)s)') |
31 | parser.add_argument('-t', '--type', metavar='TYPE', |
32 | choices=('desktop', 'server', 'mini', 'alternate'), |
33 | |
34 | === modified file 'examples/run_test_bamboo_feeder.py' |
35 | --- examples/run_test_bamboo_feeder.py 2012-10-19 13:02:44 +0000 |
36 | +++ examples/run_test_bamboo_feeder.py 2012-11-08 15:07:21 +0000 |
37 | @@ -26,8 +26,7 @@ |
38 | parser.add_argument('runlists', metavar='runlist', nargs='+', |
39 | help='URLs of runlist files to run') |
40 | parser.add_argument('-s', '--series', metavar='SERIES', |
41 | - choices=('hardy', 'lucid', 'natty', |
42 | - 'oneiric', 'precise', 'quantal'), |
43 | + choices=config.serieschoices, |
44 | help='Series to use for VM creation (%(choices)s)') |
45 | parser.add_argument('-t', '--type', metavar='TYPE', |
46 | choices=('desktop', 'server', 'mini', 'alternate'), |
47 | |
48 | === modified file 'examples/run_test_cobbler.py' |
49 | --- examples/run_test_cobbler.py 2012-10-31 11:27:40 +0000 |
50 | +++ examples/run_test_cobbler.py 2012-11-08 15:07:21 +0000 |
51 | @@ -29,8 +29,7 @@ |
52 | parser.add_argument('-p', '--preseed', type=url_argument, |
53 | help='Preseed file to use for installation') |
54 | parser.add_argument('-s', '--series', metavar='SERIES', |
55 | - choices=('hardy', 'lucid', 'natty', |
56 | - 'oneiric', 'precise', 'quantal'), |
57 | + choices=config.serieschoices, |
58 | help='Series to use for VM creation (%(choices)s)') |
59 | parser.add_argument('-t', '--type', metavar='TYPE', |
60 | choices=('desktop', 'server', 'mini', 'alternate'), |
61 | |
62 | === modified file 'examples/run_test_vm.py' |
63 | --- examples/run_test_vm.py 2012-10-18 14:35:42 +0000 |
64 | +++ examples/run_test_vm.py 2012-11-08 15:07:21 +0000 |
65 | @@ -23,8 +23,7 @@ |
66 | parser.add_argument('runlists', metavar='runlist', nargs='+', |
67 | help='URLs of runlist files to run') |
68 | parser.add_argument('-s', '--series', metavar='SERIES', |
69 | - choices=('hardy', 'lucid', 'natty', |
70 | - 'oneiric', 'precise', 'quantal'), |
71 | + choices=config.serieschoices, |
72 | help='Series to use for VM creation (%(choices)s)') |
73 | parser.add_argument('-t', '--type', metavar='TYPE', |
74 | choices=('desktop', 'server', 'mini', 'alternate'), |
75 | |
76 | === modified file 'examples/run_utah_tests.py' |
77 | --- examples/run_utah_tests.py 2012-10-19 21:57:01 +0000 |
78 | +++ examples/run_utah_tests.py 2012-11-08 15:07:21 +0000 |
79 | @@ -26,7 +26,7 @@ |
80 | parser.add_argument('runlists', metavar='runlist', nargs='+', |
81 | type=url_argument, help='URLs of runlist files to run') |
82 | parser.add_argument('-m', '--machinetype', metavar='MACHINETYPE', |
83 | - choices=('physical', 'virtual'), default='virtual', |
84 | + choices=('physical', 'virtual'), |
85 | help='Type of machine to provision (%(choices)s)') |
86 | parser.add_argument('-e', '--emulator', |
87 | help=('Emulator to use (kvm and qemu are supported, ' |
88 | @@ -47,8 +47,7 @@ |
89 | help=('Size in gigabytes of virtual disk, ' |
90 | 'specify more than once for multiple disks')) |
91 | parser.add_argument('-s', '--series', metavar='SERIES', |
92 | - choices=('hardy', 'lucid', 'natty', |
93 | - 'oneiric', 'precise', 'quantal'), |
94 | + choices=config.serieschoices, |
95 | help='Series to use for installation (%(choices)s)') |
96 | parser.add_argument('-t', '--type', metavar='TYPE', |
97 | choices=('desktop', 'server', 'mini', 'alternate'), |
98 | @@ -87,10 +86,15 @@ |
99 | if args is None: |
100 | args = get_parser().parse_args() |
101 | |
102 | + if args.machinetype is None: |
103 | + machinetype = config.machinetype |
104 | + else: |
105 | + machinetype = args.machinetype |
106 | + |
107 | if args.arch is not None and 'arm' in args.arch: |
108 | from run_test_bamboo_feeder import run_test_bamboo_feeder |
109 | function = run_test_bamboo_feeder |
110 | - elif args.machinetype == 'physical': |
111 | + elif machinetype == 'physical': |
112 | from run_test_cobbler import run_test_cobbler |
113 | function = run_test_cobbler |
114 | else: |
115 | |
116 | === modified file 'utah/config.py' |
117 | --- utah/config.py 2012-11-06 16:47:07 +0000 |
118 | +++ utah/config.py 2012-11-08 15:07:21 +0000 |
119 | @@ -12,6 +12,8 @@ |
120 | import socket |
121 | import subprocess |
122 | |
123 | +from utah.exceptions import UTAHException |
124 | + |
125 | |
126 | def getbridge(): |
127 | """ |
128 | @@ -26,71 +28,178 @@ |
129 | return 'virbr0' |
130 | |
131 | DEFAULTS = dict( |
132 | - arch='i386', |
133 | + # Default kernel parameters |
134 | + boot=None, |
135 | + # Time to wait for installed system to boot |
136 | boottimeout=90, |
137 | + # Time to wait between checking if system is available over ssh |
138 | checktimeout=15, |
139 | + # Default log level to print to the console |
140 | consoleloglevel=logging.WARNING, |
141 | + # Default debug setting |
142 | debug=False, |
143 | + # Default diskbus for VMs |
144 | + diskbus='virtio', |
145 | + # Default disk size list for VMs (in GB) |
146 | + disksizes=[8], |
147 | + # Default emulator for VMs |
148 | + # If None, kvm will be used if available, otherwise qemu |
149 | + emulator=None, |
150 | + # Default log level to write to log file |
151 | fileloglevel=logging.INFO, |
152 | + # Group for file ownership and permissions |
153 | group='utah', |
154 | + # Default image to use for system installation |
155 | image=None, |
156 | + # Default initrd to use for system installation |
157 | initrd=None, |
158 | + # Packages to install on system |
159 | installpackages=['openssh-server', 'gdebi'], |
160 | + # Time limit for overall install process |
161 | installtimeout=3600, |
162 | - installtype='desktop', |
163 | + # Default install type (mini is default to save bandwidth and space) |
164 | + installtype='mini', |
165 | + # Default kernel for installation |
166 | kernel=None, |
167 | + # Default location of log directory |
168 | logpath=os.path.join('/', 'var', 'log', 'utah'), |
169 | + # Default machine ID |
170 | machineid=None, |
171 | + # Default machine type |
172 | + machinetype='virtual', |
173 | + # Default machine name |
174 | name=None, |
175 | + # Default setting of installing a new machine vs. using an existing one |
176 | new=False, |
177 | - nfscommand=['sudo', os.path.join('/', 'etc', 'init.d', 'nfs-kernel-server'), 'reload'], |
178 | + # Command to reload NFS configuration |
179 | + # NFS options currently only used for cobbler-based desktop installs |
180 | + nfscommand=['sudo', os.path.join('/', 'etc', 'init.d', |
181 | + 'nfs-kernel-server'), 'reload'], |
182 | + # Path to NFS config file |
183 | nfsconfigfile=os.path.join('/', 'etc', 'exports'), |
184 | + # Default options for NFS shares |
185 | nfsoptions='*(ro,async,no_root_squash,no_subtree_check)', |
186 | + # Time to wait between power off and power on for physical systems |
187 | powertimeout=15, |
188 | - preseed=None, |
189 | + # Default preseed |
190 | + preseed=os.path.join('/', 'etc', 'utah', 'default-preseed.cfg'), |
191 | + # Location of PXE configuration files |
192 | pxedir=os.path.join('/', 'var', 'lib', 'tftpboot', 'pxelinux.cfg'), |
193 | + # libvirt URL for virtual machine creation |
194 | qemupath='qemu:///system', |
195 | + # Default setting for configuration rewriting |
196 | rewrite='all', |
197 | - series='precise', |
198 | + # Available releases |
199 | + serieschoices=[ # Remember to update uqt-vm-tools.conf as well |
200 | + 'hardy', |
201 | + 'lucid', |
202 | + 'oneiric', |
203 | + 'precise', |
204 | + 'quantal', |
205 | + 'raring', |
206 | + ], |
207 | + # Default machine template |
208 | template=None, |
209 | + # Directory to hold web-accessible files |
210 | wwwdir=os.path.join('/', 'var', 'www', 'utah'), |
211 | + # Default VM XML file |
212 | + xml=os.path.join('/', 'etc', 'utah', 'default-vm.xml'), |
213 | ) |
214 | |
215 | # These depend on the local user/path, and need to be filtered out |
216 | # of the config file created at package build time. |
217 | LOCALDEFAULTS = dict( |
218 | + # Default network bridge for machines |
219 | bridge=getbridge(), |
220 | + # Hostname (used for logfile among other things) |
221 | hostname=socket.gethostname(), |
222 | + # SSH private key to use for provisioned machine logins |
223 | sshprivatekey=os.path.join(os.path.expanduser('~'), '.ssh', 'utah'), |
224 | + # SSH public key to install on provisioned machines |
225 | sshpublickey=os.path.join(os.path.expanduser('~'), '.ssh', 'utah.pub'), |
226 | - sshknownhosts=os.path.join(os.path.expanduser('~'), '.ssh', 'known_hosts'), |
227 | + # SSH known hosts file |
228 | + sshknownhosts=os.path.join(os.path.expanduser('~'), '.ssh', |
229 | + 'known_hosts'), |
230 | + # User to install and use on provisioned machines |
231 | user=getpass.getuser(), |
232 | + # Path for VM files |
233 | vmpath=os.path.join(os.path.expanduser('~'), 'vm'), |
234 | ) |
235 | |
236 | # These depend on other config options, so they're added last. |
237 | +# Default logfile is /var/log/utah/{hostname}.log |
238 | LOCALDEFAULTS['logfile'] = os.path.join(DEFAULTS['logpath'], |
239 | LOCALDEFAULTS['hostname'] + '.log') |
240 | +# Default logfile is /var/log/utah/{hostname}-debug.log |
241 | +# Set to None to disable separate debug log |
242 | LOCALDEFAULTS['debuglog'] = os.path.join(DEFAULTS['logpath'], |
243 | LOCALDEFAULTS['hostname'] + '-debug.log') |
244 | |
245 | +# This depends on a binary that may not be installed. |
246 | +# Also, the null thing may seem obvious, but I found it here: |
247 | +# http://stackoverflow.com/questions/699325/ |
248 | +# suppress-output-in-python-calls-to-executables |
249 | +with open(os.devnull, 'w') as fnull: |
250 | + if subprocess.call(['which', 'dpkg-architecture'], |
251 | + stdout=fnull, stderr=fnull) == 0: |
252 | + # If dpkg-architecture is available, default to current host arch |
253 | + LOCALDEFAULTS['arch'] = subprocess.check_output( |
254 | + ['dpkg-architecture', '-qDEB_HOST_ARCH']).strip() |
255 | + else: |
256 | + # Otherwise, default to i386 |
257 | + LOCALDEFAULTS['arch'] = 'i386' |
258 | + |
259 | +# I'm not sure lsb_release is always around |
260 | +with open(os.devnull, 'w') as fnull: |
261 | + if subprocess.call(['which', 'lsb_release'], |
262 | + stdout=fnull, stderr=fnull) == 0: |
263 | + # If lsb_release is available, default to current series |
264 | + LOCALDEFAULTS['series'] = subprocess.check_output( |
265 | + ['lsb_release', '-sc']).strip() |
266 | + else: |
267 | + # Otherwise, default to precise |
268 | + LOCALDEFAULTS['series'] = 'precise' |
269 | + |
270 | DEFAULTS.update(LOCALDEFAULTS) |
271 | |
272 | CONFIG = {} |
273 | CONFIG.update(DEFAULTS) |
274 | |
275 | # Process config files. |
276 | -files = ['/etc/utah/config', '~/.utah/config', os.getenv('UTAH_CONFIG_FILE')] |
277 | +# First, the standard /etc/utah/config file is processed |
278 | +# Second, anything in /etc/utah/conf.d |
279 | +# Third, any existing ~/.utah/config file |
280 | +# Fourth, anything in ~/.utah/conf.d |
281 | +# Fifth, a file referred to by UTAH_CONFIG_FILE |
282 | +# Sixth, anything in UTAH_CONFIG_DIR |
283 | +# Technically, all files will process as directories, and vice versa |
284 | +files = [] |
285 | +paths = ['/etc/utah/config', '/etc/utah/conf.d', '~/.utah/config', |
286 | + '~/.utah/conf.d', os.getenv('UTAH_CONFIG_FILE'), |
287 | + os.getenv('UTAH_CONFIG_DIR')] |
288 | +for path in paths: |
289 | + if path is not None: |
290 | + abspath = os.path.expanduser(path) |
291 | + if os.path.isfile(abspath): |
292 | + files.append(abspath) |
293 | + elif os.path.isdir(abspath): |
294 | + for walkdir, _dirs, walkfiles in os.walk(abspath): |
295 | + for walkfile in walkfiles: |
296 | + files.append(os.path.join(abspath, walkdir, walkfile)) |
297 | for conffile in files: |
298 | - if conffile is not None: |
299 | - myfile = os.path.expanduser(conffile) |
300 | - if os.path.isfile(myfile) and os.path.getsize(myfile) > 0: |
301 | - with open(myfile) as fp: |
302 | + if os.path.isfile(conffile) and os.path.getsize(conffile) > 0: |
303 | + with open(conffile) as fp: |
304 | + try: |
305 | CONFIG.update(json.load(fp)) |
306 | - |
307 | + except ValueError: |
308 | + raise UTAHException(conffile + ' is not a valid JSON file') |
309 | + |
310 | + |
311 | +# Allow variables to be accessed via config.variable |
312 | locals().update(CONFIG) |
313 | |
314 | |
315 | +# Dump the default values to create a configuration file |
316 | def dumpdefaults(build=False): |
317 | if build: |
318 | # Remove user and path dependent items so they won't get set on the |
319 | @@ -100,6 +209,7 @@ |
320 | return json.dumps(DEFAULTS, sort_keys=True, indent=4) |
321 | |
322 | |
323 | +# Dump all config values |
324 | def dumpconfig(): |
325 | return json.dumps(CONFIG, sort_keys=True, indent=4) |
326 | |
327 | |
328 | === modified file 'utah/provisioning/baremetal/bamboofeeder.py' |
329 | --- utah/provisioning/baremetal/bamboofeeder.py 2012-10-19 21:05:04 +0000 |
330 | +++ utah/provisioning/baremetal/bamboofeeder.py 2012-11-08 15:07:21 +0000 |
331 | @@ -24,8 +24,8 @@ |
332 | """ |
333 | Provide a class to provision an ARM board from a bamboo-feeder setup. |
334 | """ |
335 | - def __init__(self, boot=None, cargs=None, inventory=None, |
336 | - name=None, powercmd=None, preboot=None, *args, **kw): |
337 | + def __init__(self, cargs=None, inventory=None, name=None, powercmd=None, |
338 | + preboot=None, *args, **kw): |
339 | # TODO: change the name of cargs here and elsewhere |
340 | # TODO: respect rewrite setting |
341 | if name is None: |
342 | @@ -174,7 +174,7 @@ |
343 | Add the needed options to the command line for an automatic install. |
344 | """ |
345 | if boot is None: |
346 | - boot = '' |
347 | + boot = self.boot |
348 | super(BambooFeederMachine, self)._cmdlinesetup(boot=boot) |
349 | # TODO: minimize these |
350 | for option in ('auto', 'ro', 'text'): |
351 | |
352 | === modified file 'utah/provisioning/baremetal/cobbler.py' |
353 | --- utah/provisioning/baremetal/cobbler.py 2012-10-29 11:26:22 +0000 |
354 | +++ utah/provisioning/baremetal/cobbler.py 2012-11-08 15:07:21 +0000 |
355 | @@ -24,8 +24,8 @@ |
356 | Provide a class to provision a machine via cobbler. |
357 | """ |
358 | # TODO: may need to fix DHCP/hostname issues, may just be magners |
359 | - def __init__(self, boot=None, cargs=None, inventory=None, |
360 | - name=None, preseed=None, *args, **kw): |
361 | + def __init__(self, cargs=None, inventory=None, name=None, preseed=None, |
362 | + *args, **kw): |
363 | if name is None: |
364 | raise UTAHBMProvisioningException( |
365 | 'Machine name reqired for cobbler machine') |
366 | @@ -42,8 +42,7 @@ |
367 | if self.image is None: |
368 | raise UTAHBMProvisioningException( |
369 | 'Image file required for cobbler installation') |
370 | - self._custominit(arch=self.arch, boot=boot, |
371 | - installtype=self.installtype, series=self.series) |
372 | + self._custominit() |
373 | # TODO: verify we have nfs support for desktop image |
374 | |
375 | # TODO: Rework cinitrd to be less of a confusing collection of kludges |
376 | |
377 | === modified file 'utah/provisioning/provisioning.py' |
378 | --- utah/provisioning/provisioning.py 2012-10-25 20:07:44 +0000 |
379 | +++ utah/provisioning/provisioning.py 2012-11-08 15:07:21 +0000 |
380 | @@ -47,9 +47,9 @@ |
381 | * stop, uploadfiles, downloadfiles, run |
382 | (these must be implemented separately.) |
383 | """ |
384 | - def __init__(self, arch=None, clean=None, debug=False, directory=None, |
385 | - image=None, dlpercentincrement=1, initrd=None, |
386 | - installtype=None, kernel=None, machineid=None, |
387 | + def __init__(self, arch=None, boot=None, clean=None, debug=False, |
388 | + directory=None, image=None, dlpercentincrement=1, |
389 | + initrd=None, installtype=None, kernel=None, machineid=None, |
390 | machineuuid=None, name=None, new=False, prefix='utah', |
391 | preseed=None, rewrite=None, series=None, template=None, |
392 | xml=None): |
393 | @@ -96,14 +96,11 @@ |
394 | none | | | | | |
395 | """ |
396 | # TODO: Make this work right with super at some point. |
397 | - self.arch = arch |
398 | self.debug = debug |
399 | self.dlpercentincrement = dlpercentincrement |
400 | - self.installtype = installtype |
401 | self.machineid = machineid |
402 | self.new = new |
403 | self.prefix = prefix |
404 | - self.series = series |
405 | self.template = template |
406 | |
407 | if clean is None: |
408 | @@ -118,10 +115,26 @@ |
409 | self._namesetup(name) |
410 | self._dirsetup(directory) |
411 | |
412 | + if arch is None: |
413 | + self.arch = config.arch |
414 | + else: |
415 | + self.arch = arch |
416 | + if boot is None: |
417 | + self.boot = config.boot |
418 | + else: |
419 | + self.boot = boot |
420 | + if installtype is None: |
421 | + self.installtype = config.installtype |
422 | + else: |
423 | + self.installtype = installtype |
424 | if rewrite is None: |
425 | self.rewrite = config.rewrite |
426 | else: |
427 | self.rewrite = rewrite |
428 | + if series is None: |
429 | + self.series = config.series |
430 | + else: |
431 | + self.series = series |
432 | |
433 | if machineuuid is None: |
434 | self.uuid = str(uuid.uuid4()) |
435 | @@ -133,10 +146,12 @@ |
436 | self._loggersetup() |
437 | |
438 | if preseed is None: |
439 | - preseed = '/etc/utah/default-preseed.cfg' |
440 | - |
441 | - fileargs = ['preseed', 'xml', 'kernel', 'initrd'] |
442 | - |
443 | + preseed = config.preseed |
444 | + |
445 | + fileargs = ['initrd', 'kernel', 'preseed', 'xml'] |
446 | + |
447 | + if image is None: |
448 | + image = config.image |
449 | if image is None: |
450 | self.image = None |
451 | elif image.endswith('.iso'): |
452 | @@ -150,6 +165,8 @@ |
453 | # Ensure every file/url type argument is available locally |
454 | arg = locals()[item] |
455 | if arg is None: |
456 | + arg = getattr(config, item) |
457 | + if arg is None: |
458 | setattr(self, item, None) |
459 | else: |
460 | if arg.startswith('~'): |
461 | @@ -1123,7 +1140,9 @@ |
462 | Add the needed options to the command line for an automatic install. |
463 | """ |
464 | if boot is None: |
465 | - self.cmdline = '' |
466 | + self.cmdline = self.boot |
467 | + if boot is None: |
468 | + self.cmdline ='' |
469 | else: |
470 | self.cmdline = boot |
471 | self.boottimeout = config.boottimeout |
472 | |
473 | === modified file 'utah/provisioning/vm/libvirtvm.py' |
474 | --- utah/provisioning/vm/libvirtvm.py 2012-10-19 21:57:01 +0000 |
475 | +++ utah/provisioning/vm/libvirtvm.py 2012-11-08 15:07:21 +0000 |
476 | @@ -142,16 +142,11 @@ |
477 | """ |
478 | Provide a class to provision a VM using the ubuntu-qa-tools vm-tools. |
479 | """ |
480 | - def __init__(self, arch='i386', installtype='desktop', machineid=None, |
481 | - prefix='utah', series='precise', *args, **kw): |
482 | + def __init__(self, machineid=None, prefix='utah', *args, **kw): |
483 | if not apt.cache.Cache()['vm-tools'].is_installed: |
484 | raise UTAHVMProvisioningException('vm-tools is not installed. ' |
485 | 'Try: sudo apt-get install vm-tools') |
486 | - super(VMToolsVM, self).__init__(*args, arch=arch, |
487 | - installtype=installtype, |
488 | - machineid=machineid, |
489 | - name=None, |
490 | - series=series, |
491 | + super(VMToolsVM, self).__init__(*args, machineid=machineid, name=None, |
492 | **kw) |
493 | self.logger.debug('VMToolsVM init finished') |
494 | |
495 | @@ -346,10 +341,9 @@ |
496 | """ |
497 | Install a VM from an image using libvirt direct kernel booting. |
498 | """ |
499 | - def __init__(self, arch=None, boot=None, diskbus=None, disksizes=None, |
500 | - emulator=None, image=None, initrd=None, installtype=None, |
501 | - kernel=None, machineid=None, macs=None, name=None, |
502 | - prefix='utah', series=None, xml=None, *args, **kw): |
503 | + def __init__(self, diskbus=None, disksizes=None, emulator=None, |
504 | + machineid=None, macs=None, name=None, prefix='utah', *args, |
505 | + **kw): |
506 | # Make sure that no other virtualization solutions are running |
507 | # TODO: see if this is needed for qemu or just kvm |
508 | process_checker = ProcessChecker() |
509 | @@ -360,10 +354,12 @@ |
510 | raise UTAHVMProvisioningException(message) |
511 | |
512 | if diskbus is None: |
513 | - self.diskbus = 'virtio' |
514 | + self.diskbus = config.diskbus |
515 | else: |
516 | self.diskbus = diskbus |
517 | if disksizes is None: |
518 | + disksizes = config.disksizes |
519 | + if disksizes is None: |
520 | self.disksizes = [8] |
521 | else: |
522 | self.disksizes = disksizes |
523 | @@ -372,25 +368,22 @@ |
524 | name = '-'.join([str(prefix), str(machineid)]) |
525 | else: |
526 | autoname = False |
527 | - if xml is None: |
528 | - xml = '/etc/utah/default-vm.xml' |
529 | - super(CustomVM, self).__init__(arch=arch, image=image, initrd=initrd, |
530 | - installtype=installtype, kernel=kernel, |
531 | - machineid=machineid, name=name, |
532 | - series=series, xml=xml, *args, **kw) |
533 | + super(CustomVM, self).__init__(machineid=machineid, name=name, *args, |
534 | + **kw) |
535 | # TODO: do a better job of separating installation |
536 | # into _create rather than __init__ |
537 | if self.image is None: |
538 | raise UTAHVMProvisioningException('Image file required ' |
539 | 'for custom VM installation') |
540 | - self._custominit(arch=arch, boot=boot, |
541 | - installtype=installtype, series=series) |
542 | + self._custominit() |
543 | if autoname: |
544 | self._namesetup() |
545 | self._loggerunsetup() |
546 | self._loggersetup() |
547 | self._dirsetup() |
548 | if emulator is None: |
549 | + emulator = config.emulator |
550 | + if emulator is None: |
551 | if self._supportsdomaintype('kvm'): |
552 | self.logger.info('Setting type to kvm ' |
553 | 'since it is present in libvirt capabilities') |
554 | @@ -412,7 +405,6 @@ |
555 | if macs is None: |
556 | macs = [] |
557 | self.macs = macs |
558 | - self.xml = xml |
559 | self.dircheck() |
560 | self.logger.debug('CustomVM init finished') |
561 |
Looks good to me.
One nit; I'd put the release choices into a module level variable somewhere so you only have to make the change in one place.
in common.py
SERIES_CHOICES = ['hardy', 'lucid', ..., 'raring']
and in the other places
from common import SERIES_CHOICES add_argument( ..., choices= SERIES_ CHOICES. ..
...
parser.
and
vm_release_list = " ".join( SERIES_ CHOICES)