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] CP-1632: Add restrictions option for Heterogeneous Poo

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] CP-1632: Add restrictions option for Heterogeneous Pools feature
From: Rob Hoes <rob.hoes@xxxxxxxxxx>
Date: Fri, 12 Feb 2010 12:41:54 +0000
Delivery-date: Fri, 12 Feb 2010 04:41:53 -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 Rob Hoes <rob.hoes@xxxxxxxxxx>
CP-1632: Add restrictions option for Heterogeneous Pools feature

Plus some cleanup of the restrictions file.

Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>

diff -r 93602fe9a6ba ocaml/license/restrictions.ml
--- a/ocaml/license/restrictions.ml     Fri Feb 05 09:53:59 2010 +0000
+++ b/ocaml/license/restrictions.ml     Fri Feb 05 10:00:20 2010 +0000
@@ -1,5 +1,5 @@
 (*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
+ * Copyright (C) 2006-2010 Citrix Systems Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
@@ -55,6 +55,7 @@
        enable_dmc : bool;
        enable_checkpoint : bool;
        enable_vswitch_controller : bool;
+       enable_cpu_masking : bool;
        restrict_connection : bool;
        platform_filter : bool;
        regular_nag_dialog : bool;
@@ -76,8 +77,9 @@
                "WLB"     ,     x.enable_wlb           ;
                "RBAC"    ,     x.enable_rbac          ;
                "DMC"     ,     x.enable_dmc           ;
+               "chpt"    ,     x.enable_checkpoint    ;
                "DVSC"    ,     x.enable_vswitch_controller;
-               "chpt"    ,     x.enable_checkpoint    ;
+               "Mask"    ,     x.enable_cpu_masking;
                "Cnx"     , not x.restrict_connection  ;
                "Plat"    , not x.platform_filter      ;
                "nag"     ,     x.regular_nag_dialog   ;
@@ -103,6 +105,7 @@
        enable_dmc            = true;
        enable_checkpoint     = true;
        enable_vswitch_controller = true;
+       enable_cpu_masking = true;
        restrict_connection   = false;
        platform_filter       = false;
        regular_nag_dialog    = false;
@@ -126,6 +129,7 @@
        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;
+       enable_cpu_masking = a.enable_cpu_masking && b.enable_cpu_masking;
        restrict_connection   = a.restrict_connection   || 
b.restrict_connection;
        platform_filter       = a.platform_filter       || b.platform_filter;
        regular_nag_dialog    = a.regular_nag_dialog    || b.regular_nag_dialog;
@@ -135,10 +139,10 @@
 
 (* Returns true if the pool SKUs are 'floodgate free' (ie if any are express *)
 let pool_is_floodgate_free_of_list (license_params: ((string * string) list) 
list) = 
-  (* Some of the license_params might be malformed due to initial startup 
glitches *)
-  let valid = List.filter (fun license_params -> try 
ignore(License.of_assoc_list license_params); true with _ -> false) 
license_params in
-  let licenses = List.map License.of_assoc_list license_params in
-  List.fold_left (||) false (List.map (fun x -> is_floodgate_free 
(sku_of_string x.License.sku)) licenses)
+       (* Some of the license_params might be malformed due to initial startup 
glitches *)
+       let valid = List.filter (fun license_params -> try 
ignore(License.of_assoc_list license_params); true with _ -> false) 
license_params in
+       let licenses = List.map License.of_assoc_list license_params in
+       List.fold_left (||) false (List.map (fun x -> is_floodgate_free 
(sku_of_string x.License.sku)) licenses)
 
 let _restrict_connection = "restrict_connection"
 let _restrict_pooling = "restrict_pooling"
@@ -157,103 +161,108 @@
 let _restrict_dmc = "restrict_dmc"
 let _restrict_checkpoint = "restrict_checkpoint"
 let _restrict_vswitch_controller = "restrict_vswitch_controller"
+let _restrict_cpu_masking = "restrict_cpu_masking"
 let _regular_nag_dialog = "regular_nag_dialog"
 
 let to_assoc_list (x: restrictions) = 
-  [ (_restrict_connection,string_of_bool x.restrict_connection);
-    (_restrict_pooling,string_of_bool (not x.enable_pooling));
-    (_restrict_qos,string_of_bool (not x.enable_qos));
-    (_restrict_pool_attached_storage,string_of_bool (not 
x.enable_shared_storage));
-    (_restrict_netapp, string_of_bool (not x.enable_netapp));
-    (_restrict_equalogic, string_of_bool (not x.enable_equalogic));
-    (_restrict_vlan,string_of_bool (not x.enable_vlans));
-    (_enable_xha, string_of_bool (x.enable_xha));
-    (_restrict_marathon, string_of_bool (not x.enable_mtc_pci));
-    (_platform_filter, string_of_bool x.platform_filter);
-    (_restrict_email_alerting, string_of_bool (not x.enable_email));
-    (_restrict_historical_performance, string_of_bool (not 
x.enable_performance));
-    (_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);
-  ]
+       [ (_restrict_connection,string_of_bool x.restrict_connection);
+               (_restrict_pooling,string_of_bool (not x.enable_pooling));
+               (_restrict_qos,string_of_bool (not x.enable_qos));
+               (_restrict_pool_attached_storage,string_of_bool (not 
x.enable_shared_storage));
+               (_restrict_netapp, string_of_bool (not x.enable_netapp));
+               (_restrict_equalogic, string_of_bool (not x.enable_equalogic));
+               (_restrict_vlan,string_of_bool (not x.enable_vlans));
+               (_enable_xha, string_of_bool (x.enable_xha));
+               (_restrict_marathon, string_of_bool (not x.enable_mtc_pci));
+               (_platform_filter, string_of_bool x.platform_filter);
+               (_restrict_email_alerting, string_of_bool (not x.enable_email));
+               (_restrict_historical_performance, string_of_bool (not 
x.enable_performance));
+               (_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 ));
+               (_restrict_cpu_masking,            string_of_bool (not 
x.enable_cpu_masking   ));
+               (_regular_nag_dialog, string_of_bool x.regular_nag_dialog);
+       ]
 
 (* Read an association list possibly generated by a slave running a previous 
version and hence possibly 
    missing some values. In the case where a value is missing we default to the 
most_permissive. *)
 let of_assoc_list x = 
-  let find fn key = if List.mem_assoc key x then Some (fn (List.assoc key x)) 
else None in
-  { 
-    enable_vlans          = Opt.default most_permissive.enable_vlans          
(Opt.map not (find bool_of_string _restrict_vlan));
-    enable_qos            = Opt.default most_permissive.enable_qos            
(Opt.map not (find bool_of_string _restrict_qos));
-    enable_shared_storage = Opt.default most_permissive.enable_shared_storage 
(Opt.map not (find bool_of_string _restrict_pool_attached_storage));
-    enable_netapp         = Opt.default most_permissive.enable_netapp         
(Opt.map not (find bool_of_string _restrict_netapp));
-    enable_equalogic      = Opt.default most_permissive.enable_equalogic      
(Opt.map not (find bool_of_string _restrict_equalogic));
-    enable_pooling        = Opt.default most_permissive.enable_pooling        
(Opt.map not (find bool_of_string _restrict_pooling));
-    enable_xha            = Opt.default most_permissive.enable_xha             
            (find bool_of_string _enable_xha);
-    enable_mtc_pci        = Opt.default most_permissive.enable_mtc_pci        
(Opt.map not (find bool_of_string _restrict_marathon));
-    restrict_connection   = Opt.default most_permissive.restrict_connection    
            (find bool_of_string _restrict_connection);
-    platform_filter       = Opt.default most_permissive.platform_filter        
            (find bool_of_string _platform_filter);
-    enable_email          = Opt.default most_permissive.enable_email          
(Opt.map not (find bool_of_string _restrict_email_alerting));
-    enable_performance    = Opt.default most_permissive.enable_performance    
(Opt.map not (find bool_of_string _restrict_historical_performance));
-    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_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);
-  }
+       let find fn key = if List.mem_assoc key x then Some (fn (List.assoc key 
x)) else None in
+       { 
+               enable_vlans          = Opt.default 
most_permissive.enable_vlans          (Opt.map not (find bool_of_string 
_restrict_vlan));
+               enable_qos            = Opt.default most_permissive.enable_qos  
          (Opt.map not (find bool_of_string _restrict_qos));
+               enable_shared_storage = Opt.default 
most_permissive.enable_shared_storage (Opt.map not (find bool_of_string 
_restrict_pool_attached_storage));
+               enable_netapp         = Opt.default 
most_permissive.enable_netapp         (Opt.map not (find bool_of_string 
_restrict_netapp));
+               enable_equalogic      = Opt.default 
most_permissive.enable_equalogic      (Opt.map not (find bool_of_string 
_restrict_equalogic));
+               enable_pooling        = Opt.default 
most_permissive.enable_pooling        (Opt.map not (find bool_of_string 
_restrict_pooling));
+               enable_xha            = Opt.default most_permissive.enable_xha  
                       (find bool_of_string _enable_xha);
+               enable_mtc_pci        = Opt.default 
most_permissive.enable_mtc_pci        (Opt.map not (find bool_of_string 
_restrict_marathon));
+               restrict_connection   = Opt.default 
most_permissive.restrict_connection                (find bool_of_string 
_restrict_connection);
+               platform_filter       = Opt.default 
most_permissive.platform_filter                    (find bool_of_string 
_platform_filter);
+               enable_email          = Opt.default 
most_permissive.enable_email          (Opt.map not (find bool_of_string 
_restrict_email_alerting));
+               enable_performance    = Opt.default 
most_permissive.enable_performance    (Opt.map not (find bool_of_string 
_restrict_historical_performance));
+               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_checkpoint     = Opt.default 
most_permissive.enable_checkpoint     (Opt.map not (find bool_of_string 
_restrict_dmc));
+               enable_vswitch_controller = Opt.default 
most_permissive.enable_vswitch_controller (Opt.map not (find bool_of_string 
_restrict_vswitch_controller));
+               enable_cpu_masking    = Opt.default 
most_permissive.enable_cpu_masking    (Opt.map not (find bool_of_string 
_restrict_cpu_masking));
+               regular_nag_dialog    = Opt.default 
most_permissive.regular_nag_dialog                 (find bool_of_string 
_regular_nag_dialog);
+       }
 
 
 (* Encodes the minimum set of restrictions available in all SKUs (ie FG-Free 
and FG-PaidFor) *)
 let common_to_all_skus =
