blob: 95c6193fe9966c0f793d87b05aa75fa97d97b84f [file] [log] [blame]
David Zeuthen107f2492015-02-17 12:53:54 -05001This file is intended for onboarding new SWEs hacking on buffet.
2
3 A. Common workflows.
4 B. Registering your DUT.
5
6---
7A. COMMON WORKFLOWS
8---
9
Christopher Wileyd318b272014-03-27 15:33:28 -070010Some common workflows for developing with buffet:
11
12# Tell portage that you'd like to make local changes to Buffet:
Vitaly Buka5da65962014-10-07 14:34:47 -070013cros_workon start --board=${BOARD} buffet
Christopher Wileyd318b272014-03-27 15:33:28 -070014
15# Edit files in platform2/buffet/
16vim ...
17
18# Compile and install those changes into the chroot:
Vitaly Buka5da65962014-10-07 14:34:47 -070019USE=buffet emerge-${BOARD} buffet
Christopher Wileyd318b272014-03-27 15:33:28 -070020
21# Compile and run buffet unittests
Vitaly Buka5da65962014-10-07 14:34:47 -070022USE=buffet FEATURES=test emerge-${BOARD} buffet
Christopher Wileyd318b272014-03-27 15:33:28 -070023
24# Deploy the most recently built version of buffet to a DUT:
Vitaly Buka5da65962014-10-07 14:34:47 -070025cros deploy --board=${BOARD} <remote host> buffet
Alex Vakulenko5298c2c2014-04-21 17:05:51 -070026
27#To enable additional debug logging in buffet daemon, run it as:
28# buffet --v=<level>, where <level> is verbosity level of debug info:
29# 1 - enable additional tracing of internal object construction and destruction
30# 2 - add tracing of request and response data sent over HTTP (beware of
31# privacy concerns).
32# 3 - enable low-level CURL tracing for HTTP communication.
33buffet --v=2
David Zeuthen107f2492015-02-17 12:53:54 -050034
35---
36B. REGISTERING YOUR DUT
37---
38
39This process in described in great detail at
40
41 https://developers.google.com/cloud-devices/v1/dev-guides/getting-started/register
42
43but since these instructions are generic and comprehensive, here's
44exactly what you need to do to get started when working with
45buffet/Brillo, in ten simple steps.
46
47The word DUT in this context is meant as the device that you want to
48associate with the cloud - for most buffet/Brillo developers this will
49be a Chromebook or another embedded device. These notes assume you
50have shell access to the DUT and also have access to a normal Linux
51workstation with shell and browser access.
52
531. Open an Incognito window in Chrome on your workstation, go to
54https://www.google.com and log in with your test google account (NEVER
55use @google.com credentials on DUTs). In the following we're using
56<GMAIL_TEST_ACCOUNT> which you should replace with whatever you're
57using, e.g. my-testing-account-xyz@gmail.com.
58
592. First we need an Authorization Code for the test user. This is
60covered in more detail in
61
62 https://developers.google.com/cloud-devices/v1/dev-guides/getting-started/authorizing#code
63
64but basically amounts to entering the following URL in the Incognito window
65
66 https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/clouddevices&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&client_id=58855907228.apps.googleusercontent.com
67
68If you're not using the default buffet gcd-project, replace the
69client_id parameter in the URL with the one for the product you
70registered as per
71
72 https://developers.google.com/cloud-devices/v1/dev-guides/getting-started/authorizing#setup
73
743. The browser window should display a prompt saying that
75"clouddevicesclient" would like to "Manage your cloud device". Press
76the "Accept" button and write down the Authorization Code
77displayed. It should look something like this
78
79 4/J23qfSkXYFgF_0H7DCOtwS5O7HO69zF9LtnG9_ILIGA.QhJE9WLeqwcaJvIeHux6iLavlvowlwI
80
814. Open a bash prompt on your Linux workstation and type the following
82
83 export SETUP_USER=<GMAIL_TEST_ACCOUNT>
84 export SETUP_CODE=4/J23qfSkXYFgF_0H7DCOtwS5O7HO69zF9LtnG9_ILIGA.QhJE9WLeqwcaJvIeHux6iLavlvowlwI
85 export SETUP_CLIENT_ID=58855907228.apps.googleusercontent.com
86 export SETUP_CLIENT_SECRET=eHSAREAHrIqPsHBxCE9zPPBi
87
88replacing the values for SETUP_USER and SETUP_CODE as
89appropriate. Again, if you're not using the default buffet gcd-project
90replace the values SETUP_CLIENT_ID and SETUP_CLIENT_SECRET as
91appropriate.
92
935. Now we can get an Access Token. Run the following command from the shell:
94
95 curl -d "code=${SETUP_CODE}&client_id=${SETUP_CLIENT_ID}&client_secret=${SETUP_CLIENT_SECRET}&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code" https://accounts.google.com/o/oauth2/token
96
97It should print out something like this:
98
99 {
100 "access_token" : "ya29.HQE<...>",
101 "token_type" : "Bearer",
102 "expires_in" : 3600,
103 "refresh_token" : "1/iMq4<...>"
104 }
105
1066. Export the access token in the shell:
107
108 export SETUP_ACCESS_TOKEN=ya29.HQE<...>
109
1107. Now we can get the Registration Ticket Id for the device. Run the following
111
112 curl --header "Authorization: Bearer ${SETUP_ACCESS_TOKEN}" --header "Content-Type: application/json; charset=UTF-8" --data "{ \"userEmail\": \"${SETUP_USER}\" }" https://www.googleapis.com/clouddevices/v1/registrationTickets
113
114It should print out something like this
115
116 {
117 "kind": "clouddevices#registrationTicket",
118 "id": "453f1139-bd<...>",
119 "deviceId": "77500a3f-458b-<...>",
120 "userEmail": "<GMAIL_TEST_ACCOUNT>",
121 "creationTimeMs": "1424193538212",
122 "expirationTimeMs": "1424193778212"
123 }
124
1258. Now, open a shell on the DUT and export the following
126
127 export DUT_SETUP_TICKET_ID=453f1139-bd<...>
128
1299. Run the following command on the DUT shell
130
131 buffet_client RegisterDevice ticket_id=${DUT_SETUP_TICKET_ID}
132
133appropriate. If you're not using the default buffet gcd-project you
134also need to pass other parameters such as client_id, client_secret
135and api_key.
136
137It should succeed and print the device-id
138
139 Device registered: 77500a3f-458b-<...>
140
14110. The registered DUT should now show up in the Google account that
142you associated it with. In the Incognito window opened in step 1, go
143to
144
145 https://security.google.com/settings/security/permissions
146
147where you can e.g. revoke access to the device.