Skip to content

Commit

Permalink
Adding supported image formats in sm-list
Browse files Browse the repository at this point in the history
When running `xe sm-list params=all` you will now have the info of supported
image formats if the SM plugin specified it in its DRIVER_INFO. The field is
called `supported-image-formats`. If the plugin doesn't provide the info the
field will be empty.

Signed-off-by: Guillaume <guillaume.thouvenin@vates.tech>
  • Loading branch information
gthvn1 committed Jan 23, 2025
1 parent 5ad963e commit e67f045
Show file tree
Hide file tree
Showing 25 changed files with 72 additions and 17 deletions.
4 changes: 4 additions & 0 deletions ocaml/idl/datamodel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3479,6 +3479,10 @@ module SM = struct
"required_cluster_stack"
"The storage plugin requires that one of these cluster stacks is \
configured and running."
; field ~in_oss_since:None ~qualifier:DynamicRO
~default_value:(Some (VSet [])) ~ty:(Set String)
"supported_image_formats"
"Image formats suported but the SR (vhd, raw, qcow, ...)"
]
()
end
Expand Down
2 changes: 1 addition & 1 deletion ocaml/idl/datamodel_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open Datamodel_roles
to leave a gap for potential hotfixes needing to increment the schema version.*)
let schema_major_vsn = 5

let schema_minor_vsn = 779
let schema_minor_vsn = 781

(* Historical schema versions just in case this is useful later *)
let rio_schema_major_vsn = 5
Expand Down
2 changes: 1 addition & 1 deletion ocaml/idl/schematest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let hash x = Digest.string x |> Digest.to_hex
(* BEWARE: if this changes, check that schema has been bumped accordingly in
ocaml/idl/datamodel_common.ml, usually schema_minor_vsn *)

let last_known_schema_hash = "efdb1c7e536362523741ccdb7f33f797"
let last_known_schema_hash = "a084fd06086eefd4084f91dc63261e4e"

let current_schema_hash : string =
let open Datamodel_types in
Expand Down
5 changes: 3 additions & 2 deletions ocaml/tests/common/test_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,11 @@ let make_sm ~__context ?(ref = Ref.make ()) ?(uuid = make_uuid ())
?(copyright = "") ?(version = "") ?(required_api_version = "")
?(capabilities = []) ?(features = default_sm_features) ?(configuration = [])
?(other_config = []) ?(driver_filename = "/dev/null")
?(required_cluster_stack = []) () =
?(required_cluster_stack = []) ?(supported_image_formats = []) () =
Db.SM.create ~__context ~ref ~uuid ~_type ~name_label ~name_description
~vendor ~copyright ~version ~required_api_version ~capabilities ~features
~configuration ~other_config ~driver_filename ~required_cluster_stack ;
~configuration ~other_config ~driver_filename ~required_cluster_stack
~supported_image_formats ;
ref

let make_sr ~__context ?(ref = Ref.make ()) ?(uuid = make_uuid ())
Expand Down
1 change: 1 addition & 0 deletions ocaml/tests/test_sm_features.ml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ module CreateSMObject = Generic.MakeStateful (struct
; features
; configuration= []
; required_cluster_stack= []
; supported_image_formats= []
}

let extract_output __context _ =
Expand Down
1 change: 1 addition & 0 deletions ocaml/tests/test_vdi_cbt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ let register_smapiv2_server (module S : Storage_interface.Server_impl) sr_ref =
; features= []
; configuration= []
; required_cluster_stack= []
; supported_image_formats= []
}
in

