CLI: Add default device targeting.
Adds default device targeting to brillo debug/deploy/flash/shell, so
that if --device isn't specified it will try to auto-detect the USB
connected device.
The logging and error messages probably need to be cleaned up a bit in a
future CL, this is just to get the functionality plugged in.
BUG=brillo:82
TEST=cbuildbot/run_tests
Change-Id: I72e1911f40bc2e21c4b21102827740e3c694a3ac
Reviewed-on: https://chromium-review.googlesource.com/263989
Reviewed-by: David Pursell <dpursell@chromium.org>
Tested-by: David Pursell <dpursell@chromium.org>
Commit-Queue: David Pursell <dpursell@chromium.org>
diff --git a/cli/deploy.py b/cli/deploy.py
index 789a224..51d1d68 100644
--- a/cli/deploy.py
+++ b/cli/deploy.py
@@ -825,7 +825,7 @@
"""Deploys packages to a device.
Args:
- device: commandline.Device object.
+ device: commandline.Device object; None to use the default device.
packages: List of packages (strings) to deploy to device.
board: Board to use; None to automatically detect.
brick: Brick locator to use. Overrides |board| if not None.
@@ -858,10 +858,14 @@
if brick:
board = brick.FriendlyName()
+ if device:
+ hostname, username, port = device.hostname, device.username, device.port
+ else:
+ hostname, username, port = None, None, None
+
with remote_access.ChromiumOSDeviceHandler(
- device.hostname, port=device.port, username=device.username,
- private_key=ssh_private_key, base_dir=_DEVICE_BASE_DIR,
- ping=ping) as device:
+ hostname, port=port, username=username, private_key=ssh_private_key,
+ base_dir=_DEVICE_BASE_DIR, ping=ping) as device:
try:
board = cros_build_lib.GetBoard(device_board=device.board,
override_board=board)