Skip to content

Commit 8291b1c

Browse files
committed
CP-308201: make unimplemented function more obvious
Rename the "u" function used across storage and observer_helpers to make its meaning more obvious and use __FUNCTION__ instead of hardcoding the function name. Signed-off-by: Steven Woods <[email protected]>
1 parent efdf9a1 commit 8291b1c

File tree

8 files changed

+157
-165
lines changed

8 files changed

+157
-165
lines changed

ocaml/xapi-idl/lib/observer_skeleton.ml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,36 @@
1313
*)
1414
[@@@ocaml.warning "-27"]
1515

16-
let u x = raise Observer_helpers.(Observer_error (Errors.Unimplemented x))
16+
let unimplemented x = raise Observer_helpers.(Observer_error (Errors.Unimplemented x))
1717

1818
module Observer = struct
1919
type context = unit
2020

2121
let create ctx ~dbg ~uuid ~name_label ~attributes ~endpoints ~enabled =
22-
u "Observer.create"
22+
unimplemented __FUNCTION__
2323

24-
let destroy ctx ~dbg ~uuid = u "Observer.destroy"
24+
let destroy ctx ~dbg ~uuid = unimplemented __FUNCTION__
2525

26-
let set_enabled ctx ~dbg ~uuid ~enabled = u "Observer.set_enabled"
26+
let set_enabled ctx ~dbg ~uuid ~enabled = unimplemented __FUNCTION__
2727

28-
let set_attributes ctx ~dbg ~uuid ~attributes = u "Observer.set_attributes"
28+
let set_attributes ctx ~dbg ~uuid ~attributes = unimplemented __FUNCTION__
2929

30-
let set_endpoints ctx ~dbg ~uuid ~endpoints = u "Observer.set_endpoints"
30+
let set_endpoints ctx ~dbg ~uuid ~endpoints = unimplemented __FUNCTION__
3131

32-
let init ctx ~dbg = u "Observer.init"
32+
let init ctx ~dbg = unimplemented __FUNCTION__
3333

34-
let set_trace_log_dir ctx ~dbg ~dir = u "Observer.set_trace_log_dir"
34+
let set_trace_log_dir ctx ~dbg ~dir = unimplemented __FUNCTION__
3535

36-
let set_export_interval ctx ~dbg ~interval = u "Observer.set_export_interval"
36+
let set_export_interval ctx ~dbg ~interval = unimplemented __FUNCTION__
3737

38-
let set_max_spans ctx ~dbg ~spans = u "Observer.set_max_spans"
38+
let set_max_spans ctx ~dbg ~spans = unimplemented __FUNCTION__
3939

40-
let set_max_traces ctx ~dbg ~traces = u "Observer.set_max_traces"
40+
let set_max_traces ctx ~dbg ~traces = unimplemented __FUNCTION__
4141

42-
let set_max_file_size ctx ~dbg ~file_size = u "Observer.set_max_file_size"
42+
let set_max_file_size ctx ~dbg ~file_size = unimplemented __FUNCTION__
4343

44-
let set_host_id ctx ~dbg ~host_id = u "Observer.set_host_id"
44+
let set_host_id ctx ~dbg ~host_id = unimplemented __FUNCTION__
4545

4646
let set_compress_tracing_files ctx ~dbg ~enabled =
47-
u "Observer.set_compress_tracing_files"
47+
unimplemented __FUNCTION__
4848
end

ocaml/xapi-idl/storage/storage_interface.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ end
425425

426426
exception Storage_error of Errors.error
427427

428+
let unimplemented x = raise (Storage_error (Errors.Unimplemented x))
429+
428430
let () =
429431
(* register printer *)
430432
let sprintf = Printf.sprintf in

ocaml/xapi-idl/storage/storage_skeleton.ml

Lines changed: 75 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*)
1414
[@@@ocaml.warning "-27"]
1515

16-
let u x = raise Storage_interface.(Storage_error (Errors.Unimplemented x))
17-
1816
type context = unit
1917