Expand Down
5 changes: 5 additions & 0 deletions ocaml/xapi-cli-server/records.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3783,6 +3783,11 @@ let sm_record rpc session_id sm =
; make_field ~name:"required-cluster-stack"
~get:(fun () -> concat_with_comma (x ()).API.sM_required_cluster_stack)
()
; make_field ~name:"supported-image-formats"
~get:(fun () ->
concat_with_comma (x ()).API.sM_supported_image_formats
)
()
]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>Status</name><value>Success</value></member><member><name>Value</name><value><struct><member><name>required_cluster_stack</name><value><array><data></data></array></value></member><member><name>configuration</name><value><struct><member><name>configuration</name><value>configuration</value></member></struct></value></member><member><name>features</name><value><array><data></data></array></value></member><member><name>required_api_version</name><value>required_api_version</value></member><member><name>version</name><value>version</value></member><member><name>copyright</name><value>copyright</value></member><member><name>vendor</name><value>vendor</value></member><member><name>description</name><value>description</value></member><member><name>name</name><value>name</value></member><member><name>driver</name><value>driver</value></member></struct></value></member></struct></value></param></params></methodResponse>
<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>Status</name><value>Success</value></member><member><name>Value</name><value><struct><member><name>supported_image_formats</name><value><array><data></data></array></value></member><member><name>required_cluster_stack</name><value><array><data></data></array></value></member><member><name>configuration</name><value><struct><member><name>configuration</name><value>configuration</value></member></struct></value></member><member><name>features</name><value><array><data></data></array></value></member><member><name>required_api_version</name><value>required_api_version</value></member><member><name>version</name><value>version</value></member><member><name>copyright</name><value>copyright</value></member><member><name>vendor</name><value>vendor</value></member><member><name>description</name><value>description</value></member><member><name>name</name><value>name</value></member><member><name>driver</name><value>driver</value></member></struct></value></member></struct></value></param></params></methodResponse>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>Status</name><value>Success</value></member><member><name>Value</name><value><struct><member><name>required_cluster_stack</name><value><array><data></data></array></value></member><member><name>configuration</name><value><struct><member><name>configuration</name><value>configuration</value></member></struct></value></member><member><name>features</name><value><array><data><value>features</value></data></array></value></member><member><name>required_api_version</name><value>required_api_version</value></member><member><name>version</name><value>version</value></member><member><name>copyright</name><value>copyright</value></member><member><name>vendor</name><value>vendor</value></member><member><name>description</name><value>description</value></member><member><name>name</name><value>name</value></member><member><name>driver</name><value>driver</value></member></struct></value></member></struct></value></param></params></methodResponse>
<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>Status</name><value>Success</value></member><member><name>Value</name><value><struct><member><name>supported_image_formats</name><value><array><data></data></array></value></member><member><name>required_cluster_stack</name><value><array><data></data></array></value></member><member><name>configuration</name><value><struct><member><name>configuration</name><value>configuration</value></member></struct></value></member><member><name>features</name><value><array><data><value>features</value></data></array></value></member><member><name>required_api_version</name><value>required_api_version</value></member><member><name>version</name><value>version</value></member><member><name>copyright</name><value>copyright</value></member><member><name>vendor</name><value>vendor</value></member><member><name>description</name><value>description</value></member><member><name>name</name><value>name</value></member><member><name>driver</name><value>driver</value></member></struct></value></member></struct></value></param></params></methodResponse>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>Status</name><value>Success</value></member><member><name>Value</name><value><struct><member><name>required_cluster_stack</name><value><array><data><value>required_cluster_stack</value></data></array></value></member><member><name>configuration</name><value><struct><member><name>configuration</name><value>configuration</value></member></struct></value></member><member><name>features</name><value><array><data></data></array></value></member><member><name>required_api_version</name><value>required_api_version</value></member><member><name>version</name><value>version</value></member><member><name>copyright</name><value>copyright</value></member><member><name>vendor</name><value>vendor</value></member><member><name>description</name><value>description</value></member><member><name>name</name><value>name</value></member><member><name>driver</name><value>driver</value></member></struct></value></member></struct></value></param></params></methodResponse>
<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>Status</name><value>Success</value></member><member><name>Value</name><value><struct><member><name>supported_image_formats</name><value><array><data><value><string>vhd</string></value></data></array></value></member><member><name>required_cluster_stack</name><value><array><data><value>required_cluster_stack</value></data></array></value></member><member><name>configuration</name><value><struct><member><name>configuration</name><value>configuration</value></member></struct></value></member><member><name>features</name><value><array><data></data></array></value></member><member><name>required_api_version</name><value>required_api_version</value></member><member><name>version</name><value>version</value></member><member><name>copyright</name><value>copyright</value></member><member><name>vendor</name><value>vendor</value></member><member><name>description</name><value>description</value></member><member><name>name</name><value>name</value></member><member><name>driver</name><value>driver</value></member></struct></value></member></struct></value></param></params></methodResponse>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>Status</name><value>Success</value></member><member><name>Value</name><value><struct><member><name>required_cluster_stack</name><value><array><data><value>required_cluster_stack</value></data></array></value></member><member><name>configuration</name><value><struct><member><name>configuration</name><value>configuration</value></member></struct></value></member><member><name>features</name><value><array><data><value>features</value></data></array></value></member><member><name>required_api_version</name><value>required_api_version</value></member><member><name>version</name><value>version</value></member><member><name>copyright</name><value>copyright</value></member><member><name>vendor</name><value>vendor</value></member><member><name>description</name><value>description</value></member><member><name>name</name><value>name</value></member><member><name>driver</name><value>driver</value></member></struct></value></member></struct></value></param></params></methodResponse>
<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>Status</name><value>Success</value></member><member><name>Value</name><value><struct><member><name>supported_image_formats</name><value><array><data></data></array></value></member><member><name>required_cluster_stack</name><value><array><data><value>required_cluster_stack</value></data></array></value></member><member><name>configuration</name><value><struct><member><name>configuration</name><value>configuration</value></member></struct></value></member><member><name>features</name><value><array><data><value>features</value></data></array></value></member><member><name>required_api_version</name><value>required_api_version</value></member><member><name>version</name><value>version</value></member><member><name>copyright</name><value>copyright</value></member><member><name>vendor</name><value>vendor</value></member><member><name>description</name><value>description</value></member><member><name>name</name><value>name</value></member><member><name>driver</name><value>driver</value></member></struct></value></member></struct></value></param></params></methodResponse>
1 change: 1 addition & 0 deletions ocaml/xapi-idl/storage/storage_interface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ type query_result = {
; features: string list
; configuration: (string * string) list
; required_cluster_stack: string list
; supported_image_formats: string list
}
[@@deriving rpcty]

