# HG changeset patch
# User Javier.Alvarez-Valle@citrix.com
# Date 1258724132 18000
# Node ID 076eb4721e47789608d195c880598ad631663704
# Parent  47d58c4a02663f7b9c0d9dc1aaee209b48f2c685
Introduce a check to dont allow-operations power-on if the power-on-mode is disabled
Signed-off-by: Javier.Alvarez-Valle@citrix.com

diff -r 47d58c4a0266 -r 076eb4721e47 ocaml/idl/api_errors.ml
--- a/ocaml/idl/api_errors.ml	Fri Nov 20 08:27:47 2009 -0500
+++ b/ocaml/idl/api_errors.ml	Fri Nov 20 08:35:32 2009 -0500
@@ -54,6 +54,7 @@
 let host_not_disabled = "HOST_NOT_DISABLED"
 let host_not_live = "HOST_NOT_LIVE"
 let host_is_live = "HOST_IS_LIVE"
+let host_power_on_mode_disabled="HOST_POWER_ON_MODE_DISABLED"
 let host_not_enough_free_memory = "HOST_NOT_ENOUGH_FREE_MEMORY"
 let no_hosts_available = "NO_HOSTS_AVAILABLE"
 let host_offline = "HOST_OFFLINE"
diff -r 47d58c4a0266 -r 076eb4721e47 ocaml/idl/datamodel.ml
--- a/ocaml/idl/datamodel.ml	Fri Nov 20 08:27:47 2009 -0500
+++ b/ocaml/idl/datamodel.ml	Fri Nov 20 08:35:32 2009 -0500
@@ -485,6 +485,8 @@
     ~doc:"This operation cannot be completed as the host is not live." ();
   error Api_errors.host_is_live [ "host" ]
     ~doc:"This operation cannot be completed as the host is still live." ();
+  error Api_errors.host_power_on_mode_disabled []
+    ~doc:"This operation cannot be completed as the host power on mode is disabled." ();
 
   error Api_errors.host_still_booting []
     ~doc:"The host is still booting." ();
diff -r 47d58c4a0266 -r 076eb4721e47 ocaml/xapi/xapi_host_helpers.ml
--- a/ocaml/xapi/xapi_host_helpers.ml	Fri Nov 20 08:27:47 2009 -0500
+++ b/ocaml/xapi/xapi_host_helpers.ml	Fri Nov 20 08:35:32 2009 -0500
@@ -69,6 +69,13 @@
       then set_errors Api_errors.host_is_live [ _ref ] [ `power_on ] 
     with _ -> () 
   end;
+  (* The host power_on_mode must be not disabled *)
+  begin 
+    try 
+      if Db.Host.get_power_on_mode ~__context ~self:_ref' ==""
+      then set_errors Api_errors.host_power_on_mode_disabled [] [ `power_on ]
+    with _ -> () 
+  end;
   (* The power-on-host plugin must be available before power_on is possible *)
   begin 
     try Unix.access (Filename.concat Xapi_globs.xapi_plugins_root Constants.power_on_plugin) [ Unix.X_OK ]