2018
module UPDATES = struct
@@ -27,193 +25,193 @@ module UPDATES = struct
2725
end
2826

2927
module Query = struct
30-
let query ctx ~dbg = u "Query.query"
28+
let query ctx ~dbg = unimplemented __FUNCTION__
3129

32-
let diagnostics ctx ~dbg = u "Query.diagnostics"
30+
let diagnostics ctx ~dbg = unimplemented __FUNCTION__
3331
end
3432

3533
module DP = struct
36-
let create ctx ~dbg ~id = u "DP.create"
34+
let create ctx ~dbg ~id = unimplemented __FUNCTION__
3735

38-
let destroy ctx ~dbg ~dp ~allow_leak = u "DP.destroy"
36+
let destroy ctx ~dbg ~dp ~allow_leak = unimplemented __FUNCTION__
3937

40-
let destroy2 ctx ~dbg ~dp ~sr ~vdi ~vm ~allow_leak = u "DP.destroy2"
38+
let destroy2 ctx ~dbg ~dp ~sr ~vdi ~vm ~allow_leak = unimplemented __FUNCTION__
4139

42-
let attach_info ctx ~dbg ~sr ~vdi ~dp ~vm = u "DP.attach_info"
40+
let attach_info ctx ~dbg ~sr ~vdi ~dp ~vm = unimplemented __FUNCTION__
4341

44-
let diagnostics ctx () = u "DP.diagnostics"
42+
let diagnostics ctx () = unimplemented __FUNCTION__
4543

46-
let stat_vdi ctx ~dbg ~sr ~vdi () = u "DP.stat_vdi"
44+
let stat_vdi ctx ~dbg ~sr ~vdi () = unimplemented __FUNCTION__
4745
end
4846

4947
module SR = struct
5048
let create ctx ~dbg ~sr ~name_label ~name_description ~device_config
5149
~physical_size =
52-
u "SR.create"
50+
unimplemented __FUNCTION__
5351

54-
let attach ctx ~dbg ~sr ~device_config = u "SR.attach"
52+
let attach ctx ~dbg ~sr ~device_config = unimplemented __FUNCTION__
5553

56-
let set_name_label ctx ~dbg ~sr ~new_name_label = u "SR.set_name_label"
54+
let set_name_label ctx ~dbg ~sr ~new_name_label = unimplemented __FUNCTION__
5755

5856
let set_name_description ctx ~dbg ~sr ~new_name_description =
59-
u "SR.set_name_description"
57+
unimplemented __FUNCTION__
6058

61-
let detach ctx ~dbg ~sr = u "SR.detach"
59+
let detach ctx ~dbg ~sr = unimplemented __FUNCTION__
6260

63-
let reset ctx ~dbg ~sr = u "SR.reset"
61+
let reset ctx ~dbg ~sr = unimplemented __FUNCTION__
6462

65-
let destroy ctx ~dbg ~sr = u "SR.destroy"
63+
let destroy ctx ~dbg ~sr = unimplemented __FUNCTION__
6664

67-
let probe ctx ~dbg ~queue ~device_config ~sm_config = u "SR.probe"
65+
let probe ctx ~dbg ~queue ~device_config ~sm_config = unimplemented __FUNCTION__
6866

69-
let scan ctx ~dbg ~sr = u "SR.scan"
67+
let scan ctx ~dbg ~sr = unimplemented __FUNCTION__
7068

71-
let scan2 ctx ~dbg ~sr = u "SR.scan2"
69+
let scan2 ctx ~dbg ~sr = unimplemented __FUNCTION__
7270

7371
let update_snapshot_info_src ctx ~dbg ~sr ~vdi ~url ~dest ~dest_vdi
7472
~snapshot_pairs =
75-
u "SR.update_snapshot_info_src"
73+
unimplemented __FUNCTION__
7674

