-
Notifications
You must be signed in to change notification settings - Fork 292
CP-51042: Introduce new SR.scan2 for SMAPI{v1,v2,v3} #5959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
message-switch-async | ||
message-switch-unix | ||
ppx_deriving.runtime | ||
result | ||
rpclib.core | ||
rpclib.json | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1207,6 +1207,74 @@ let bind ~volume_script_dir = | |
|> wrap | ||
in | ||
S.SR.scan sr_scan_impl ; | ||
let sr_scan2_impl dbg sr = | ||
Attached_SRs.find sr | ||
>>>= (fun sr -> | ||
return_volume_rpc (fun () -> Sr_client.stat (volume_rpc ~dbg) dbg sr) | ||
>>>= fun response -> | ||
Deferred.Result.return | ||
{ | ||
Storage_interface.sr_uuid= response.Xapi_storage.Control.uuid | ||
; name_label= response.Xapi_storage.Control.name | ||
; name_description= response.Xapi_storage.Control.description | ||
; total_space= response.Xapi_storage.Control.total_space | ||
; free_space= response.Xapi_storage.Control.free_space | ||
; clustered= response.Xapi_storage.Control.clustered | ||
; health= | ||
( match response.Xapi_storage.Control.health with | ||
| Xapi_storage.Control.Healthy _ -> | ||
Healthy | ||
| Xapi_storage.Control.Recovering _ -> | ||
Recovering | ||
| Xapi_storage.Control.Unreachable _ -> | ||
Unreachable | ||
| Xapi_storage.Control.Unavailable _ -> | ||
Unavailable | ||
) | ||
} | ||
>>>= fun sr_info -> | ||
match sr_info.health with | ||
| Healthy -> | ||
return_volume_rpc (fun () -> | ||
Sr_client.ls | ||
(volume_rpc ~dbg ~compat_out:Compat.compat_out_volumes) | ||
dbg sr | ||
) | ||
>>>= fun response -> | ||
let response = Array.to_list response in | ||
(* Filter out volumes which are clone-on-boot transients *) | ||
let transients = | ||
List.fold | ||
~f:(fun set x -> | ||
match | ||
List.Assoc.find x.Xapi_storage.Control.keys | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this list is short? Otherwise this could be costly if response is large. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied this from the previous implementation, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this would depend on the size of |
||
_clone_on_boot_key ~equal:String.equal | ||
with | ||
| None -> | ||
set | ||
| Some transient -> | ||
Set.add set transient | ||
) | ||
~init:Core.String.Set.empty response | ||
in | ||
let response = | ||
List.filter | ||
~f:(fun x -> | ||
not (Set.mem transients x.Xapi_storage.Control.key) | ||
) | ||
response | ||
in | ||
Deferred.Result.return | ||
(List.map ~f:vdi_of_volume response, sr_info) | ||
| health -> | ||
debug "%s: sr unhealthy %s" __FUNCTION__ | ||
(Storage_interface.show_sr_health health) ; | ||
Deferred.Result.fail | ||
Storage_interface.(Errors.Sr_unhealthy health) | ||
) | ||
|> wrap | ||
in | ||
S.SR.scan2 sr_scan2_impl ; | ||
let vdi_create_impl dbg sr (vdi_info : Storage_interface.vdi_info) = | ||
Attached_SRs.find sr | ||
>>>= (fun sr -> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about this: removed the to_string function now since I can't type it right