示例#1
0
 def run(self, connection, max_end_time):
     connection = super().run(connection, max_end_time)
     lxc_name = is_lxc_requested(self.job)
     serial_number = self.job.device['fastboot_serial_number']
     boot_img = self.get_namespace_data(action='download-action',
                                        label='boot',
                                        key='file')
     if not boot_img:
         raise JobError("Boot image not found, unable to boot")
     else:
         if lxc_name:
             boot_img = os.path.join(LAVA_LXC_HOME,
                                     os.path.basename(boot_img))
     fastboot_cmd = lxc_cmd_prefix(self.job) + [
         'fastboot', '-s', serial_number, 'boot', boot_img
     ] + self.job.device['fastboot_options']
     command_output = self.parsed_command(fastboot_cmd, allow_fail=True)
     if command_output and 'booting' not in command_output.lower():
         raise JobError("Unable to boot with fastboot: %s" % command_output)
     else:
         lines = [
             status for status in command_output.split('\n')
             if 'finished' in status.lower()
         ]
         if lines:
             self.results = {'status': lines[0].strip()}
         else:
             self.results = {'fail': self.name}
     self.set_namespace_data(action='shared',
                             label='shared',
                             key='connection',
                             value=connection)
     return connection
示例#2
0
文件: fastboot.py 项目: mytxyang/lava
 def run(self, connection, max_end_time):
     connection = super().run(connection, max_end_time)
     lxc_name = is_lxc_requested(self.job)
     serial_number = self.job.device["fastboot_serial_number"]
     boot_img = self.get_namespace_data(
         action="download-action", label="boot", key="file"
     )
     if not boot_img:
         raise JobError("Boot image not found, unable to boot")
     else:
         if lxc_name:
             boot_img = os.path.join(LAVA_LXC_HOME, os.path.basename(boot_img))
     fastboot_cmd = (
         lxc_cmd_prefix(self.job)
         + ["fastboot", "-s", serial_number, "boot", boot_img]
         + self.job.device["fastboot_options"]
     )
     command_output = self.parsed_command(fastboot_cmd, allow_fail=True)
     if command_output and "booting" not in command_output.lower():
         raise JobError("Unable to boot with fastboot: %s" % command_output)
     else:
         lines = [
             status
             for status in command_output.split("\n")
             if "finished" in status.lower()
         ]
         if lines:
             self.results = {"status": lines[0].strip()}
         else:
             self.results = {"fail": self.name}
     return connection
示例#3
0
    def populate(self, parameters):
        self.internal_pipeline = Pipeline(parent=self,
                                          job=self.job,
                                          parameters=parameters)

        if parameters.get("commands"):
            self.internal_pipeline.add_action(BootFastbootCommands())

        # Always ensure the device is in fastboot mode before trying to boot.
        # Check if the device has a power command such as HiKey, Dragonboard,
        # etc. against device that doesn't like Nexus, etc.
        if self.job.device.get("fastboot_via_uboot", False):
            self.internal_pipeline.add_action(ConnectDevice())
            self.internal_pipeline.add_action(UBootEnterFastbootAction())
        elif self.job.device.hard_reset_command:
            self.force_prompt = True
            self.internal_pipeline.add_action(ConnectDevice())
            self.internal_pipeline.add_action(ResetDevice())
        else:
            self.internal_pipeline.add_action(EnterFastbootAction())

        # Based on the boot sequence defined in the device configuration, add
        # the required pipeline actions.
        sequences = self.job.device["actions"]["boot"]["methods"].get(
            "fastboot", [])
        for sequence in sequences:
            mapped = _fastboot_sequence_map(sequence)
            if mapped[1]:
                self.internal_pipeline.add_action(
                    mapped[0](device_actions=mapped[1]))
            elif mapped[0]:
                self.internal_pipeline.add_action(mapped[0]())
        if self.job.device.hard_reset_command:
            if not is_lxc_requested(self.job):
                self.internal_pipeline.add_action(PreOs())
            if self.has_prompts(parameters):
                self.internal_pipeline.add_action(AutoLoginAction())
                if self.test_has_shell(parameters):
                    self.internal_pipeline.add_action(ExpectShellSession())
                    if "transfer_overlay" in parameters:
                        self.internal_pipeline.add_action(OverlayUnpack())
                    self.internal_pipeline.add_action(
                        ExportDeviceEnvironment())
        else:
            if not is_lxc_requested(self.job):
                self.internal_pipeline.add_action(ConnectAdb())
                self.internal_pipeline.add_action(AdbOverlayUnpack())
