~ubuntu-branches/ubuntu/quantal/xen-api/quantal

« back to all changes in this revision

Viewing changes to ocaml/multipathrt/tc_9079.ml

  • Committer: Package Import Robot
  • Author(s): Jon Ludlam
  • Date: 2011-07-07 21:50:18 UTC
  • Revision ID: package-import@ubuntu.com-20110707215018-3t9ekbh7qy5y2b1p
Tags: upstream-1.3
ImportĀ upstreamĀ versionĀ 1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(*
 
2
 * Copyright (C) 2006-2009 Citrix Systems Inc.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published
 
6
 * by the Free Software Foundation; version 2.1 only. with the special
 
7
 * exception on linking described in file LICENSE.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU Lesser General Public License for more details.
 
13
 *)
 
14
(* Path fail-over time on FC multipath *)
 
15
 
 
16
open Listext
 
17
open Pervasiveext
 
18
open Client
 
19
open Utils
 
20
open Hba_utils
 
21
 
 
22
let max_failover_time = 50. (* seconds *)
 
23
 
 
24
let run_fc rpc session =
 
25
  Random.self_init();
 
26
 
 
27
  let master = get_master rpc session in
 
28
  if not(is_multipathing_enabled rpc session master) then enable_multipathing rpc session master;
 
29
 
 
30
  let sr = get_fc_sr rpc session in
 
31
  debug "Found FibreChannel SR: %s" (Ref.string_of sr);
 
32
  let scsiid = get_fc_scsiid rpc session sr in
 
33
  debug "SCSIid is %s" scsiid;
 
34
 
 
35
  let num_paths = get_num_paths rpc session sr scsiid in
 
36
  debug "PBD.other-config indicates that there is a maximum of %d paths to this SR" num_paths;
 
37
 
 
38
  debug "Creating VDI in FibreChannel SR...";
 
39
  let vdi = create_test_vdi rpc session sr in
 
40
  finally
 
41
    (fun () ->
 
42
      debug "Attaching VDI to dom0...";
 
43
      let vbd = plug_vdi_to_dom0 rpc session vdi in
 
44
 
 
45
      let time1 = time_data_transfer rpc session master vbd in
 
46
      debug " ** Duration of dd (with %d of %d paths) was %f seconds **" num_paths num_paths time1;
 
47
 
 
48
      finally
 
49
        (fun () ->
 
50
          modify_fc_paths_manual rpc session master true;
 
51
 
 
52
          finally
 
53
            (fun () ->
 
54
              let time2 = time_data_transfer rpc session master vbd in
 
55
              debug " ** Duration of dd (with 1 of %d paths) was %f seconds **" num_paths time2;
 
56
              let failover_time = time2 -. time1 in
 
57
              debug "So failover time was about %.1f seconds" failover_time;
 
58
              if failover_time > max_failover_time then failwith (Printf.sprintf "It took too long to failover between paths. It took %.1f secs, tolerance is %.1f secs" failover_time max_failover_time)
 
59
            )
 
60
            (fun () ->
 
61
              debug "Reinstating removed paths...";
 
62
              modify_fc_paths_manual rpc session master false
 
63
            )
 
64
        )
 
65
        (fun () ->
 
66
          debug "Unplugging VBD...";
 
67
          Client.VBD.unplug ~rpc ~session_id:session ~self:vbd
 
68
        )
 
69
    )
 
70
    (fun () ->
 
71
      debug "Removing test VDI...";
 
72
      Client.VDI.destroy ~rpc ~session_id:session ~self:vdi
 
73
    )