-  {
-    enable_vlans = true;
-    enable_qos = true;
-    enable_shared_storage = true;
-    enable_netapp = false;
-    enable_equalogic = false;
-    enable_pooling = true;
-    enable_xha = false;
-    enable_mtc_pci = true;
-    restrict_connection = false;
-    platform_filter = true;
-    enable_email = false;
-    enable_performance = false;
-    enable_wlb = false;
-    enable_rbac = false;
-    enable_dmc = false;
-    enable_checkpoint     = false;
-    enable_vswitch_controller = false;
-    regular_nag_dialog = true;
-  }
+       {
+               enable_vlans = true;
+               enable_qos = true;
+               enable_shared_storage = true;
+               enable_netapp = false;
+               enable_equalogic = false;
+               enable_pooling = true;
+               enable_xha = false;
+               enable_mtc_pci = true;
+               restrict_connection = false;
+               platform_filter = true;
+               enable_email = false;
+               enable_performance = false;
+               enable_wlb = false;
+               enable_rbac = false;
+               enable_dmc = false;
+               enable_checkpoint = false;
+               enable_vswitch_controller = false;
+               enable_cpu_masking = false;
+               regular_nag_dialog = true;
+       }
 
 let get_sku () = sku_of_string !License.license.License.sku
 
 let get_sku_from_license l = sku_of_string l.sku
 
 let rec restrictions_of_sku = function