Expand Down
2 changes: 2 additions & 0 deletions ocaml/xapi-storage-script/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ let bind ~volume_script_dir =
; configuration= response.Xapi_storage.Plugin.configuration
; required_cluster_stack=
response.Xapi_storage.Plugin.required_cluster_stack
; supported_image_formats=
response.Xapi_storage.Plugin.supported_image_formats
}
in
wrap th
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def query(self, dbg):
"VDI_CREATE",
"VDI_DESTROY"],
"configuration": {},
"required_cluster_stack": []}
"required_cluster_stack": [],
"supported_image_formats": []}


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def query(self, dbg):
"VDI_CREATE",
"VDI_DESTROY"],
"configuration": {},
"required_cluster_stack": []}
"required_cluster_stack": [],
"supported_image_formats": []}


if __name__ == "__main__":
Expand Down
3 changes: 3 additions & 0 deletions ocaml/xapi-storage/generator/lib/plugin.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ type query_result = {
(** Key/description pairs describing required device_config parameters. *)
; required_cluster_stack: string list
(** The plugin requires one of these cluster stacks to be active. *)
; supported_image_formats: string list
(** List of image formats (vhd, raw, qcow, ...) supported by an
SR.type. *)
}
[@@deriving rpcty]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def query(self, dbg):
"required_api_version": "5.0",
"features": [],
"configuration": {},
"required_cluster_stack": []}
"required_cluster_stack": [],
"supported_image_formats": []}


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def query(self, dbg):
"VDI_RESIZE",
"THIN_PROVISIONING"],
"configuration": config,
"required_cluster_stack": []
"required_cluster_stack": [],
"supported_image_formats": []
}

