Merge lp:~nuclearbob/utah/config-changes into lp:utah

Proposed by Max Brustkern
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
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Max Brustkern (community) Needs Resubmitting
Review via email: mp+133347@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
Joe Talbott (joetalbott) wrote :

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
...
parser.add_argument(..., choices=SERIES_CHOICES...

and

vm_release_list = " ".join(SERIES_CHOICES)

review: Approve
Revision history for this message
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.

lp:~nuclearbob/utah/config-changes updated
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

Revision history for this message
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.

review: Needs Resubmitting
Revision history for this message
Joe Talbott (joetalbott) wrote :

Looks good to me. Merge away.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'conf/utah/uqt-vm-tools.conf'
--- conf/utah/uqt-vm-tools.conf 2012-07-11 17:43:36 +0000
+++ conf/utah/uqt-vm-tools.conf 2012-11-08 15:07:21 +0000
@@ -1,5 +1,5 @@
1# list of all active releases (included devel)1# list of all active releases (included devel)
2vm_release_list="hardy lucid natty oneiric precise quantal"2vm_release_list="hardy lucid oneiric precise quantal raring"
33
4# used by vm-repo (ie 'umt repo' puts stuff in /var/www/debs/testing/..., so4# used by vm-repo (ie 'umt repo' puts stuff in /var/www/debs/testing/..., so
5# vm_repo_url should be the URL to those files. The IP of the host is by5# vm_repo_url should be the URL to those files. The IP of the host is by
66
=== modified file 'examples/run_install_test.py'
--- examples/run_install_test.py 2012-10-19 21:57:01 +0000
+++ examples/run_install_test.py 2012-11-08 15:07:21 +0000
@@ -3,6 +3,7 @@
3import argparse3import argparse
4import sys4import sys
55
6from utah import config
6from utah.exceptions import UTAHException7from utah.exceptions import UTAHException
7from utah.url import url_argument8from utah.url import url_argument
8from utah.group import check_user_group, print_group_error_message9from utah.group import check_user_group, print_group_error_message
@@ -46,8 +47,7 @@
46 help=('Size in gigabytes of virtual disk, '47 help=('Size in gigabytes of virtual disk, '
47 'specify more than once for multiple disks'))48 'specify more than once for multiple disks'))
48 parser.add_argument('-s', '--series', metavar='SERIES',49 parser.add_argument('-s', '--series', metavar='SERIES',
49 choices=('hardy', 'lucid', 'natty',50 choices=config.serieschoices,
50 'oneiric', 'precise', 'quantal'),
51 help='Series to use for installation (%(choices)s)')51 help='Series to use for installation (%(choices)s)')
52 parser.add_argument('-t', '--type', metavar='TYPE',52 parser.add_argument('-t', '--type', metavar='TYPE',
53 choices=('desktop', 'server', 'mini', 'alternate'),53 choices=('desktop', 'server', 'mini', 'alternate'),
5454
=== modified file 'examples/run_test_bamboo_feeder.py'
--- examples/run_test_bamboo_feeder.py 2012-10-19 13:02:44 +0000
+++ examples/run_test_bamboo_feeder.py 2012-11-08 15:07:21 +0000
@@ -26,8 +26,7 @@
26 parser.add_argument('runlists', metavar='runlist', nargs='+',26 parser.add_argument('runlists', metavar='runlist', nargs='+',
27 help='URLs of runlist files to run')27 help='URLs of runlist files to run')
28 parser.add_argument('-s', '--series', metavar='SERIES',28 parser.add_argument('-s', '--series', metavar='SERIES',
29 choices=('hardy', 'lucid', 'natty',29 choices=config.serieschoices,
30 'oneiric', 'precise', 'quantal'),
31 help='Series to use for VM creation (%(choices)s)')30 help='Series to use for VM creation (%(choices)s)')
32 parser.add_argument('-t', '--type', metavar='TYPE',31 parser.add_argument('-t', '--type', metavar='TYPE',
33 choices=('desktop', 'server', 'mini', 'alternate'),32 choices=('desktop', 'server', 'mini', 'alternate'),
3433
=== modified file 'examples/run_test_cobbler.py'
--- examples/run_test_cobbler.py 2012-10-31 11:27:40 +0000
+++ examples/run_test_cobbler.py 2012-11-08 15:07:21 +0000
@@ -29,8 +29,7 @@
29 parser.add_argument('-p', '--preseed', type=url_argument,29 parser.add_argument('-p', '--preseed', type=url_argument,
30 help='Preseed file to use for installation')30 help='Preseed file to use for installation')
31 parser.add_argument('-s', '--series', metavar='SERIES',31 parser.add_argument('-s', '--series', metavar='SERIES',
32 choices=('hardy', 'lucid', 'natty',32 choices=config.serieschoices,
33 'oneiric', 'precise', 'quantal'),
34 help='Series to use for VM creation (%(choices)s)')33 help='Series to use for VM creation (%(choices)s)')
35 parser.add_argument('-t', '--type', metavar='TYPE',34 parser.add_argument('-t', '--type', metavar='TYPE',
36 choices=('desktop', 'server', 'mini', 'alternate'),35 choices=('desktop', 'server', 'mini', 'alternate'),
3736
=== modified file 'examples/run_test_vm.py'
--- examples/run_test_vm.py 2012-10-18 14:35:42 +0000
+++ examples/run_test_vm.py 2012-11-08 15:07:21 +0000
@@ -23,8 +23,7 @@
23 parser.add_argument('runlists', metavar='runlist', nargs='+',23 parser.add_argument('runlists', metavar='runlist', nargs='+',
24 help='URLs of runlist files to run')24 help='URLs of runlist files to run')
25 parser.add_argument('-s', '--series', metavar='SERIES',25 parser.add_argument('-s', '--series', metavar='SERIES',
26 choices=('hardy', 'lucid', 'natty',26 choices=config.serieschoices,
27 'oneiric', 'precise', 'quantal'),
28 help='Series to use for VM creation (%(choices)s)')27 help='Series to use for VM creation (%(choices)s)')
29 parser.add_argument('-t', '--type', metavar='TYPE',28 parser.add_argument('-t', '--type', metavar='TYPE',
30 choices=('desktop', 'server', 'mini', 'alternate'),29 choices=('desktop', 'server', 'mini', 'alternate'),
3130
=== modified file 'examples/run_utah_tests.py'
--- examples/run_utah_tests.py 2012-10-19 21:57:01 +0000
+++ examples/run_utah_tests.py 2012-11-08 15:07:21 +0000
@@ -26,7 +26,7 @@
26 parser.add_argument('runlists', metavar='runlist', nargs='+',26 parser.add_argument('runlists', metavar='runlist', nargs='+',
27 type=url_argument, help='URLs of runlist files to run')27 type=url_argument, help='URLs of runlist files to run')
28 parser.add_argument('-m', '--machinetype', metavar='MACHINETYPE',28 parser.add_argument('-m', '--machinetype', metavar='MACHINETYPE',
29 choices=('physical', 'virtual'), default='virtual',29 choices=('physical', 'virtual'),
30 help='Type of machine to provision (%(choices)s)')30 help='Type of machine to provision (%(choices)s)')
31 parser.add_argument('-e', '--emulator',31 parser.add_argument('-e', '--emulator',
32 help=('Emulator to use (kvm and qemu are supported, '32 help=('Emulator to use (kvm and qemu are supported, '
@@ -47,8 +47,7 @@
47 help=('Size in gigabytes of virtual disk, '47 help=('Size in gigabytes of virtual disk, '
48 'specify more than once for multiple disks'))48 'specify more than once for multiple disks'))
49 parser.add_argument('-s', '--series', metavar='SERIES',49 parser.add_argument('-s', '--series', metavar='SERIES',
50 choices=('hardy', 'lucid', 'natty',50 choices=config.serieschoices,
51 'oneiric', 'precise', 'quantal'),
52 help='Series to use for installation (%(choices)s)')51 help='Series to use for installation (%(choices)s)')
53 parser.add_argument('-t', '--type', metavar='TYPE',52 parser.add_argument('-t', '--type', metavar='TYPE',
54 choices=('desktop', 'server', 'mini', 'alternate'),53 choices=('desktop', 'server', 'mini', 'alternate'),
@@ -87,10 +86,15 @@
87 if args is None:86 if args is None:
88 args = get_parser().parse_args()87 args = get_parser().parse_args()
8988
89 if args.machinetype is None:
90 machinetype = config.machinetype
91 else:
92 machinetype = args.machinetype
93
90 if args.arch is not None and 'arm' in args.arch:94 if args.arch is not None and 'arm' in args.arch:
91 from run_test_bamboo_feeder import run_test_bamboo_feeder95 from run_test_bamboo_feeder import run_test_bamboo_feeder
92 function = run_test_bamboo_feeder96 function = run_test_bamboo_feeder
93 elif args.machinetype == 'physical':97 elif machinetype == 'physical':
94 from run_test_cobbler import run_test_cobbler98 from run_test_cobbler import run_test_cobbler
95 function = run_test_cobbler99 function = run_test_cobbler
96 else:100 else:
97101
=== modified file 'utah/config.py'
--- utah/config.py 2012-11-06 16:47:07 +0000
+++ utah/config.py 2012-11-08 15:07:21 +0000
@@ -12,6 +12,8 @@
12import socket12import socket
13import subprocess13import subprocess
1414
15from utah.exceptions import UTAHException
16
1517
16def getbridge():18def getbridge():
17 """19 """
@@ -26,71 +28,178 @@
26 return 'virbr0'28 return 'virbr0'
2729
28DEFAULTS = dict(30DEFAULTS = dict(
29 arch='i386',31 # Default kernel parameters
32 boot=None,
33 # Time to wait for installed system to boot
30 boottimeout=90,34 boottimeout=90,
35 # Time to wait between checking if system is available over ssh
31 checktimeout=15,36 checktimeout=15,
37 # Default log level to print to the console
32 consoleloglevel=logging.WARNING,38 consoleloglevel=logging.WARNING,
39 # Default debug setting
33 debug=False,40 debug=False,
41 # Default diskbus for VMs
42 diskbus='virtio',
43 # Default disk size list for VMs (in GB)
44 disksizes=[8],
45 # Default emulator for VMs
46 # If None, kvm will be used if available, otherwise qemu
47 emulator=None,
48 # Default log level to write to log file
34 fileloglevel=logging.INFO,49 fileloglevel=logging.INFO,
50 # Group for file ownership and permissions
35 group='utah',51 group='utah',
52 # Default image to use for system installation
36 image=None,53 image=None,
54 # Default initrd to use for system installation
37 initrd=None,55 initrd=None,
56 # Packages to install on system
38 installpackages=['openssh-server', 'gdebi'],57 installpackages=['openssh-server', 'gdebi'],
58 # Time limit for overall install process
39 installtimeout=3600,59 installtimeout=3600,
40 installtype='desktop',60 # Default install type (mini is default to save bandwidth and space)
61 installtype='mini',
62 # Default kernel for installation
41 kernel=None,63 kernel=None,
64 # Default location of log directory
42 logpath=os.path.join('/', 'var', 'log', 'utah'),65 logpath=os.path.join('/', 'var', 'log', 'utah'),
66 # Default machine ID
43 machineid=None,67 machineid=None,
68 # Default machine type
69 machinetype='virtual',
70 # Default machine name
44 name=None,71 name=None,
72 # Default setting of installing a new machine vs. using an existing one
45 new=False,73 new=False,
46 nfscommand=['sudo', os.path.join('/', 'etc', 'init.d', 'nfs-kernel-server'), 'reload'],74 # Command to reload NFS configuration
75 # NFS options currently only used for cobbler-based desktop installs
76 nfscommand=['sudo', os.path.join('/', 'etc', 'init.d',
77 'nfs-kernel-server'), 'reload'],
78 # Path to NFS config file
47 nfsconfigfile=os.path.join('/', 'etc', 'exports'),79 nfsconfigfile=os.path.join('/', 'etc', 'exports'),
80 # Default options for NFS shares
48 nfsoptions='*(ro,async,no_root_squash,no_subtree_check)',81 nfsoptions='*(ro,async,no_root_squash,no_subtree_check)',
82 # Time to wait between power off and power on for physical systems
49 powertimeout=15,83 powertimeout=15,
50 preseed=None,84 # Default preseed
85 preseed=os.path.join('/', 'etc', 'utah', 'default-preseed.cfg'),
86 # Location of PXE configuration files
51 pxedir=os.path.join('/', 'var', 'lib', 'tftpboot', 'pxelinux.cfg'),87 pxedir=os.path.join('/', 'var', 'lib', 'tftpboot', 'pxelinux.cfg'),
88 # libvirt URL for virtual machine creation
52 qemupath='qemu:///system',89 qemupath='qemu:///system',
90 # Default setting for configuration rewriting
53 rewrite='all',91 rewrite='all',
54 series='precise',92 # Available releases
93 serieschoices=[ # Remember to update uqt-vm-tools.conf as well
94 'hardy',
95 'lucid',
96 'oneiric',
97 'precise',
98 'quantal',
99 'raring',
100 ],
101 # Default machine template
55 template=None,102 template=None,
103 # Directory to hold web-accessible files
56 wwwdir=os.path.join('/', 'var', 'www', 'utah'),104 wwwdir=os.path.join('/', 'var', 'www', 'utah'),
105 # Default VM XML file
106 xml=os.path.join('/', 'etc', 'utah', 'default-vm.xml'),
57)107)
58108
59# These depend on the local user/path, and need to be filtered out109# These depend on the local user/path, and need to be filtered out
60# of the config file created at package build time.110# of the config file created at package build time.
61LOCALDEFAULTS = dict(111LOCALDEFAULTS = dict(
112 # Default network bridge for machines
62 bridge=getbridge(),113 bridge=getbridge(),
114 # Hostname (used for logfile among other things)
63 hostname=socket.gethostname(),115 hostname=socket.gethostname(),
116 # SSH private key to use for provisioned machine logins
64 sshprivatekey=os.path.join(os.path.expanduser('~'), '.ssh', 'utah'),117 sshprivatekey=os.path.join(os.path.expanduser('~'), '.ssh', 'utah'),
118 # SSH public key to install on provisioned machines
65 sshpublickey=os.path.join(os.path.expanduser('~'), '.ssh', 'utah.pub'),119 sshpublickey=os.path.join(os.path.expanduser('~'), '.ssh', 'utah.pub'),
66 sshknownhosts=os.path.join(os.path.expanduser('~'), '.ssh', 'known_hosts'),120 # SSH known hosts file
121 sshknownhosts=os.path.join(os.path.expanduser('~'), '.ssh',
122 'known_hosts'),
123 # User to install and use on provisioned machines
67 user=getpass.getuser(),124 user=getpass.getuser(),
125 # Path for VM files
68 vmpath=os.path.join(os.path.expanduser('~'), 'vm'),126 vmpath=os.path.join(os.path.expanduser('~'), 'vm'),
69)127)
70128
71# These depend on other config options, so they're added last.129# These depend on other config options, so they're added last.
130# Default logfile is /var/log/utah/{hostname}.log
72LOCALDEFAULTS['logfile'] = os.path.join(DEFAULTS['logpath'],131LOCALDEFAULTS['logfile'] = os.path.join(DEFAULTS['logpath'],
73 LOCALDEFAULTS['hostname'] + '.log')132 LOCALDEFAULTS['hostname'] + '.log')
133# Default logfile is /var/log/utah/{hostname}-debug.log
134# Set to None to disable separate debug log
74LOCALDEFAULTS['debuglog'] = os.path.join(DEFAULTS['logpath'],135LOCALDEFAULTS['debuglog'] = os.path.join(DEFAULTS['logpath'],
75 LOCALDEFAULTS['hostname'] + '-debug.log')136 LOCALDEFAULTS['hostname'] + '-debug.log')
76137
138# This depends on a binary that may not be installed.
139# Also, the null thing may seem obvious, but I found it here:
140# http://stackoverflow.com/questions/699325/
141# suppress-output-in-python-calls-to-executables
142with open(os.devnull, 'w') as fnull:
143 if subprocess.call(['which', 'dpkg-architecture'],
144 stdout=fnull, stderr=fnull) == 0:
145 # If dpkg-architecture is available, default to current host arch
146 LOCALDEFAULTS['arch'] = subprocess.check_output(
147 ['dpkg-architecture', '-qDEB_HOST_ARCH']).strip()
148 else:
149 # Otherwise, default to i386
150 LOCALDEFAULTS['arch'] = 'i386'
151
152# I'm not sure lsb_release is always around
153with open(os.devnull, 'w') as fnull:
154 if subprocess.call(['which', 'lsb_release'],
155 stdout=fnull, stderr=fnull) == 0:
156 # If lsb_release is available, default to current series
157 LOCALDEFAULTS['series'] = subprocess.check_output(
158 ['lsb_release', '-sc']).strip()
159 else:
160 # Otherwise, default to precise
161 LOCALDEFAULTS['series'] = 'precise'
162
77DEFAULTS.update(LOCALDEFAULTS)163DEFAULTS.update(LOCALDEFAULTS)
78164
79CONFIG = {}165CONFIG = {}
80CONFIG.update(DEFAULTS)166CONFIG.update(DEFAULTS)
81167
82# Process config files.168# Process config files.
83files = ['/etc/utah/config', '~/.utah/config', os.getenv('UTAH_CONFIG_FILE')]169# First, the standard /etc/utah/config file is processed
170# Second, anything in /etc/utah/conf.d
171# Third, any existing ~/.utah/config file
172# Fourth, anything in ~/.utah/conf.d
173# Fifth, a file referred to by UTAH_CONFIG_FILE
174# Sixth, anything in UTAH_CONFIG_DIR
175# Technically, all files will process as directories, and vice versa
176files = []
177paths = ['/etc/utah/config', '/etc/utah/conf.d', '~/.utah/config',
178 '~/.utah/conf.d', os.getenv('UTAH_CONFIG_FILE'),
179 os.getenv('UTAH_CONFIG_DIR')]
180for path in paths:
181 if path is not None:
182 abspath = os.path.expanduser(path)
183 if os.path.isfile(abspath):
184 files.append(abspath)
185 elif os.path.isdir(abspath):
186 for walkdir, _dirs, walkfiles in os.walk(abspath):
187 for walkfile in walkfiles:
188 files.append(os.path.join(abspath, walkdir, walkfile))
84for conffile in files:189for conffile in files:
85 if conffile is not None:190 if os.path.isfile(conffile) and os.path.getsize(conffile) > 0:
86 myfile = os.path.expanduser(conffile)191 with open(conffile) as fp:
87 if os.path.isfile(myfile) and os.path.getsize(myfile) > 0:192 try:
88 with open(myfile) as fp:
89 CONFIG.update(json.load(fp))193 CONFIG.update(json.load(fp))
90194 except ValueError:
195 raise UTAHException(conffile + ' is not a valid JSON file')
196
197
198# Allow variables to be accessed via config.variable
91locals().update(CONFIG)199locals().update(CONFIG)
92200
93201
202# Dump the default values to create a configuration file
94def dumpdefaults(build=False):203def dumpdefaults(build=False):
95 if build:204 if build:
96 # Remove user and path dependent items so they won't get set on the205 # Remove user and path dependent items so they won't get set on the
@@ -100,6 +209,7 @@
100 return json.dumps(DEFAULTS, sort_keys=True, indent=4)209 return json.dumps(DEFAULTS, sort_keys=True, indent=4)
101210
102211
212# Dump all config values
103def dumpconfig():213def dumpconfig():
104 return json.dumps(CONFIG, sort_keys=True, indent=4)214 return json.dumps(CONFIG, sort_keys=True, indent=4)
105215
106216
=== modified file 'utah/provisioning/baremetal/bamboofeeder.py'
--- utah/provisioning/baremetal/bamboofeeder.py 2012-10-19 21:05:04 +0000
+++ utah/provisioning/baremetal/bamboofeeder.py 2012-11-08 15:07:21 +0000
@@ -24,8 +24,8 @@
24 """24 """
25 Provide a class to provision an ARM board from a bamboo-feeder setup.25 Provide a class to provision an ARM board from a bamboo-feeder setup.
26 """26 """
27 def __init__(self, boot=None, cargs=None, inventory=None,27 def __init__(self, cargs=None, inventory=None, name=None, powercmd=None,
28 name=None, powercmd=None, preboot=None, *args, **kw):28 preboot=None, *args, **kw):
29 # TODO: change the name of cargs here and elsewhere29 # TODO: change the name of cargs here and elsewhere
30 # TODO: respect rewrite setting30 # TODO: respect rewrite setting
31 if name is None:31 if name is None:
@@ -174,7 +174,7 @@
174 Add the needed options to the command line for an automatic install.174 Add the needed options to the command line for an automatic install.
175 """175 """
176 if boot is None:176 if boot is None:
177 boot = ''177 boot = self.boot
178 super(BambooFeederMachine, self)._cmdlinesetup(boot=boot)178 super(BambooFeederMachine, self)._cmdlinesetup(boot=boot)
179 # TODO: minimize these179 # TODO: minimize these
180 for option in ('auto', 'ro', 'text'):180 for option in ('auto', 'ro', 'text'):
181181
=== modified file 'utah/provisioning/baremetal/cobbler.py'
--- utah/provisioning/baremetal/cobbler.py 2012-10-29 11:26:22 +0000
+++ utah/provisioning/baremetal/cobbler.py 2012-11-08 15:07:21 +0000
@@ -24,8 +24,8 @@
24 Provide a class to provision a machine via cobbler.24 Provide a class to provision a machine via cobbler.
25 """25 """
26 # TODO: may need to fix DHCP/hostname issues, may just be magners26 # TODO: may need to fix DHCP/hostname issues, may just be magners
27 def __init__(self, boot=None, cargs=None, inventory=None,27 def __init__(self, cargs=None, inventory=None, name=None, preseed=None,
28 name=None, preseed=None, *args, **kw):28 *args, **kw):
29 if name is None:29 if name is None:
30 raise UTAHBMProvisioningException(30 raise UTAHBMProvisioningException(
31 'Machine name reqired for cobbler machine')31 'Machine name reqired for cobbler machine')
@@ -42,8 +42,7 @@
42 if self.image is None:42 if self.image is None:
43 raise UTAHBMProvisioningException(43 raise UTAHBMProvisioningException(
44 'Image file required for cobbler installation')44 'Image file required for cobbler installation')
45 self._custominit(arch=self.arch, boot=boot,45 self._custominit()
46 installtype=self.installtype, series=self.series)
47 # TODO: verify we have nfs support for desktop image46 # TODO: verify we have nfs support for desktop image
4847
49 # TODO: Rework cinitrd to be less of a confusing collection of kludges48 # TODO: Rework cinitrd to be less of a confusing collection of kludges
5049
=== modified file 'utah/provisioning/provisioning.py'
--- utah/provisioning/provisioning.py 2012-10-25 20:07:44 +0000
+++ utah/provisioning/provisioning.py 2012-11-08 15:07:21 +0000
@@ -47,9 +47,9 @@
47 * stop, uploadfiles, downloadfiles, run47 * stop, uploadfiles, downloadfiles, run
48 (these must be implemented separately.)48 (these must be implemented separately.)
49 """49 """
50 def __init__(self, arch=None, clean=None, debug=False, directory=None,50 def __init__(self, arch=None, boot=None, clean=None, debug=False,
51 image=None, dlpercentincrement=1, initrd=None,51 directory=None, image=None, dlpercentincrement=1,
52 installtype=None, kernel=None, machineid=None,52 initrd=None, installtype=None, kernel=None, machineid=None,
53 machineuuid=None, name=None, new=False, prefix='utah',53 machineuuid=None, name=None, new=False, prefix='utah',
54 preseed=None, rewrite=None, series=None, template=None,54 preseed=None, rewrite=None, series=None, template=None,
55 xml=None):55 xml=None):
@@ -96,14 +96,11 @@
96 none | | | | |96 none | | | | |
97 """97 """
98 # TODO: Make this work right with super at some point.98 # TODO: Make this work right with super at some point.
99 self.arch = arch
100 self.debug = debug99 self.debug = debug
101 self.dlpercentincrement = dlpercentincrement100 self.dlpercentincrement = dlpercentincrement
102 self.installtype = installtype
103 self.machineid = machineid101 self.machineid = machineid
104 self.new = new102 self.new = new
105 self.prefix = prefix103 self.prefix = prefix
106 self.series = series
107 self.template = template104 self.template = template
108105
109 if clean is None:106 if clean is None:
@@ -118,10 +115,26 @@
118 self._namesetup(name)115 self._namesetup(name)
119 self._dirsetup(directory)116 self._dirsetup(directory)
120117
118 if arch is None:
119 self.arch = config.arch
120 else:
121 self.arch = arch
122 if boot is None:
123 self.boot = config.boot
124 else:
125 self.boot = boot
126 if installtype is None:
127 self.installtype = config.installtype
128 else:
129 self.installtype = installtype
121 if rewrite is None:130 if rewrite is None:
122 self.rewrite = config.rewrite131 self.rewrite = config.rewrite
123 else:132 else:
124 self.rewrite = rewrite133 self.rewrite = rewrite
134 if series is None:
135 self.series = config.series
136 else:
137 self.series = series
125138
126 if machineuuid is None:139 if machineuuid is None:
127 self.uuid = str(uuid.uuid4())140 self.uuid = str(uuid.uuid4())
@@ -133,10 +146,12 @@
133 self._loggersetup()146 self._loggersetup()
134147
135 if preseed is None:148 if preseed is None:
136 preseed = '/etc/utah/default-preseed.cfg'149 preseed = config.preseed
137150
138 fileargs = ['preseed', 'xml', 'kernel', 'initrd']151 fileargs = ['initrd', 'kernel', 'preseed', 'xml']
139152
153 if image is None:
154 image = config.image
140 if image is None:155 if image is None:
141 self.image = None156 self.image = None
142 elif image.endswith('.iso'):157 elif image.endswith('.iso'):
@@ -150,6 +165,8 @@
150 # Ensure every file/url type argument is available locally165 # Ensure every file/url type argument is available locally
151 arg = locals()[item]166 arg = locals()[item]
152 if arg is None:167 if arg is None:
168 arg = getattr(config, item)
169 if arg is None:
153 setattr(self, item, None)170 setattr(self, item, None)
154 else:171 else:
155 if arg.startswith('~'):172 if arg.startswith('~'):
@@ -1123,7 +1140,9 @@
1123 Add the needed options to the command line for an automatic install.1140 Add the needed options to the command line for an automatic install.
1124 """1141 """
1125 if boot is None:1142 if boot is None:
1126 self.cmdline = ''1143 self.cmdline = self.boot
1144 if boot is None:
1145 self.cmdline =''
1127 else:1146 else:
1128 self.cmdline = boot1147 self.cmdline = boot
1129 self.boottimeout = config.boottimeout1148 self.boottimeout = config.boottimeout
11301149
=== modified file 'utah/provisioning/vm/libvirtvm.py'
--- utah/provisioning/vm/libvirtvm.py 2012-10-19 21:57:01 +0000
+++ utah/provisioning/vm/libvirtvm.py 2012-11-08 15:07:21 +0000
@@ -142,16 +142,11 @@
142 """142 """
143 Provide a class to provision a VM using the ubuntu-qa-tools vm-tools.143 Provide a class to provision a VM using the ubuntu-qa-tools vm-tools.
144 """144 """
145 def __init__(self, arch='i386', installtype='desktop', machineid=None,145 def __init__(self, machineid=None, prefix='utah', *args, **kw):
146 prefix='utah', series='precise', *args, **kw):
147 if not apt.cache.Cache()['vm-tools'].is_installed:146 if not apt.cache.Cache()['vm-tools'].is_installed:
148 raise UTAHVMProvisioningException('vm-tools is not installed. '147 raise UTAHVMProvisioningException('vm-tools is not installed. '
149 'Try: sudo apt-get install vm-tools')148 'Try: sudo apt-get install vm-tools')
150 super(VMToolsVM, self).__init__(*args, arch=arch,149 super(VMToolsVM, self).__init__(*args, machineid=machineid, name=None,
151 installtype=installtype,
152 machineid=machineid,
153 name=None,
154 series=series,
155 **kw)150 **kw)
156 self.logger.debug('VMToolsVM init finished')151 self.logger.debug('VMToolsVM init finished')
157152
@@ -346,10 +341,9 @@
346 """341 """
347 Install a VM from an image using libvirt direct kernel booting.342 Install a VM from an image using libvirt direct kernel booting.
348 """343 """
349 def __init__(self, arch=None, boot=None, diskbus=None, disksizes=None,344 def __init__(self, diskbus=None, disksizes=None, emulator=None,
350 emulator=None, image=None, initrd=None, installtype=None,345 machineid=None, macs=None, name=None, prefix='utah', *args,
351 kernel=None, machineid=None, macs=None, name=None,346 **kw):
352 prefix='utah', series=None, xml=None, *args, **kw):
353 # Make sure that no other virtualization solutions are running347 # Make sure that no other virtualization solutions are running
354 # TODO: see if this is needed for qemu or just kvm348 # TODO: see if this is needed for qemu or just kvm
355 process_checker = ProcessChecker()349 process_checker = ProcessChecker()
@@ -360,10 +354,12 @@
360 raise UTAHVMProvisioningException(message)354 raise UTAHVMProvisioningException(message)
361355
362 if diskbus is None:356 if diskbus is None:
363 self.diskbus = 'virtio'357 self.diskbus = config.diskbus
364 else:358 else:
365 self.diskbus = diskbus359 self.diskbus = diskbus
366 if disksizes is None:360 if disksizes is None:
361 disksizes = config.disksizes
362 if disksizes is None:
367 self.disksizes = [8]363 self.disksizes = [8]
368 else:364 else:
369 self.disksizes = disksizes365 self.disksizes = disksizes
@@ -372,25 +368,22 @@
372 name = '-'.join([str(prefix), str(machineid)])368 name = '-'.join([str(prefix), str(machineid)])
373 else:369 else:
374 autoname = False370 autoname = False
375 if xml is None:371 super(CustomVM, self).__init__(machineid=machineid, name=name, *args,
376 xml = '/etc/utah/default-vm.xml'372 **kw)
377 super(CustomVM, self).__init__(arch=arch, image=image, initrd=initrd,
378 installtype=installtype, kernel=kernel,
379 machineid=machineid, name=name,
380 series=series, xml=xml, *args, **kw)
381 # TODO: do a better job of separating installation373 # TODO: do a better job of separating installation
382 # into _create rather than __init__374 # into _create rather than __init__
383 if self.image is None:375 if self.image is None:
384 raise UTAHVMProvisioningException('Image file required '376 raise UTAHVMProvisioningException('Image file required '
385 'for custom VM installation')377 'for custom VM installation')
386 self._custominit(arch=arch, boot=boot,378 self._custominit()
387 installtype=installtype, series=series)
388 if autoname:379 if autoname:
389 self._namesetup()380 self._namesetup()
390 self._loggerunsetup()381 self._loggerunsetup()
391 self._loggersetup()382 self._loggersetup()
392 self._dirsetup()383 self._dirsetup()
393 if emulator is None:384 if emulator is None:
385 emulator = config.emulator
386 if emulator is None:
394 if self._supportsdomaintype('kvm'):387 if self._supportsdomaintype('kvm'):
395 self.logger.info('Setting type to kvm '388 self.logger.info('Setting type to kvm '
396 'since it is present in libvirt capabilities')389 'since it is present in libvirt capabilities')
@@ -412,7 +405,6 @@
412 if macs is None:405 if macs is None:
413 macs = []406 macs = []
414 self.macs = macs407 self.macs = macs
415 self.xml = xml
416 self.dircheck()408 self.dircheck()
417 self.logger.debug('CustomVM init finished')409 self.logger.debug('CustomVM init finished')
418410

Subscribers

People subscribed via source and target branches