示例#4
0
 def driver(self):
     __driver__ = getattr(self, "__driver__", None)
     if not __driver__:
         lxc = is_lxc_requested(self.job)
         if lxc:
             self.__driver__ = LxcDriver(self, lxc)
         elif "docker" in self.parameters:
             image = self.parameters["docker"]["image"]
             self.__driver__ = DockerDriver(self, image)
         else:
             self.__driver__ = NullDriver(self)
     return self.__driver__
示例#5
0
 def test_db410c_minus_lxc(self):
     # Do not run job.validate() since it will require some android tools
     # such as fastboot, adb, etc. to be installed.
     job = self.factory.create_db410c_job("sample_jobs/db410c-minus-lxc.yaml")
     description_ref = self.pipeline_reference("db410c-minus-lxc.yaml", job=job)
     self.assertEqual(description_ref, job.pipeline.describe(False))
     # There shouldn't be any lxc defined
     lxc_name = is_lxc_requested(job)
     self.assertEqual(lxc_name, False)
     deploy = [
         action
         for action in job.pipeline.actions
         if action.name == "fastboot-deploy"
     ][0]
     # No lxc requested, hence lxc_cmd_prefix is an empty list
     self.assertEqual([], lxc_cmd_prefix(job))
示例#6
0
    def populate(self, parameters):
        self.pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
        if self.test_needs_overlay(parameters):
            self.pipeline.add_action(OverlayAction())
        # Check if the device has a power command such as HiKey, Dragonboard,
        # etc. against device that doesn't like Nexus, etc.
        if self.job.device.get("fastboot_via_uboot", False):
            self.pipeline.add_action(ConnectDevice())
            self.pipeline.add_action(UBootEnterFastbootAction())
        elif self.job.device.hard_reset_command:
            self.force_prompt = True
            self.pipeline.add_action(ConnectDevice())
            if not is_lxc_requested(self.job):
                self.pipeline.add_action(PrePower())
            self.pipeline.add_action(ResetDevice())
        else:
            self.pipeline.add_action(EnterFastbootAction())

        fastboot_dir = self.mkdtemp()
        for image in sorted(parameters["images"].keys()):
            self.pipeline.add_action(
                DownloaderAction(
                    image, fastboot_dir, params=parameters["images"][image]
                )
            )
            if parameters["images"][image].get("apply-overlay", False):
                if self.test_needs_overlay(parameters):
                    if parameters["images"][image].get("sparse", True):
                        self.pipeline.add_action(ApplyOverlaySparseImage(image))
                    else:
                        use_root_part = parameters["images"][image].get(
                            "root_partition", False
                        )
                        self.pipeline.add_action(
                            ApplyOverlayImage(image, use_root_partition=use_root_part)
                        )

            if self.test_needs_overlay(parameters) and self.test_needs_deployment(
                parameters
            ):
                self.pipeline.add_action(DeployDeviceEnvironment())
        self.pipeline.add_action(FastbootFlashOrderAction())
示例#7
0
文件: fastboot.py 项目: ivoire/lava
    def run(self, connection, max_end_time):  # pylint: disable=too-many-locals
        connection = super().run(connection, max_end_time)

        src = self.get_namespace_data(
            action="download-action", label=self.command, key="file"
        )
        if not src:
            return connection
        self.logger.debug("%s bytes", os.stat(src)[6])
        lxc_name = is_lxc_requested(self.job)
        if lxc_name:
            src = copy_to_lxc(lxc_name, src, self.job.parameters["dispatcher"])
        sequence = self.job.device["actions"]["boot"]["methods"].get("fastboot", [])
        if "no-flash-boot" in sequence and self.command in ["boot"]:
            return connection

        # if a reboot is requested, will need to wait for the prompt
        # if not, continue in the existing mode.
        reboot = self.get_namespace_data(
            action=self.name, label="interrupt", key="reboot"
        )
        if self.interrupt_prompt and reboot:
            connection.prompt_str = self.interrupt_prompt
            self.logger.debug("Changing prompt to '%s'", connection.prompt_str)
            self.wait(connection)

        serial_number = self.job.device["fastboot_serial_number"]
        fastboot_opts = self.job.device["fastboot_options"]
        fastboot_cmd = (
            lxc_cmd_prefix(self.job)
            + ["fastboot", "-s", serial_number, "flash", self.command, src]
            + fastboot_opts
        )
        self.logger.info("Handling %s", self.command)
        # needs to move to self.run_cmd with support for raising InfrastructureError
        command_output = self.run_command(fastboot_cmd)
        if not command_output:
            raise InfrastructureError(
                "Unable to flash %s using fastboot" % self.command
            )
        self.results = {"label": self.command}
        return connection
