예제 #1
0
 def repair(self, host):
     # pylint: disable=missing-docstring
     image_name = host.get_cros_repair_image_name()
     logging.info('Staging build for AU: %s', image_name)
     devserver = dev_server.ImageServer.resolve(image_name, host.hostname)
     devserver.trigger_download(image_name, synchronous=False)
     update_url = tools.image_url_pattern() % (devserver.url(), image_name)
     afe_utils.machine_install_and_update_labels(host, update_url)
    def run_once(self, host, value=None, force=False, repair=False):
        """The method called by the control file to start the test.

        @param host: The host object to update to |value|.
        @param value: The host object to provision with a build corresponding
                      to |value|.
        @param force: True iff we should re-provision the machine regardless of
                      the current image version.  If False and the image
                      version matches our expected image version, no
                      provisioning will be done.
        @param repair: If True, we are doing a repair provision, therefore the
                       build to provision is looked up from the AFE's
                       get_stable_version RPC.

        """
        logging.debug('Start provisioning %s to %s', host, value)

        if not value and not repair:
            raise error.TestFail('No build provided and this is not a repair '
                                 ' job.')

        # If the host is already on the correct build, we have nothing to do.
        if not force and afe_utils.get_build(host) == value:
            # We can't raise a TestNA, as would make sense, as that makes
            # job.run_test return False as if the job failed.  However, it'd
            # still be nice to get this into the status.log, so we manually
            # emit an INFO line instead.
            self.job.record('INFO', None, None,
                            'Host already running %s' % value)
            return

        os_type = None
        board = afe_utils.get_board(host)
        if board:
            logging.debug('Host %s is board type: %s', host, board)
            if adb_host.OS_TYPE_BRILLO in board:
                os_type = adb_host.OS_TYPE_BRILLO
            else:
                os_type = adb_host.OS_TYPE_ANDROID

        if repair:
            board=board.split('-')[-1]
            value = afe_utils.get_stable_version(board=board, android=True)
            if not value:
                raise error.TestFail('No stable version assigned for board: '
                                     '%s' % board)
        url, _ = host.stage_build_for_install(value, os_type=os_type)

        logging.debug('Installing image from: %s', url)
        try:
            afe_utils.machine_install_and_update_labels(
                    host, build_url=url, os_type=os_type)
        except error.InstallError as e:
            logging.error(e)
            raise error.TestFail(str(e))
        logging.debug('Finished provisioning %s to %s', host, value)
예제 #3
0
    def run_once(self, host, value=None, force=False, repair=False):
        """The method called by the control file to start the test.

        @param host: The testbed object to update to |value|.
                     NOTE: This arg must be called host to align with the other
                           provision actions.
        @param value: The testbed object to provision with a build
                      corresponding to |value|.
        @param force: True iff we should re-provision the machine regardless of
                      the current image version.  If False and the image
                      version matches our expected image version, no
                      provisioning will be done.
        @param repair: Not yet supported for testbeds.

        """
        testbed = host
        logging.debug('Start provisioning %s to %s', testbed, value)

        if not value and not repair:
            raise error.TestFail('No build provided and this is not a repair '
                                 ' job.')

        if not force:
            info = testbed.host_info_store.get()
            # If the host is already on the correct build, we have nothing to
            # do.
            if self._builds_to_set(info.build) == self._builds_to_set(value):
                # We can't raise a TestNA, as would make sense, as that makes
                # job.run_test return False as if the job failed.  However, it'd
                # still be nice to get this into the status.log, so we manually
                # emit an INFO line instead.
                self.job.record('INFO', None, None,
                                'Testbed already running %s' % value)
                return

        try:
            afe_utils.machine_install_and_update_labels(host, image=value)
        except error.InstallError as e:
            logging.exception(e)
            raise error.TestFail(str(e))
        logging.debug('Finished provisioning %s to %s', host, value)