if __name__ == "__main__":
Expand Down
20 changes: 18 additions & 2 deletions ocaml/xapi-storage/python/xapi/storage/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def query(self, args):
for tmp_3 in results['required_cluster_stack']:
if not isinstance(tmp_3, str) and not isinstance(tmp_3, unicode):
raise TypeError("string", repr(tmp_3))
if not isinstance(results['supported_image_formats'], list):
raise TypeError("string list", repr(results['supported_image_formats']))
for tmp_4 in results['supported_image_formats']:
if not isinstance(tmp_4, str) and not isinstance(tmp_4, unicode):
raise TypeError("string", repr(tmp_4))
return results
def ls(self, args):
"""type-check inputs, call implementation, type-check outputs and return"""
Expand Down Expand Up @@ -118,7 +123,18 @@ def __init__(self):
def query(self, dbg):
"""Discover properties of this implementation. Every implementation must support the query interface or it will not be recognised as a storage plugin by xapi."""
result = {}
result["query_result"] = { "plugin": "string", "name": "string", "description": "string", "vendor": "string", "copyright": "string", "version": "string", "required_api_version": "string", "features": [ "string", "string" ], "configuration": { "string": "string" }, "required_cluster_stack": [ "string", "string" ] }
result["query_result"] = {
"plugin": "string",
"name": "string",
"description": "string",
"vendor": "string",
"copyright": "string",
"version": "string",
"required_api_version": "string",
"features": [ "string", "string" ],
"configuration": {"string": "string" },
"required_cluster_stack": [ "string","string" ],
"supported_image_formats": [ "string", "string" ] }
return result
def ls(self, dbg):
"""Discover properties of this implementation. Every implementation must support the query interface or it will not be recognised as a storage plugin by xapi."""
Expand Down Expand Up @@ -230,4 +246,4 @@ def _dispatch(self, method, params):
class plugin_server_test(plugin_server_dispatcher):
"""Create a server which will respond to all calls, returning arbitrary values. This is intended as a marshal/unmarshal test."""
def __init__(self):
plugin_server_dispatcher.__init__(self, Plugin_server_dispatcher(Plugin_test()))
plugin_server_dispatcher.__init__(self, Plugin_server_dispatcher(Plugin_test()))
8 changes: 8 additions & 0 deletions ocaml/xapi/sm_exec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,13 @@ let parse_sr_get_driver_info driver (xml : Xml.xml) =
)
(XMLRPC.From.array XMLRPC.From.structure (safe_assoc "configuration" info))
in
let file_formats =
XMLRPC.From.array XMLRPC.From.string
(safe_assoc "supported_image_formats" info)
in
List.iter
(fun s -> debug "%s: Found supported file format %s" name s)
file_formats ;
{
sr_driver_filename= driver
; sr_driver_name= name
Expand All @@ -575,6 +582,7 @@ let parse_sr_get_driver_info driver (xml : Xml.xml) =
; sr_driver_configuration= configuration
; sr_driver_text_features= text_features
; sr_driver_required_cluster_stack= []
; sr_driver_supported_image_formats= file_formats
}

let sr_get_driver_info ~dbg driver =
Expand Down
2 changes: 2 additions & 0 deletions ocaml/xapi/smint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ type sr_driver_info = {
; sr_driver_text_features: string list
; sr_driver_configuration: (string * string) list
; sr_driver_required_cluster_stack: string list
; sr_driver_supported_image_formats: string list
}

let query_result_of_sr_driver_info x =
Expand All @@ -165,6 +166,7 @@ let query_result_of_sr_driver_info x =
; features= x.sr_driver_text_features
; configuration= x.sr_driver_configuration
; required_cluster_stack= x.sr_driver_required_cluster_stack
; supported_image_formats= x.sr_driver_supported_image_formats
}

type attach_info = {
Expand Down
1 change: 1 addition & 0 deletions ocaml/xapi/storage_mux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ module Mux = struct
; features= []
; configuration= []
; required_cluster_stack= []
; supported_image_formats= []
}

let diagnostics () ~dbg =
Expand Down
1 change: 1 addition & 0 deletions ocaml/xapi/storage_smapiv1.ml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ module SMAPIv1 : Server_impl = struct
; features= []
; configuration= []
; required_cluster_stack= []
; supported_image_formats= []
}

let diagnostics _context ~dbg:_ =
Expand Down
1 change: 1 addition & 0 deletions ocaml/xapi/xapi_services.ml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ let get_handler (req : Http.Request.t) s _ =
; features= List.map (fun x -> path [_services; x]) [_SM]
; configuration= []
; required_cluster_stack= []
; supported_image_formats= []
}
in
respond req (Storage_interface.(rpc_of query_result) q) s
Expand Down
Loading

0 comments on commit e67f045

Please sign in to comment.