7775
let update_snapshot_info_dest ctx ~dbg ~sr ~vdi ~src_vdi ~snapshot_pairs =
78-
u "SR.update_snapshot_info_dest"
76+
unimplemented __FUNCTION__
7977

80-
let stat ctx ~dbg ~sr = u "SR.stat"
78+
let stat ctx ~dbg ~sr = unimplemented __FUNCTION__
8179

82-
let list ctx ~dbg = u "SR.list"
80+
let list ctx ~dbg = unimplemented __FUNCTION__
8381
end
8482

8583
module VDI = struct
86-
let create ctx ~dbg ~sr ~vdi_info = u "VDI.create"
84+
let create ctx ~dbg ~sr ~vdi_info = unimplemented __FUNCTION__
8785

88-
let set_name_label ctx ~dbg ~sr ~vdi ~new_name_label = u "VDI.set_name_label"
86+
let set_name_label ctx ~dbg ~sr ~vdi ~new_name_label = unimplemented __FUNCTION__
8987

9088
let set_name_description ctx ~dbg ~sr ~vdi ~new_name_description =
91-
u "VDI.set_name_description"
89+
unimplemented __FUNCTION__
9290

93-
let snapshot ctx ~dbg ~sr ~vdi_info = u "VDI.snapshot"
91+
let snapshot ctx ~dbg ~sr ~vdi_info = unimplemented __FUNCTION__
9492

95-
let clone ctx ~dbg ~sr ~vdi_info = u "VDI.clone"
93+
let clone ctx ~dbg ~sr ~vdi_info = unimplemented __FUNCTION__
9694

97-
let resize ctx ~dbg ~sr ~vdi ~new_size = u "VDI.resize"
95+
let resize ctx ~dbg ~sr ~vdi ~new_size = unimplemented __FUNCTION__
9896

99-
let destroy ctx ~dbg ~sr ~vdi = u "VDI.destroy"
97+
let destroy ctx ~dbg ~sr ~vdi = unimplemented __FUNCTION__
10098

101-
let stat ctx ~dbg ~sr ~vdi = u "VDI.stat"
99+
let stat ctx ~dbg ~sr ~vdi = unimplemented __FUNCTION__
102100

103-
let introduce ctx ~dbg ~sr ~uuid ~sm_config ~location = u "VDI.introduce"
101+
let introduce ctx ~dbg ~sr ~uuid ~sm_config ~location = unimplemented __FUNCTION__
104102

105-
let set_persistent ctx ~dbg ~sr ~vdi ~persistent = u "VDI.set_persistent"
103+
let set_persistent ctx ~dbg ~sr ~vdi ~persistent = unimplemented __FUNCTION__
106104

107105
let epoch_begin ctx ~dbg ~sr ~vdi ~vm ~persistent = ()
108106

109-
let attach ctx ~dbg ~dp ~sr ~vdi ~read_write = u "VDI.attach"
107+
let attach ctx ~dbg ~dp ~sr ~vdi ~read_write = unimplemented __FUNCTION__
110108

111-
let attach2 ctx ~dbg ~dp ~sr ~vdi ~read_write = u "VDI.attach2"
109+
let attach2 ctx ~dbg ~dp ~sr ~vdi ~read_write = unimplemented __FUNCTION__
112110

113-
let attach3 ctx ~dbg ~dp ~sr ~vdi ~vm ~read_write = u "VDI.attach3"
111+
let attach3 ctx ~dbg ~dp ~sr ~vdi ~vm ~read_write = unimplemented __FUNCTION__
114112

115-
let activate ctx ~dbg ~dp ~sr ~vdi = u "VDI.activate"
113+
let activate ctx ~dbg ~dp ~sr ~vdi = unimplemented __FUNCTION__
116114

117-
let activate3 ctx ~dbg ~dp ~sr ~vdi ~vm = u "VDI.activate3"
115+
let activate3 ctx ~dbg ~dp ~sr ~vdi ~vm = unimplemented __FUNCTION__
118116

119-
let activate_readonly ctx ~dbg ~dp ~sr ~vdi ~vm = u "VDI.activate_readonly"
117+
let activate_readonly ctx ~dbg ~dp ~sr ~vdi ~vm = unimplemented __FUNCTION__
120118

121-
let deactivate ctx ~dbg ~dp ~sr ~vdi ~vm = u "VDI.deactivate"
119+
let deactivate ctx ~dbg ~dp ~sr ~vdi ~vm = unimplemented __FUNCTION__
122120

123-
let detach ctx ~dbg ~dp ~sr ~vdi ~vm = u "VDI.detach"
121+
let detach ctx ~dbg ~dp ~sr ~vdi ~vm = unimplemented __FUNCTION__
124122

125123
let epoch_end ctx ~dbg ~sr ~vdi ~vm = ()
126124

127-
let get_url ctx ~dbg ~sr ~vdi = u "VDI.get_url"
125+
let get_url ctx ~dbg ~sr ~vdi = unimplemented __FUNCTION__
128126

129-
let similar_content ctx ~dbg ~sr ~vdi = u "VDI.similar_content"
127+
let similar_content ctx ~dbg ~sr ~vdi = unimplemented __FUNCTION__
130128

131-
let get_by_name ctx ~dbg ~sr ~name = u "VDI.get_by_name"
129+
let get_by_name ctx ~dbg ~sr ~name = unimplemented __FUNCTION__
132130

133-
let set_content_id ctx ~dbg ~sr ~vdi ~content_id = u "VDI.set_content_id"
131+
let set_content_id ctx ~dbg ~sr ~vdi ~content_id = unimplemented __FUNCTION__
134132

135-
let compose ctx ~dbg ~sr ~vdi1 ~vdi2 = u "VDI.compose"
133+
let compose ctx ~dbg ~sr ~vdi1 ~vdi2 = unimplemented __FUNCTION__
136134

137-
let add_to_sm_config ctx ~dbg ~sr ~vdi ~key ~value = u "VDI.add_to_sm_config"
135+
let add_to_sm_config ctx ~dbg ~sr ~vdi ~key ~value = unimplemented __FUNCTION__
138136

139137
let remove_from_sm_config ctx ~dbg ~sr ~vdi ~key =
140-
u "VDI.remove_from_sm_config"
138+
unimplemented __FUNCTION__
141139

142-
let enable_cbt ctx ~dbg ~sr ~vdi = u "VDI.enable_cbt"
140+
let enable_cbt ctx ~dbg ~sr ~vdi = unimplemented __FUNCTION__
143141

144-
let disable_cbt ctx ~dbg ~sr ~vdi = u "VDI.disable_cbt"
142+
let disable_cbt ctx ~dbg ~sr ~vdi = unimplemented __FUNCTION__
145143

146-
let data_destroy ctx ~dbg ~sr ~vdi = u "VDI.data_destroy"
144+
let data_destroy ctx ~dbg ~sr ~vdi = unimplemented __FUNCTION__
147145

148146
let list_changed_blocks ctx ~dbg ~sr ~vdi_from ~vdi_to =
149-
u "VDI.list_changed_blocks"
147+
unimplemented __FUNCTION__
150148
end
151149

152-
let get_by_name ctx ~dbg ~name = u "get_by_name"
150+
let get_by_name ctx ~dbg ~name = unimplemented __FUNCTION__
153151

154152
module DATA = struct
155-
let copy ctx ~dbg ~sr ~vdi ~vm ~url ~dest = u "DATA.copy"
153+
let copy ctx ~dbg ~sr ~vdi ~vm ~url ~dest = unimplemented __FUNCTION__
156154

157-
let mirror ctx ~dbg ~sr ~vdi ~vm ~dest = u "DATA.mirror"
155+
let mirror ctx ~dbg ~sr ~vdi ~vm ~dest = unimplemented __FUNCTION__
158156

