WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] make sure VM_metrics records exist

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] make sure VM_metrics records exist
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Tue, 2 Mar 2010 12:19:28 +0000
Delivery-date: Tue, 02 Mar 2010 04:11:32 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# 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
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] make sure VM_metrics records exist, David Scott <=