Ejemplo n.º 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
Ejemplo n.º 2
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}
     return connection
Ejemplo n.º 3
0
 def run(self, connection, max_end_time):
     serial_number = self.job.device["fastboot_serial_number"]
     self.logger.info("Running custom fastboot boot commands....")
     for command in self.parameters.get("commands"):
         pre_cmd = (lxc_cmd_prefix(self.job) +
                    ["fastboot", "-s", serial_number, command] +
                    self.job.device["fastboot_options"])
         self.run_command(pre_cmd)
Ejemplo n.º 4
0
    def run(self, connection, max_end_time):
        connection = super().run(connection, max_end_time)

        cmd_prefix = lxc_cmd_prefix(self.job)
        # Try to enter fastboot mode with adb.
        adb_serial_number = self.job.device["adb_serial_number"]
        # start the adb daemon
        adb_cmd = cmd_prefix + ["adb", "start-server"]
        command_output = self.parsed_command(adb_cmd, allow_fail=True)
        if command_output and "successfully" in command_output:
            self.logger.debug("adb daemon started: %s", command_output)
        adb_cmd = cmd_prefix + ["adb", "-s", adb_serial_number, "devices"]
        command_output = self.parsed_command(adb_cmd, allow_fail=True)
        if command_output and adb_serial_number in command_output:
            self.logger.debug("Device is in adb: %s", command_output)
            adb_cmd = cmd_prefix + ["adb", "-s", adb_serial_number, "reboot-bootloader"]
            self.run_command(adb_cmd)
            return connection

        # Enter fastboot mode with fastboot.
        fastboot_serial_number = self.job.device["fastboot_serial_number"]
        fastboot_opts = self.job.device["fastboot_options"]
        fastboot_cmd = (
            cmd_prefix
            + ["fastboot", "-s", fastboot_serial_number, "devices"]
            + fastboot_opts
        )
        command_output = self.parsed_command(fastboot_cmd)
        if command_output and fastboot_serial_number in command_output:
            self.logger.debug("Device is in fastboot: %s", command_output)
            fastboot_cmd = (
                cmd_prefix
                + ["fastboot", "-s", fastboot_serial_number, "reboot-bootloader"]
                + fastboot_opts
            )
            command_output = self.parsed_command(fastboot_cmd)
            if command_output and "okay" not in command_output.lower():
                raise InfrastructureError(
                    "Unable to enter 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
Ejemplo n.º 5
0
    def run(self, connection, max_end_time):  # pylint: disable=too-many-locals
        connection = super().run(connection, max_end_time)

        serial_number = self.job.device['fastboot_serial_number']
        fastboot_opts = self.job.device['fastboot_options']

        self.logger.info("fastboot reboot device to bootloader.")
        fastboot_cmd = lxc_cmd_prefix(self.job) + [
            'fastboot', '-s', serial_number, 'reboot-bootloader'
        ] + fastboot_opts
        command_output = self.run_command(fastboot_cmd)
        if not command_output:
            raise InfrastructureError("Unable to reboot to bootloader")
        return connection
Ejemplo n.º 6
0
    def run(self, connection, max_end_time):
        connection = super().run(connection, max_end_time)

        serial_number = self.job.device["fastboot_serial_number"]
        fastboot_opts = self.job.device["fastboot_options"]

        self.logger.info("fastboot rebooting device.")
        fastboot_cmd = (lxc_cmd_prefix(self.job) +
                        ["fastboot", "-s", serial_number, "reboot"] +
                        fastboot_opts)
        # needs to move to self.run_cmd with support
        command_output = self.run_command(fastboot_cmd)
        if not command_output:
            raise InfrastructureError("Unable to reboot")
        return connection
Ejemplo n.º 7
0
 def run(self, connection, max_end_time):
     connection = super().run(connection, max_end_time)
     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,
                                                'reboot'] + fastboot_opts
     command_output = self.run_command(fastboot_cmd, allow_fail=True)
     if command_output and 'rebooting' not in command_output:
         raise JobError("Unable to fastboot reboot: %s" % command_output)
     else:
         status = [status.strip() for status in command_output.split(
             '\n') if 'finished' in status][0]
         self.results = {'status': status}
     self.set_namespace_data(action='shared', label='shared', key='connection', value=connection)
     return connection