159-
let stat ctx ~dbg ~sr ~vdi ~vm ~key = u "DATA.stat"
157+
let stat ctx ~dbg ~sr ~vdi ~vm ~key = unimplemented __FUNCTION__
160158

161159
let import_activate ctx ~dbg ~dp ~sr ~vdi ~vm =
162-
u "DATA.MIRROR.import_activate"
160+
unimplemented __FUNCTION__
163161

164-
let get_nbd_server ctx ~dbg ~dp ~sr ~vdi ~vm = u "DATA.MIRROR.get_nbd_server"
162+
let get_nbd_server ctx ~dbg ~dp ~sr ~vdi ~vm = unimplemented __FUNCTION__
165163

166164
module MIRROR = struct
167165
type context = unit
168166

169167
let send_start ctx ~dbg ~task_id ~dp ~sr ~vdi ~mirror_vm ~mirror_id
170168
~local_vdi ~copy_vm ~live_vm ~url ~remote_mirror ~dest_sr ~verify_dest =
171-
u "DATA.MIRROR.send_start"
169+
unimplemented __FUNCTION__
172170

173171
let receive_start ctx ~dbg ~sr ~vdi_info ~id ~similar =
174-
u "DATA.MIRROR.receive_start"
172+
unimplemented __FUNCTION__
175173

176174
let receive_start2 ctx ~dbg ~sr ~vdi_info ~id ~similar ~vm =
177-
u "DATA.MIRROR.receive_start2"
175+
unimplemented __FUNCTION__
178176

179177
let receive_start3 ctx ~dbg ~sr ~vdi_info ~mirror_id ~similar ~vm ~url
180178
~verify_dest =
181-
u "DATA.MIRROR.receive_start3"
179+
unimplemented __FUNCTION__
182180

183-
let receive_finalize ctx ~dbg ~id = u "DATA.MIRROR.receive_finalize"
181+
let receive_finalize ctx ~dbg ~id = unimplemented __FUNCTION__
184182

185-
let receive_finalize2 ctx ~dbg ~id = u "DATA.MIRROR.receive_finalize2"
183+
let receive_finalize2 ctx ~dbg ~id = unimplemented __FUNCTION__
186184

187185
let receive_finalize3 ctx ~dbg ~mirror_id ~sr ~url ~verify_dest =
188-
u "DATA.MIRROR.receive_finalize3"
186+
unimplemented __FUNCTION__
189187

190-
let receive_cancel ctx ~dbg ~id = u "DATA.MIRROR.receive_cancel"
188+
let receive_cancel ctx ~dbg ~id = unimplemented __FUNCTION__
191189

192190
let receive_cancel2 ctx ~dbg ~mirror_id ~url ~verify_dest =
193-
u "DATA.MIRROR.receive_cancel2"
191+
unimplemented __FUNCTION__
194192

195193
let pre_deactivate_hook ctx ~dbg ~dp ~sr ~vdi =
196-
u "DATA.MIRROR.pre_deactivate_hook"
194+
unimplemented __FUNCTION__
197195

198196
let has_mirror_failed ctx ~dbg ~mirror_id ~sr =
199-
u "DATA.MIRROR.has_mirror_failed"
197+
unimplemented __FUNCTION__
200198

201-
let list ctx ~dbg = u "DATA.MIRROR.list"
199+
let list ctx ~dbg = unimplemented __FUNCTION__
202200

203-
let stat ctx ~dbg ~id = u "DATA.MIRROR.stat"
201+
let stat ctx ~dbg ~id = unimplemented __FUNCTION__
204202
end
205203
end
206204

207205
module Policy = struct
208-
let get_backend_vm ctx ~dbg ~vm ~sr ~vdi = u "Policy.get_backend_vm"
206+
let get_backend_vm ctx ~dbg ~vm ~sr ~vdi = unimplemented __FUNCTION__
209207
end
210208

