[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH 2 of 2] CR47: Give the possibility to restrict the checkpoint feature in experimental settings



# HG changeset patch
# User Thomas Gazagnaire <thomas.gazagnaire@xxxxxxxxxx>
# Date 1265307792 0
# Node ID 61b4d603ff2d9e85fbf308f5a848d39fcf5f031e
# Parent  e0dee2a5e88b51c84fc16759ad553db791079182
CR47: Give the possibility to restrict the checkpoint feature in experimental 
settings

Signed-off-by: Thomas Gazagnaire <thomas.gazagnaire@xxxxxxxxxx>

diff -r e0dee2a5e88b -r 61b4d603ff2d ocaml/license/restrictions.ml
--- a/ocaml/license/restrictions.ml     Thu Feb 04 18:23:11 2010 +0000
+++ b/ocaml/license/restrictions.ml     Thu Feb 04 18:23:12 2010 +0000
@@ -53,6 +53,7 @@
        enable_wlb : bool;
        enable_rbac : bool;
        enable_dmc : bool;
+       enable_checkpoint : bool;
        enable_vswitch_controller : bool;
        restrict_connection : bool;
        platform_filter : bool;
@@ -76,6 +77,7 @@
                "RBAC"    ,     x.enable_rbac          ;
                "DMC"     ,     x.enable_dmc           ;
                "DVSC"    ,     x.enable_vswitch_controller;
+               "chpt"    ,     x.enable_checkpoint    ;
                "Cnx"     , not x.restrict_connection  ;
                "Plat"    , not x.platform_filter      ;
                "nag"     ,     x.regular_nag_dialog   ;
@@ -99,6 +101,7 @@
        enable_wlb            = true;
        enable_rbac           = true;
        enable_dmc            = true;
+       enable_checkpoint     = true;
        enable_vswitch_controller = true;
        restrict_connection   = false;
        platform_filter       = false;
@@ -121,6 +124,7 @@
        enable_wlb            = a.enable_wlb            && b.enable_wlb;
        enable_rbac           = a.enable_rbac           && b.enable_rbac;
        enable_dmc            = a.enable_dmc            && b.enable_dmc;
+       enable_checkpoint     = a.enable_checkpoint     && b.enable_checkpoint;
        enable_vswitch_controller = a.enable_vswitch_controller && 
b.enable_vswitch_controller;
        restrict_connection   = a.restrict_connection   || 
b.restrict_connection;
        platform_filter       = a.platform_filter       || b.platform_filter;
@@ -151,6 +155,7 @@
 let _restrict_wlb = "restrict_wlb"
 let _restrict_rbac = "restrict_rbac"
 let _restrict_dmc = "restrict_dmc"
+let _restrict_checkpoint = "restrict_checkpoint"
 let _restrict_vswitch_controller = "restrict_vswitch_controller"
 let _regular_nag_dialog = "regular_nag_dialog"
 
@@ -170,6 +175,7 @@
     (_restrict_wlb, string_of_bool (not x.enable_wlb));
     (_restrict_rbac, string_of_bool (not x.enable_rbac));
     (_restrict_dmc,                    string_of_bool (not x.enable_dmc        
   ));
+    (_restrict_checkpoint,             string_of_bool (not x.enable_checkpoint 
   ));
     (_restrict_vswitch_controller,     string_of_bool (not 
x.enable_vswitch_controller ));
     (_regular_nag_dialog, string_of_bool x.regular_nag_dialog);
   ]
@@ -194,7 +200,8 @@
     enable_wlb            = Opt.default most_permissive.enable_wlb            
(Opt.map not (find bool_of_string _restrict_wlb));
     enable_rbac           = Opt.default most_permissive.enable_rbac           
(Opt.map not (find bool_of_string _restrict_rbac));
     enable_dmc            = Opt.default most_permissive.enable_dmc            
(Opt.map not (find bool_of_string _restrict_dmc));
-       enable_vswitch_controller = Opt.default most_permissive.enable_dmc      
      (Opt.map not (find bool_of_string _restrict_vswitch_controller));
+    enable_checkpoint     = Opt.default most_permissive.enable_checkpoint     
(Opt.map not (find bool_of_string _restrict_dmc));
+    enable_vswitch_controller = Opt.default most_permissive.enable_dmc         
   (Opt.map not (find bool_of_string _restrict_vswitch_controller));
     regular_nag_dialog    = Opt.default most_permissive.regular_nag_dialog     
            (find bool_of_string _regular_nag_dialog);
   }
 