예제 #4
0
 def repair(self, host):
     afe_utils.machine_install_and_update_labels(host, repair=True)
    def run_once(self,
                 host,
                 value=None,
                 force=False,
                 repair=False,
                 board=None,
                 os=None):
        """The method called by the control file to start the test.

        @param host: The host object to update to |value|.
        @param value: The host object to provision with a build corresponding
                      to |value|.
        @param force: True iff we should re-provision the machine regardless of
                      the current image version.  If False and the image
                      version matches our expected image version, no
                      provisioning will be done.
        @param repair: If True, we are doing a repair provision, therefore the
                       build to provision is looked up from the AFE's
                       get_stable_version RPC.
        @param board: Board name of the device. For host created in testbed,
                      it does not have host labels and attributes. Therefore,
                      the board name needs to be passed in from the testbed
                      repair call.
        @param os: OS of the device. For host created in testbed, it does not
                   have host labels and attributes. Therefore, the OS needs to
                   be passed in from the testbed repair call.

        """
        logging.debug('Start provisioning %s to %s', host, value)

        if not value and not repair:
            raise error.TestFail('No build provided and this is not a repair '
                                 ' job.')

        info = host.host_info_store.get()
        # If the host is already on the correct build, we have nothing to do.
        if not force and info.build == value:
            # We can't raise a TestNA, as would make sense, as that makes
            # job.run_test return False as if the job failed.  However, it'd
            # still be nice to get this into the status.log, so we manually
            # emit an INFO line instead.
            self.job.record('INFO', None, None,
                            'Host already running %s' % value)
            return

        board = board or info.board
        os = os or info.os
        logging.debug('Host %s is board type: %s, OS type: %s', host, board,
                      os)
        if repair:
            # TODO(kevcheng): remove the board.split() line when all android
            # devices have their board label updated to have no android in
            # there.
            board = board.split('-')[-1]
            value = afe_utils.get_stable_android_version(board)
            if not value:
                raise error.TestFail('No stable version assigned for board: '
                                     '%s' % board)
            logging.debug('Stable version found for board %s: %s', board,
                          value)

        if not isinstance(host, testbed.TestBed):
            url, _ = host.stage_build_for_install(value, os_type=os)
            logging.debug('Installing image from: %s', url)
            args = {'build_url': url, 'os_type': os}
        else:
            logging.debug('Installing image: %s', value)
            args = {'image': value}
        try:
            afe_utils.machine_install_and_update_labels(host, **args)
        except error.InstallError as e:
            logging.error(e)
            raise error.TestFail, str(e), sys.exc_info()[2]
        logging.debug('Finished provisioning %s to %s', host, value)
예제 #6
0
    def run_once(self, host, value, force=False):
        """The method called by the control file to start the test.

        @param host: The host object to update to |value|.
        @param value: The host object to provision with a build corresponding
                      to |value|.
        @param force: True iff we should re-provision the machine regardless of
                      the current image version.  If False and the image
                      version matches our expected image version, no
                      provisioning will be done.

        """
        logging.debug('Start provisioning %s to %s', host, value)
        image = value

        # If the host is already on the correct build, we have nothing to do.
        # Note that this means we're not doing any sort of stateful-only
        # update, and that we're relying more on cleanup to do cleanup.
        # We could just not pass |force_update=True| to |machine_install|,
        # but I'd like the semantics that a provision test 'returns' TestNA
        # if the machine is already properly provisioned.
        if not force and afe_utils.get_build(host) == value:
            # We can't raise a TestNA, as would make sense, as that makes
            # job.run_test return False as if the job failed.  However, it'd
            # still be nice to get this into the status.log, so we manually
            # emit an INFO line instead.
            self.job.record('INFO', None, None,
                            'Host already running %s' % value)
            return

        # We're about to reimage a machine, so we need full_payload and
        # stateful.  If something happened where the devserver doesn't have one
        # of these, then it's also likely that it'll be missing autotest.
        # Therefore, we require the devserver to also have autotest staged, so
        # that the test that runs after this provision finishes doesn't error
        # out because the devserver that its job_repo_url is set to is missing
        # autotest test code.
        # TODO(milleral): http://crbug.com/249426
        # Add an asynchronous staging call so that we can ask the devserver to
        # fetch autotest in the background here, and then wait on it after
        # reimaging finishes or at some other point in the provisioning.
        try:
            ds = dev_server.ImageServer.resolve(image, host.hostname)
            ds.stage_artifacts(
                image, ['full_payload', 'stateful', 'autotest_packages'])
        except dev_server.DevServerException as e:
            raise error.TestFail(str(e))

        self.log_devserver_match_stats(host.hostname, ds.url())

        url = _IMAGE_URL_PATTERN % (ds.url(), image)

        logging.debug('Installing image')
        try:
            afe_utils.machine_install_and_update_labels(
                host,
                force_update=True,
                update_url=url,
                force_full_update=force)
        except error.InstallError as e:
            logging.error(e)
            raise error.TestFail(str(e))
        logging.debug('Finished provisioning %s to %s', host, value)
예제 #7
0
파일: reinstall.py 프로젝트: ghat/honor7x
 def execute(self, host):
     try:
         afe_utils.machine_install_and_update_labels(host)
     except Exception, e:
         raise error.TestFail(str(e))