-| Express -> common_to_all_skus
-| Enterprise ->
-       {
-               common_to_all_skus with
-               enable_xha = true;
-               platform_filter = false;
-               enable_netapp = true;
-               enable_equalogic = true;
-               enable_email = true;
-               enable_performance = true;
-               enable_wlb = true;
-               enable_rbac = true;
-               enable_dmc = true;
-               enable_checkpoint  = true;
-               enable_vswitch_controller = true;
-               regular_nag_dialog = false;
-       }
+       | Express -> common_to_all_skus
+       | Enterprise ->
+               {
+                       common_to_all_skus with
+                       enable_xha = true;
+                       platform_filter = false;
+                       enable_netapp = true;
+                       enable_equalogic = true;
+                       enable_email = true;
+                       enable_performance = true;
+                       enable_wlb = true;
+                       enable_rbac = true;
+                       enable_dmc = true;
+                       enable_checkpoint  = true;
+                       enable_vswitch_controller = true;
+                       enable_cpu_masking = true;
+                       regular_nag_dialog = false;
+               }
 
 let get () =
-  restrictions_of_sku (get_sku ())
+       restrictions_of_sku (get_sku ())
 
 (* Cache of pool restrictions, always updated at least once when the master 
reads its license *)
 let pool_restrictions = ref most_permissive
