Lines Matching +full:write +full:- +full:host
3 # Use of this source code is governed by a BSD-style license that can be
30 * For the full deployment case, install dev-signed RO firmware
39 * Every servo host is up and running, and accessible via SSH.
84 _LOG_FORMAT = '%(asctime)s | %(levelname)-10s | %(message)s'
92 _LOG_BUCKET_NAME = 'chromeos-install-logs'
94 _OMAHA_STATUS = 'gs://chromeos-build-release-console/omaha_status.json'
97 # host's prior state.
98 _LOCK_REASON_EXISTING = 'Repairing or deploying an existing host'
99 _LOCK_REASON_NEW_HOST = 'Repairing or deploying a new host'
125 def write(self, s): member in _MultiFileWriter
126 """Write a string to the files.
128 @param s Write this string.
131 file.write(s)
148 utils.run(['gsutil', 'cp', '-r', '--', dirpath, gspath])
163 R##-####.#.#. Will return `None` if no Beta channel
166 ret = utils.run(['gsutil', 'cat', '--', _OMAHA_STATUS])
168 omaha_board = board.replace('_', '-')
174 return 'R%s-%s' % (milestone, build)
187 This host object is used to update AFE label information for the DUT, but
188 can not be used for installation image on the DUT. In particular, this host
193 @param afe_host AFE Host object for the DUT.
205 """Lock a host in the AFE, and report whether it succeeded.
210 @param afe_host AFE Host instance to be locked.
215 logging.warning('Locking host now.')
226 """Unlock a host in the AFE, and report whether it succeeded.
231 @param afe_host AFE Host instance to be unlocked.
236 logging.warning('Unlocking host.')
246 """Update the attributes for a given host.
249 @param hostname Host name of the DUT.
251 host.
269 """Extract servo attributes from the host attribute dict, setting defaults.
290 Poll the host with the given `host_id` via `afe`, waiting for it
294 @param host_id Id of the host that's expected to become idle.
309 running on the given `afe_host`, abort it, then wait for the host to
313 @param afe_host Host to be aborted.
315 @return A true value if the host is idle at return, or a false value
316 if the host wasn't idle after some reasonable time.
323 # * Host status on the main can lag actual status on the shard
325 # guaranteed to post-date the call to lock the DUT.
338 """Get an AFE Host object for the given host.
340 If the host is found in the database, return the object
343 If no host is found, create one with appropriate servo
347 @param hostname Host name of the DUT.
349 host.
353 whether the Host should be unlocked if subsequent operations
364 raise Exception('Failed to lock host')
367 raise Exception('Failed to abort host, and failed to unlock it')
368 raise Exception('Failed to abort task on host')
369 # This host was pre-existing; if the user didn't supply
412 'provided %s %s does not match the %s %s for host %s' %
418 def _create_host_for_installation(host, arguments): argument
421 The host object yielded by the returned context manager is agnostic of the
425 @param host: A server.hosts.CrosHost object.
430 info = host.host_info_store.get()
431 s_host, s_port, s_serial = _extract_servo_attributes(host.hostname,
433 return preparedut.create_cros_host(host.hostname, arguments.board,
439 def _install_test_image(host, arguments): argument
445 @param host Host instance for the DUT being installed.
448 repair_image = _get_cros_repair_image_name(host)
454 preparedut.download_image_to_servo_usb(host, repair_image)
460 preparedut.install_test_image(host)
463 raise Exception('chromeos-install failed')
468 preparedut.flash_firmware_using_servo(host, repair_image)
470 logging.debug('Install FW by chromeos-firmwareupdate.')
471 preparedut.install_firmware(host)
476 else 'chromeos-firmwareupdate')
480 preparedut.reinstall_test_image(host)
483 raise Exception('chromeos-install failed')
488 preparedut.verify_boot_into_rec_mode(host)
499 First, lock the host if it exists and is unlocked. Then,
508 @param hostname Host name of the DUT.
510 host.
515 host = None
517 host = _create_host(hostname, afe, afe_host)
519 _setup_labstation(host)
521 with _create_host_for_installation(host, arguments) as target_host:
523 _update_servo_type_attribute(target_host, host)
527 host.labels.update_labels(host)
531 platform = host.get_platform()
542 logging.error('Failed to unlock host!')
545 if host is not None:
546 host.close()
559 @param hostname Host name of the DUT to install on.
593 followed by a divider line. Then results are printed, one host
596 @param report_log File-like object for logging report
605 report_log.write(heading)
606 report_log.write(_DIVIDER)
608 report_log.write('{result.hostname:30} {result.message}\n'
610 report_log.write('\n')
622 @param report_log File-like object for logging report output.
626 corresponding host succeeded.
643 'Host already in %s' % label)
653 'Host added to %s' % target_pool)
655 report_log.write(_DIVIDER)
658 report_log.write(
688 Return a list of used servo ports for the given servo host.
690 @param servo_hostname: Hostname of the servo host to check for.
693 @returns a list of used ports for the given servo host.
698 for host in host_list:
699 afe_host = afe.get_hosts(hostname=host)
712 @param servo_hostname: Hostname of the servo host.
714 for the given servo host.
717 @returns a free servo port if servo_hostname is non-empty, otherwise an
724 # inferred from the dut hostname (by appending '-servo' to it). We only
729 # If we haven't checked this servo host yet, check the AFE if other duts
730 # used this servo host and grab the ports specified for them.
739 end_port = start_port - 99
741 for port in xrange(start_port, end_port - 1, -1):
753 Get the servo port from the afe if it matches the same servo host hostname.
757 @returns Servo port (int) if servo host hostname matches the one specified
760 @raises _NoAFEServoPortError: When there is no stored host info or servo
761 port host attribute in the AFE for the given host.
781 Get host attributes if a hostname_file was supplied.
795 # If the host already has an entry in the AFE that matches the same
796 # servo host hostname and the servo port is set, use that port.
809 def _get_cros_repair_image_name(host): argument
810 """Get the CrOS repair image name for given host.
812 @param host: hosts.CrosHost object. This object need not have an AFE
815 info = host.host_info_store.get()
817 raise InstallFailedError('Unknown board for given host')
828 dev-signed firmware on the DUT prior to installing the test
837 sys.stderr.write('Installation output logs in %s\n' % arguments.logdir)
857 report_log.write('Dry run - installation and most testing '
870 sys.stderr.write('Logs will be uploaded to %s\n' % (gspath,))
877 sys.stderr.write('Failed to upload logs;'
883 def _update_servo_type_attribute(host, host_to_update): argument
886 @param host A CrOSHost with a initialized servo property.
893 info.attributes['servo_type'] = host.servo.get_servo_version()
898 def _setup_labstation(host): argument
899 """Do initial setup for labstation host.
901 @param host A LabstationHost object.
905 if not host.is_labstation():
906 raise InstallFailedError('Current OS on host %s is not a labstation'
907 ' image.', host.hostname)
909 raise InstallFailedError('Unable to verify host has a labstation image,'
910 ' this can be caused by host is unsshable.')
915 info = host.host_info_store.get()
916 hwid = host.run('crossystem hwid', ignore_status=True).stdout
920 serial_number = host.run('vpd -g serial_number',
924 if info != host.host_info_store.get():
925 host.host_info_store.commit(info)
927 raise InstallFailedError('Failed to get HWID & Serial Number for host'
928 ' %s: %s' % (host.hostname, str(e)))
930 host.labels.update_labels(host)