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

[Xen-API] [PATCH 14 of 17] CP-2137: Allow additional feature flags to be set by v6d


  • To: xen-api@xxxxxxxxxxxxxxxxxxx
  • From: Rob Hoes <rob.hoes@xxxxxxxxxx>
  • Date: Fri, 7 Jan 2011 16:57:57 +0000
  • Delivery-date: Fri, 07 Jan 2011 09:05:12 -0800
  • List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>

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


# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
# Date 1294419412 0
# Node ID a2f59b3ad6f216c794847ab5d7af9bac77b2468f
# Parent  14b65539326c2fbb5d91a5cefed4b058e6223e01
CP-2137: Allow additional feature flags to be set by v6d

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

diff -r 14b65539326c -r a2f59b3ad6f2 ocaml/xapi/features.ml
--- a/ocaml/xapi/features.ml
+++ b/ocaml/xapi/features.ml
@@ -31,7 +31,6 @@
        | RBAC
        | DMC
        | Checkpoint
-       | Vswitch_controller
        | CPU_masking
        | Connection
        | No_platform_filter
@@ -57,7 +56,6 @@
                RBAC, ("restrict_rbac", Negative, "RBAC");
                DMC, ("restrict_dmc", Negative, "DMC");
                Checkpoint, ("restrict_checkpoint", Negative, "chpt");
-               Vswitch_controller, ("restrict_vswitch_controller", Negative, 
"DVSC");
                CPU_masking, ("restrict_cpu_masking", Negative, "Mask");
                Connection, ("restrict_connection", Negative, "Cnx");
                No_platform_filter, ("platform_filter", Negative, "Plat");
diff -r 14b65539326c -r a2f59b3ad6f2 ocaml/xapi/features.mli
--- a/ocaml/xapi/features.mli
+++ b/ocaml/xapi/features.mli
@@ -31,7 +31,6 @@
        | RBAC                         (** Enable Role-Based Access Control 
(RBAC) *)
        | DMC                          (** Enable Dynamic Memory Control (DMC) 
*)
        | Checkpoint                   (** Enable Checkpoint functionality *)
-       | Vswitch_controller           (** Enable use of a Distributed VSwitch 
(DVS) Controller *)
        | CPU_masking                  (** Enable masking of CPU features *)
        | Connection                   (** Used by XenCenter *)
        | No_platform_filter           (** Filter platform data *)
diff -r 14b65539326c -r a2f59b3ad6f2 ocaml/xapi/pool_features.ml
--- a/ocaml/xapi/pool_features.ml
+++ b/ocaml/xapi/pool_features.ml
@@ -15,27 +15,46 @@
 module D = Debug.Debugger(struct let name="pool_features" end)
 open D
 
+let all_flags = List.map (fun (k, v) -> k) (to_assoc_list all_features)
+
+let new_restrictions params =
+       let kvs = List.filter (fun (k, v) ->
+                       try String.sub k 0 9 = "restrict_" && not (List.mem k 
all_flags)
+                       with Invalid_argument _ -> false
+               ) params in
+       List.map (fun (k, v) -> k) kvs
+
 let pool_features_of_list hosts =
        List.fold_left Listext.List.intersect all_features hosts
-       
+
 let get_pool_features ~__context =
        let pool = List.hd (Db.Pool.get_all ~__context) in
        of_assoc_list (Db.Pool.get_restrictions ~__context ~self:pool)
-       
+
 let is_enabled ~__context f =
        let pool_features = get_pool_features ~__context in
        List.mem f pool_features
 
 let update_pool_features ~__context =
        let pool = List.hd (Db.Pool.get_all ~__context) in
-       let pool_features = get_pool_features ~__context in
+       let pool_restrictions = Db.Pool.get_restrictions ~__context ~self:pool 
in
        let hosts = List.map
-               (fun (_, host_r) -> of_assoc_list 
host_r.API.host_license_params)
+               (fun (_, host_r) -> host_r.API.host_license_params)
                (Db.Host.get_all_records ~__context) in
-       let new_features = pool_features_of_list hosts in
-       if new_features <> pool_features then begin
+       let new_features = pool_features_of_list (List.map of_assoc_list hosts) 
in
+       let additional_flags = new_restrictions (List.hd hosts) in
+       let rec find_additional = function
+               | [] -> []
+               | flag :: rest ->
+                       let switches = List.map (function params -> 
bool_of_string (List.assoc flag params)) hosts in
+                       (flag, string_of_bool (List.fold_left (||) false 
switches)) :: find_additional rest
+       in
+       let additional_restrictions = find_additional additional_flags in
+       let new_restrictions = additional_restrictions @ (to_assoc_list 
new_features) in
+       if new_restrictions <> pool_restrictions then begin
+               let pool_features = of_assoc_list pool_restrictions in
                info "Old pool features enabled: %s" (to_compact_string 
pool_features);
                info "New pool features enabled: %s" (to_compact_string 
new_features);
-               Db.Pool.set_restrictions ~__context ~self:pool 
~value:(to_assoc_list new_features)
+               Db.Pool.set_restrictions ~__context ~self:pool 
~value:new_restrictions
        end
 

Attachment: xen-api.hg-14.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®.