@@ -262,30 +271,33 @@
 let get_pool () = Mutex.execute pool_restrictions_m (fun () -> 
!pool_restrictions)
 
 let update_pool_restrictions ~__context = 
-  Mutex.execute pool_restrictions_m
-    (fun () ->
-       let hosts = List.map (fun (_, host_r) -> 
host_r.API.host_license_params) (Db.Host.get_all_records ~__context) in
-       let new_restrictions = pool_restrictions_of_list (List.map 
of_assoc_list hosts) in
-       if new_restrictions <> !pool_restrictions then begin
-                info "Old pool restrictions: %s" (to_compact_string 
!pool_restrictions);
-                info "New pool restrictions: %s" (to_compact_string 
new_restrictions);
-                pool_restrictions := new_restrictions
-       end;
-       let pool = List.hd (Db.Pool.get_all ~__context) in
-       Db.Pool.set_restrictions ~__context ~self:pool ~value:(to_assoc_list 
new_restrictions)
-    )
+       Mutex.execute pool_restrictions_m (fun () ->
+               let hosts = List.map (fun (_, host_r) -> 
host_r.API.host_license_params) (Db.Host.get_all_records ~__context) in
+               let new_restrictions = pool_restrictions_of_list (List.map 
of_assoc_list hosts) in
+               if new_restrictions <> !pool_restrictions then begin
+                       info "Old pool restrictions: %s" (to_compact_string 
!pool_restrictions);
+                       info "New pool restrictions: %s" (to_compact_string 
new_restrictions);
+                       pool_restrictions := new_restrictions
+               end;
+               let pool = List.hd (Db.Pool.get_all ~__context) in
+               Db.Pool.set_restrictions ~__context ~self:pool 
~value:(to_assoc_list new_restrictions)
+       )
 
 let license_ok_for_wlb ~__context =
-  (get_pool()).enable_wlb
+       (get_pool()).enable_wlb
 
 let license_ok_for_rbac ~__context =
-  (get_pool()).enable_rbac
-  
+       (get_pool()).enable_rbac
+
 let context_ok_for_dmc ~__context = 
-  (get_pool()).enable_dmc
+       (get_pool()).enable_dmc
 
 let ok_for_checkpoint () =
        (get_pool()).enable_checkpoint
 
-let license_ok_for_vswitch_controller ~__context = 
-  (get_pool()).enable_vswitch_controller
+let ok_for_vswitch_controller () =
+       (get_pool()).enable_vswitch_controller
+
+let ok_for_cpu_masking () =
+       (get_pool()).enable_cpu_masking
+
diff -r 93602fe9a6ba ocaml/license/restrictions.mli
--- a/ocaml/license/restrictions.mli    Fri Feb 05 09:53:59 2010 +0000
+++ b/ocaml/license/restrictions.mli    Fri Feb 05 10:00:20 2010 +0000
@@ -48,6 +48,7 @@
        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 *)
+       enable_cpu_masking    : bool; (** enable masking of CPU features *)
        restrict_connection   : bool; (** not used anymore; perhaps XenCenter 
does? *)
        platform_filter       : bool; (** filter platform data on domain 
create? *)
        regular_nag_dialog    : bool; (** used by XenCenter *)
@@ -91,3 +92,10 @@
 
 (** Checks whether we are entitled to enable checkpoint *)
 val ok_for_checkpoint : unit -> bool
+
+(** Checks whether we are entitled to use a VSwitch Controller *)
+val ok_for_vswitch_controller : unit -> bool
+
+(** Checks whether we are entitled to mask CPU features *)
+val ok_for_cpu_masking : unit -> bool
+

Attachment: flex-restrictions
Description: Text document

_______________________________________________
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] CP-1632: Add restrictions option for Heterogeneous Pools feature, Rob Hoes <=