Skip to content

Commit e28d763

Browse files
committed
fixup! Datamodel: add supported_image_format field to SM object
1 parent c30a92e commit e28d763

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

ocaml/idl/datamodel.ml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4998,6 +4998,17 @@ module SR = struct
49984998
end
49994999

50005000
module SM = struct
5001+
let formats =
5002+
[
5003+
("raw", "Plain disk image")
5004+
; ("vhd", "Virtual Hard Disk")
5005+
; ("qcow2", "Qemu Copy-On-Write version 2")
5006+
]
5007+
5008+
let formats_desc = formats |> List.map fst |> String.concat ", "
5009+
5010+
let image_format_type = Enum ("image_format_type", formats)
5011+
50015012
(** XXX: just make this a field and be done with it. Cowardly refusing to change the schema for now. *)
50025013
let get_driver_filename =
50035014
call ~name:"get_driver_filename" ~in_oss_since:None
@@ -5119,9 +5130,9 @@ module SM = struct
51195130
"The storage plugin requires that one of these cluster stacks is \
51205131
configured and running."
51215132
; field ~lifecycle:[] ~qualifier:DynamicRO
5122-
~default_value:(Some (VSet [])) ~ty:(Set String)
5133+
~default_value:(Some (VSet [])) ~ty:(Set image_format_type)
51235134
"supported_image_formats"
5124-
"Image formats supported by the SR (VHD, RAW, Qcow2, ...)"
5135+
(Printf.sprintf "Image formats supported by the SR: %s" formats_desc)
51255136
]
51265137
()
51275138
end

ocaml/idl/schematest.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let hash x = Digest.string x |> Digest.to_hex
33
(* BEWARE: if this changes, check that schema has been bumped accordingly in
44
ocaml/idl/datamodel_common.ml, usually schema_minor_vsn *)
55

6-
let last_known_schema_hash = "d7e51f8c9ed9bb9ded5982b6a79bd426"
6+
let last_known_schema_hash = "957db9d8442259d5888ac88c0ae01a7b"
77

88
let current_schema_hash : string =
99
let open Datamodel_types in

ocaml/xapi-cli-server/records.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3867,7 +3867,8 @@ let sm_record rpc session_id sm =
38673867
()
38683868
; make_field ~name:"supported-image-formats"
38693869
~get:(fun () ->
3870-
concat_with_comma (x ()).API.sM_supported_image_formats
3870+
map_and_concat Record_util.image_format_type_to_string
3871+
(x ()).API.sM_supported_image_formats
38713872
)
38723873
()
38733874
]

ocaml/xapi/xapi_sm.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ let create_from_query_result ~__context q =
4949
~host_pending_features:[] ~configuration:q.configuration ~other_config:[]
5050
~driver_filename:(Sm_exec.cmd_name q.driver)
5151
~required_cluster_stack:q.required_cluster_stack
52-
~supported_image_formats:q.supported_image_formats
52+
~supported_image_formats:
53+
(List.map Record_util.image_format_type_of_string
54+
q.supported_image_formats
55+
)
5356
)
5457

5558
let find_pending_features existing_features features =
@@ -113,6 +116,10 @@ let update_from_query_result ~__context (self, r) q_result =
113116
|> addto_pending_hosts_features ~__context self
114117
|> valid_hosts_pending_features ~__context
115118
in
119+
let supported_image_formats =
120+
List.map Record_util.image_format_type_of_string
121+
q_result.supported_image_formats
122+
in
116123
remove_valid_features_from_pending ~__context ~self new_features ;
117124
let features = existing_features @ new_features in
118125
List.iter
@@ -145,9 +152,9 @@ let update_from_query_result ~__context (self, r) q_result =
145152
Db.SM.set_configuration ~__context ~self ~value:q_result.configuration ;
146153
if r.API.sM_driver_filename <> driver_filename then
147154
Db.SM.set_driver_filename ~__context ~self ~value:driver_filename ;
148-
if r.API.sM_supported_image_formats <> q_result.supported_image_formats then
155+
if r.API.sM_supported_image_formats <> supported_image_formats then
149156
Db.SM.set_supported_image_formats ~__context ~self
150-
~value:q_result.supported_image_formats
157+
~value:supported_image_formats
151158
)
152159

153160
let is_v1 x = version_of_string x < [2; 0]

0 commit comments

Comments
 (0)