211209
module TASK = struct
212-
let stat ctx ~dbg ~task = u "TASK.stat"
210+
let stat ctx ~dbg ~task = unimplemented __FUNCTION__
213211

214-
let cancel ctx ~dbg ~task = u "TASK.cancel"
212+
let cancel ctx ~dbg ~task = unimplemented __FUNCTION__
215213

216-
let destroy ctx ~dbg ~task = u "TASK.destroy"
214+
let destroy ctx ~dbg ~task = unimplemented __FUNCTION__
217215

218-
let list ctx ~dbg = u "TASK.list"
216+
let list ctx ~dbg = unimplemented __FUNCTION__
219217
end

ocaml/xapi/storage_mux.ml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -844,12 +844,10 @@ module Mux = struct
844844
module MIRROR = struct
845845
type context = unit
846846

847-
let u x = raise Storage_interface.(Storage_error (Errors.Unimplemented x))
848-
849847
let send_start _ctx ~dbg:_ ~task_id:_ ~dp:_ ~sr:_ ~vdi:_ ~mirror_vm:_
850848
~mirror_id:_ ~local_vdi:_ ~copy_vm:_ ~live_vm:_ ~url:_
851849
~remote_mirror:_ ~dest_sr:_ ~verify_dest:_ =
852-
u "DATA.MIRROR.send_start" (* see storage_smapi{v1,v3}_migrate.ml *)
850+
Storage_interface.unimplemented __FUNCTION__ (* see storage_smapi{v1,v3}_migrate.ml *)
853851

854852
let receive_start () ~dbg ~sr ~vdi_info ~id ~similar =
855853
with_dbg ~name:"DATA.MIRROR.receive_start" ~dbg @@ fun _di ->
@@ -880,7 +878,7 @@ module Mux = struct
880878
(** see storage_smapiv{1,3}_migrate.receive_start3 *)
881879
let receive_start3 () ~dbg:_ ~sr:_ ~vdi_info:_ ~mirror_id:_ ~similar:_
882880
~vm:_ =
883-
u __FUNCTION__
881+
Storage_interface.unimplemented __FUNCTION__
884882

885883
let receive_finalize () ~dbg ~id =
886884
with_dbg ~name:"DATA.MIRROR.receive_finalize" ~dbg @@ fun di ->
@@ -893,21 +891,21 @@ module Mux = struct
893891
Storage_smapiv1_migrate.MIRROR.receive_finalize2 () ~dbg:di.log ~id
894892

895893
let receive_finalize3 () ~dbg:_ ~mirror_id:_ ~sr:_ ~url:_ ~verify_dest:_ =
896-
u __FUNCTION__
894+
Storage_interface.unimplemented __FUNCTION__
897895

898896
let receive_cancel () ~dbg ~id =
899897
with_dbg ~name:"DATA.MIRROR.receive_cancel" ~dbg @@ fun di ->
900898
info "%s dbg: %s mirror_id: %s" __FUNCTION__ dbg id ;
901899
Storage_smapiv1_migrate.MIRROR.receive_cancel () ~dbg:di.log ~id
902900

903901
let receive_cancel2 () ~dbg:_ ~mirror_id:_ ~url:_ ~verify_dest:_ =
904-
u __FUNCTION__
902+
Storage_interface.unimplemented __FUNCTION__
905903

906904
let pre_deactivate_hook _ctx ~dbg:_ ~dp:_ ~sr:_ ~vdi:_ =
907-
u "DATA.MIRROR.pre_deactivate_hook"
905+
Storage_interface.unimplemented __FUNCTION__
908906

909907
let has_mirror_failed _ctx ~dbg:_ ~mirror_id:_ ~sr:_ =
910-
u "DATA.MIRROR.has_mirror_failed"
908+
Storage_interface.unimplemented __FUNCTION__
911909

912910
let list () ~dbg =
913911
with_dbg ~name:"DATA.MIRROR.list" ~dbg @@ fun di ->

0 commit comments

Comments
 (0)