示例#8
0
    def run(self, connection, max_end_time):  # pylint: disable=too-many-locals
        connection = super().run(connection, max_end_time)

        src = self.get_namespace_data(action='download-action',
                                      label=self.command,
                                      key='file')
        if not src:
            return connection
        self.logger.debug("%s bytes", os.stat(src)[6])
        lxc_name = is_lxc_requested(self.job)
        if lxc_name:
            src = copy_to_lxc(lxc_name, src, self.job.parameters['dispatcher'])
        sequence = self.job.device['actions']['boot']['methods'].get(
            'fastboot', [])
        if 'no-flash-boot' in sequence and self.command in ['boot']:
            return connection

        # if a reboot is requested, will need to wait for the prompt
        # if not, continue in the existing mode.
        reboot = self.get_namespace_data(action=self.name,
                                         label='interrupt',
                                         key='reboot')
        if self.interrupt_prompt and reboot:
            connection.prompt_str = self.interrupt_prompt
            self.logger.debug("Changing prompt to '%s'", connection.prompt_str)
            self.wait(connection)

        serial_number = self.job.device['fastboot_serial_number']
        fastboot_opts = self.job.device['fastboot_options']
        fastboot_cmd = lxc_cmd_prefix(self.job) + [
            'fastboot', '-s', serial_number, 'flash', self.command, src
        ] + fastboot_opts
        self.logger.info("Handling %s", self.command)
        # needs to move to self.run_cmd with support for raising InfrastructureError
        command_output = self.run_command(fastboot_cmd)
        if not command_output:
            raise InfrastructureError("Unable to flash %s using fastboot" %
                                      self.command)
        self.results = {'label': self.command}
        return connection
