@@ -65,6 +65,34 @@ let find_content ~__context ?sr name =
6565 || (vdi_rec.API. vDI_location = name) (* PR-1255 *)
6666 ) all
6767
68+ let vdi_info_of_vdi_rec __context vdi_rec =
69+ let content_id =
70+ try
71+ List. assoc " content_id" vdi_rec.API. vDI_other_config
72+ with Not_found -> vdi_rec.API. vDI_location (* PR-1255 *)
73+ in {
74+ vdi = vdi_rec.API. vDI_location;
75+ uuid = Some vdi_rec.API. vDI_uuid;
76+ content_id = content_id; (* PR-1255 *)
77+ name_label = vdi_rec.API. vDI_name_label;
78+ name_description = vdi_rec.API. vDI_name_description;
79+ ty = Storage_utils. string_of_vdi_type vdi_rec.API. vDI_type;
80+ metadata_of_pool = Ref. string_of vdi_rec.API. vDI_metadata_of_pool;
81+ is_a_snapshot = vdi_rec.API. vDI_is_a_snapshot;
82+ snapshot_time = Date. to_string vdi_rec.API. vDI_snapshot_time;
83+ snapshot_of =
84+ if Db. is_valid_ref __context vdi_rec.API. vDI_snapshot_of
85+ then Db.VDI. get_uuid ~__context ~self: vdi_rec.API. vDI_snapshot_of
86+ else " " ;
87+ read_only = vdi_rec.API. vDI_read_only;
88+ cbt_enabled = vdi_rec.API. vDI_cbt_enabled;
89+ virtual_size = vdi_rec.API. vDI_virtual_size;
90+ physical_utilisation = vdi_rec.API. vDI_physical_utilisation;
91+ persistent = vdi_rec.API. vDI_on_boot = `persist ;
92+ sharable = vdi_rec.API. vDI_sharable;
93+ sm_config = vdi_rec.API. vDI_sm_config;
94+ }
95+
6896let redirect sr =
6997 raise (Redirect (Some (Pool_role. get_master_address () )))
7098
@@ -82,34 +110,6 @@ module SMAPIv1 = struct
82110
83111 type context = Smint .request
84112
85- let vdi_info_of_vdi_rec __context vdi_rec =
86- let content_id =
87- if List. mem_assoc " content_id" vdi_rec.API. vDI_other_config
88- then List. assoc " content_id" vdi_rec.API. vDI_other_config
89- else vdi_rec.API. vDI_location (* PR-1255 *)
90- in {
91- vdi = vdi_rec.API. vDI_location;
92- uuid = Some vdi_rec.API. vDI_uuid;
93- content_id = content_id; (* PR-1255 *)
94- name_label = vdi_rec.API. vDI_name_label;
95- name_description = vdi_rec.API. vDI_name_description;
96- ty = Storage_utils. string_of_vdi_type vdi_rec.API. vDI_type;
97- metadata_of_pool = Ref. string_of vdi_rec.API. vDI_metadata_of_pool;
98- is_a_snapshot = vdi_rec.API. vDI_is_a_snapshot;
99- snapshot_time = Date. to_string vdi_rec.API. vDI_snapshot_time;
100- snapshot_of =
101- if Db. is_valid_ref __context vdi_rec.API. vDI_snapshot_of
102- then Db.VDI. get_uuid ~__context ~self: vdi_rec.API. vDI_snapshot_of
103- else " " ;
104- read_only = vdi_rec.API. vDI_read_only;
105- cbt_enabled = vdi_rec.API. vDI_cbt_enabled;
106- virtual_size = vdi_rec.API. vDI_virtual_size;
107- physical_utilisation = vdi_rec.API. vDI_physical_utilisation;
108- persistent = vdi_rec.API. vDI_on_boot = `persist ;
109- sharable = vdi_rec.API. vDI_sharable;
110- sm_config = vdi_rec.API. vDI_sm_config;
111- }
112-
113113 let vdi_info_from_db ~__context self =
114114 let vdi_rec = Db.VDI. get_record ~__context ~self in
115115 vdi_info_of_vdi_rec __context vdi_rec
@@ -569,9 +569,10 @@ module SMAPIv1 = struct
569569 with _ ->
570570 Uuid. string_of_uuid (Uuid. make_uuid () )
571571 in
572+ let snapshot_time = Date. of_float (Unix. gettimeofday () ) in
572573 Db.VDI. set_name_label ~__context ~self ~value: vdi_info.name_label;
573574 Db.VDI. set_name_description ~__context ~self ~value: vdi_info.name_description;
574- Db.VDI. set_snapshot_time ~__context ~self ~value: ( Date. of_string vdi_info. snapshot_time) ;
575+ Db.VDI. set_snapshot_time ~__context ~self ~value: snapshot_time;
575576 Db.VDI. set_is_a_snapshot ~__context ~self ~value: is_a_snapshot;
576577 Db.VDI. remove_from_other_config ~__context ~self ~key: " content_id" ;
577578 Db.VDI. add_to_other_config ~__context ~self ~key: " content_id" ~value: content_id;
0 commit comments