]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
Displays an accurate message when xapi fails to initialise when host is its own slave.
authorRok Strnisa <rok.strnisa@citrix.com>
Tue, 24 Aug 2010 15:28:22 +0000 (16:28 +0100)
committerRok Strnisa <rok.strnisa@citrix.com>
Tue, 24 Aug 2010 15:28:22 +0000 (16:28 +0100)
Signed-off-by: Rok Strnisa <rok.strnisa@citrix.com>
ocaml/idl/api_errors.ml
ocaml/idl/datamodel.ml
ocaml/xapi/xapi.ml

index 78b94fa51d8ef2ac529df3e6e6f7776fabd527e0..23a1dff66ce095d399b09e4d16380f40d1983bdf 100644 (file)
@@ -64,6 +64,7 @@ let host_name_invalid = "HOST_NAME_INVALID"
 let host_has_resident_vms = "HOST_HAS_RESIDENT_VMS"
 
 (* Host errors which explain why the host is in emergency mode *)
+let host_its_own_slave = "HOST_ITS_OWN_SLAVE"
 let host_still_booting = "HOST_STILL_BOOTING"
 (* license *)
 let host_has_no_management_ip = "HOST_HAS_NO_MANAGEMENT_IP"
index 0b1ddadb28cb21934c408f3f12020aba9a7c205f..fe4864482d12144776b0cd65601bd2913109b38b 100644 (file)
@@ -565,6 +565,8 @@ let _ =
   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_its_own_slave []
+    ~doc:"The host is its own slave. Please use pool-emergency-transition-to-master or pool-emergency-reset-master." ();
   error Api_errors.host_still_booting []
     ~doc:"The host is still booting." ();
   error Api_errors.host_has_no_management_ip []
index 89b3de3e8cb4fb0f99593047871cbab99f50efe7..484f3382e0b57064d737149d55081848b3231ba9 100644 (file)
@@ -372,13 +372,19 @@ let bring_up_management_if ~__context () =
     debug "Caught exception bringing up management interface: %s" (ExnHelper.string_of_exn e)
 
 (** When booting as a slave we must have a management IP address in order to talk to the master. *)
-let wait_for_management_ip_address () = 
-  debug "Attempting to acquire a management IP address";
-  Xapi_host.set_emergency_mode_error Api_errors.host_has_no_management_ip [];
-  let ip = Xapi_mgmt_iface.wait_for_management_ip () in
-  debug "Acquired management IP address: %s" ip;
-  Xapi_host.set_emergency_mode_error Api_errors.host_still_booting [];
-  ip
+let wait_for_management_ip_address () =
+       debug "Attempting to acquire a management IP address";
+       Xapi_host.set_emergency_mode_error Api_errors.host_has_no_management_ip [];
+       let ip = Xapi_mgmt_iface.wait_for_management_ip () in
+       debug "Acquired management IP address: %s" ip;
+       Xapi_host.set_emergency_mode_error Api_errors.host_still_booting [];
+       (* Check whether I am my own slave. *)
+       let masters_ip = Pool_role.get_master_address () in
+       if masters_ip = "127.0.0.1" || masters_ip = ip then begin
+               debug "Realised that I am my own slave!";
+               Xapi_host.set_emergency_mode_error Api_errors.host_its_own_slave [];
+       end;
+       ip
 
 type hello_error =
   | Permanent (* e.g. the pool secret is wrong i.e. wrong master *)
@@ -818,14 +824,14 @@ let server_init() =
         (* Set emergency mode until we actually talk to the master *)
         Xapi_globs.slave_emergency_mode := true;
         (* signal the init script that it should succeed even though we're bust *)
-        Helpers.touch_file !Xapi_globs.ready_file; 
-                
+        Helpers.touch_file !Xapi_globs.ready_file;
+
         (* Keep trying to log into master *)
         let finished = ref false in
         while not(!finished) do
           (* Grab the management IP address (wait forever for it if necessary) *)
           let ip = wait_for_management_ip_address () in
-          
+
           debug "Attempting to communicate with master";
           (* Try to say hello to the pool *)
           begin match attempt_pool_hello ip with