|
| 1 | +(* |
| 2 | + * Copyright (C) 2006-2009 Citrix Systems Inc. |
| 3 | + * |
| 4 | + * This program is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU Lesser General Public License as published |
| 6 | + * by the Free Software Foundation; version 2.1 only. with the special |
| 7 | + * exception on linking described in file LICENSE. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU Lesser General Public License for more details. |
| 13 | + *) |
| 14 | + |
| 15 | + type event_record = |
| 16 | + | Session of [`Session ] API.Ref.t * API.session_t option |
| 17 | + | Task of [`task ] API.Ref.t * API.task_t option |
| 18 | + | Event of [`Event] API.Ref.t * API.event_t option |
| 19 | + | VM of [`VM] API.Ref.t * API.vM_t option |
| 20 | + | VM_metrics of [`VM_metrics] API.Ref.t * API.vM_metrics_t option |
| 21 | + | VM_guest_metrics of [`VM_guest_metrics] API.Ref.t * API.vM_guest_metrics_t option |
| 22 | + | Host of [`host] API.Ref.t * API.host_t option |
| 23 | + | Host_metrics of [`host_metrics] API.Ref.t * API.host_metrics_t option |
| 24 | + | Host_cpu of [`host_cpu] API.Ref.t * API.host_cpu_t option |
| 25 | + | Network of [`network] API.Ref.t * API.network_t option |
| 26 | + | VIF of [`VIF] API.Ref.t * API.vIF_t option |
| 27 | + | VIF_metrics of [`VIF_metrics] API.Ref.t * API.vIF_metrics_t option |
| 28 | + | PIF of [`PIF] API.Ref.t * API.pIF_t option |
| 29 | + | PIF_metrics of [`PIF_metrics] API.Ref.t * API.pIF_metrics_t option |
| 30 | + | SR of [`SR] API.Ref.t * API.sR_t option |
| 31 | + | VDI of [`VDI] API.Ref.t * API.vDI_t option |
| 32 | + | VBD of [`VBD] API.Ref.t * API.vBD_t option |
| 33 | + | VBD_metrics of [`VBD_metrics] API.Ref.t * API.vBD_metrics_t option |
| 34 | + | PBD of [`PBD] API.Ref.t * API.pBD_t option |
| 35 | + | Crashdump of [`Crashdump] API.Ref.t * API.crashdump_t option |
| 36 | + | VTPM of [`VTPM] API.Ref.t * API.vTPM_t option |
| 37 | + | Console of [`Console] API.Ref.t * API.console_t option |
| 38 | + | User of [`User] API.Ref.t * API.user_t option |
| 39 | + | Pool of [`pool] API.Ref.t * API.pool_t option |
| 40 | + | Message of [`message] API.Ref.t * API.message_t option |
| 41 | + | Secret of [`secret] API.Ref.t * API.secret_t option |
| 42 | + | VMPP of [`VMPP] API.Ref.t * API.vMPP_t option |
| 43 | + |
| 44 | + let maybe f x = |
| 45 | + match x with |
| 46 | + | Some x -> Some (f x) |
| 47 | + | None -> None |
| 48 | + |
| 49 | + let record_of_event ev = |
| 50 | + let xmlrpc = ev.Event_types.snapshot in |
| 51 | + match ev.Event_types.ty with |
| 52 | + | "session" -> Session (API.Ref.of_string ev.Event_types.reference, maybe (API.From.session_t "") xmlrpc) |
| 53 | + | "task" -> Task (API.Ref.of_string ev.Event_types.reference, maybe (API.From.task_t "") xmlrpc) |
| 54 | + | "event" -> Event (API.Ref.of_string ev.Event_types.reference, maybe (API.From.event_t "") xmlrpc) |
| 55 | + | "vm" -> VM (API.Ref.of_string ev.Event_types.reference, maybe (API.From.vM_t "") xmlrpc) |
| 56 | + | "vm_metrics" -> VM_metrics (API.Ref.of_string ev.Event_types.reference, maybe (API.From.vM_metrics_t "") xmlrpc) |
| 57 | + | "vm_guest_metrics" -> VM_guest_metrics (API.Ref.of_string ev.Event_types.reference, maybe (API.From.vM_guest_metrics_t "") xmlrpc) |
| 58 | + | "host" -> Host (API.Ref.of_string ev.Event_types.reference, maybe (API.From.host_t "") xmlrpc) |
| 59 | + | "host_metrics" -> Host_metrics (API.Ref.of_string ev.Event_types.reference, maybe (API.From.host_metrics_t "") xmlrpc) |
| 60 | + | "host_cpu" -> Host_cpu (API.Ref.of_string ev.Event_types.reference, maybe (API.From.host_cpu_t "") xmlrpc) |
| 61 | + | "network" -> Network (API.Ref.of_string ev.Event_types.reference, maybe (API.From.network_t "") xmlrpc) |
| 62 | + | "vif" -> VIF (API.Ref.of_string ev.Event_types.reference, maybe (API.From.vIF_t "") xmlrpc) |
| 63 | + | "vif_metrics" -> VIF_metrics (API.Ref.of_string ev.Event_types.reference, maybe (API.From.vIF_metrics_t "") xmlrpc) |
| 64 | + | "pif" -> PIF (API.Ref.of_string ev.Event_types.reference, maybe (API.From.pIF_t "") xmlrpc) |
| 65 | + | "pif_metrics" -> PIF_metrics (API.Ref.of_string ev.Event_types.reference, maybe (API.From.pIF_metrics_t "") xmlrpc) |
| 66 | + | "sr" -> SR (API.Ref.of_string ev.Event_types.reference, maybe (API.From.sR_t "") xmlrpc) |
| 67 | + | "vdi" -> VDI (API.Ref.of_string ev.Event_types.reference, maybe (API.From.vDI_t "") xmlrpc) |
| 68 | + | "vbd" -> VBD (API.Ref.of_string ev.Event_types.reference, maybe (API.From.vBD_t "") xmlrpc) |
| 69 | + | "vbd_metrics" -> VBD_metrics (API.Ref.of_string ev.Event_types.reference, maybe (API.From.vBD_metrics_t "") xmlrpc) |
| 70 | + | "pbd" -> PBD (API.Ref.of_string ev.Event_types.reference, maybe (API.From.pBD_t "") xmlrpc) |
| 71 | + | "crashdump" -> Crashdump (API.Ref.of_string ev.Event_types.reference, maybe (API.From.crashdump_t "") xmlrpc) |
| 72 | + | "vtpm" -> VTPM (API.Ref.of_string ev.Event_types.reference, maybe (API.From.vTPM_t "") xmlrpc) |
| 73 | + | "console" -> Console (API.Ref.of_string ev.Event_types.reference, maybe (API.From.console_t "") xmlrpc) |
| 74 | + | "user" -> User (API.Ref.of_string ev.Event_types.reference, maybe (API.From.user_t "") xmlrpc) |
| 75 | + | "pool" -> Pool (API.Ref.of_string ev.Event_types.reference, maybe (API.From.pool_t "") xmlrpc) |
| 76 | + | "message" -> Message (API.Ref.of_string ev.Event_types.reference, maybe (API.From.message_t "") xmlrpc) |
| 77 | + | "secret" -> Secret (API.Ref.of_string ev.Event_types.reference, maybe (API.From.secret_t "") xmlrpc) |
| 78 | + | "vmpp" -> VMPP (API.Ref.of_string ev.Event_types.reference, maybe (API.From.vMPP_t "") xmlrpc) |
| 79 | + | _ -> failwith "unknown event type" |
0 commit comments