def validate(self): super(CompressRamdisk, self).validate() if not self.parameters.get('ramdisk', None): # idempotency return try: which('mkimage') except InfrastructureError: raise InfrastructureError("Unable to find mkimage - is u-boot-tools installed?")
def validate(self): super(CompressRamdisk, self).validate() if not self.parameters.get('ramdisk', None): # idempotency return try: which('mkimage') except InfrastructureError: raise InfrastructureError( "Unable to find mkimage - is u-boot-tools installed?")
def validate(self): super(TftpAction, self).validate() if 'kernel' not in self.parameters: self.errors = "%s needs a kernel to deploy" % self.name if not self.valid: return lava_test_results_dir = self.parameters['deployment_data']['lava_test_results_dir'] self.data['lava_test_results_dir'] = lava_test_results_dir % self.job.job_id if self.suffix: self.data[self.name].setdefault('suffix', self.suffix) self.data[self.name].setdefault('suffix', os.path.basename(self.tftp_dir)) try: which("in.tftpd") except InfrastructureError as exc: self.errors = str(exc)
def validate(self): super(CallQemuAction, self).validate() if 'prompts' not in self.parameters: self.errors = "Unable to identify boot prompts from job definition." if 'download_action' not in self.data: self.errors = "No download_action data" try: # FIXME: need a schema and do this inside the NewDevice with a QemuDevice class? (just for parsing) boot = self.job.device['actions']['boot']['methods']['qemu'] qemu_binary = which(boot['parameters']['command']) self.sub_command = [qemu_binary] self.sub_command.extend(boot['parameters'].get('options', [])) # FIXME: AttributeError is an InfrastructureError in fact except (KeyError, TypeError, AttributeError): self.errors = "Invalid parameters" substitutions = {} commands = [] for action in self.data['download_action'].keys(): if action != 'offset' or action != 'available_loops': image_arg = self.data['download_action'][action]['image_arg'] action_arg = self.data['download_action'][action]['file'] if not image_arg or not action_arg: self.errors = "Missing image_arg for %s. " % action continue substitutions["{%s}" % action] = action_arg commands.append(image_arg) self.sub_command.extend(substitute(commands, substitutions)) if not self.sub_command: self.errors = "No QEMU command to execute"
def validate(self): super(MonitorQemuAction, self).validate() try: boot = self.job.device['actions']['boot']['methods']['qemu'] qemu_binary = which(boot['parameters']['command']) self.sub_command = [qemu_binary] self.sub_command.extend(boot['parameters'].get('options', [])) except AttributeError as exc: raise InfrastructureError(exc) except (KeyError, TypeError): self.errors = "Invalid parameters for %s" % self.name substitutions = {} commands = [] for action in self.data['download_action'].keys(): if action == 'offset' or action == 'available_loops' or action == 'uefi': continue image_arg = self.data['download_action'][action].get('image_arg', None) action_arg = self.data['download_action'][action].get('file', None) if not image_arg or not action_arg: self.errors = "Missing image_arg for %s. " % action continue substitutions["{%s}" % action] = action_arg commands.append(image_arg) self.sub_command.extend(substitute(commands, substitutions)) if not self.sub_command: self.errors = "No QEMU command to execute"
def validate(self): super(MonitorQemuAction, self).validate() try: boot = self.job.device['actions']['boot']['methods']['qemu'] qemu_binary = which(boot['parameters']['command']) self.sub_command = [qemu_binary] self.sub_command.extend(boot['parameters'].get('options', [])) except AttributeError as exc: raise InfrastructureError(exc) except (KeyError, TypeError): self.errors = "Invalid parameters for %s" % self.name substitutions = {} commands = [] for action in self.data['download_action'].keys(): if action == 'offset' or action == 'available_loops' or action == 'uefi': continue image_arg = self.data['download_action'][action].get( 'image_arg', None) action_arg = self.data['download_action'][action].get('file', None) if not image_arg or not action_arg: self.errors = "Missing image_arg for %s. " % action continue substitutions["{%s}" % action] = action_arg commands.append(image_arg) self.sub_command.extend(substitute(commands, substitutions)) if not self.sub_command: self.errors = "No QEMU command to execute"
def validate(self): super(CallQemuAction, self).validate() if "prompts" not in self.parameters: self.errors = "Unable to identify boot prompts from job definition." if "download_action" not in self.data: self.errors = "No download_action data" try: # FIXME: need a schema and do this inside the NewDevice with a QemuDevice class? (just for parsing) boot = self.job.device["actions"]["boot"]["methods"]["qemu"] qemu_binary = which(boot["parameters"]["command"]) self.sub_command = [qemu_binary] self.sub_command.extend(boot["parameters"].get("options", [])) # FIXME: AttributeError is an InfrastructureError in fact except (KeyError, TypeError, AttributeError): self.errors = "Invalid parameters" substitutions = {} commands = [] for action in self.data["download_action"].keys(): if action != "offset" or action != "available_loops": image_arg = self.data["download_action"][action]["image_arg"] action_arg = self.data["download_action"][action]["file"] if not image_arg or not action_arg: self.errors = "Missing image_arg for %s. " % action continue substitutions["{%s}" % action] = action_arg commands.append(image_arg) self.sub_command.extend(substitute(commands, substitutions)) if not self.sub_command: self.errors = "No QEMU command to execute"
def validate(self): super(QemuCommandLine, self).validate() boot = self.job.device['actions']['boot']['methods']['qemu'] qemu_binary = which(boot['parameters']['command']) self.sub_command = [qemu_binary] self.sub_command.extend(boot['parameters'].get('options', [])) boot_opts = boot['parameters'].get('boot_options', None) if boot_opts: self.console = "console=%s" % boot_opts['console'] self.boot_order = "-boot %s" % boot_opts['boot_order'] if not qemu_binary or not self.console or not self.boot_order: self.errors = "Invalid parameters for %s" % self.name # create the preseed.cfg url # needs to be an IP address for DI, DNS is not available. # PRESEED_URL='http://10.15.0.32/tmp/d-i/jessie/preseed.cfg' self.preseed_url = 'tftp://%s/' % dispatcher_ip() self.sub_command.append(' -drive format=raw,file={emptyimage} ') self.sub_command.append(self.boot_order) self.command_line = " -append '%s console=tty0 console=tty1 %s %s %s %s preseed/url=%s{preseed} --- %s ' " % ( self.parameters['deployment_data']['base'], self.parameters['deployment_data']['locale'], self.console, self.parameters['deployment_data']['keymaps'], self.parameters['deployment_data']['netcfg'], self.preseed_url, self.console) self.set_common_data(self.name, 'prompts', self.parameters['deployment_data']['prompts']) self.set_common_data(self.name, 'append', self.command_line)
def validate(self): super(QemuCommandLine, self).validate() boot = self.job.device['actions']['boot']['methods']['qemu'] qemu_binary = which(boot['parameters']['command']) self.sub_command = [qemu_binary] self.sub_command.extend(boot['parameters'].get('options', [])) boot_opts = boot['parameters'].get('boot_options', None) if boot_opts: self.console = "console=%s" % boot_opts['console'] self.boot_order = "-boot %s" % boot_opts['boot_order'] if not qemu_binary or not self.console or not self.boot_order: self.errors = "Invalid parameters for %s" % self.name # create the preseed.cfg url # needs to be an IP address for DI, DNS is not available. # PRESEED_URL='http://10.15.0.32/tmp/d-i/jessie/preseed.cfg' self.preseed_url = 'tftp://%s/' % dispatcher_ip() self.sub_command.append(' -drive format=raw,file={emptyimage} ') self.sub_command.append(self.boot_order) self.command_line = " -append '%s console=tty0 console=tty1 %s %s %s %s preseed/url=%s{preseed} --- %s ' " % ( self.parameters['deployment_data']['base'], self.parameters['deployment_data']['locale'], self.console, self.parameters['deployment_data']['keymaps'], self.parameters['deployment_data']['netcfg'], self.preseed_url, self.console) self.set_common_data(self.name, 'prompts', self.parameters['deployment_data']['prompts']) self.set_common_data(self.name, 'append', self.command_line)
def validate(self): super(ConnectDevice, self).validate() if 'connect' not in self.job.device['commands']: self.errors = "Unable to connect to device %s - missing connect command." % self.job.device.hostname return if 'test_image_prompts' not in self.job.device: self.errors = "Unable to identify test image prompts from device configuration." command = self.job.device['commands']['connect'] exe = '' try: exe = command.split(' ')[0] except AttributeError: self.errors = "Unable to parse the connection command %s" % command try: which(exe) except InfrastructureError: if exe != '': self.errors = "Unable to find %s - is it installed?" % exe
def validate(self): super(ConnectDevice, self).validate() if 'connect' not in self.job.device['commands']: self.errors = "Unable to connect to device %s - missing connect command." % self.job.device.hostname return if 'test_image_prompts' not in self.job.device: self.errors = "Unable to identify test image prompts from device configuration." command = self.job.device['commands']['connect'] exe = '' try: exe = command.split(' ')[0] except AttributeError: self.errors = "Unable to parse the connection command %s" % command try: which(exe) except InfrastructureError: if exe != '': self.errors = "Unable to find %s - is it installed?" % exe
def validate(self): super(TftpAction, self).validate() if 'kernel' not in self.parameters: self.errors = "%s needs a kernel to deploy" % self.name if not self.valid: return lava_test_results_dir = self.parameters['deployment_data'][ 'lava_test_results_dir'] self.data[ 'lava_test_results_dir'] = lava_test_results_dir % self.job.job_id if self.suffix: self.data[self.name].setdefault('suffix', self.suffix) self.data[self.name].setdefault('suffix', os.path.basename(self.tftp_dir)) try: which("in.tftpd") except InfrastructureError as exc: self.errors = str(exc)
def validate(self): super(BootQemuRetry, self).validate() try: # FIXME: need a schema and do this inside the NewDevice with a QemuDevice class? (just for parsing) boot = self.job.device['actions']['boot']['methods']['qemu'] qemu_binary = which(boot['parameters']['command']) command = [qemu_binary] command.extend(boot['parameters'].get('options', [])) self.set_common_data('qemu-command', 'command', command) # FIXME: AttributeError is an InfrastructureError in fact except (KeyError, TypeError, AttributeError): self.errors = "Invalid parameters"
def validate(self): super(BootQemuRetry, self).validate() try: # FIXME: need a schema and do this inside the NewDevice with a QemuDevice class? (just for parsing) boot = self.job.device['actions']['boot']['methods']['qemu'] qemu_binary = which(boot['parameters']['command']) command = [qemu_binary] command.extend(boot['parameters'].get('options', [])) self.set_common_data('qemu-command', 'command', command) # FIXME: AttributeError is an InfrastructureError in fact except (KeyError, TypeError, AttributeError): self.errors = "Invalid parameters"
def validate(self): super(IsoRebootAction, self).validate() if 'prompts' not in self.parameters: self.errors = "Unable to identify boot prompts from job definition." try: boot = self.job.device['actions']['boot']['methods']['qemu'] qemu_binary = which(boot['parameters']['command']) self.sub_command = [qemu_binary] self.sub_command.extend(boot['parameters'].get('options', [])) except AttributeError as exc: raise InfrastructureError(exc) except (KeyError, TypeError): self.errors = "Invalid parameters for %s" % self.name
def validate(self): super(FlashDFUAction, self).validate() try: boot = self.job.device['actions']['boot']['methods']['dfu'] dfu_binary = which(boot['parameters']['command']) self.base_command = [dfu_binary] self.base_command.extend(boot['parameters'].get('options', [])) if self.job.device['board_id'] == '0000000000': self.errors = "board_id unset" if self.job.device['usb_vendor_id'] == '0000': self.errors = 'usb_vendor_id unset' if self.job.device['usb_product_id'] == '0000': self.errors = 'usb_product_id unset' self.usb_vendor_id = self.job.device['usb_vendor_id'] self.usb_product_id = self.job.device['usb_product_id'] self.board_id = self.job.device['board_id'] self.base_command.extend(['--serial', self.board_id]) self.base_command.extend([ '--device', '%s:%s' % (self.usb_vendor_id, self.usb_product_id) ]) except AttributeError as exc: raise ConfigurationError(exc) except (KeyError, TypeError): self.errors = "Invalid parameters for %s" % self.name substitutions = {} namespace = self.parameters['namespace'] for action in self.data[namespace]['download-action'].keys(): dfu_full_command = [] image_arg = self.data[namespace]['download-action'][action].get( 'image_arg', None) action_arg = self.data[namespace]['download-action'][action].get( 'file', None) if not image_arg or not action_arg: self.errors = "Missing image_arg for %s. " % action continue if not isinstance(image_arg, str): self.errors = "image_arg is not a string (try quoting it)" continue substitutions["{%s}" % action] = action_arg dfu_full_command.extend(self.base_command) dfu_full_command.extend(substitute([image_arg], substitutions)) self.exec_list.append(dfu_full_command) if len(self.exec_list) < 1: self.errors = "No DFU command to execute"
def validate(self): super(CallQemuAction, self).validate() if self.parameters[ 'method'] == 'qemu' and 'prompts' not in self.parameters: self.errors = "Unable to identify boot prompts from job definition." try: boot = self.job.device['actions']['boot']['methods']['qemu'] if 'parameters' not in boot or 'command' not in boot['parameters']: self.errors = "Invalid device configuration - missing parameters" elif not boot['parameters']['command']: self.errors = "No QEMU binary command found - missing context." qemu_binary = which(boot['parameters']['command']) self.sub_command = [qemu_binary] self.sub_command.extend(boot['parameters'].get('options', [])) self.sub_command.extend( ['%s' % item for item in boot['parameters'].get('extra', [])]) except AttributeError as exc: self.errors = "Unable to parse device options: %s %s" % ( exc, self.job.device['actions']['boot']['methods']['qemu']) except (KeyError, TypeError): self.errors = "Invalid parameters for %s" % self.name substitutions = {} commands = [] for action in self.data['download_action'].keys(): if action == 'offset' or action == 'available_loops' or action == 'uefi': continue image_arg = self.data['download_action'][action].get( 'image_arg', None) action_arg = self.data['download_action'][action].get('file', None) if not image_arg or not action_arg: self.errors = "Missing image_arg for %s. " % action continue substitutions["{%s}" % action] = action_arg commands.append(image_arg) self.sub_command.extend(substitute(commands, substitutions)) if not self.sub_command: self.errors = "No QEMU command to execute" uefi_dir = self.get_common_data('image', 'uefi_dir') if uefi_dir: self.sub_command.extend(['-L', uefi_dir, '-monitor', 'none'])
def validate(self): super(CallQemuAction, self).validate() if self.parameters['method'] == 'qemu' and 'prompts' not in self.parameters: self.errors = "Unable to identify boot prompts from job definition." try: boot = self.job.device['actions']['boot']['methods']['qemu'] if 'parameters' not in boot or 'command' not in boot['parameters']: self.errors = "Invalid device configuration - missing parameters" elif not boot['parameters']['command']: self.errors = "No QEMU binary command found - missing context." qemu_binary = which(boot['parameters']['command']) self.sub_command = [qemu_binary] self.sub_command.extend(boot['parameters'].get('options', [])) self.sub_command.extend( ['%s' % item for item in boot['parameters'].get('extra', [])]) except AttributeError as exc: self.errors = "Unable to parse device options: %s %s" % ( exc, self.job.device['actions']['boot']['methods']['qemu']) except (KeyError, TypeError): self.errors = "Invalid parameters for %s" % self.name substitutions = {} commands = [] for action in self.data['download_action'].keys(): if action == 'offset' or action == 'available_loops' or action == 'uefi': continue image_arg = self.data['download_action'][action].get('image_arg', None) action_arg = self.data['download_action'][action].get('file', None) if not image_arg or not action_arg: self.errors = "Missing image_arg for %s. " % action continue substitutions["{%s}" % action] = action_arg commands.append(image_arg) self.sub_command.extend(substitute(commands, substitutions)) if not self.sub_command: self.errors = "No QEMU command to execute" uefi_dir = self.get_common_data('image', 'uefi_dir') if uefi_dir: self.sub_command.extend(['-L', uefi_dir, '-monitor', 'none'])
def validate(self): super(CallQemuAction, self).validate() # 'arch' must be defined in job definition context. try: if self.job.parameters['context']['arch'] not in \ self.job.device['available_architectures']: self.errors = "Non existing architecture specified in context arch parameter. Please check the device configuration for available options." return except KeyError: self.errors = "Arch parameter must be set in the context section. Please check the device configuration for available architectures." return if self.job.parameters['context']['arch'] in ['amd64', 'x86_64']: self.logger.info( "qemu-system-x86, installed at version: %s" % debian_package_version(pkg='qemu-system-x86', split=False)) if self.job.parameters['context']['arch'] in [ 'arm64', 'arm', 'armhf', 'aarch64' ]: self.logger.info( "qemu-system-arm, installed at version: %s" % debian_package_version(pkg='qemu-system-arm', split=False)) if self.parameters['method'] in ['qemu', 'qemu-nfs']: if 'prompts' not in self.parameters: if self.test_has_shell(self.parameters): self.errors = "Unable to identify boot prompts from job definition." self.methods = self.job.device['actions']['boot']['methods'] method = self.parameters['method'] boot = self.methods[ 'qemu'] if 'qemu' in self.methods else self.methods['qemu-nfs'] try: if 'parameters' not in boot or 'command' not in boot['parameters']: self.errors = "Invalid device configuration - missing parameters" elif not boot['parameters']['command']: self.errors = "No QEMU binary command found - missing context." qemu_binary = which(boot['parameters']['command']) self.sub_command = [qemu_binary] self.sub_command.extend(boot['parameters'].get('options', [])) self.sub_command.extend( ['%s' % item for item in boot['parameters'].get('extra', [])]) except AttributeError as exc: self.errors = "Unable to parse device options: %s %s" % ( exc, self.job.device['actions']['boot']['methods'][method]) except (KeyError, TypeError): self.errors = "Invalid parameters for %s" % self.name namespace = self.parameters['namespace'] for label in self.data[namespace]['download-action'].keys(): if label in ['offset', 'available_loops', 'uefi', 'nfsrootfs']: continue image_arg = self.get_namespace_data(action='download-action', label=label, key='image_arg') action_arg = self.get_namespace_data(action='download-action', label=label, key='file') if not image_arg or not action_arg: self.errors = "Missing image_arg for %s. " % label continue self.substitutions["{%s}" % label] = action_arg self.commands.append(image_arg) self.substitutions["{NFS_SERVER_IP}"] = dispatcher_ip( self.job.parameters['dispatcher']) self.sub_command.extend(substitute(self.commands, self.substitutions)) if not self.sub_command: self.errors = "No QEMU command to execute" uefi_dir = self.get_namespace_data(action='deployimages', label='image', key='uefi_dir') if uefi_dir: self.sub_command.extend(['-L', uefi_dir, '-monitor', 'none']) # Check for enable-kvm command line option in device configuration. if method not in self.job.device['actions']['boot']['methods']: self.errors = "Unknown boot method '%s'" % method return options = self.job.device['actions']['boot']['methods'][method][ 'parameters']['options'] if "-enable-kvm" in options: # Check if the worker has kvm enabled. if not os.path.exists(SYS_CLASS_KVM): self.errors = "Device configuration contains -enable-kvm option but kvm module is not enabled."