Power on and off new interface

The changes introduce the following:
   - New state manager file
   - Variables are local and will get moved out eventually
   - New keywords for Power on and off
   - New supporting keywords for state check

Resolves openbmc/openbmc-test-automation#269

Change-Id: I8cd0f975749078f76174c5c4872b2b915b973fa5
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/state_manager.robot b/lib/state_manager.robot
new file mode 100755
index 0000000..92c3e23
--- /dev/null
+++ b/lib/state_manager.robot
@@ -0,0 +1,82 @@
+*** Settings ***
+Resource                ../lib/utils.robot
+
+*** Variables ***
+
+# Once the State Manager support is ready remove this variables block
+# and use appropriate resource or variable file imports
+
+# State Manager States
+${HOST_POWEROFF_TRANS}       xyz.openbmc_project.State.Host.Transition.Off
+${HOST_POWERON_TRANS}        xyz.openbmc_project.State.Host.Transition.On
+${HOST_POWEROFF_STATE}       xyz.openbmc_project.State.Host.HostState.Off
+${HOST_POWERON_STATE}        xyz.openbmc_project.State.Host.HostState.Running
+
+${CHASSIS_POWEROFF_TRANS}    xyz.openbmc_project.State.Chassis.Transition.Off
+${CHASSIS_POWERON_TRANS}     xyz.openbmc_project.State.Chassis.Transition.On
+${CHASSIS_POWEROFF_STATE}    xyz.openbmc_project.State.Chassis.PowerState.Off
+${CHASSIS_POWERON_STATE}     xyz.openbmc_project.State.Chassis.PowerState.On
+
+# State Manager URI's
+${HOST_STATE_URI}           /xyz/openbmc_project/state/host0/
+${CHASSIS_STATE_URI}        /xyz/openbmc_project/state/chassis0/
+
+${QUIET}  ${0}
+
+*** Keywords ***
+
+Initiate Host Boot
+    [Documentation]  Initiate host power on.
+    ${args}=  Create Dictionary   data=${HOST_POWERON_TRANS}
+    Write Attribute
+    ...  ${HOST_STATE_URI}  RequestedHostTransition   data=${args}
+
+    Wait Until Keyword Succeeds
+    ...  10 min  10 sec  Is Host Running
+
+
+Initiate Host PowerOff
+    [Documentation]  Initiate host power off.
+    ${args}=  Create Dictionary   data=${HOST_POWEROFF_TRANS}
+    Write Attribute
+    ...  ${HOST_STATE_URI}  RequestedHostTransition   data=${args}
+
+    Wait Until Keyword Succeeds
+    ...  3 min  10 sec  Is Host Off
+
+
+Is Host Running
+    [Documentation]  Check if Chassis and Host state is ON.
+    ${power_state}=  Get Chassis Power State
+    Should Be Equal  ${CHASSIS_POWERON_STATE}   ${power_state}
+    ${host_state}=  Get Host State
+    Should Be Equal  ${HOST_POWERON_STATE}   ${host_state}
+
+
+Is Host Off
+    [Documentation]  Check if Chassis and Host state is OFF.
+    ${power_state}=  Get Chassis Power State
+    Should Be Equal  ${CHASSIS_POWEROFF_STATE}   ${power_state}
+    ${host_state}=  Get Host State
+    Should Be Equal  ${HOST_POWEROFF_STATE}   ${host_state}
+
+
+Get Host State
+    [Documentation]  Return the state of the host as a string.
+    [Arguments]  ${quiet}=${QUIET}
+    # quiet - Suppress REST output logging to console.
+    ${state}=
+    ...  Read Attribute  ${HOST_STATE_URI}  CurrentHostState
+    ...  quiet=${quiet}
+    [Return]  ${state}
+
+
+Get Chassis Power State
+    [Documentation]  Return the power state of the Chassis
+    ...              as a string.
+    [Arguments]  ${quiet}=${QUIET}
+    # quiet - Suppress REST output logging to console.
+    ${state}=
+    ...  Read Attribute  ${CHASSIS_STATE_URI}  CurrentPowerState
+    ...  quiet=${quiet}
+    [Return]  ${state}