Skip to content

Commit ba0ef88

Browse files
committed
CP-13995: Copy and load RRDs from sr-stats vdi during pbd plug
1) Xapi queries xcp-rrdd for RRDs filesystem location. 2) Xapi copies RRDs from sr-stats vdi to filesystem. 3) Xapi asks xcp-rrdd to load these RRDs Signed-off-by: Sharad Yadav <[email protected]>
1 parent 3798dea commit ba0ef88

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

ocaml/xapi/message_forwarding.ml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3721,12 +3721,7 @@ module Forward = functor(Local: Custom_actions.CUSTOM_ACTIONS) -> struct
37213721
Helpers.call_api_functions ~__context
37223722
(fun rpc session_id ->
37233723
Client.SR.update rpc session_id sr
3724-
);
3725-
3726-
(* Check if SR has SR_STATS capability then create SR-stats VDI *)
3727-
let sr_record = Db.SR.get_record_internal ~__context ~self:sr in
3728-
if Smint.(has_capability Sr_stats (Xapi_sr_operations.features_of_sr ~__context sr_record)) then
3729-
Xapi_vdi_helpers.create_rrd_vdi ~__context ~sr:sr
3724+
)
37303725

37313726
let unplug ~__context ~self =
37323727
info "PBD.unplug: PBD = '%s'" (pbd_uuid ~__context self);

ocaml/xapi/xapi_pbd.ml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,15 @@ let plug ~__context ~self =
151151
Xapi_sm.register_plugin ~__context query_result;
152152

153153
(* The allowed-operations depend on the capabilities *)
154-
Xapi_sr_operations.update_allowed_operations ~__context ~self:sr
154+
Xapi_sr_operations.update_allowed_operations ~__context ~self:sr;
155+
156+
(* Check if SR has SR_STATS capability and sr master then create SR-stats VDI*)
157+
let sr_record = Db.SR.get_record_internal ~__context ~self:sr in
158+
if (Smint.(has_capability Sr_stats (Xapi_sr_operations.features_of_sr ~__context sr_record)) &&
159+
(Helpers.i_am_srmaster ~__context ~sr)) then begin
160+
let vdi = Xapi_vdi_helpers.create_rrd_vdi ~__context ~sr:sr in
161+
Xapi_vdi_helpers.push_sr_rdds ~__context ~sr:sr ~vdi:vdi
162+
end
155163
end
156164

157165
let unplug ~__context ~self =

ocaml/xapi/xapi_vdi_helpers.ml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,16 @@ let read_rrd ~__context ~sr ~vdi =
265265
)
266266
)
267267

268+
269+
module Rrdd = Rrd_client.Client
270+
271+
let push_sr_rdds ~__context ~sr ~vdi =
272+
let sr_uuid = Db.SR.get_uuid ~__context ~self:sr in
273+
let sr_rrds_path = Rrdd.sr_rrds_path ~sr_uuid:sr_uuid in
274+
let gzipped_rrds = read_rrd ~__context ~sr:sr ~vdi:vdi in
275+
begin match gzipped_rrds with
276+
| None -> debug "stats vdi doesn't have rdds"
277+
| Some x ->
278+
Unixext.write_string_to_file sr_rrds_path x;
279+
Rrdd.push_sr_rrd ~sr_uuid:sr_uuid
280+
end

0 commit comments

Comments
 (0)