Skip to content

Commit

Permalink
Merge pull request #2775 from jonludlam/CA-182929
Browse files Browse the repository at this point in the history
CA-182929: Raise an error if the storage backend type is unknown.
  • Loading branch information
euanh authored Sep 16, 2016
2 parents 85afda1 + 4dd92c4 commit 01c0635
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ocaml/xapi/storage_access.ml
Original file line number Diff line number Diff line change
Expand Up @@ -889,9 +889,22 @@ let make_service uuid ty =
url = Constants.path [ Constants._services; Constants._driver; uuid; Constants._SM; ty ];
}

let check_queue_exists queue_name =
let t = Xcp_client.(get_ok (Protocol_unix.Client.connect ~switch:!switch_path ())) in
let results =
match Protocol_unix.Client.list ~t ~prefix:!Storage_interface.queue_name ~filter:`Alive () with
| `Ok list -> list
| _ -> failwith "Failed to contact switch" (* Shouldn't ever happen *) in
if not (List.mem queue_name results)
then
let prefix_len = String.length !Storage_interface.queue_name + 1 in
let driver = String.sub queue_name prefix_len (String.length queue_name - prefix_len) in
raise Api_errors.(Server_error(sr_unknown_driver,[driver]))

let external_rpc queue_name uri =
let open Xcp_client in
if !use_switch then check_queue_exists queue_name;
fun call ->
let open Xcp_client in
if !use_switch
then json_switch_rpc queue_name call
else xml_http_rpc
Expand Down

0 comments on commit 01c0635

Please sign in to comment.