@@ -216,7 +223,8 @@
     enable_performance = false;
     enable_wlb = false;
     enable_rbac = false;
-       enable_dmc = false;
+    enable_dmc = false;
+    enable_checkpoint     = false;
     enable_vswitch_controller = false;
     regular_nag_dialog = true;
   }
@@ -239,7 +247,8 @@
                enable_wlb = true;
                enable_rbac = true;
                enable_dmc = true;
-        enable_vswitch_controller = true;
+               enable_checkpoint  = true;
+               enable_vswitch_controller = true;
                regular_nag_dialog = false;
        }
 
@@ -273,5 +282,8 @@
 let context_ok_for_dmc ~__context = 
   (get_pool()).enable_dmc
 
+let ok_for_checkpoint () =
+       (get_pool()).enable_checkpoint
+
 let license_ok_for_dmc ~__context = 
   (get_pool()).enable_vswitch_controller
diff -r e0dee2a5e88b -r 61b4d603ff2d ocaml/license/restrictions.mli
--- a/ocaml/license/restrictions.mli    Thu Feb 04 18:23:11 2010 +0000
+++ b/ocaml/license/restrictions.mli    Thu Feb 04 18:23:12 2010 +0000
@@ -46,6 +46,7 @@
        enable_wlb            : bool; (** enable Workload Balancing (WLB) *)
        enable_rbac           : bool; (** enable Role-Based Access Control 
(RBAC) *)
        enable_dmc            : bool; (** enable Dynamic Memory Control (DMC) *)
+       enable_checkpoint     : bool; (** enable Checkpoint *)
        enable_vswitch_controller : bool; (** enable use of a Distributed 
VSwitch (DVS) Controller *)
        restrict_connection   : bool; (** not used anymore; perhaps XenCenter 
does? *)
        platform_filter       : bool; (** filter platform data on domain 
create? *)
@@ -87,3 +88,6 @@
 (** Checks whether we are entitled to enable Dynamic Memory Control (DMC)
   * in the pool. *)
 val context_ok_for_dmc : __context:'a -> bool
+
+(** Checks whether we are entitled to enable checkpoint *)
+val ok_for_checkpoint : unit -> bool
diff -r e0dee2a5e88b -r 61b4d603ff2d ocaml/xapi/xapi_vm.ml
--- a/ocaml/xapi/xapi_vm.ml     Thu Feb 04 18:23:11 2010 +0000
+++ b/ocaml/xapi/xapi_vm.ml     Thu Feb 04 18:23:12 2010 +0000
@@ -981,14 +981,18 @@
 (* As the checkpoint operation modify the domain state, we take the vm_lock to 
do not let the event *)
 (* thread mess around with that. *)
 let checkpoint ~__context ~vm ~new_name =
-       Local_work_queue.wait_in_line Local_work_queue.long_running_queue 
-    (Printf.sprintf "VM.checkpoint %s" (Context.string_of_task __context))
-         (fun () ->
-               TaskHelper.set_cancellable ~__context;
-               Locking_helpers.with_lock vm 
-                       (fun token () -> Xapi_vm_snapshot.checkpoint ~__context 
~vm ~new_name)
-                       ()
-       )
+       if not (Restrictions.ok_for_checkpoint ()) then
+               raise (Api_errors.Server_error(Api_errors.license_restriction, 
[]))
+       else begin
+               Local_work_queue.wait_in_line 
Local_work_queue.long_running_queue 
+                       (Printf.sprintf "VM.checkpoint %s" 
(Context.string_of_task __context))
+                       (fun () ->
+                               TaskHelper.set_cancellable ~__context;
+                               Locking_helpers.with_lock vm 
+                                       (fun token () -> 
Xapi_vm_snapshot.checkpoint ~__context ~vm ~new_name)
+                                       ()
+                       )
+       end
        
 let copy ~__context ~vm ~new_name ~sr =
        (* See if the supplied SR is suitable: it must exist and be a non-ISO 
SR *)
3 files changed, 31 insertions(+), 11 deletions(-)
ocaml/license/restrictions.ml  |   18 +++++++++++++++---
ocaml/license/restrictions.mli |    4 ++++
ocaml/xapi/xapi_vm.ml          |   20 ++++++++++++--------


Attachment: xen-api.hg-2.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.