18
18
module Date = Clock. Date
19
19
module XenAPI = Client. Client
20
20
open Storage_interface
21
-
22
- exception No_VDI
21
+ open Storage_utils
23
22
24
23
let s_of_vdi = Vdi. string_of
25
24
@@ -30,26 +29,6 @@ let with_lock = Xapi_stdext_threads.Threadext.Mutex.execute
30
29
let with_dbg ~name ~dbg f =
31
30
Debug_info. with_dbg ~module_name: " SMAPIv1" ~name ~dbg f
32
31
33
- (* Find a VDI given a storage-layer SR and VDI *)
34
- let find_vdi ~__context sr vdi =
35
- let sr = s_of_sr sr in
36
- let vdi = s_of_vdi vdi in
37
- let open Xapi_database.Db_filter_types in
38
- let sr = Db.SR. get_by_uuid ~__context ~uuid: sr in
39
- match
40
- Db.VDI. get_records_where ~__context
41
- ~expr:
42
- (And
43
- ( Eq (Field " location" , Literal vdi)
44
- , Eq (Field " SR" , Literal (Ref. string_of sr))
45
- )
46
- )
47
- with
48
- | x :: _ ->
49
- x
50
- | _ ->
51
- raise No_VDI
52
-
53
32
(* Find a VDI reference given a name *)
54
33
let find_content ~__context ?sr name =
55
34
(* PR-1255: the backend should do this for us *)
@@ -132,32 +111,6 @@ module SMAPIv1 : Server_impl = struct
132
111
let vdi_rec = Db.VDI. get_record ~__context ~self in
133
112
vdi_info_of_vdi_rec __context vdi_rec
134
113
135
- (* For SMAPIv1, is_a_snapshot, snapshot_time and snapshot_of are stored in
136
- * xapi's database. For SMAPIv2 they should be implemented by the storage
137
- * backend. *)
138
- let set_is_a_snapshot _context ~dbg ~sr ~vdi ~is_a_snapshot =
139
- Server_helpers. exec_with_new_task " VDI.set_is_a_snapshot"
140
- ~subtask_of: (Ref. of_string dbg) (fun __context ->
141
- let vdi, _ = find_vdi ~__context sr vdi in
142
- Db.VDI. set_is_a_snapshot ~__context ~self: vdi ~value: is_a_snapshot
143
- )
144
-
145
- let set_snapshot_time _context ~dbg ~sr ~vdi ~snapshot_time =
146
- Server_helpers. exec_with_new_task " VDI.set_snapshot_time"
147
- ~subtask_of: (Ref. of_string dbg) (fun __context ->
148
- let vdi, _ = find_vdi ~__context sr vdi in
149
- let snapshot_time = Date. of_iso8601 snapshot_time in
150
- Db.VDI. set_snapshot_time ~__context ~self: vdi ~value: snapshot_time
151
- )
152
-
153
- let set_snapshot_of _context ~dbg ~sr ~vdi ~snapshot_of =
154
- Server_helpers. exec_with_new_task " VDI.set_snapshot_of"
155
- ~subtask_of: (Ref. of_string dbg) (fun __context ->
156
- let vdi, _ = find_vdi ~__context sr vdi in
157
- let snapshot_of, _ = find_vdi ~__context sr snapshot_of in
158
- Db.VDI. set_snapshot_of ~__context ~self: vdi ~value: snapshot_of
159
- )
160
-
161
114
module Query = struct
162
115
let query _context ~dbg :_ =
163
116
{
@@ -433,46 +386,9 @@ module SMAPIv1 : Server_impl = struct
433
386
~dest_vdi :_ ~snapshot_pairs :_ =
434
387
assert false
435
388
436
- let update_snapshot_info_dest _context ~dbg ~sr ~vdi ~src_vdi :_
437
- ~snapshot_pairs =
438
- Server_helpers. exec_with_new_task " SR.update_snapshot_info_dest"
439
- ~subtask_of: (Ref. of_string dbg) (fun __context ->
440
- let local_vdis = scan __context ~dbg ~sr in
441
- let find_sm_vdi ~vdi ~vdi_info_list =
442
- try List. find (fun x -> x.vdi = vdi) vdi_info_list
443
- with Not_found ->
444
- raise (Storage_error (Vdi_does_not_exist (s_of_vdi vdi)))
445
- in
446
- let assert_content_ids_match ~vdi_info1 ~vdi_info2 =
447
- if vdi_info1.content_id <> vdi_info2.content_id then
448
- raise
449
- (Storage_error
450
- (Content_ids_do_not_match
451
- (s_of_vdi vdi_info1.vdi, s_of_vdi vdi_info2.vdi)
452
- )
453
- )
454
- in
455
- (* For each (local snapshot vdi, source snapshot vdi) pair:
456
- * - Check that the content_ids are the same
457
- * - Copy snapshot_time from the source VDI to the local VDI
458
- * - Set the local VDI's snapshot_of to vdi
459
- * - Set is_a_snapshot = true for the local snapshot *)
460
- List. iter
461
- (fun (local_snapshot , src_snapshot_info ) ->
462
- let local_snapshot_info =
463
- find_sm_vdi ~vdi: local_snapshot ~vdi_info_list: local_vdis
464
- in
465
- assert_content_ids_match ~vdi_info1: local_snapshot_info
466
- ~vdi_info2: src_snapshot_info ;
467
- set_snapshot_time __context ~dbg ~sr ~vdi: local_snapshot
468
- ~snapshot_time: src_snapshot_info.snapshot_time ;
469
- set_snapshot_of __context ~dbg ~sr ~vdi: local_snapshot
470
- ~snapshot_of: vdi ;
471
- set_is_a_snapshot __context ~dbg ~sr ~vdi: local_snapshot
472
- ~is_a_snapshot: true
473
- )
474
- snapshot_pairs
475
- )
389
+ let update_snapshot_info_dest _context ~dbg :_ ~sr :_ ~vdi :_ ~src_vdi :_
390
+ ~snapshot_pairs :_ =
391
+ assert false
476
392
end
477
393
478
394
module VDI = struct
0 commit comments