@@ -43,96 +43,132 @@ type event_record =
43
43
| VMPP of [`VMPP ] Ref .t * API .vMPP_t option
44
44
| VMSS of [`VMSS ] Ref .t * API .vMSS_t option
45
45
46
- let maybe f x = match x with Some x -> Some (f x) | None -> None
47
-
48
46
let record_of_event ev =
49
47
let rpc = ev.Event_types. snapshot in
50
48
match ev.Event_types. ty with
51
49
| "session" ->
52
50
Session
53
51
( Ref. of_secret_string ev.Event_types. reference
54
- , maybe API. session_t_of_rpc rpc
52
+ , Option. map API. session_t_of_rpc rpc
55
53
)
56
54
| "task" ->
57
- Task (Ref. of_string ev.Event_types. reference, maybe API. task_t_of_rpc rpc)
55
+ Task
56
+ ( Ref. of_string ev.Event_types. reference
57
+ , Option. map API. task_t_of_rpc rpc
58
+ )
58
59
| "event" ->
59
60
Event
60
- (Ref. of_string ev.Event_types. reference, maybe API. event_t_of_rpc rpc)
61
+ ( Ref. of_string ev.Event_types. reference
62
+ , Option. map API. event_t_of_rpc rpc
63
+ )
61
64
| "vm" ->
62
- VM (Ref. of_string ev.Event_types. reference, maybe API. vM_t_of_rpc rpc)
65
+ VM (Ref. of_string ev.Event_types. reference, Option. map API. vM_t_of_rpc rpc)
63
66
| "vm_metrics" ->
64
67
VM_metrics
65
68
( Ref. of_string ev.Event_types. reference
66
- , maybe API. vM_metrics_t_of_rpc rpc
69
+ , Option. map API. vM_metrics_t_of_rpc rpc
67
70
)
68
71
| "vm_guest_metrics" ->
69
72
VM_guest_metrics
70
73
( Ref. of_string ev.Event_types. reference
71
- , maybe API. vM_guest_metrics_t_of_rpc rpc
74
+ , Option. map API. vM_guest_metrics_t_of_rpc rpc
72
75
)
73
76
| "host" ->
74
- Host (Ref. of_string ev.Event_types. reference, maybe API. host_t_of_rpc rpc)
77
+ Host
78
+ ( Ref. of_string ev.Event_types. reference
79
+ , Option. map API. host_t_of_rpc rpc
80
+ )
75
81
| "host_metrics" ->
76
82
Host_metrics
77
83
( Ref. of_string ev.Event_types. reference
78
- , maybe API. host_metrics_t_of_rpc rpc
84
+ , Option. map API. host_metrics_t_of_rpc rpc
79
85
)
80
86
| "host_cpu" ->
81
87
Host_cpu
82
- (Ref. of_string ev.Event_types. reference, maybe API. host_cpu_t_of_rpc rpc)
88
+ ( Ref. of_string ev.Event_types. reference
89
+ , Option. map API. host_cpu_t_of_rpc rpc
90
+ )
83
91
| "network" ->
84
92
Network
85
- (Ref. of_string ev.Event_types. reference, maybe API. network_t_of_rpc rpc)
93
+ ( Ref. of_string ev.Event_types. reference
94
+ , Option. map API. network_t_of_rpc rpc
95
+ )
86
96
| "vif" ->
87
- VIF (Ref. of_string ev.Event_types. reference, maybe API. vIF_t_of_rpc rpc)
97
+ VIF
98
+ (Ref. of_string ev.Event_types. reference, Option. map API. vIF_t_of_rpc rpc)
88
99
| "vif_metrics" ->
89
100
VIF_metrics
90
101
( Ref. of_string ev.Event_types. reference
91
- , maybe API. vIF_metrics_t_of_rpc rpc
102
+ , Option. map API. vIF_metrics_t_of_rpc rpc
92
103
)
93
104
| "pif" ->
94
- PIF (Ref. of_string ev.Event_types. reference, maybe API. pIF_t_of_rpc rpc)
105
+ PIF
106
+ (Ref. of_string ev.Event_types. reference, Option. map API. pIF_t_of_rpc rpc)
95
107
| "pif_metrics" ->
96
108
PIF_metrics
97
109
( Ref. of_string ev.Event_types. reference
98
- , maybe API. pIF_metrics_t_of_rpc rpc
110
+ , Option. map API. pIF_metrics_t_of_rpc rpc
99
111
)
100
112
| "sr" ->
101
- SR (Ref. of_string ev.Event_types. reference, maybe API. sR_t_of_rpc rpc)
113
+ SR (Ref. of_string ev.Event_types. reference, Option. map API. sR_t_of_rpc rpc)
102
114
| "vdi" ->
103
- VDI (Ref. of_string ev.Event_types. reference, maybe API. vDI_t_of_rpc rpc)
115
+ VDI
116
+ (Ref. of_string ev.Event_types. reference, Option. map API. vDI_t_of_rpc rpc)
104
117
| "vbd" ->
105
- VBD (Ref. of_string ev.Event_types. reference, maybe API. vBD_t_of_rpc rpc)
118
+ VBD
119
+ (Ref. of_string ev.Event_types. reference, Option. map API. vBD_t_of_rpc rpc)
106
120
| "vbd_metrics" ->
107
121
VBD_metrics
108
122
( Ref. of_string ev.Event_types. reference
109
- , maybe API. vBD_metrics_t_of_rpc rpc
123
+ , Option. map API. vBD_metrics_t_of_rpc rpc
110
124
)
111
125
| "pbd" ->
112
- PBD (Ref. of_string ev.Event_types. reference, maybe API. pBD_t_of_rpc rpc)
126
+ PBD
127
+ (Ref. of_string ev.Event_types. reference, Option. map API. pBD_t_of_rpc rpc)
113
128
| "crashdump" ->
114
129
Crashdump
115
130
( Ref. of_string ev.Event_types. reference
116
- , maybe API. crashdump_t_of_rpc rpc
131
+ , Option. map API. crashdump_t_of_rpc rpc
117
132
)
118
133
| "vtpm" ->
119
- VTPM (Ref. of_string ev.Event_types. reference, maybe API. vTPM_t_of_rpc rpc)
134
+ VTPM
135
+ ( Ref. of_string ev.Event_types. reference
136
+ , Option. map API. vTPM_t_of_rpc rpc
137
+ )
120
138
| "console" ->
121
139
Console
122
- (Ref. of_string ev.Event_types. reference, maybe API. console_t_of_rpc rpc)
140
+ ( Ref. of_string ev.Event_types. reference
141
+ , Option. map API. console_t_of_rpc rpc
142
+ )
123
143
| "user" ->
124
- User (Ref. of_string ev.Event_types. reference, maybe API. user_t_of_rpc rpc)
144
+ User
145
+ ( Ref. of_string ev.Event_types. reference
146
+ , Option. map API. user_t_of_rpc rpc
147
+ )
125
148
| "pool" ->
126
- Pool (Ref. of_string ev.Event_types. reference, maybe API. pool_t_of_rpc rpc)
149
+ Pool
150
+ ( Ref. of_string ev.Event_types. reference
151
+ , Option. map API. pool_t_of_rpc rpc
152
+ )
127
153
| "message" ->
128
154
Message
129
- (Ref. of_string ev.Event_types. reference, maybe API. message_t_of_rpc rpc)
155
+ ( Ref. of_string ev.Event_types. reference
156
+ , Option. map API. message_t_of_rpc rpc
157
+ )
130
158
| "secret" ->
131
159
Secret
132
- (Ref. of_string ev.Event_types. reference, maybe API. secret_t_of_rpc rpc)
160
+ ( Ref. of_string ev.Event_types. reference
161
+ , Option. map API. secret_t_of_rpc rpc
162
+ )
133
163
| "vmpp" ->
134
- VMPP (Ref. of_string ev.Event_types. reference, maybe API. vMPP_t_of_rpc rpc)
164
+ VMPP
165
+ ( Ref. of_string ev.Event_types. reference
166
+ , Option. map API. vMPP_t_of_rpc rpc
167
+ )
135
168
| "vmss" ->
136
- VMSS (Ref. of_string ev.Event_types. reference, maybe API. vMSS_t_of_rpc rpc)
169
+ VMSS
170
+ ( Ref. of_string ev.Event_types. reference
171
+ , Option. map API. vMSS_t_of_rpc rpc
172
+ )
137
173
| _ ->
138
174
failwith " unknown event type"
0 commit comments