def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None): self._target_type = target_type self._use_boot_cmds = True if rootfs is not None: self._image_deployment = True else: self._ramdisk_deployment = True self.deployment_data = deployment_data.get(self._target_type) deploy_attempts = self.config.boot_retries attempts = 0 deployed = False while (attempts < deploy_attempts) and (not deployed): logging.info("Deploying test image. Attempt: %d", attempts + 1) try: if self._image_deployment: self._enter_fastboot() self.driver.deploy_linaro_kernel(kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, self._target_type, self.scratch_dir, qemu_pflash=qemu_pflash) deployed = True except (subprocess.CalledProcessError, pexpect.TIMEOUT) as e: msg = "Deployment failed: %s" % e logging.error(msg) attempts += 1 continue if not deployed: logging.error("Infrastructure Error: image deployment failed") msg = "Deployment Failed" logging.critical(msg) raise CriticalError(msg)
def deploy_android(self, images, rootfstype, bootloadertype, target_type): self._target_type = target_type self._image_deployment = True self.deployment_data = deployment_data.get(self._target_type) deploy_attempts = self.config.boot_retries attempts = 0 deployed = False while (attempts < deploy_attempts) and (not deployed): logging.info("Deploying test images image Attempt: %d", attempts + 1) try: self._enter_fastboot() self.driver.deploy_android(images, rootfstype, bootloadertype, self._target_type, self.scratch_dir) deployed = True except (subprocess.CalledProcessError, pexpect.TIMEOUT) as e: msg = "Deployment failed: %s" % e logging.error(msg) attempts += 1 continue if not deployed: logging.error("Infrastructure Error: image deployment failed") msg = "Deployment Failed" logging.critical(msg) raise CriticalError(msg)
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, modules, rootfs, nfsrootfs, bootloader, firmware, bl1, bl2, bl31, rootfstype, bootloadertype, target_type): self._target_type = target_type self._use_boot_cmds = True if rootfs is not None: self._image_deployment = True else: self._ramdisk_deployment = True self.deployment_data = deployment_data.get(self._target_type) deploy_attempts = self.config.boot_retries attempts = 0 deployed = False while (attempts < deploy_attempts) and (not deployed): logging.info("Deploying test image. Attempt: %d" % (attempts + 1)) try: self._enter_fastboot() self.driver.deploy_linaro_kernel(kernel, ramdisk, dtb, modules, rootfs, nfsrootfs, bootloader, firmware, bl1, bl2, bl31, rootfstype, bootloadertype, self._target_type, self.scratch_dir) deployed = True except subprocess.CalledProcessError as e: msg = "Deployment failed: %s" % e logging.error(msg) attempts += 1 continue
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None): # Get deployment data self.deployment_data = deployment_data.get(target_type) self._boot_tags, self._default_boot_cmds = \ self.driver.deploy_linaro_kernel(kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, self.scratch_dir, qemu_pflash=qemu_pflash)
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, modules, rootfs, nfsrootfs, bootloader, firmware, bl1, bl2, bl31, rootfstype, bootloadertype, target_type): # Get deployment data self.deployment_data = deployment_data.get(target_type) self._boot_tags, self._default_boot_cmds = \ self.driver.deploy_linaro_kernel(kernel, ramdisk, dtb, modules, rootfs, nfsrootfs, bootloader, firmware, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, self.scratch_dir)
def deploy_linaro_prebuilt(self, image, dtb, rootfstype, bootfstype, bootloadertype, qemu_pflash=None): self.boot_master_image() if self.context.job_data.get('health_check', False): (boot_tgz, root_tgz, distro) = tarballcache.get_tarballs( self.context, image, self.scratch_dir, self._generate_tarballs) self.deployment_data = deployment_data.get(distro) else: image_file = download_image(image, self.context, self.scratch_dir) (boot_tgz, root_tgz, distro) = self._generate_tarballs(image_file) self._read_boot_cmds(boot_tgz=boot_tgz) self._deploy_tarballs(boot_tgz, root_tgz, rootfstype, bootfstype)
def deploy_linaro_prebuilt(self, image, dtb, rootfstype, bootloadertype, qemu_pflash=None): self.boot_master_image() if self.context.job_data.get('health_check', False): (boot_tgz, root_tgz, distro) = tarballcache.get_tarballs( self.context, image, self.scratch_dir, self._generate_tarballs) self.deployment_data = deployment_data.get(distro) else: image_file = download_image(image, self.context, self.scratch_dir) (boot_tgz, root_tgz, distro) = self._generate_tarballs(image_file) self._read_boot_cmds(boot_tgz=boot_tgz) self._deploy_tarballs(boot_tgz, root_tgz, rootfstype)
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None): # Check for errors if rootfs is None and ramdisk is None: raise CriticalError("You must specify a QEMU file system image or ramdisk") if kernel is None and firmware is None: raise CriticalError("No bootloader or kernel image to boot") if bootloadertype == 'uefi': if firmware is None and qemu_pflash is None \ and self.config.qemu_pflash is None: raise CriticalError("No firmware or qemu_pflash specified with " "bootloadertype UEFI") if rootfs: self._sd_image = download_image(rootfs, self.context) self.customize_image(self._sd_image) self._kernel = download_image(kernel, self.context) if ramdisk is not None: ramdisk = download_image(ramdisk, self.context, decompress=False) if overlays is not None: ramdisk_dir = extract_ramdisk(ramdisk, self.scratch_dir, is_uboot=self._is_uboot_ramdisk(ramdisk)) for overlay in overlays: overlay = download_image(overlay, self.context, self.scratch_dir, decompress=False) extract_overlay(overlay, ramdisk_dir) ramdisk = create_ramdisk(ramdisk_dir, self.scratch_dir) self._ramdisk = ramdisk if rootfs is None: logging.debug("Attempting to set deployment data") self.deployment_data = deployment_data.get(target_type) if dtb is not None: dtb = download_image(dtb, self.context) self._dtb = dtb if bootloadertype == 'uefi': self._bootloadertype = 'uefi' if firmware is not None: firmware = download_image(firmware, self.context) self._firmware = firmware else: # Try downloading pflash files, if it exists. self._download_qemu_pflash_files(qemu_pflash=qemu_pflash)
def parse(self, content, device, output_dir=None): self.loader = yaml.Loader(content) self.loader.compose_node = self.compose_node self.loader.construct_mapping = self.construct_mapping data = self.loader.get_single_data() job = Job(data) job.device = device job.parameters['output_dir'] = output_dir pipeline = Pipeline(job=job) for action_data in data['actions']: line = action_data.pop('yaml_line', None) for name in action_data: if name == "deploy": # allow the classmethod to check the parameters deploy = Deployment.select(device, action_data[name])(pipeline) deploy.action.parameters = action_data[name] # still need to pass the parameters to the instance if 'test' in data['actions']: deploy.action.parameters = action_data['test'] deploy.action.yaml_line = line device.deployment_data = deployment_data.get(deploy.action.parameters['os']) deploy.action.parameters = {'deployment_data': device.deployment_data} else: action_class = Action.find(name) # select the specific action of this class for this job action = action_class() # put parameters (like rootfs_type, results_dir) into the actions. if type(action_data[name]) == dict: action.parameters = action_data[name] elif name == "commands": # FIXME pass elif type(action_data[name]) == list: for param in action_data[name]: action.parameters = param action.summary = name pipeline.add_action(action) # uncomment for debug # print action.parameters # the only parameters sent to the job are job parameters # like job_name, logging_level or target_group. data.pop('actions') data['output_dir'] = output_dir job.set_pipeline(pipeline) return job
def deploy_lxc_image(self, name, release, arch, target_type, persist): # Check for errors if release is None and arch is None: raise CriticalError("You must specify a release and architecture") try: subprocess.check_output(['lxc-create', '-t', 'download', '-n', name, '--', '--dist', target_type, '--release', release, '--arch', arch]).strip() logging.info("Container created.") except subprocess.CalledProcessError: logging.info("Container already exists.") logging.debug("Attempting to set deployment data") self.deployment_data = deployment_data.get(target_type) self.name = name self.persist = persist
def deploy_lxc_image(self, name, release, arch, target_type, persist): # Check for errors if release is None and arch is None: raise CriticalError("You must specify a release and architecture") try: subprocess.check_output([ 'lxc-create', '-t', 'download', '-n', name, '--', '--dist', target_type, '--release', release, '--arch', arch ]).strip() logging.info("Container created.") except subprocess.CalledProcessError: logging.info("Container already exists.") logging.debug("Attempting to set deployment data") self.deployment_data = deployment_data.get(target_type) self.name = name self.persist = persist
def deploy_android(self, boot, system, userdata, rootfstype, bootloadertype, target_type): self._target_type = target_type self._image_deployment = True self.deployment_data = deployment_data.get(self._target_type) deploy_attempts = self.config.boot_retries attempts = 0 deployed = False while (attempts < deploy_attempts) and (not deployed): logging.info("Deploying test image. Attempt: %d" % (attempts + 1)) try: self._enter_fastboot() self.driver.deploy_android(boot, system, userdata, rootfstype, bootloadertype, self._target_type, self.scratch_dir) deployed = True except subprocess.CalledProcessError as e: msg = "Deployment failed: %s" % e logging.error(msg) attempts += 1 continue
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None): if self.__deployment_data__ is None: # Get deployment data logging.debug("Attempting to set deployment data") self.deployment_data = deployment_data.get(target_type) else: # Reset deployment data logging.debug("Attempting to reset deployment data") self.power_off(self.proc) self.__init__(self.context, self.config) # Get deployment data self.deployment_data = deployment_data.get(target_type) # We set the boot type self._set_boot_type(bootloadertype) # At a minimum we must have a kernel if kernel is None: raise CriticalError("No kernel image to boot") if self._is_uboot() or self._is_uefi() or self._is_ipxe(): # Set the server IP (Dispatcher) self._boot_tags['{SERVER_IP}'] = self.context.config.lava_server_ip # We have been passed kernel image kernel = download_image(kernel, self.context, self._tmpdir, decompress=False) if self._is_uboot() or self._is_uefi(): if self.config.uimage_only and not is_uimage(kernel, self.context): if len(self.config.u_load_addrs) == 3: if self.config.text_offset: load_addr = self.config.text_offset else: load_addr = self.config.u_load_addrs[0] kernel = create_uimage(kernel, load_addr, self._tmpdir, self.config.uimage_xip, self.config.uimage_arch) logging.info('uImage created successfully') else: logging.error('Undefined u_load_addrs, aborting uImage creation') self._boot_tags['{KERNEL}'] = self._get_rel_path(kernel, self._base_tmpdir) if ramdisk is not None: # We have been passed a ramdisk ramdisk = download_image(ramdisk, self.context, self._tmpdir, decompress=False) if overlays is not None: ramdisk_dir = extract_ramdisk(ramdisk, self._tmpdir, is_uboot=self._is_uboot_ramdisk(ramdisk)) for overlay in overlays: overlay = download_image(overlay, self.context, self._tmpdir, decompress=False) extract_overlay(overlay, ramdisk_dir) ramdisk = create_ramdisk(ramdisk_dir, self._tmpdir) if self._is_uboot(): # Ensure ramdisk has u-boot header if not self._is_uboot_ramdisk(ramdisk): ramdisk_uboot = ramdisk + ".uboot" logging.info("RAMdisk needs u-boot header. Adding.") cmd = "mkimage -A %s -T ramdisk -C none -d %s %s > /dev/null" \ % (self.config.uimage_arch, ramdisk, ramdisk_uboot) r = subprocess.call(cmd, shell=True) if r == 0: ramdisk = ramdisk_uboot else: logging.warning("Unable to add u-boot header to ramdisk. Tried %s", cmd) self._boot_tags['{RAMDISK}'] = self._get_rel_path(ramdisk, self._base_tmpdir) if dtb is not None: # We have been passed a device tree blob dtb = download_image(dtb, self.context, self._tmpdir, decompress=False) if self.config.append_dtb: kernel = append_dtb(kernel, dtb, self._tmpdir) logging.info('Appended dtb to kernel image successfully') self._boot_tags['{KERNEL}'] = self._get_rel_path(kernel, self._base_tmpdir) else: self._boot_tags['{DTB}'] = self._get_rel_path(dtb, self._base_tmpdir) if rootfs is not None: # We have been passed a rootfs rootfs = download_image(rootfs, self.context, self._tmpdir, decompress=False) self._boot_tags['{ROOTFS}'] = self._get_rel_path(rootfs, self._base_tmpdir) if nfsrootfs is not None: # Extract rootfs into nfsrootfs directory nfsrootfs = download_image(nfsrootfs, self.context, self._tmpdir, decompress=False) self._lava_nfsrootfs = self._setup_nfs(nfsrootfs, self._tmpdir) self._default_boot_cmds = 'boot_cmds_nfs' self._boot_tags['{NFSROOTFS}'] = self._lava_nfsrootfs if overlays is not None and ramdisk is None: for overlay in overlays: overlay = download_image(overlay, self.context, self._tmpdir, decompress=False) extract_overlay(overlay, self._lava_nfsrootfs) if bootloader is not None: # We have been passed a bootloader bootloader = download_image(bootloader, self.context, self._tmpdir, decompress=False) self._boot_tags['{BOOTLOADER}'] = self._get_rel_path(bootloader, self._base_tmpdir) if firmware is not None: # We have been passed firmware firmware = download_image(firmware, self.context, self._tmpdir, decompress=False) self._boot_tags['{FIRMWARE}'] = self._get_rel_path(firmware, self._base_tmpdir) if self._is_uboot(): self._boot_tags['{BOOTX}'] = self._get_uboot_boot_command(kernel, ramdisk, dtb)
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None): if self.__deployment_data__ is None: # Get deployment data logging.debug("Attempting to set deployment data") self.deployment_data = deployment_data.get(target_type) else: # Reset deployment data logging.debug("Attempting to reset deployment data") self.power_off(self.proc) self.__init__(self.context, self.config) # Get deployment data self.deployment_data = deployment_data.get(target_type) # We set the boot type self._set_boot_type(bootloadertype) # At a minimum we must have a kernel if kernel is None: raise CriticalError("No kernel image to boot") if self._is_uboot() or self._is_uefi() or self._is_ipxe(): # Set the server IP (Dispatcher) self._boot_tags['{SERVER_IP}'] = self.context.config.lava_server_ip # We have been passed kernel image kernel = download_image(kernel, self.context, self._tmpdir, decompress=False) if self._is_uboot() or self._is_uefi(): if self.config.uimage_only and not is_uimage(kernel, self.context): if len(self.config.u_load_addrs) == 3: if self.config.text_offset: load_addr = self.config.text_offset else: load_addr = self.config.u_load_addrs[0] kernel = create_uimage(kernel, load_addr, self._tmpdir, self.config.uimage_xip, self.config.uimage_arch) logging.info('uImage created successfully') else: logging.error('Undefined u_load_addrs, aborting uImage creation') self._boot_tags['{KERNEL}'] = self._get_rel_path(kernel, self._base_tmpdir) if ramdisk is not None: # We have been passed a ramdisk ramdisk = download_image(ramdisk, self.context, self._tmpdir, decompress=False) if overlays is not None: ramdisk_dir = extract_ramdisk(ramdisk, self._tmpdir, is_uboot=self._is_uboot_ramdisk(ramdisk)) for overlay in overlays: overlay = download_image(overlay, self.context, self._tmpdir, decompress=False) extract_overlay(overlay, ramdisk_dir) ramdisk = create_ramdisk(ramdisk_dir, self._tmpdir) if self._is_uboot() and not self.config.ramdisk_raw: # Ensure ramdisk has u-boot header if not self._is_uboot_ramdisk(ramdisk): ramdisk_uboot = ramdisk + ".uboot" logging.info("RAMdisk needs u-boot header. Adding.") cmd = "mkimage -A %s -T ramdisk -C none -d %s %s > /dev/null" \ % (self.config.uimage_arch, ramdisk, ramdisk_uboot) r = subprocess.call(cmd, shell=True) if r == 0: ramdisk = ramdisk_uboot else: logging.warning("Unable to add u-boot header to ramdisk. Tried %s", cmd) self._boot_tags['{RAMDISK}'] = self._get_rel_path(ramdisk, self._base_tmpdir) if dtb is not None: # We have been passed a device tree blob dtb = download_image(dtb, self.context, self._tmpdir, decompress=False) if self.config.append_dtb: kernel = append_dtb(kernel, dtb, self._tmpdir) logging.info('Appended dtb to kernel image successfully') self._boot_tags['{KERNEL}'] = self._get_rel_path(kernel, self._base_tmpdir) else: self._boot_tags['{DTB}'] = self._get_rel_path(dtb, self._base_tmpdir) if rootfs is not None: # We have been passed a rootfs rootfs = download_image(rootfs, self.context, self._tmpdir, decompress=False) self._boot_tags['{ROOTFS}'] = self._get_rel_path(rootfs, self._base_tmpdir) if nfsrootfs is not None: # Extract rootfs into nfsrootfs directory nfsrootfs = download_image(nfsrootfs, self.context, self._tmpdir, decompress=False) self._lava_nfsrootfs = self._setup_nfs(nfsrootfs, self._tmpdir) self._default_boot_cmds = 'boot_cmds_nfs' self._boot_tags['{NFSROOTFS}'] = self._lava_nfsrootfs if overlays is not None and ramdisk is None: for overlay in overlays: overlay = download_image(overlay, self.context, self._tmpdir, decompress=False) extract_overlay(overlay, self._lava_nfsrootfs) if bootloader is not None: # We have been passed a bootloader bootloader = download_image(bootloader, self.context, self._tmpdir, decompress=False) self._boot_tags['{BOOTLOADER}'] = self._get_rel_path(bootloader, self._base_tmpdir) if firmware is not None: # We have been passed firmware firmware = download_image(firmware, self.context, self._tmpdir, decompress=False) self._boot_tags['{FIRMWARE}'] = self._get_rel_path(firmware, self._base_tmpdir) if self._is_uboot(): self._boot_tags['{BOOTX}'] = self._get_uboot_boot_command(kernel, ramdisk, dtb)
def run(self, target_type): device = self.client.target_device device.deployment_data = deployment_data.get(target_type) self.client.dummy_deploy(target_type)
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, modules, rootfs, nfsrootfs, bootloader, firmware, bl1, bl2, bl31, rootfstype, bootloadertype, target_type): # Required if kernel is None: raise CriticalError("A kernel image is required") elif ramdisk is None: raise CriticalError("A ramdisk image is required") elif dtb is None: raise CriticalError("A dtb is required") elif bootloader is None: raise CriticalError("UEFI image is required") elif bootloader is None: raise CriticalError("BL1 firmware is required") if rootfs is not None or nfsrootfs is not None or firmware is not None: logging.warn( "This platform only suports ramdisk booting, ignoring other parameters" ) self._ramdisk_boot = True self._kernel = download_image(kernel, self.context, self._scratch_dir, decompress=False) self._boot_tags['{KERNEL}'] = os.path.relpath(self._kernel, self._scratch_dir) self._initrd = download_image(ramdisk, self.context, self._scratch_dir, decompress=False) if modules is not None: modules = download_image(modules, self.context, self._scratch_dir, decompress=False) ramdisk_dir = extract_ramdisk( self._initrd, self._scratch_dir, is_uboot=self._is_uboot_ramdisk(ramdisk)) extract_modules(modules, ramdisk_dir) self._initrd = create_ramdisk(ramdisk_dir, self._scratch_dir) self._boot_tags['{RAMDISK}'] = os.path.relpath(self._initrd, self._scratch_dir) self._dtb = download_image(dtb, self.context, self._scratch_dir, decompress=False) self._boot_tags['{DTB}'] = os.path.relpath(self._dtb, self._scratch_dir) self._uefi = download_image(bootloader, self.context, self._scratch_dir, decompress=False) self._bl1 = download_image(bl1, self.context, self._scratch_dir, decompress=False) # Optional if bl2 is not None: self._bl2 = download_image(bl2, self.context, self._scratch_dir, decompress=False) if bl31 is not None: self._bl31 = download_image(bl31, self.context, self._scratch_dir, decompress=False) # Get deployment data self.deployment_data = deployment_data.get(target_type) # Booting is not supported without an _sd_image defined self._sd_image = self._kernel self._default_boot_cmds = 'boot_cmds_ramdisk'
def dummy_deploy(self, target_type): logging.info("Doing dummy deployment %s" % target_type) self._image_deployment = True self._target_type = target_type self.deployment_data = deployment_data.get(self._target_type) self.driver.dummy_deploy(target_type, self.scratch_dir)
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None): # Check for errors if rootfs is None and ramdisk is None: raise CriticalError( "You must specify a QEMU file system image or ramdisk") if kernel is None and firmware is None: raise CriticalError("No bootloader or kernel image to boot") if bootloadertype == 'uefi': if firmware is None and qemu_pflash is None \ and self.config.qemu_pflash is None: raise CriticalError( "No firmware or qemu_pflash specified with " "bootloadertype UEFI") if rootfs: self._sd_image = download_image(rootfs, self.context) self.customize_image(self._sd_image) self._kernel = download_image(kernel, self.context) if ramdisk is not None: ramdisk = download_image(ramdisk, self.context, decompress=False) if overlays is not None: ramdisk_dir = extract_ramdisk( ramdisk, self.scratch_dir, is_uboot=self._is_uboot_ramdisk(ramdisk)) for overlay in overlays: overlay = download_image(overlay, self.context, self.scratch_dir, decompress=False) extract_overlay(overlay, ramdisk_dir) ramdisk = create_ramdisk(ramdisk_dir, self.scratch_dir) self._ramdisk = ramdisk if rootfs is None: logging.debug("Attempting to set deployment data") self.deployment_data = deployment_data.get(target_type) if dtb is not None: dtb = download_image(dtb, self.context) self._dtb = dtb if bootloadertype == 'uefi': self._bootloadertype = 'uefi' if firmware is not None: firmware = download_image(firmware, self.context) self._firmware = firmware else: # Try downloading pflash files, if it exists. self._download_qemu_pflash_files(qemu_pflash=qemu_pflash)
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None): # Required if kernel is None: raise CriticalError("A kernel image is required") elif ramdisk is None: raise CriticalError("A ramdisk image is required") if rootfs is not None or nfsrootfs is not None or firmware is not None: logging.warning("This platform only supports ramdisk booting, ignoring other parameters") self._ramdisk_boot = True self._kernel = download_image(kernel, self.context, self._scratch_dir, decompress=False) self._boot_tags['{KERNEL}'] = os.path.relpath(self._kernel, self._scratch_dir) self._initrd = download_image(ramdisk, self.context, self._scratch_dir, decompress=False) if overlays is not None: ramdisk_dir = extract_ramdisk(self._initrd, self._scratch_dir, is_uboot=self._is_uboot_ramdisk(ramdisk)) for overlay in overlays: overlay = download_image(overlay, self.context, self._scratch_dir, decompress=False) extract_overlay(overlay, ramdisk_dir) self._initrd = create_ramdisk(ramdisk_dir, self._scratch_dir) self._boot_tags['{RAMDISK}'] = os.path.relpath(self._initrd, self._scratch_dir) # Optional if dtb is not None: self._dtb = download_image(dtb, self.context, self._scratch_dir, decompress=False) self._boot_tags['{DTB}'] = os.path.relpath(self._dtb, self._scratch_dir) if bootloader is None: if self.config.simulator_uefi_default is None: raise CriticalError("UEFI image is required") else: self._uefi = download_image(self.config.simulator_uefi_default, self.context, self._scratch_dir, decompress=False) else: self._uefi = download_image(bootloader, self.context, self._scratch_dir, decompress=False) if bl1 is None: if self.config.simulator_bl1_default is None: raise CriticalError("BL1 firmware is required") else: self._bl1 = download_image(self.config.simulator_bl1_default, self.context, self._scratch_dir, decompress=False) else: self._bl1 = download_image(bl1, self.context, self._scratch_dir, decompress=False) if bl0 is not None: self._bl0 = download_image(bl0, self.context, self._scratch_dir, decompress=False) if bl2 is not None: self._bl2 = download_image(bl2, self.context, self._scratch_dir, decompress=False) if bl31 is not None: self._bl31 = download_image(bl31, self.context, self._scratch_dir, decompress=False) if self.config.simulator_uefi_vars and self._uefi_vars is None: # Create file for flashloader1 self._uefi_vars = os.path.join(self._scratch_dir, self.config.simulator_uefi_vars) touch(self._uefi_vars) # Get deployment data self.deployment_data = deployment_data.get(target_type) if image is not None: self._sd_image = download_image(image, self.context, self._scratch_dir, decompress=True) else: # Booting is not supported without an _sd_image defined self._sd_image = self._kernel self._default_boot_cmds = 'boot_cmds_ramdisk'
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, modules, rootfs, nfsrootfs, bootloader, firmware, bl1, bl2, bl31, rootfstype, bootloadertype, target_type): if self.__deployment_data__ is None: # Get deployment data logging.debug("Attempting to set deployment data") self.deployment_data = deployment_data.get(target_type) else: # Reset deployment data logging.debug("Attempting to reset deployment data") self.power_off(self.proc) self.__init__(self.context, self.config) # Get deployment data self.deployment_data = deployment_data.get(target_type) # We set the boot type self._set_boot_type(bootloadertype) # At a minimum we must have a kernel if kernel is None: raise CriticalError("No kernel image to boot") if self._is_uboot() or self._is_uefi(): # Set the server IP (Dispatcher) self._boot_tags['{SERVER_IP}'] = self.context.config.lava_server_ip # We have been passed kernel image kernel = download_image(kernel, self.context, self._tmpdir, decompress=False) self._boot_tags['{KERNEL}'] = self._get_rel_path(kernel, self._base_tmpdir) if ramdisk is not None: # We have been passed a ramdisk ramdisk = download_image(ramdisk, self.context, self._tmpdir, decompress=False) if modules is not None: modules = download_image(modules, self.context, self._tmpdir, decompress=False) ramdisk_dir = extract_ramdisk(ramdisk, self._tmpdir, is_uboot=self._is_uboot_ramdisk(ramdisk)) extract_modules(modules, ramdisk_dir) ramdisk = create_ramdisk(ramdisk_dir, self._tmpdir) if self._is_uboot(): # Ensure ramdisk has u-boot header if not self._is_uboot_ramdisk(ramdisk): ramdisk_uboot = ramdisk + ".uboot" logging.info("RAMdisk needs u-boot header. Adding.") cmd = "mkimage -A arm -T ramdisk -C none -d %s %s > /dev/null" \ % (ramdisk, ramdisk_uboot) r = subprocess.call(cmd, shell=True) if r == 0: ramdisk = ramdisk_uboot else: logging.warn("Unable to add u-boot header to ramdisk. Tried %s", cmd) self._boot_tags['{RAMDISK}'] = self._get_rel_path(ramdisk, self._base_tmpdir) if dtb is not None: # We have been passed a device tree blob dtb = download_image(dtb, self.context, self._tmpdir, decompress=False) self._boot_tags['{DTB}'] = self._get_rel_path(dtb, self._base_tmpdir) if rootfs is not None: # We have been passed a rootfs rootfs = download_image(rootfs, self.context, self._tmpdir, decompress=False) self._boot_tags['{ROOTFS}'] = self._get_rel_path(rootfs, self._base_tmpdir) if nfsrootfs is not None: # Extract rootfs into nfsrootfs directory nfsrootfs = download_image(nfsrootfs, self.context, self._tmpdir, decompress=False) self._lava_nfsrootfs = self._setup_nfs(nfsrootfs, self._tmpdir) self._default_boot_cmds = 'boot_cmds_nfs' self._boot_tags['{NFSROOTFS}'] = self._lava_nfsrootfs if modules is not None and ramdisk is None: modules = download_image(modules, self.context, self._tmpdir, decompress=False) extract_modules(modules, self._lava_nfsrootfs) if bootloader is not None: # We have been passed a bootloader bootloader = download_image(bootloader, self.context, self._tmpdir, decompress=False) self._boot_tags['{BOOTLOADER}'] = self._get_rel_path(bootloader, self._base_tmpdir) if firmware is not None: # We have been passed firmware firmware = download_image(firmware, self.context, self._tmpdir, decompress=False) self._boot_tags['{FIRMWARE}'] = self._get_rel_path(firmware, self._base_tmpdir) if self._is_uboot(): self._boot_tags['{BOOTX}'] = self._get_uboot_boot_command(kernel, ramdisk, dtb) elif self._is_ipxe(): # We have been passed kernel image kernel = download_image(kernel, self.context, self._tmpdir, decompress=False) kernel_url = self._get_http_url(kernel) self._boot_tags['{KERNEL}'] = kernel_url # We have been passed a ramdisk if ramdisk is not None: # We have been passed a ramdisk ramdisk = download_image(ramdisk, self.context, self._tmpdir, decompress=False) if modules is not None: modules = download_image(modules, self.context, self._tmpdir, decompress=False) ramdisk_dir = extract_ramdisk(ramdisk, self._tmpdir, is_uboot=self._is_uboot_ramdisk(ramdisk)) extract_modules(modules, ramdisk_dir) ramdisk = create_ramdisk(ramdisk_dir, self._tmpdir) ramdisk_url = self._get_http_url(ramdisk) self._boot_tags['{RAMDISK}'] = ramdisk_url elif rootfs is not None: # We have been passed a rootfs rootfs = download_image(rootfs, self.context, self._tmpdir, decompress=False) rootfs_url = self._get_http_url(rootfs) self._boot_tags['{ROOTFS}'] = rootfs_url
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None): # Required if kernel is None: raise CriticalError("A kernel image is required") elif ramdisk is None: raise CriticalError("A ramdisk image is required") if rootfs is not None or nfsrootfs is not None or firmware is not None: logging.warning("This platform only supports ramdisk booting, ignoring other parameters") self._ramdisk_boot = True self._kernel = download_image(kernel, self.context, self._scratch_dir, decompress=False) self._boot_tags['{KERNEL}'] = os.path.relpath(self._kernel, self._scratch_dir) self._initrd = download_image(ramdisk, self.context, self._scratch_dir, decompress=False) if overlays is not None: ramdisk_dir = extract_ramdisk(self._initrd, self._scratch_dir, is_uboot=self._is_uboot_ramdisk(ramdisk)) for overlay in overlays: overlay = download_image(overlay, self.context, self._scratch_dir, decompress=False) extract_overlay(overlay, ramdisk_dir) self._initrd = create_ramdisk(ramdisk_dir, self._scratch_dir) self._boot_tags['{RAMDISK}'] = os.path.relpath(self._initrd, self._scratch_dir) # Optional if dtb is not None: self._dtb = download_image(dtb, self.context, self._scratch_dir, decompress=False) self._boot_tags['{DTB}'] = os.path.relpath(self._dtb, self._scratch_dir) if bootloader is None: if self.config.simulator_uefi_default is None: raise CriticalError("UEFI image is required") else: self._uefi = download_image(self.config.simulator_uefi_default, self.context, self._scratch_dir, decompress=False) else: self._uefi = download_image(bootloader, self.context, self._scratch_dir, decompress=False) if bl1 is None: if self.config.simulator_bl1_default is None: raise CriticalError("BL1 firmware is required") else: self._bl1 = download_image(self.config.simulator_bl1_default, self.context, self._scratch_dir, decompress=False) else: self._bl1 = download_image(bl1, self.context, self._scratch_dir, decompress=False) if bl0 is not None: self._bl0 = download_image(bl0, self.context, self._scratch_dir, decompress=False) if bl2 is not None: self._bl2 = download_image(bl2, self.context, self._scratch_dir, decompress=False) if bl31 is not None: self._bl31 = download_image(bl31, self.context, self._scratch_dir, decompress=False) if self.config.simulator_uefi_vars and self._uefi_vars is None: # Create file for flashloader1 self._uefi_vars = os.path.join(self._scratch_dir, self.config.simulator_uefi_vars) touch(self._uefi_vars) # Get deployment data self.deployment_data = deployment_data.get(target_type) if image is not None: self._sd_image = download_image(image, self.context, self._scratch_dir, decompress=False) else: # Booting is not supported without an _sd_image defined self._sd_image = self._kernel self._default_boot_cmds = 'boot_cmds_ramdisk'
def parse(self, content, device, output_dir=None): self.loader = yaml.Loader(content) self.loader.compose_node = self.compose_node self.loader.construct_mapping = self.construct_mapping data = self.loader.get_single_data() job = Job(data) job.device = device job.parameters['output_dir'] = output_dir pipeline = Pipeline(job=job) for action_data in data['actions']: line = action_data.pop('yaml_line', None) for name in action_data: if name == "deploy": # allow the classmethod to check the parameters deploy = Deployment.select(device, action_data[name])(pipeline) deploy.action.parameters = action_data[ name] # still need to pass the parameters to the instance if 'test' in data['actions']: deploy.action.parameters = action_data['test'] deploy.action.yaml_line = line device.deployment_data = deployment_data.get( deploy.action.parameters['os']) deploy.action.parameters = { 'deployment_data': device.deployment_data } elif name == "boot": boot = Boot.select(device, action_data[name])(pipeline) boot.action.parameters = action_data[name] boot.action.yaml_line = line # elif name == "test": # lavatest = LavaTest.select(device, action_data[name])(pipeline) # lavatest.action.parameters = action_data[name] # lavatest.action.yaml_line = line else: # May only end up being used for submit as other actions all need strategy method objects # select the specific action of this class for this job action = Action.find(name)() # put parameters (like rootfs_type, results_dir) into the actions. if type(action_data[name]) == dict: action.parameters = action_data[name] elif name == "commands": # FIXME pass elif type(action_data[name]) == list: for param in action_data[name]: action.parameters = param action.summary = name pipeline.add_action(action) # uncomment for debug # print action.parameters # there's always going to need to be a finalize_process action pipeline.add_action(FinalizeAction()) # the only parameters sent to the job are job parameters # like job_name, logging_level or target_group. data.pop('actions') data['output_dir'] = output_dir job.set_pipeline(pipeline) return job