meta-bletchley: motor-ctrl: fix host-ac-on failed during bmc boot

1. add service dependency to avoid host-ac-on service failed due to
inventory (presence_sledX) property not avaliable.

host-ac-on@X.service
  |- motor-init-calibration@X.service (Requires, After)
     |- phosphor-gpio-presence@presence-sledX.service (Requires, After)

2. simplify check method for ac-on & ac-off actions, just check host
ac status before set ac on/off.

3. fix host-ac-on service shows failed when ac is aready turned on
(ex: BMC reset), return 0 for both ac-on & ac-off actions no
matter GPIO (power-hostX) set required or not.

Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I2c878dea05ea2511e6564c0980ba34dc28a46e2c
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl
index e430f8f..25cab0b 100755
--- a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl
@@ -595,10 +595,19 @@
     exit 1
 fi
 
-HOST_CURR_STATUS=$(get_host_status "$SLED_NUM")
-if [ "$ACTION" = "$ACTION_STATUS" ];then
+if [ "$ACTION" = "$ACTION_AC_ON" ]; then
+    if [ "$(get_ac_status "$SLED_NUM")" = "$HOST_AC_OFF" ]; then
+        do_action_ac_on "$SLED_NUM"
+    fi
+elif [ "$ACTION" = "$ACTION_AC_OFF" ]; then
+    if [ "$(get_ac_status "$SLED_NUM")" != "$HOST_AC_OFF" ]; then
+        do_action_ac_off "$SLED_NUM"
+    fi
+elif [ "$ACTION" = "$ACTION_STATUS" ];then
+    HOST_CURR_STATUS=$(get_host_status "$SLED_NUM")
     echo "$HOST_CURR_STATUS"
 else
+    HOST_CURR_STATUS=$(get_host_status "$SLED_NUM")
     case $HOST_CURR_STATUS in
         "$HOST_AC_OFF")
             host_state_ac_off_action_handler "$SLED_NUM" "$ACTION"