Skip to content

Commit 792f8a2

Browse files
committed
system_status: add URL parameter to show xen-bugtool entries
This allows the clients to request only the entries they are interested in. This is done by adding `?list` to the URL: ``` $ curl -k -i -H "cookie: session_id=OpaqueRef:XXX" https://metavega/system-status?list HTTP/1.1 200 OK content-length: 6373 connection: close cache-control: no-cache, no-store Server: xapi/25.27 content-type: application/xml [...] ``` Signed-off-by: Pau Ruiz Safont <[email protected]>
1 parent b51352f commit 792f8a2

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

ocaml/xapi/system_status.ml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,35 @@ let with_api_errors f ctx s entries output =
149149
let msg = "xen-bugtool failed: " ^ Printexc.to_string exn in
150150
raise Api_errors.(Server_error (system_status_retrieval_failed, [msg]))
151151

152+
let send_capabilities req s =
153+
let content = get_capabilities () in
154+
let xml_type = "application/xml" in
155+
let hdrs =
156+
[
157+
("Server", Xapi_version.xapi_user_agent); (Http.Hdr.content_type, xml_type)
158+
]
159+
in
160+
Http_svr.response_str req ~hdrs s content
161+
152162
let handler (req : Request.t) s _ =
153163
req.Request.close <- true ;
154164
let get_param s = List.assoc_opt s req.Request.query in
165+
let list_capabilies = Option.is_some (get_param "list") in
155166
let entries = Option.value ~default:"" (get_param "entries") in
156-
let output =
157-
Option.bind (get_param "output") Output.of_string
158-
|> Option.value ~default:Output.Tar
159-
in
160-
Xapi_http.with_context task_label req s (fun __context ->
161-
if Helpers.on_oem ~__context && output <> Output.Tar then
162-
raise Api_errors.(Server_error (system_status_must_use_tar_on_oem, []))
163-
else if output = Output.Tar then
167+
let output = Option.bind (get_param "output") Output.of_string in
168+
169+
let send_list () = send_capabilities req s in
170+
let send_file () =
171+
Xapi_http.with_context task_label req s @@ fun __context ->
172+
match
173+
(Helpers.on_oem ~__context, Option.value ~default:Output.Tar output)
174+
with
175+
| _, (Output.Tar as output) ->
164176
with_api_errors send_via_fd __context s entries output
165-
else
177+
| false, output ->
166178
with_api_errors send_via_cp __context s entries output
167-
)
179+
| true, _ ->
180+
raise Api_errors.(Server_error (system_status_must_use_tar_on_oem, []))
181+
in
182+
183+
if list_capabilies then send_list () else send_file ()

0 commit comments

Comments
 (0)