1// Copyright 2021 The ChromiumOS Authors 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5syntax = "proto3"; 6 7package chromiumos.test.api; 8 9option go_package = "go.chromium.org/chromiumos/config/go/test/api"; 10 11import "chromiumos/config/api/test/xmlrpc/xmlrpc.proto"; 12import "chromiumos/longrunning/operations.proto"; 13 14// Provides the ability to start/stop servod daemon and execute servod 15// commands on it. 16// Servod daemon can be running either inside a Docker container or directly 17// on the host. 18// The servo host could also be the same as the service host or a remote host. 19// go/cros-servod-design to learn more about the design. 20service ServodService { 21 // StartServod runs a servod Docker container and starts the servod daemon 22 // inside the container if servod is containerized. Otherwise, it simply 23 // starts the servod daemon. 24 rpc StartServod(StartServodRequest) 25 returns (longrunning.Operation) { 26 option (longrunning.operation_info) = { 27 response_type: "StartServodResponse", 28 metadata_type: "StartServodMetadata" 29 }; 30 } 31 32 // StopServod stops the servod daemon inside the container and stops the 33 // servod Docker container if servod is containerized. Otherwise, it simply 34 // stops the servod daemon. 35 rpc StopServod(StopServodRequest) 36 returns (longrunning.Operation) { 37 option (longrunning.operation_info) = { 38 response_type: "StopServodResponse", 39 metadata_type: "StopServodMetadata" 40 }; 41 } 42 43 // ExecCmd executes a system command that is provided through the command 44 // parameter in the request. It allows the user to execute arbitrary commands 45 // that can't be handled by calling servod (e.g. update firmware through 46 // "futility", remote file copy through "scp"). 47 // It executes the command inside the servod Docker container if the 48 // servod_docker_container_name parameter is provided in the request. 49 // Otherwise, it executes the command directly inside the host that the servo 50 // is physically connected to. 51 rpc ExecCmd(ExecCmdRequest) 52 returns (ExecCmdResponse); 53 54 // CallServod runs a servod command through an XML-RPC call. 55 // It runs the command inside the servod Docker container if the 56 // servod_docker_container_name parameter is provided in the request. 57 // Otherwise, it runs the command directly inside the host that the servo 58 // is physically connected to. 59 // Allowed methods: doc, get, set, and hwinit. 60 rpc CallServod(CallServodRequest) 61 returns (CallServodResponse); 62 63 // LogCheckPoint will create checkpoint certain files so that some files 64 // can be saved partially when SaveLogs is called. 65 // For example, /var/log/messages in a labstation can be 66 // very big and include information from a few days ago. 67 // Getting the checkpoint of the current /var/log/messages will 68 // allow SaveLogs to save the portion only relevant to the current 69 // testing session. 70 rpc LogCheckPoint(LogCheckPointRequest) returns (LogCheckPointResponse) {} 71 72 // SaveLogs will save servod related logs on the host that this service 73 // is running. 74 // Logs include: 75 // /var/log/message from the servod host. 76 // /var/log/servod_<port>/ latest.DEBUG from servod host. 77 // /var/log/servod_<port>.STARTUP.log from servod host. 78 // The output of "dmesg -H" from the servod host. 79 // The extraction of the MCU console logs from latest.DEBUG 80 rpc SaveLogs(SaveLogsRequest) returns (SaveLogsResponse) {} 81} 82 83message StartServodRequest { 84 // The path (URI) for the servod (containerized or running as a daemon) host. 85 // If cros-servod and docker-servod live on the same host, this parameter 86 // should be empty. 87 string servo_host_path = 1; 88 89 // The servod Docker container name. 90 string servod_docker_container_name = 2; 91 92 // The servod Docker image path to pull from GCR. 93 // Example: gcr.io/chromeos-bot/servod@sha256:2d25f6313c7bbac349607 94 string servod_docker_image_path = 3; 95 96 // The --PORT parameter value for servod command. 97 int32 servod_port = 4; 98 99 // The --BOARD parameter value for servod command. 100 string board = 5; 101 102 // The --MODEL parameter value for servod command. 103 string model = 6; 104 105 // The --SERIALNAME parameter value for servod command. 106 string serial_name = 7; 107 108 // The --DEBUG parameter value for servod command. 109 string debug = 8; 110 111 // The --RECOVERY_MODE parameter value for servod command. 112 string recovery_mode = 9; 113 114 // The --CONFIG parameter value for servod command. 115 string config = 10; 116 117 // The --ALLOW-DUAL-V4 parameter value for servod command. 118 string allow_dual_v4 = 11; 119} 120 121message StartServodResponse { 122 // Empty response for success. 123 message Success { 124 } 125 126 // Error message for failure. 127 message Failure { 128 string error_message = 1; 129 } 130 131 oneof result { 132 Success success = 1; 133 Failure failure = 2; 134 } 135} 136 137message StartServodMetadata { 138} 139 140message StopServodRequest { 141 // The path (URI) for the servod (containerized or running as a daemon) host. 142 // If cros-servod and docker-servod live on the same host, this parameter 143 // should be empty. 144 string servo_host_path = 1; 145 146 // The servod Docker container name. 147 string servod_docker_container_name = 2; 148 149 // The port that servod is running on the servo host. 150 int32 servod_port = 3; 151} 152 153message StopServodResponse { 154 // Empty response for success. 155 message Success { 156 } 157 158 // Error message for failure. 159 message Failure { 160 string error_message = 1; 161 } 162 163 oneof result { 164 Success success = 1; 165 Failure failure = 2; 166 } 167} 168 169message StopServodMetadata { 170} 171 172message ExecCmdRequest { 173 // The path (URI) for the servod (containerized or running as a daemon) host. 174 // If cros-servod and docker-servod live on the same host, this parameter 175 // should be empty. 176 string servo_host_path = 1; 177 178 // The servod Docker container name. 179 string servod_docker_container_name = 2; 180 181 // The command to execute on the servo host. 182 // Example (Flash firmware with the provided image): 183 // "futility update -i <IMAGE> --servo_port=<PORT>" 184 // Example (Copy a file from B to A while logged into B): 185 // "scp /path/to/file username@A:/path/to/destination" 186 string command = 3; 187 188 // stdin is passed to the command as the program's stdin. 189 // An empty bytes is not treated specially; if the command reads 190 // from stdin, it will receive zero bytes. 191 bytes stdin = 4; 192} 193 194message ExecCmdResponse { 195 message ExitInfo { 196 // status provides information about how the command process 197 // terminated. 198 // 199 // If the command failed to start, status is set to an arbitrary 200 // non-zero value. 201 // 202 // If signaled is set, status is set to the signal that caused 203 // the command to terminate. 204 // 205 // Otherwise, status is set to the exit status of the process. 206 // Exit statuses outside of 0 to 255 inclusive are not supported; 207 // they will be mapped to an arbitrary non-zero value. 208 // 209 // status is zero if and only if the process was successfully 210 // started and exited with a zero status. 211 int32 status = 1; 212 // signaled indicates whether the command exited due to a signal. 213 // If set, status contains the signal. 214 bool signaled = 2; 215 // started indicates whether the command was started. 216 bool started = 3; 217 // error_message provides a human readable explanation for some errors. 218 // This MUST NOT be inspected by programs. 219 string error_message = 4; 220 } 221 // The exit information that is set when the command has exited 222 // or failed to start. 223 ExitInfo exit_info = 1; 224 // The shell command's stdout output since the last response. 225 bytes stdout = 2; 226 // The shell command's stderr output since the last response. 227 bytes stderr = 3; 228} 229 230message ExecCmdMetadata { 231} 232 233message CallServodRequest { 234 // The path (URI) for the servod (containerized or running as a daemon) host. 235 // If cros-servod and docker-servod live on the same host, this parameter 236 // should be empty. 237 string servo_host_path = 1; 238 239 // The servod Docker container name. 240 string servod_docker_container_name = 2; 241 242 // The port that servod is running on the servo host. 243 int32 servod_port = 3; 244 245 // The allowed methods to run. 246 enum Method { 247 // Shows info about control. 248 DOC = 0; 249 // Gets the value of control. 250 GET = 1; 251 // Sets the value of control. 252 SET = 2; 253 // Initializes all controls. 254 HWINIT = 3; 255 } 256 257 // The method to run. 258 Method method = 4; 259 260 // The arguments to pass to the servod call. 261 // For the doc and get methods, it will be control name as single 262 // array value (e.g. ["lid_open"]). 263 // For the set method, it will be control name and the value as 264 // separate array values (e.g. ["lid_open", "yes"]). 265 repeated chromiumos.config.api.test.xmlrpc.Value args = 5; 266} 267 268message CallServodResponse { 269 // Response for success. 270 message Success { 271 chromiumos.config.api.test.xmlrpc.Value result = 1; 272 } 273 274 // Error message for failure. 275 message Failure { 276 string error_message = 1; 277 } 278 279 oneof result { 280 Success success = 1; 281 Failure failure = 2; 282 } 283} 284 285message CallServodMetadata { 286} 287 288 289message LogCheckPointRequest { 290 // The path (URI) for the servod (containerized or running as a daemon) host. 291 // If cros-servod and docker-servod live on the same host, this parameter 292 // should be empty. 293 string servo_host_path = 1; 294 295 // The servod Docker container name. 296 string servod_docker_container_name = 2; 297 298 // The paths to the files that need checkpoint information. 299 repeated string paths = 3; 300} 301 302message LogCheckPointResponse { 303 // A mapping between the paths in the requests and their current 304 // line numbers. 305 // If a file does not exist on the host, it will not be included in 306 // this map. There will be no errors. 307 map<string, int32> path_to_line_number = 1; 308} 309 310message SaveLogsRequest { 311 // The path (URI) for the servod (containerized or running as a daemon) host. 312 // If cros-servod and docker-servod live on the same host, this parameter 313 // should be empty. 314 string servo_host_path = 1; 315 316 // The servod Docker container name. 317 string servod_docker_container_name = 2; 318 319 // A list of ports that servod is running on the servo host. 320 repeated int32 servod_ports = 3; 321 322 // A mapping between the paths in the requests and their checkpoint 323 // line numbers. 324 // For all files in the map, only the content will be saved after their 325 // corresponding line number. 326 // For the files that are no in the map, the whole file will be saved. 327 map<string, int32> path_to_line_number = 4; 328 329 // The directory where servo and servo host log files should be saved to. 330 string dest = 5; 331} 332 333message SaveLogsResponse { 334} 335