remote_access: Simplify RemoteAccess connection.
Previously when using the RemoteAccess object it was possible to misuse
the object by trying to execute a remote function before Connect() was
called.
This CL changes the connection logic so that the connection is made
automatically as soon as the agent is needed. Also cleans up the setup
and device work dir logic so users can do everything from the
constructor.
BUG=brillo:948
TEST=cbuildbot/run_tests
TEST=brillo shell --device <ip>
TEST=cros deploy <ip> <package>
Change-Id: Id7abb1824395a116a6951ac440fab7b5d02d0587
Reviewed-on: https://chromium-review.googlesource.com/268664
Trybot-Ready: David Pursell <dpursell@chromium.org>
Tested-by: David Pursell <dpursell@chromium.org>
Reviewed-by: Yiming Chen <yimingc@chromium.org>
Commit-Queue: David Pursell <dpursell@chromium.org>
diff --git a/cli/deploy.py b/cli/deploy.py
index e9408ba..e6b94dd 100644
--- a/cli/deploy.py
+++ b/cli/deploy.py
@@ -316,8 +316,8 @@
"""Initializes a dictionary of packages installed on |device|."""
get_vartree_script = self._GetVartreeSnippet(root)
try:
- result = device.agent.RemoteSh('python', remote_sudo=True,
- input=get_vartree_script)
+ result = device.GetAgent().RemoteSh('python', remote_sudo=True,
+ input=get_vartree_script)
except cros_build_lib.RunCommandError as e:
logging.error('Cannot get target vartree:\n%s', e.result.error)
raise