Lines Matching +full:- +full:- +full:host
3 # Use of this source code is governed by a BSD-style license that can be
54 # _DEV_MODE_ALLOW_POOLS - The set of pools that are allowed to be
78 # - triggers: _CROS_PROVISION_TRIGGERS
79 # - depends on: _CROS_USB_TRIGGERS + _CROS_POWERWASH_TRIGGERS
82 # - triggers: _CROS_POWERWASH_TRIGGERS + _CROS_PROVISION_TRIGGERS
83 # - depends on: _CROS_USB_TRIGGERS
86 # - triggers: _CROS_USB_TRIGGERS + _CROS_POWERWASH_TRIGGERS +
88 # - depends on: _CROS_USB_DEPENDENCIES
140 def verify(self, host): argument
141 # pylint: disable=missing-docstring
142 info = self._load_info(host)
144 self._validate_battery(host, info)
146 def _load_info(self, host): argument
148 info = host.get_power_supply_info()
164 def _validate_battery(self, host, info): argument
165 host_info = host.host_info_store.get()
168 data = {'host': host.hostname, 'model': host_info.model}
183 'host': host.hostname,
197 host.run('ectool chargecontrol normal', ignore_status=True)
200 info = self._load_info(host)
206 'model': host.host_info_store.get().model,
217 metrics_data = {'host': host.hostname,
218 'board': host.host_info_store.get().board}
227 logging.warning('Cannot determine battery state -'
232 # pylint: disable=missing-docstring
237 """Confirm that current ChromeOS image on the host is matches
241 provision-cros_version or provisioning-job_repo_url labels, which could
242 cause the next test run on the same host gets an unexpected data and
247 def verify(self, host): argument
248 self._verify_cros_version(host)
249 self._verify_job_repo_url(host)
251 def _verify_cros_version(self, host): argument
252 """Verify that cros-version match version on the host."""
255 label_match = host.verify_cros_version_label()
262 host.hostname, e)
265 raise hosts.AutoservVerifyError('ChromeOS image on the host'
266 ' does not match to cros-version'
269 def _verify_job_repo_url(self, host): argument
270 """Verify that job_repo_url match version on the host."""
271 info = host.host_info_store.get()
276 os_from_host = host.get_release_builder_path()
278 raise hosts.AutoservVerifyError('ChromeOS image on the host'
284 # pylint: disable=missing-docstring
285 return 'ChromeOS image on host matches cros_version label'
294 system status to read-only. This checks that that hasn't happened.
307 # N.B. Order matters here: Encrypted stateful is loop-mounted from
313 def verify(self, host): argument
314 # pylint: disable=missing-docstring
318 if not host.is_file_system_writable([testdir]):
324 # pylint: disable=missing-docstring
334 def verify(self, host): argument
335 # pylint: disable=missing-docstring
336 # grep for stateful FS errors of the type "EXT4-fs error (device sda1):"
337 command = ("dmesg | grep -E \"EXT4-fs error \(device "
338 "$(cut -d ' ' -f 5,9 /proc/$$/mountinfo | "
339 "grep -e '^/mnt/stateful_partition ' | "
340 "cut -d ' ' -f 2 | cut -d '/' -f 3)\):\"")
341 output = host.run(command=command, ignore_status=True).stdout
348 output = host.run(command=command, ignore_status=True).stdout
357 # pylint: disable=missing-docstring
376 def verify(self, host): argument
377 # pylint: disable=missing-docstring
378 result = host.run('test -f %s' % provisioner.PROVISION_FAILED,
386 # pylint: disable=missing-docstring
391 """Verify that the host's TPM is in a good state."""
394 def verify(self, host): argument
395 # pylint: disable=missing-docstring
396 if _is_virtual_machine(host):
397 # We do not forward host TPM / emulated TPM to qemu VMs, so skip
403 status = TpmStatus(host)
405 logging.info('Cannot determine the Cryptohome valid status - '
411 'TPM is not enabled -- Hardware is not working.')
415 logging.info('Cannot determine the TPM valid status - '
420 # pylint: disable=missing-docstring
421 return 'The host\'s TPM is available and working'
428 def verify(self, host): argument
429 # pylint: disable=missing-docstring
430 result = host.run('python -c "import json"',
435 search = host.run('which python', ignore_status=True)
443 # pylint: disable=missing-docstring
444 return 'Python on the host is installed and working'
448 """Verify that the host is not in dev mode."""
451 def verify(self, host): argument
452 # pylint: disable=missing-docstring
454 info = host.host_info_store.get()
459 result = host.run('crossystem devsw_boot', ignore_status=True).stdout
461 raise hosts.AutoservVerifyError('The host is in dev mode')
465 # pylint: disable=missing-docstring
466 return 'The host should not be in dev mode'
470 """Verify that the host is set to boot the internal disk by default."""
473 def verify(self, host): argument
474 # pylint: disable=missing-docstring
475 result = host.run('crossystem dev_default_boot', ignore_status=True)
479 'The host has incorrect dev_default_boot value: %r'
484 # pylint: disable=missing-docstring
485 return 'The host should have dev_default_boot=disk'
489 """Verify that the host has HWID & serial number."""
492 def verify(self, host): argument
493 # pylint: disable=missing-docstring
494 info = host.host_info_store.get()
505 ' Marking DUT for need re-deployment.')
506 host.set_device_repair_state(
510 host_hwid = host.run('crossystem hwid', ignore_status=True).stdout
511 host_serial_number = self._get_serial_number(host, info_serial_number)
514 'Failed to get HWID & Serial Number for host %s' %
515 host.hostname)
521 'host': host.hostname,
532 ' Marking DUT for need re-deployment.', info_serial_number,
534 host.set_device_repair_state(
537 def _get_serial_number(self, host, serial_number): argument
543 @param host CrosHost
544 @param serial_number Serial-number from host-info
546 req = host.run('vpd -g serial_number', ignore_status=True)
551 l1 = host.run('vpd -l', ignore_status=True)
552 l2 = host.run('vpd -l |grep "\"serial_number\"="',
558 cmd = 'vpd -s serial_number=%s'
559 host.run(cmd % serial_number, ignore_status=True)
560 host.run('dump_vpd_log --force', ignore_status=True)
562 req = host.run('vpd -g serial_number', ignore_status=True)
565 def _is_applicable(self, host): argument
566 if host.is_satlab():
573 # pylint: disable=missing-docstring
574 return 'The host should have valid HWID and Serial Number'
581 Flag 1 - The presence of install attributes file in
584 Flag 2 - The value of "check_enrollment" from VPD. Can be obtained by
586 /mnt/stateful_partition/unencrypted/cache/vpd/full-v2.txt
589 State 1 - Device is enrolled, means flag 1 is true and in
591 State 2 - Device is consumer owned, means flag 1 is true and in
593 State 3 - Device is enrolled and has been powerwashed, means flag 1 is
595 device will perform forced re-enrollment check and depending
604 VPD_CACHE = '/mnt/stateful_partition/unencrypted/cache/vpd/full-v2.txt'
607 def verify(self, host): argument
608 # pylint: disable=missing-docstring
609 if self._get_enrollment_state(host):
614 def _get_enrollment_state(self, host): argument
616 response = host.run('grep "check_enrollment" %s' % self.VPD_CACHE,
627 def _is_applicable(self, host): argument
628 info = host.host_info_store.get()
634 # pylint: disable=missing-docstring
635 return 'The enrollment state is clean on the host'
641 For dev-signed firmware, tpm_fwver and tpm_kernver reported from
653 def verify(self, host): argument
654 # pylint: disable=missing-docstring
656 result = host.run('crossystem %s' % field, ignore_status=True)
667 def _is_applicable(self, host): argument
668 return cros_firmware._is_firmware_testing_device(host)
672 # pylint: disable=missing-docstring
681 def verify(self, host): argument
682 # pylint: disable=missing-docstring
684 status = TpmStatus(host)
695 # command is line-oriented property/value pairs.
696 result = host.run('cryptohome --action=tpm_status')
705 # pylint: disable=missing-docstring
714 def verify(self, host): argument
715 # pylint: disable=missing-docstring
718 result = host.run('cryptohome --action=tpm_more_status')
723 result = host.run('cryptohome --action=tpm_attestation_get_ek')
733 # pylint: disable=missing-docstring
743 def verify(self, host): argument
744 # pylint: disable=missing-docstring
746 host.run('pgrep ap-controller')
749 'ap-controller process is not running')
753 # pylint: disable=missing-docstring
767 def verify(self, host): argument
769 host.run('stop ui && start ui', ignore_status=True, timeout=45)
783 to re-image the host to recover it.
784 If host-info has label 'cr50' then we expect to have GSC tool on the host.
787 VERIFY_GSC_CMD = 'gsctool -a -f'
790 def verify(self, host): argument
791 r = host.run(self.VERIFY_GSC_CMD, ignore_status=True, timeout=10)
797 def _is_applicable(self, host): argument
798 host_info = host.host_info_store.get()
801 logging.info('GSC is not on the host.')
817 def verify(self, host): argument
818 # pylint: disable=missing-docstring
821 usb_dev = host._servo_host._probe_and_validate_usb_dev()
825 host_info = host.host_info_store.get()
829 host.host_info_store.commit(host_info)
831 'USB-drive is not detected or bad')
833 # Check if USB-drive marked for replacement.
837 # Allow to use USB-key marked for replacement.
842 # 'USB-drive marked for replacement')
844 # The USB-drive detected and was not mark for replacement.
848 host.host_info_store.commit(host_info)
850 def _is_applicable(self, host): argument
851 if host.servo:
869 def verify(self, host): argument
870 # pylint: disable=missing-docstring
871 verifier = audit_verify.VerifyDutStorage(host)
879 host.set_device_needs_replacement()
895 def verify(self, host): argument
896 # pylint: disable=missing-docstring
899 state = self._get_validator(host).validate()
908 host.set_device_needs_replacement()
910 def _is_applicable(self, host): argument
911 return self._get_validator(host).is_battery_expected()
913 def _get_validator(self, host): argument
915 self._validator = battery_validator.BatteryValidator(host)
924 """Not critical verify to flash servo keyboard for the host.
926 Check if host support servo keyboard and update if firmware is not present.
930 def verify(self, host): argument
933 if flasher.is_image_supported(host):
934 flasher.update(host)
938 'Fail to verify/update servo keyboard map on the host.')
940 def _is_applicable(self, host): argument
941 if host.servo:
951 """Not critical verify to cache NIC mac address for the host on servo.
958 def verify(self, host): argument
961 helper.update_if_needed(host)
965 'Fail to verify/update servo NIC mac address for host.')
967 def _is_applicable(self, host): argument
968 if host.servo:
980 def _collect_logs(self, host): argument
983 local_log_dir = crashcollect.get_crashinfo_dir(host, dirname)
985 crashcollect.get_crashinfo(host, None)
987 def _check_reset_success(self, host): argument
990 if host.wait_up(host.BOOT_TIMEOUT):
991 if host.get_verifier_state('ssh') == hosts.VERIFY_SUCCESS:
998 self._collect_logs(host)
1003 logging.exception('Non-critical failure in log '
1008 'Host %s is offline after %s.' % (host.hostname, self.tag),
1016 Sending 3 times the Alt+VolUp+x key combination (aka sysrq-x)
1022 def repair(self, host): argument
1023 # pylint: disable=missing-docstring
1024 repair_utils.require_servo(host, ignore_state=True)
1030 host.servo.sysrq_x()
1033 'cannot press sysrq-x: %s.' % str(ex),
1037 self._check_reset_success(host)
1041 # pylint: disable=missing-docstring
1042 return 'Reset the DUT via keyboard sysrq-x'
1049 def repair(self, host): argument
1050 # pylint: disable=missing-docstring
1051 repair_utils.require_servo(host, ignore_state=True)
1052 host.servo.get_power_state_controller().reset()
1053 self._check_reset_success(host)
1055 def _is_applicable(self, host): argument
1056 if host.servo:
1062 # pylint: disable=missing-docstring
1074 def repair(self, host): argument
1075 # pylint: disable=missing-docstring
1077 host.servo.get_power_state_controller().cr50_reset()
1078 self._check_reset_success(host)
1081 # so we want to re-initialize servo after cr50 reset if the main
1083 if host.servo.main_device_uses_gsc_drv():
1084 host.servo.initialize_dut()
1086 def _is_applicable(self, host): argument
1087 if host.servo:
1088 if host.servo.has_control('cr50_reboot'):
1094 # pylint: disable=missing-docstring
1102 def repair(self, host): argument
1103 # pylint: disable=missing-docstring
1104 host.run('crossystem dev_default_boot=disk', ignore_status=True)
1108 # pylint: disable=missing-docstring
1116 def repair(self, host): argument
1117 # pylint: disable=missing-docstring
1120 host.run('/usr/share/vboot/bin/set_gbb_flags.sh 0',
1122 host.run('crossystem disable_dev_request=1',
1124 super(CrosRebootRepair, self).repair(host)
1128 # pylint: disable=missing-docstring
1129 return 'Reset GBB flags and Reboot the host'
1133 """Repair issue with provisioning labels for the host.
1136 re-generate required fields.
1140 def repair(self, host): argument
1141 afe_utils.clean_provision_labels(host)
1145 # pylint: disable=missing-docstring
1146 return 'Cleanup provisioning labels for the host'
1153 def repair(self, host): argument
1155 host.run('/usr/sbin/update_rw_vpd check_enrollment 0')
1158 tpm_utils.ClearTPMOwnerRequest(host, wait_for_ready=True,
1159 timeout=host.BOOT_TIMEOUT)
1161 def _is_applicable(self, host): argument
1162 info = host.host_info_store.get()
1168 # pylint: disable=missing-docstring
1169 return 'Cleanup enrollment state and reboot the host'
1174 Repair by re-installing a test image using quick provision.
1181 def repair(self, host): argument
1182 # pylint: disable=missing-docstring
1183 image_name = host.get_cros_repair_image_name()
1185 devserver = dev_server.ImageServer.resolve(image_name, host.hostname)
1189 afe_utils.machine_install_and_update_labels(host, update_url)
1193 # pylint: disable=missing-docstring
1194 return 'Re-install the stable build on the host'
1199 Powerwash the DUT, then re-install using quick provision.
1201 Powerwash the DUT, then attempt to re-install a stable test image as
1206 def repair(self, host): argument
1207 # pylint: disable=missing-docstring
1208 host.run('echo "fast safe" > '
1210 host.reboot(timeout=host.POWERWASH_BOOT_TIMEOUT, wait=True)
1211 super(PowerWashRepair, self).repair(host)
1215 # pylint: disable=missing-docstring
1216 return 'Powerwash and then re-install the stable build on the host'
1223 Use servo to re-install the DUT's designated "stable test image"
1224 from servo-attached USB storage.
1230 def repair(self, host): argument
1232 # pylint: disable=missing-docstring
1233 repair_utils.require_servo(host, ignore_state=True)
1234 image_name = host.get_cros_repair_image_name()
1235 image_name_on_usb = host._servo_host.validate_image_usbkey()
1245 # Verify if we want to force re-image the USB.
1246 if not need_update_image and host.health_profile:
1247 repair_failed_count = host.health_profile.get_repair_fail_count()
1248 # try to re-image USB when previous attempt failed
1252 'Required re-download image to usbkey as'
1260 _, update_url = host.stage_image_for_servo()
1261 afe_utils.clean_provision_labels(host)
1263 need_snk = host.require_snk_mode_in_recovery()
1265 host.servo.get_power_state_controller().power_off()
1268 host.install_image_to_servo_usb(image_url=update_url)
1270 # Format USB-storage as incorrect download image can cause
1272 self._format_usb_storage(host)
1275 host.servo.get_power_state_controller().power_on()
1282 host.boot_in_recovery_mode(need_snk=need_snk)
1286 host.run_install_image(install_timeout=host.ADMIN_INSTALL_TIMEOUT * 2,
1289 afe_utils.add_provision_labels(host, host.VERSION_PREFIX, image_name)
1290 # Collect info which USB-key used for successful re-image.
1291 host_info = host.host_info_store.get()
1295 metrics_data = {'host': host.hostname, 'usb_state': usb_state}
1299 def _format_usb_storage(self, host): argument
1300 """Format USB-storage connected to servo."""
1302 # Format USB-storage to prevent corrupted image to be
1304 usb_path = host.servo.probe_host_usb_dev()
1306 cmd = 'mkfs.ext4 -F %s' % usb_path
1307 host._servo_host.run(cmd, ignore_status=True)
1309 logging.info('(Not critical) fail to format USB-storage: %s', e)
1313 # pylint: disable=missing-docstring
1318 """Repair a host by resetting it with servo.
1321 USB-install. The repair will be applicable only if device was successful
1322 booted from USB-key.
1326 def repair(self, host): argument
1327 # pylint: disable=missing-docstring
1328 host.servo.get_power_state_controller().reset()
1329 self._check_reset_success(host)
1331 def _is_applicable(self, host): argument
1332 if not host.servo:
1334 if host.is_marked_for_replacement():
1338 usb_install = host.get_repair_strategy_node('usb')
1350 # pylint: disable=missing-docstring
1351 return 'Reset the DUT via servo after USB-install'
1355 """Recover FW on the host when host can boot in recovery mode.
1358 USB-install but successful booted in recovery mode.
1360 If host can boot in recovery mode but fail boot in default mode then
1362 on the host by booting from USB-key.
1365 # Command to update firmware located on host
1366 _FW_UPDATE_CMD = 'chromeos-firmwareupdate --mode=recovery'
1369 def repair(self, host): argument
1370 # pylint: disable=missing-docstring
1372 # USB-key direction to DUT but it is not yet seeing by DUT.
1373 host.servo.switch_usbkey('host')
1374 time.sleep(host.servo.USB_DETECTION_DELAY)
1375 # Power off the DUT as in this case the host will boot
1377 host.servo.get_power_state_controller().power_off()
1382 # Boot host in recovery mode as it is working and verified
1384 need_snk = host.require_snk_mode_in_recovery()
1386 host.boot_in_recovery_mode(need_snk=need_snk)
1387 logging.debug('Host booted in recovery mode')
1389 result = host.run(self._FW_UPDATE_CMD, ignore_status=True)
1391 logging.error('chromeos-firmwareupdate failed: %s',
1393 host.halt()
1406 host.servo.get_power_state_controller().power_off()
1407 host.servo.switch_usbkey('off')
1410 host.servo.set_servo_v4_role('src')
1411 # Use cold-reset instead 'on' to increase the chance to boot DUT
1412 host.servo.get_power_state_controller().reset()
1413 self._check_reset_success(host)
1415 def _is_applicable(self, host): argument
1416 if not host.servo:
1418 if host.is_marked_for_replacement():
1422 usb_install = host.get_repair_strategy_node('usb')
1430 dhp = host.health_profile
1443 # pylint: disable=missing-docstring
1444 return 'Recover FW on the host after USB-install'
1455 def repair(self, host): argument
1456 # pylint: disable=missing-docstring
1457 repair_utils.require_servo(host, ignore_state=True)
1461 host.servo.get_ec_board()
1465 # to wake it up we do cold-reboot then we will have active ec
1467 host.servo.get_power_state_controller().reset()
1469 if host.servo.get('battery_is_charging'):
1476 # Simple off-on not always working stable in all cases as source-sink
1481 self._set_pd_dualrole(host, 'off')
1482 self._set_pd_dualrole(host, 'on')
1483 self._set_pd_dualrole(host, 'source')
1484 self._set_pd_dualrole(host, 'sink')
1488 host.servo.get_power_state_controller().reset()
1490 if not host.servo.get('battery_is_charging'):
1494 self._check_reset_success(host)
1496 def _set_pd_dualrole(self, host, role): argument
1497 host.servo.set_nocheck('ec_uart_flush', 'off')
1498 host.servo.set_nocheck('ec_uart_cmd', 'pd dualrole %s' % role)
1499 host.servo.set_nocheck('ec_uart_flush', 'on')
1502 def _is_applicable(self, host): argument
1503 if not host._servo_host.is_ec_supported():
1506 host_info = host.host_info_store.get()
1514 # pylint: disable=missing-docstring
1522 def repair(self, host): argument
1523 # pylint: disable=missing-docstring
1524 host.run('rm -f /var/cache/ap/setup-network', ignore_status=True)
1525 host.run('rm -f /home/chronos/.oobe_completed', ignore_status=True)
1526 host.run('rm -f /home/.shadow/.can_attempt_ownership',
1528 host.run('crossystem clear_tpm_owner_request=1', ignore_status=True)
1529 host.reboot()
1533 # pylint: disable=missing-docstring
1541 def repair(self, host): argument
1542 # pylint: disable=missing-docstring
1543 host.cleanup_services()
1547 # pylint: disable=missing-docstring
1668 # the logic to create action/verifier DAG for different host
1743 # to create action/verifier DAG for different host type
1864 def _is_virtual_machine(host): argument
1865 """Determine whether the given |host| is a virtual machine.
1867 @param host: a hosts.Host object.
1868 @returns True if the host is a virtual machine, False otherwise.
1870 output = host.run('cat /proc/cpuinfo | grep "model name"',
1877 """Wrapper for getting cryptohome status from a host."""
1879 def __init__(self, host): argument
1881 self.update(_get_tpm_status(host))
1885 # pylint: disable=missing-docstring
1890 # pylint: disable=missing-docstring
1895 # pylint: disable=missing-docstring
1900 # pylint: disable=missing-docstring
1904 def _get_tpm_status(host): argument
1907 @param host: a hosts.Host object.
1914 output = host.run(
1915 'tpm_manager_client status --nonsensitive').stdout.strip()
1916 lines = output.split('\n')[1:-1]