Update power restore from org to xyz interface

Resolves  openbmc/openbmc-test-automation#856

Change-Id: Ic9cea6032ff20e3eeff47dc68749549048de6e6d
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/data/variables.py b/data/variables.py
index 4a7c8dd..a80bff1 100644
--- a/data/variables.py
+++ b/data/variables.py
@@ -71,6 +71,14 @@
 # Host control URI variables.
 CONTROL_HOST_URI = '/xyz/openbmc_project/control/host0/'
 
+# Power restore variables.
+POWER_RESTORE_URI = CONTROL_HOST_URI + 'power_restore_policy'
+CONTROL_DBUS_BASE = 'xyz.openbmc_project.Control.'
+
+RESTORE_LAST_STATE = CONTROL_DBUS_BASE + 'Power.RestorePolicy.Policy.Restore'
+ALWAYS_POWER_ON = CONTROL_DBUS_BASE + 'Power.RestorePolicy.Policy.AlwaysOn'
+ALWAYS_POWER_OFF = CONTROL_DBUS_BASE + 'Power.RestorePolicy.Policy.AlwaysOff'
+
 # Dump URI variable
 DUMP_URI = '/xyz/openbmc_project/dump/'
 DUMP_ENTRY_URI = DUMP_URI + 'entry/'
diff --git a/lib/utils.robot b/lib/utils.robot
index ed0d2bb..d9fa770 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -726,14 +726,18 @@
     [Documentation]   Set the given BMC power policy.
     [arguments]   ${policy}
 
-    ${valueDict}=     create dictionary  data=${policy}
-    Write Attribute    ${HOST_SETTING}    power_policy   data=${valueDict}
-    ${currentPolicy}=  Read Attribute     ${HOST_SETTING}   power_policy
+    # Description of argument(s):
+    # policy    Power restore policy.
+
+    ${valueDict}=  Create Dictionary  data=${policy}
+    Write Attribute
+    ...  ${POWER_RESTORE_URI}  PowerRestorePolicy  data=${valueDict}
+    ${currentPolicy}=  Read Attribute  ${POWER_RESTORE_URI}  PowerRestorePolicy
     Should Be Equal    ${currentPolicy}   ${policy}
 
 Get System Power Policy
     [Documentation]  Get the BMC power policy.
-    ${currentPolicy}=  Read Attribute  ${HOST_SETTING}  power_policy
+    ${currentPolicy}=  Read Attribute  ${POWER_RESTORE_URI}  PowerRestorePolicy
     [Return]  ${currentPolicy}
 
 Get Auto Reboot
diff --git a/tests/test_power_restore.robot b/tests/test_power_restore.robot
index a787cb8..8ced81d 100644
--- a/tests/test_power_restore.robot
+++ b/tests/test_power_restore.robot
@@ -21,14 +21,14 @@
 
 *** Test Cases ***
 
-Test Restore Policy LEAVE_OFF With Host Off
+Test Restore Policy ALWAYS_POWER_OFF With Host Off
     # Policy                Initial Host State     Expected Host State
 
-    LEAVE_OFF               Off                    Off
+    ${ALWAYS_POWER_OFF}     Off                    Off
 
-    [Documentation]  Validate LEAVE_OFF restore policy functionality.
+    [Documentation]  Validate ALWAYS_POWER_OFF restore policy functionality.
     ...              Policy:
-    ...                    System policy set to LEAVE_OFF.
+    ...                    System policy set to ALWAYS_POWER_OFF.
     ...              Initial Host State:
     ...                    State where system should be before running the
     ...                    test case.
@@ -37,26 +37,26 @@
     ...                    specific state.
 
     [Template]  Verify Restore Policy
-    [Tags]  Test_Restore_Policy_LEAVE_OFF_With_Host_Off
+    [Tags]  Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Off
 
 
-Test Restore Policy LEAVE_OFF With Host Running
+Test Restore Policy ALWAYS_POWER_OFF With Host Running
     # Policy                Initial Host State     Expected Host State
 
-    LEAVE_OFF               Running                Off
+    ${ALWAYS_POWER_OFF}     Running                Off
 
     [Template]  Verify Restore Policy
-    [Tags]  Test_Restore_Policy_LEAVE_OFF_With_Host_Running
+    [Tags]  Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Running
 
 
 Test Restore Policy ALWAYS_POWER_ON With Host Off
     # Policy                Initial Host State     Expected Host State
 
-    ALWAYS_POWER_ON         Off                    Running
+    ${ALWAYS_POWER_ON}      Off                    Running
 
     [Documentation]  Validate ALWAYS_POWER_ON restore policy functionality.
     ...              Policy:
-    ...                    System policy set to LEAVE_OFF.
+    ...                    System policy set to ALWAYS_POWER_OFF.
     ...              Initial Host State:
     ...                    State where system should be before running the
     ...                    test case.
@@ -71,7 +71,7 @@
 Test Restore Policy ALWAYS_POWER_ON With Host Running
     # Policy                Initial Host State     Expected Host State
 
-    ALWAYS_POWER_ON         Running                Running
+    ${ALWAYS_POWER_ON}      Running                Running
 
     [Template]  Verify Restore Policy
     [Tags]  Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Running
@@ -80,7 +80,7 @@
 Test Restore Policy Restore Last State With Host Running
     # Policy                Initial Host State     Expected Host State
 
-    RESTORE_LAST_STATE      Running                Running
+    ${RESTORE_LAST_STATE}   Running                Running
 
     [Documentation]  Validate RESTORE_LAST_STATE restore policy functionality.
     ...              Policy:
@@ -99,7 +99,7 @@
 Test Restore Policy Restore Last State With Host Off
     # Policy                Initial Host State     Expected Host State
 
-    RESTORE_LAST_STATE      Off                    Off
+    ${RESTORE_LAST_STATE}   Off                    Off
 
 
     [Template]  Verify Restore Policy
@@ -130,13 +130,7 @@
     ...  '${currentState}' != '${expectedState}'
     ...  Set Initial Test State  ${expectedState}
 
-    # TBD: Replace reboot with 'Initiate BMC Reboot' keyword
-    # Reference: openbmc/openbmc#1161
-    Open Connection And Log In
-    Start Command   /sbin/reboot
-
-    Wait Until Keyword Succeeds
-    ...  5 min  10 sec  Is BMC Ready
+    Initiate BMC Reboot
 
     Wait Until Keyword Succeeds
     ...  10 min  10 sec  Verify Host State  ${nextState}
@@ -183,5 +177,5 @@
     [Documentation]  Do the post suite teardown.
     # 1. Set policy to default.
 
-    Run Keyword And Ignore Error  Set BMC Power Policy  RESTORE_LAST_STATE
+    Run Keyword And Ignore Error  Set BMC Power Policy  ${RESTORE_LAST_STATE}