示例#9
0
    def populate(self, parameters):
        self.internal_pipeline = Pipeline(parent=self,
                                          job=self.job,
                                          parameters=parameters)
        image_keys = list(parameters['images'].keys())
        if self.test_needs_overlay(parameters):
            self.logger.debug("[SEOJI] add OverlayAction")
            self.internal_pipeline.add_action(OverlayAction())
        # Check if the device has a power command such as HiKey, Dragonboard,
        # etc. against device that doesn't like Nexus, etc.
        if self.job.device.get('fastboot_via_uboot', False):
            self.internal_pipeline.add_action(ConnectDevice())
            self.internal_pipeline.add_action(UBootEnterFastbootAction())
        elif self.job.device.hard_reset_command:
            self.force_prompt = True
            self.internal_pipeline.add_action(ConnectDevice())
            if not is_lxc_requested(self.job):
                self.internal_pipeline.add_action(PrePower())
            self.internal_pipeline.add_action(ResetDevice())
        elif 'nexell_ext' in image_keys:
            # Nexell extension
            #self.internal_pipeline.add_action(OverlayAction())

            # download build result
            if 'url' in parameters['images']['nexell_ext']:
                self.logger.debug(
                    "[SEOJI] url:" +
                    str(parameters['images']['nexell_ext']['url']))
                self.path = '/opt/share'
                self.internal_pipeline.add_action(
                    DownloaderAction('nexell_ext', self.path))
                #if 'compression' in parameters['images']['nexell_ext]:
                #self.logger.debug("[SEOJI] yes compression param exist")

            self.logger.debug("SUKER: parameters in deploy/fastboot.py : " +
                              str(parameters))
            self.internal_pipeline.add_action(
                EnterNexellFastbootAction(parameters, 'deploy_script',
                                          'deploy_command1', 'dir_name'))
            self.internal_pipeline.add_action(
                ApplyNexellDeployAction(parameters, 'deploy_script',
                                        'deploy_command2', 'dir_name'))
        else:
            self.internal_pipeline.add_action(EnterFastbootAction())

        fastboot_dir = self.mkdtemp()
        image_keys = sorted(parameters['images'].keys())
        # Nexell extension
        if 'nexell_ext' in image_keys:
            self.logger.debug("[SEOJI] pass adding DownloaderAction")
            #self.internal_pipeline.add_action(DeployDeviceEnvironment())
        else:
            for image in image_keys:
                if image != 'yaml_line':
                    self.internal_pipeline.add_action(
                        DownloaderAction(image, fastboot_dir))
                    if parameters['images'][image].get('apply-overlay', False):
                        if self.test_needs_overlay(parameters):
                            if parameters['images'][image].get('sparse', True):
                                self.internal_pipeline.add_action(
                                    ApplyOverlaySparseImage(image))
                            else:
                                self.internal_pipeline.add_action(
                                    ApplyOverlayImage(
                                        image, use_root_partition=False))
                    if self.test_needs_overlay(parameters) and \
                       self.test_needs_deployment(parameters):
                        self.internal_pipeline.add_action(
                            DeployDeviceEnvironment())
            self.internal_pipeline.add_action(FastbootFlashOrderAction())
        '''
示例#10
0
    def populate(self, parameters):
        self.internal_pipeline = Pipeline(parent=self,
                                          job=self.job,
                                          parameters=parameters)

        # Nexell Extension
        if 'nexell_ext' in parameters:
            self.logger.debug("[SEOJI] ****** parameters: %s", parameters)
            self.internal_pipeline.add_action(
                NexellFastbootBootAction(parameters))
            self.internal_pipeline.add_action(ConnectDevice())
            if self.has_prompts(parameters):
                if 'auto_login' in parameters:
                    self.internal_pipeline.add_action(AutoLoginAction())
            self.internal_pipeline.add_action(
                WaitForAdbDeviceForNexell(parameters))
            self.internal_pipeline.add_action(ApplyNexellOverlay())
            self.internal_pipeline.add_action(ExpectShellSession())
        else:
            if parameters.get("commands"):
                self.logger.debug("[SEOJI] boot - add BootFastbootCommands()")
                self.internal_pipeline.add_action(BootFastbootCommands())

            # Always ensure the device is in fastboot mode before trying to boot.
            # Check if the device has a power command such as HiKey, Dragonboard,
            # etc. against device that doesn't like Nexus, etc.
            if self.job.device.get('fastboot_via_uboot', False):
                self.internal_pipeline.add_action(ConnectDevice())
                self.internal_pipeline.add_action(UBootEnterFastbootAction())
            elif self.job.device.hard_reset_command:
                self.force_prompt = True
                self.internal_pipeline.add_action(ConnectDevice())
                self.internal_pipeline.add_action(ResetDevice())
            else:
                self.logger.debug("[SEOJI] boot - add EnterFastbootAction")
                self.internal_pipeline.add_action(EnterFastbootAction())

            # Based on the boot sequence defined in the device configuration, add
            # the required pipeline actions.
            self.logger.debug("[SEOJI] get sequences")
            sequences = self.job.device['actions']['boot']['methods'].get(
                'fastboot', [])
            self.logger.debug("[SEOJI] sequences" + str(sequences))
            for sequence in sequences:
                mapped = _fastboot_sequence_map(sequence)
                if mapped[1]:
                    self.internal_pipeline.add_action(
                        mapped[0](device_actions=mapped[1]))
                elif mapped[0]:
                    self.internal_pipeline.add_action(mapped[0]())
            if self.job.device.hard_reset_command:
                if not is_lxc_requested(self.job):
                    self.internal_pipeline.add_action(PreOs())
                if self.has_prompts(parameters):
                    self.internal_pipeline.add_action(AutoLoginAction())
                    if self.test_has_shell(parameters):
                        self.internal_pipeline.add_action(ExpectShellSession())
                        if 'transfer_overlay' in parameters:
                            self.internal_pipeline.add_action(OverlayUnpack())
                        self.internal_pipeline.add_action(
                            ExportDeviceEnvironment())
            else:
                if not is_lxc_requested(self.job):
                    self.internal_pipeline.add_action(ConnectAdb())
                    self.internal_pipeline.add_action(AdbOverlayUnpack())