=== modified file 'lava_dispatcher/device/boot_options.py'
@@ -25,7 +25,7 @@
"""
Parses items from a config ini section into an options object.
"""
- def __init__(self, section, items):
+ def __init__(self, section, items, defval):
self.name = section
self.value = None
self.allowed = None
@@ -35,8 +35,9 @@
elif item[0] == 'allowed':
self.allowed = [x.strip() for x in item[1].split(',')]
else:
- logging.warn('section(%s) contains unknown item: %s' %
- (section, item))
+ logging.warn('section(%s) contains unknown item: %s', section, item)
+ if defval:
+ self.value = defval
def valid(self, option):
if self.allowed:
@@ -45,34 +46,45 @@
return True
-def as_dict(target):
+def as_dict(target, defaults={}):
+ """
+ converts the boot_options stanza for a device into a dictionary of
+ key value pairs for the option and its value
+
+ defaults - in some cases you need to override a default value specified
+ in the device's config. For example for boot_options with master.py, the
+ default for boot_cmds is boot_cmds. However, we really need to look at
+ the deployment_data's boot_cmds for the default so that booting
+ something like android will work.
+ """
options = {}
for opt in target.config.boot_options:
if opt in target.config.cp.sections():
- options[opt] = BootOption(opt, target.config.cp.items(opt))
+ defval = defaults.get(opt, None)
+ options[opt] = BootOption(opt, target.config.cp.items(opt), defval)
else:
- logging.warn('no boot option config section for: %s' % opt)
+ logging.warn('no boot option config section for: %s', opt)
for opt in target.boot_options:
keyval = opt.split('=')
if len(keyval) != 2:
- logging.warn("Invalid boot option format: %s" % opt)
+ logging.warn("Invalid boot option format: %s", opt)
elif keyval[0] not in options:
- logging.warn("Invalid boot option: %s" % keyval[0])
+ logging.warn("Invalid boot option: %s", keyval[0])
elif not options[keyval[0]].valid(keyval[1]):
- logging.warn("Invalid boot option value: %s" % opt)
+ logging.warn("Invalid boot option value: %s", opt)
else:
options[keyval[0]].value = keyval[1]
return options
-def as_string(target, join_pattern):
+def as_string(target, join_pattern, defaults={}):
"""
pulls the options into a string via the join_pattern. The join pattern
can be something like "%s=%s"
"""
- options = as_dict(target)
+ options = as_dict(target, defaults)
cmd = ''
for option in options.values():
=== modified file 'lava_dispatcher/device/master.py'
@@ -405,15 +405,17 @@
def _enter_uboot(self):
if self.proc.expect(self.config.interrupt_boot_prompt) != 0:
- raise Exception("Faile to enter uboot")
+ raise Exception("Failed to enter uboot")
self.proc.sendline(self.config.interrupt_boot_command)
def _boot_linaro_image(self):
boot_cmds = self.deployment_data['boot_cmds']
- options = boot_options.as_dict(self)
+
+ options = boot_options.as_dict(self, defaults={'boot_cmds': boot_cmds})
if 'boot_cmds' in options:
boot_cmds = options['boot_cmds'].value
+ logging.info('boot_cmds attribute: %s', boot_cmds)
boot_cmds = getattr(self.config, boot_cmds)
self._boot(string_to_list(boot_cmds.encode('ascii')))