Ejemplo n.º 8
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))
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
0
    def run(self, connection, max_end_time):
        connection = super().run(connection, max_end_time)

        cmd_prefix = lxc_cmd_prefix(self.job)
        # Try to enter fastboot mode with adb.
        adb_serial_number = self.job.device['adb_serial_number']
        # start the adb daemon
        adb_cmd = cmd_prefix + ['adb', 'start-server']
        command_output = self.run_command(adb_cmd, allow_fail=True)
        if command_output and 'successfully' in command_output:
            self.logger.debug("adb daemon started: %s", command_output)
        adb_cmd = cmd_prefix + ['adb', '-s', adb_serial_number, 'devices']
        command_output = self.run_command(adb_cmd, allow_fail=True)
        if command_output and adb_serial_number in command_output:
            self.logger.debug("Device is in adb: %s", command_output)
            adb_cmd = cmd_prefix + ['adb', '-s', adb_serial_number,
                                    'reboot-bootloader']
            self.run_command(adb_cmd)
            return connection

        # Enter fastboot mode with fastboot.
        fastboot_serial_number = self.job.device['fastboot_serial_number']
        fastboot_opts = self.job.device['fastboot_options']
        fastboot_cmd = cmd_prefix + ['fastboot', '-s', fastboot_serial_number,
                                     'devices'] + fastboot_opts
        command_output = self.run_command(fastboot_cmd)
        if command_output and fastboot_serial_number in command_output:
            self.logger.debug("Device is in fastboot: %s", command_output)
            fastboot_cmd = cmd_prefix + [
                'fastboot', '-s', fastboot_serial_number, 'reboot-bootloader'
            ] + fastboot_opts
            command_output = self.run_command(fastboot_cmd)
            if command_output and 'OKAY' not in command_output:
                raise InfrastructureError("Unable to enter fastboot: %s" %
                                          command_output)
            else:
                status = [status.strip() for status in command_output.split(
                    '\n') if 'finished' in status][0]
                self.results = {'status': status}
        return connection
Ejemplo n.º 12
0
 def run(self, connection, max_end_time):
     connection = super().run(connection, max_end_time)
     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, "reboot"]
         + fastboot_opts
     )
     command_output = self.parsed_command(fastboot_cmd, allow_fail=True)
     if command_output and "rebooting" not in command_output.lower():
         raise JobError("Unable to fastboot reboot: %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
Ejemplo n.º 13
0
 def get_command_prefix(self):
     return lxc_cmd_prefix(self.action.job)
Ejemplo n.º 14
0
    def run(self, connection, max_end_time):
        connection = super().run(connection, max_end_time)

        cmd_prefix = lxc_cmd_prefix(self.job)
        # Try to enter fastboot mode with adb.
        adb_serial_number = self.job.device['adb_serial_number']
        # start the adb daemon
        adb_cmd = cmd_prefix + ['adb', 'start-server']
        command_output = self.parsed_command(adb_cmd, allow_fail=True)
        if command_output and 'successfully' in command_output:
            self.logger.debug("adb daemon started: %s", command_output)
        adb_cmd = cmd_prefix + ['adb', '-s', adb_serial_number, 'devices']
        command_output = self.parsed_command(adb_cmd, allow_fail=True)
        if command_output and adb_serial_number in command_output:
            self.logger.debug("Device is in adb: %s", command_output)
            adb_cmd = cmd_prefix + [
                'adb', '-s', adb_serial_number, 'reboot-bootloader'
            ]
            self.run_command(adb_cmd)
            return connection

        # Enter fastboot mode with fastboot.
        fastboot_serial_number = self.job.device['fastboot_serial_number']
        fastboot_opts = self.job.device['fastboot_options']
        fastboot_cmd = cmd_prefix + [
            'fastboot', '-s', fastboot_serial_number, 'devices'
        ] + fastboot_opts
        command_output = self.parsed_command(fastboot_cmd)
        if command_output and fastboot_serial_number in command_output:
            self.logger.debug("Device is in fastboot: %s", command_output)
            # Nexell extension
            #fastboot_cmd = cmd_prefix + [
            #'fastboot', '-s', fastboot_serial_number, 'reboot-bootloader'
            #] + fastboot_opts
            fastboot_cmd = cmd_prefix + [
                'fastboot', '-s', fastboot_serial_number, 'reboot'
            ] + fastboot_opts
            self.logger.debug(
                "[SEOJI] chage 'reboot-bootloader' to 'reboot' because of version issue."
            )
            self.logger.debug("[SEOJI] fastboot_cmd:" + str(fastboot_cmd))

            command_output = self.parsed_command(fastboot_cmd)
            self.logger.debug("[SEOJI] command_output: %s", command_output)
            '''
            if command_output and 'okay' not in command_output.lower():
                raise InfrastructureError("Unable to enter 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}
            '''
            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