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 12 of 12] Refactoring slightly the function "Restrictio

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH 12 of 12] Refactoring slightly the function "Restrictions.to_compact_string" for readability
From: Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>
Date: Mon, 1 Feb 2010 16:32:14 +0000
Delivery-date: Mon, 01 Feb 2010 09:05:21 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1265041922@radon>
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 Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>
# Date 1265041877 0
# Node ID acbf8750e962fabb2ac3437e1bad829ef96398c7
# Parent  ed3d292016d805d42d591f6a0baf8c6e94969582
Refactoring slightly the function "Restrictions.to_compact_string" for 
readability.

Signed-off-by: Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>

diff -r ed3d292016d8 -r acbf8750e962 ocaml/license/restrictions.ml
--- a/ocaml/license/restrictions.ml     Mon Feb 01 16:31:16 2010 +0000
+++ b/ocaml/license/restrictions.ml     Mon Feb 01 16:31:17 2010 +0000
@@ -59,23 +59,28 @@
 }
 
 (** Used for printing compact host x restriction tables *)
-let to_compact_string (x: restrictions) = 
-       (if x.enable_vlans          then "VLAN "     else "     "    ) ^
-       (if x.enable_qos            then "QoS  "     else "     "    ) ^
-       (if x.enable_shared_storage then "SStorage " else "         ") ^
-       (if x.enable_netapp         then "NTAP "     else "     "    ) ^
-       (if x.enable_equalogic      then "EQL  "     else "     "    ) ^
-       (if x.enable_pooling        then "Pool "     else "     "    ) ^
-       (if x.enable_xha            then "XHA  "     else "     "    ) ^
-       (if x.enable_mtc_pci        then "MTC  "     else "     "    ) ^
-       (if x.enable_email          then "email "    else "      "   ) ^
-       (if x.enable_performance    then "perf "     else "     "    ) ^
-       (if x.enable_wlb            then "WLB  "     else "     "    ) ^
-       (if x.enable_rbac           then "RBAC "     else "     "    ) ^
-       (if x.enable_dmc            then "DMC "      else "    "     ) ^
-       (if x.restrict_connection   then "     "     else "Cnx  "    ) ^
-       (if x.platform_filter       then "     "     else "Plat "    ) ^
-       (if x.regular_nag_dialog    then " nag "     else "     "    )
+let to_compact_string (x: restrictions) =
+       let tag_flag_pair_list = [
+               "VLAN"    ,     x.enable_vlans         ;
+               "QoS"     ,     x.enable_qos           ;
+               "SStorage",     x.enable_shared_storage;
+               "NTAP"    ,     x.enable_netapp        ;
+               "EQL"     ,     x.enable_equalogic     ;
+               "Pool"    ,     x.enable_pooling       ;
+               "XHA"     ,     x.enable_xha           ;
+               "MTC"     ,     x.enable_mtc_pci       ;
+               "email"   ,     x.enable_email         ;
+               "perf"    ,     x.enable_performance   ;
+               "WLB"     ,     x.enable_wlb           ;
+               "RBAC"    ,     x.enable_rbac          ;
+               "DMC"     ,     x.enable_dmc           ;
+               "Cnx"     , not x.restrict_connection  ;
+               "Plat"    , not x.platform_filter      ;
+               "nag"     ,     x.regular_nag_dialog   ;
+       ] in
+       let to_string (tag, flag) =
+               if flag then tag else String.make (String.length tag) ' ' in
+       String.concat " " (List.map to_string tag_flag_pair_list)
 
 (** Represents no restrictions at all *)
 let most_permissive = {
1 file changed, 22 insertions(+), 17 deletions(-)
ocaml/license/restrictions.ml |   39 ++++++++++++++++++++++-----------------


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

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>