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

[Xen-API] [PATCH]add strict check to VCPUs-params param-key


  • To: xen-api@xxxxxxxxxxxxxxxxxxx
  • From: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>
  • Date: Mon, 19 Apr 2010 17:22:15 +0800
  • Cc:
  • Delivery-date: Mon, 19 Apr 2010 02:20:17 -0700
  • List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>

Add strict check to VCPUs-params param-key,according to Xen Cloud Platform
Administrator's Guide,there's only 'weight','cap' or 'mask' param-key available.

current:
# xe vm-param-set VCPUs-params:test=33 uuid=b7ca170b-c017-046e-116c-8d4c4d778195
# xe vm-list params=VCPUs-params uuid=b7ca170b-c017-046e-116c-8d4c4d778195
VCPUs-params (MRW)    : test: 33

after patch:
# xe vm-param-set VCPUs-params:test=33 
uuid=b7ca170b-c017-046e-116c-8d4c4d778195 
Error: Failed to add parameter 'test': expecting 'weight','cap' or 'mask'
# xe vm-list params=VCPUs-params uuid=b7ca170b-c017-046e-116c-8d4c4d778195
VCPUs-params (MRW)    :

Signed-off-by: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>

diff -r ad754527bddd ocaml/client_records/records.ml
--- a/ocaml/client_records/records.ml   Fri Apr 16 11:44:32 2010 +0100
+++ b/ocaml/client_records/records.ml   Mon Apr 19 11:53:48 2010 -0400
@@ -619,7 +619,9 @@ let vm_record rpc session_id vm =
                                ~get:(fun () -> get_uuid_from_ref (x 
()).API.vM_suspend_VDI) ();
                        make_field ~name:"VCPUs-params"
                                ~get:(fun () -> Record_util.s2sm_to_string "; " 
(x ()).API.vM_VCPUs_params)
-                               ~add_to_map:(fun k v -> 
Client.VM.add_to_VCPUs_params rpc session_id vm k v)
+                               ~add_to_map:(fun k v -> match k with
+                                               | "weight" | "cap" | "mask" -> 
Client.VM.add_to_VCPUs_params rpc session_id vm k v
+                                               | _ -> raise 
(Record_util.Record_failure ("Failed to add parameter '"^k^"': expecting 
'weight','cap' or 'mask'")))
                                ~remove_from_map:(fun k -> 
Client.VM.remove_from_VCPUs_params rpc session_id vm k) 
                                ~get_map:(fun () -> (x ()).API.vM_VCPUs_params) 
();
                        make_field ~name:"VCPUs-max"

-- 
Regards
Yang Hongyang
diff -r ad754527bddd ocaml/client_records/records.ml
--- a/ocaml/client_records/records.ml   Fri Apr 16 11:44:32 2010 +0100
+++ b/ocaml/client_records/records.ml   Mon Apr 19 11:53:48 2010 -0400
@@ -619,7 +619,9 @@ let vm_record rpc session_id vm =
                                ~get:(fun () -> get_uuid_from_ref (x 
()).API.vM_suspend_VDI) ();
                        make_field ~name:"VCPUs-params"
                                ~get:(fun () -> Record_util.s2sm_to_string "; " 
(x ()).API.vM_VCPUs_params)
-                               ~add_to_map:(fun k v -> 
Client.VM.add_to_VCPUs_params rpc session_id vm k v)
+                               ~add_to_map:(fun k v -> match k with
+                                               | "weight" | "cap" | "mask" -> 
Client.VM.add_to_VCPUs_params rpc session_id vm k v
+                                               | _ -> raise 
(Record_util.Record_failure ("Failed to add parameter '"^k^"': expecting 
'weight','cap' or 'mask'")))
                                ~remove_from_map:(fun k -> 
Client.VM.remove_from_VCPUs_params rpc session_id vm k) 
                                ~get_map:(fun () -> (x ()).API.vM_VCPUs_params) 
();
                        make_field ~name:"VCPUs-max"
_______________________________________________
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®.