[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-API] [PATCH] make sure VM_metrics records exist
# HG changeset patch # User David Scott <dave.scott@xxxxxxxxxxxxx> # Date 1267532349 0 # Node ID 1d2ea496a8f4aa0a2abfc2575a918403c3e9c172 # Parent 71512f4d5c67ea581ec04b72134b1db5b7af4271 CA-38375: make absolutely sure that every VM has a VM_metrics record: an assumption made by other parts of the code. Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx> diff -r 71512f4d5c67 -r 1d2ea496a8f4 ocaml/xapi/dbsync_master.ml --- a/ocaml/xapi/dbsync_master.ml Wed Feb 24 12:18:25 2010 +0000 +++ b/ocaml/xapi/dbsync_master.ml Tue Mar 02 12:19:09 2010 +0000 @@ -188,6 +188,30 @@ let clear_uncooperative_flags_noexn __context = Helpers.log_exn_continue "clearing uncooperative flags" clear_uncooperative_flags __context +let ensure_vm_metrics_records_exist __context = + List.iter (fun vm -> + let m = Db.VM.get_metrics ~__context ~self:vm in + if not(Db.is_valid_ref m) then begin + info "Regenerating missing VM_metrics record for VM %s" (Ref.string_of vm); + let m = Ref.make () in + let uuid = Uuid.to_string (Uuid.make_uuid ()) in + Db.VM_metrics.create ~__context ~ref:m ~uuid + ~vCPUs_number:0L + ~vCPUs_utilisation:[] ~memory_actual:0L + ~vCPUs_CPU:[] + ~vCPUs_params:[] + ~vCPUs_flags:[] + ~start_time:Date.never + ~install_time:Date.never + ~state: [] + ~last_updated:(Date.of_float 0.) + ~other_config:[]; + Db.VM.set_metrics ~__context ~self:vm ~value:m + end + ) (Db.VM.get_all __context) + +let ensure_vm_metrics_records_exist_noexn __context = Helpers.log_exn_continue "ensuring VM_metrics flags exist" ensure_vm_metrics_records_exist __context + (* Update the database to reflect current state. Called for both start of day and after an agent restart. *) let update_env __context = @@ -218,5 +242,7 @@ create_missing_vlan_records ~__context; create_tools_sr_noexn __context; - clear_uncooperative_flags_noexn __context + clear_uncooperative_flags_noexn __context; + + ensure_vm_metrics_records_exist_noexn __context 1 file changed, 27 insertions(+), 1 deletion(-) ocaml/xapi/dbsync_master.ml | 28 +++++++++++++++++++++++++++- Attachment:
xen-api.hg.patch _______________________________________________ xen-api mailing list xen-api@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/mailman/listinfo/xen-api
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |