Refactored boot related test cases to use new xyz interface.

Resolves openbmc/openbmc-test-automation#156

Change-Id: I367a57839408cac4e5ff51a29b7784bd37379ec3
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/tests/test_boot_devices.robot b/tests/test_boot_devices.robot
index bbe203f..67c1945 100644
--- a/tests/test_boot_devices.robot
+++ b/tests/test_boot_devices.robot
@@ -15,163 +15,209 @@
 
 *** Variables ***
 
-${stack_mode}     skip
-${HOST_SETTINGS}  ${SETTINGS_URI}host0
+${stack_mode}           skip
+
 
 *** Test Cases ***
 
-Set The Boot Device As Default Using REST API
-    [Documentation]  This testcase is to set the boot device as default using REST
-    ...              URI. The Boot device is read using REST API and ipmitool.
-    [Tags]  Set_The_Boot_Device_As_Default_Using_REST_API
+Set The Boot Source As Default Using REST API
+    [Documentation]  Set default boot source via REST and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Source_As_Default_Using_REST_API
 
-    ${bootDevice}=  Set Variable  Default
-    ${valueDict}=  Create Dictionary  data=${bootDevice}
-    Write Attribute  ${HOST_SETTINGS}  boot_flags  data=${valueDict}
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  Default
+    Set Boot Source  ${BOOT_SOURCE_DEFAULT}
+
+    ${boot_source}=
+    ...  Read Attribute  ${CONTROL_HOST_URI}/boot_source  BootSource
+    Should Be Equal As Strings  ${boot_source}  ${BOOT_SOURCE_DEFAULT}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  No override
 
-Set The Boot Device As Default Using Ipmitool
-    [Documentation]  This testcase is to set the boot device as default using
-    ...              ipmitool. The Boot device is read using REST API and
-    ...              ipmitool.
-    [Tags]  Set_The_Boot_Device_As_Default_Using_Ipmitool
+
+Set The Boot Source As Default Using Ipmitool
+    [Documentation]  Set default boot source via IPMI and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Source_As_Default_Using_Ipmitool
 
     Run IPMI command  0x0 0x8 0x05 0x80 0x00 0x00 0x00 0x00
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  Default
+
+    ${boot_source}=
+    ...  Read Attribute  ${CONTROL_HOST_URI}/boot_source  BootSource
+    Should Be Equal As Strings  ${boot_source}  ${BOOT_SOURCE_DEFAULT}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  No override
 
-Set The Boot Device As Network Using REST API
-    [Documentation]  This testcase is to set the boot device as Network using REST
-    ...              URI. The Boot device is read using REST API and ipmitool.
-    [Tags]  Set_The_Boot_Device_As_Network_Using_REST_API
 
-    ${bootDevice}=  Set Variable  Network
-    ${valueDict}=  Create Dictionary  data=${bootDevice}
-    Write Attribute  ${HOST_SETTINGS}  boot_flags  data=${valueDict}
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  Network
+Set The Boot Source As Network Using REST API
+    [Documentation]  Set boot source as Network via REST and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Source_As_Network_Using_REST_API
+
+    Set Boot Source  ${BOOT_SOURCE_NETWORK}
+
+    ${boot_source}=
+    ...  Read Attribute  ${CONTROL_HOST_URI}/boot_source  BootSource
+    Should Be Equal As Strings  ${boot_source}  ${BOOT_SOURCE_NETWORK}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  Force PXE
 
-Set The Boot Device As Network Using Ipmitool
-    [Documentation]  This testcase is to set the boot device as Network using
-    ...              ipmitool. The Boot device is read using REST API and
-    ...              ipmitool.
-    [Tags]  Set_The_Boot_Device_As_Network_Using_Ipmitool
+
+Set The Boot Source As Network Using Ipmitool
+    [Documentation]  Set boot source as Network via IPMI and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Source_As_Network_Using_Ipmitool
 
     Run IPMI command  0x0 0x8 0x05 0x80 0x04 0x00 0x00 0x00
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  Network
+
+    ${boot_source}=
+    ...  Read Attribute  ${CONTROL_HOST_URI}/boot_source  BootSource
+    Should Be Equal As Strings  ${boot_source}  ${BOOT_SOURCE_NETWORK}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  Force PXE
 
-Set The Boot Device As Disk Using REST API
-    [Documentation]  This testcase is to set the boot device as Disk using REST
-    ...              URI. The Boot device is read using REST API and ipmitool.
-    [Tags]  Set_The_Boot_Device_As_Disk_Using_REST_API
 
-    ${bootDevice}=  Set Variable  Disk
-    ${valueDict}=  Create Dictionary  data=${bootDevice}
-    Write Attribute  ${HOST_SETTINGS}  boot_flags  data=${valueDict}
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  Disk
+Set The Boot Source As Disk Using REST API
+    [Documentation]  Set boot source as Disk via REST and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Source_As_Disk_Using_REST_API
+
+    Set Boot Source  ${BOOT_SOURCE_DISK}
+
+    ${boot_source}=
+    ...  Read Attribute  ${CONTROL_HOST_URI}/boot_source  BootSource
+    Should Be Equal As Strings  ${boot_source}  ${BOOT_SOURCE_DISK}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  Force Boot from default Hard-Drive
 
-Set The Boot Device As Disk Using Ipmitool
-    [Documentation]  This testcase is to set the boot device as Disk using
-    ...              ipmitool. The Boot device is read using REST API and
-    ...              ipmitool.
-    [Tags]  Set_The_Boot_Device_As_Disk_Using_Ipmitool
+
+Set The Boot Source As Disk Using Ipmitool
+    [Documentation]  Set boot source as Disk via IPMI and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Source_As_Disk_Using_Ipmitool
 
     Run IPMI command  0x0 0x8 0x05 0x80 0x08 0x00 0x00 0x00
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  Disk
+
+    ${boot_source}=
+    ...  Read Attribute  ${CONTROL_HOST_URI}/boot_source  BootSource
+    Should Be Equal As Strings  ${boot_source}  ${BOOT_SOURCE_DISK}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  Force Boot from default Hard-Drive
 
-Set The Boot Device As Safe Using REST API
-    [Documentation]  This testcase is to set the boot device as Safe using REST
-    ...              URI. The Boot device is read using REST API and ipmitool.
-    [Tags]  Set_The_Boot_Device_As_Safe_Using_REST_API
 
-    ${bootDevice}=  Set Variable  Safe
-    ${valueDict}=  Create Dictionary  data=${bootDevice}
-    Write Attribute  ${HOST_SETTINGS}  boot_flags  data=${valueDict}
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  Safe
+Set The Boot Mode As Safe Using REST API
+    [Documentation]  Set boot mode as Safe via REST and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Mode_As_Safe_Using_REST_API
+
+    Set Boot Mode  ${BOOT_MODE_SAFE}
+
+    ${boot_mode}=  Read Attribute  ${CONTROL_HOST_URI}/boot_mode  BootMode
+    Should Be Equal As Strings  ${boot_mode}  ${BOOT_MODE_SAFE}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  Safe-Mode
 
-Set The Boot Device As Safe Using Ipmitool
-    [Documentation]  This testcase is to set the boot device as Safe using
-    ...              ipmitool. The Boot device is read using REST API and
-    ...              ipmitool.
-    [Tags]  Set_The_Boot_Device_As_Safe_Using_Ipmitool
+
+Set The Boot Mode As Safe Using Ipmitool
+    [Documentation]  Set boot mode as Safe via IPMI and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Mode_As_Safe_Using_Ipmitool
 
     Run IPMI command  0x0 0x8 0x05 0x80 0x0C 0x00 0x00 0x00
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  Safe
+
+    ${boot_mode}=  Read Attribute  ${CONTROL_HOST_URI}/boot_mode  BootMode
+    Should Be Equal As Strings  ${boot_mode}  ${BOOT_MODE_SAFE}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  Safe-Mode
 
-Set The Boot Device As CDROM Using REST API
-    [Documentation]  This testcase is to set the boot device as CDROM using REST
-    ...              URI. The Boot device is read using REST API and ipmitool.
-    [Tags]  Set_The_Boot_Device_As_CDROM_Using_REST_API
 
-    ${bootDevice}=  Set Variable  CDROM
-    ${valueDict}=  Create Dictionary  data=${bootDevice}
-    Write Attribute  ${HOST_SETTINGS}  boot_flags  data=${valueDict}
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  CDROM
+Set The Boot Source As CDROM Using REST API
+    [Documentation]  Set boot source as CDROM via REST and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Source_As_CDROM_Using_REST_API
+
+    Set Boot Source  ${BOOT_SOURCE_CDROM}
+
+    ${boot_source}=
+    ...  Read Attribute  ${CONTROL_HOST_URI}/boot_source  BootSource
+    Should Be Equal As Strings  ${boot_source}  ${BOOT_SOURCE_CDROM}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  Force Boot from CD/DVD
 
-Set The Boot Device As CDROM Using Ipmitool
-    [Documentation]  This testcase is to set the boot device as CDROM using
-    ...              ipmitool. The Boot device is read using REST API and
-    ...              ipmitool.
-   [Tags]  Set_The_Boot_Device_As_CDROM_Using_Ipmitool
+
+Set The Boot Source As CDROM Using Ipmitool
+    [Documentation]  Set boot source as CDROM via IPMI and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Source_As_CDROM_Using_Ipmitool
 
     Run IPMI command  0x0 0x8 0x05 0x80 0x14 0x00 0x00 0x00
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  CDROM
+
+    ${boot_source}=
+    ...  Read Attribute  ${CONTROL_HOST_URI}/boot_source  BootSource
+    Should Be Equal As Strings  ${boot_source}  ${BOOT_SOURCE_CDROM}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  Force Boot from CD/DVD
 
-Set The Boot Device As Setup Using REST API
-    [Documentation]  This testcase is to set the boot device as Setup using REST
-    ...              URI. The Boot device is read using REST API and ipmitool.
-    [Tags]  Set_The_Boot_Device_As_Setup_Using_REST_API
 
-    ${bootDevice}=  Set Variable  Setup
-    ${valueDict}=  Create Dictionary  data=${bootDevice}
-    Write Attribute  ${HOST_SETTINGS}  boot_flags  data=${valueDict}
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  Setup
+Set The Boot Mode As Setup Using REST API
+    [Documentation]  Set boot mode as Setup via REST and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Mode_As_Setup_Using_REST_API
+
+    Set Boot Mode  ${BOOT_MODE_SETUP}
+
+    ${boot_mode}=  Read Attribute  ${CONTROL_HOST_URI}/boot_mode  BootMode
+    Should Be Equal As Strings  ${boot_mode}  ${BOOT_MODE_SETUP}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  Force Boot into BIOS Setup
 
-Set The Boot Device As Setup Using Ipmitool
-    [Documentation]  This testcase is to set the boot device as Setup using
-    ...              ipmitool. The Boot device is read using REST API and
-    ...              ipmitool.
-    [Tags]  Set_The_Boot_Device_As_Setup_Using_Ipmitool
+
+Set The Boot Mode As Setup Using Ipmitool
+    [Documentation]  Set boot mode as Setup via IPMI and verify with both
+    ...              REST and IPMI.
+    [Tags]  Set_The_Boot_Mode_As_Setup_Using_Ipmitool
 
     Run IPMI command  0x0 0x8 0x05 0x80 0x18 0x00 0x00 0x00
-    Read the Attribute  ${HOST_SETTINGS}  boot_flags
-    Response Should Be Equal  Setup
+
+    ${boot_mode}=  Read Attribute  ${CONTROL_HOST_URI}/boot_mode  BootMode
+    Should Be Equal As Strings  ${boot_mode}  ${BOOT_MODE_SETUP}
+
     ${output}=  Run IPMI Standard Command  chassis bootparam get 5
     Should Contain  ${output}  Force Boot into BIOS Setup
 
+
 *** Keywords ***
 
+Set Boot Source
+    [Documentation]  Set given boot source.
+    [Arguments]  ${boot_source}
+    # Description of argument(s):
+    # boot_source  Boot source which need to be set.
+
+    ${valueDict}=  Create Dictionary  data=${boot_source}
+    Write Attribute  ${CONTROL_HOST_URI}/boot_source  BootSource  data=${valueDict}
+
+
+Set Boot Mode
+    [Documentation]  Set given boot mode.
+    [Arguments]  ${boot_mode}
+    # Description of argument(s):
+    # boot_mode  Boot mode which need to be set.
+
+    ${valueDict}=  Create Dictionary  data=${boot_mode}
+    Write Attribute  ${CONTROL_HOST_URI}/boot_mode  BootMode  data=${valueDict}
+
+
 Response Should Be Equal
     [Arguments]  ${args}
     Should Be Equal  ${OUTPUT}  ${args}
@@ -191,6 +237,8 @@
    [Documentation]  Do the post test teardown.
 
    FFDC On Test Case Fail
+   Set Boot Source  ${BOOT_SOURCE_DEFAULT}
+   Set Boot Mode  ${BOOT_MODE_REGULAR}
    Close All Connections
 
 Test Suite Setup