Changes to read the redfish boot progress state
Signed-off-by: Michael Shepos <shepos@us.ibm.com>
Change-Id: I17557c1dbff5e9b26bb0d305db02758cbfff6272
diff --git a/lib/state.py b/lib/state.py
index 61223f0..1071d06 100755
--- a/lib/state.py
+++ b/lib/state.py
@@ -81,44 +81,6 @@
redfish_support_trans_state = int(os.environ.get('REDFISH_SUPPORT_TRANS_STATE', 0)) or \
int(BuiltIn().get_variable_value("${REDFISH_SUPPORT_TRANS_STATE}", default=0))
-# When a user calls get_state w/o specifying req_states, default_req_states
-# is used as its value.
-default_req_states = ['rest',
- 'chassis',
- 'bmc',
- 'boot_progress',
- 'operating_system',
- 'host',
- 'os_ping',
- 'os_login',
- 'os_run_cmd']
-
-if redfish_support_trans_state:
- default_req_states.remove('operating_system')
-
-# valid_req_states is a list of sub states supported by the get_state function.
-# valid_req_states, default_req_states and master_os_up_match are used by the
-# get_state function.
-
-valid_req_states = ['ping',
- 'packet_loss',
- 'uptime',
- 'epoch_seconds',
- 'elapsed_boot_time',
- 'rest',
- 'chassis',
- 'requested_chassis',
- 'bmc',
- 'requested_bmc',
- 'boot_progress',
- 'operating_system',
- 'host',
- 'requested_host',
- 'attempts_left',
- 'os_ping',
- 'os_login',
- 'os_run_cmd']
-
# valid_os_req_states and default_os_req_states are used by the os_get_state
# function.
# valid_os_req_states is a list of state information supported by the
@@ -126,6 +88,7 @@
valid_os_req_states = ['os_ping',
'os_login',
'os_run_cmd']
+
# When a user calls get_os_state w/o specifying req_states,
# default_os_req_states is used as its value.
default_os_req_states = ['os_ping',
@@ -139,6 +102,41 @@
# Useful state constant definition(s).
if not redfish_support_trans_state:
+ # When a user calls get_state w/o specifying req_states, default_req_states
+ # is used as its value.
+ default_req_states = ['rest',
+ 'chassis',
+ 'bmc',
+ 'boot_progress',
+ 'operating_system',
+ 'host',
+ 'os_ping',
+ 'os_login',
+ 'os_run_cmd']
+
+ # valid_req_states is a list of sub states supported by the get_state function.
+ # valid_req_states, default_req_states and master_os_up_match are used by the
+ # get_state function.
+
+ valid_req_states = ['ping',
+ 'packet_loss',
+ 'uptime',
+ 'epoch_seconds',
+ 'elapsed_boot_time',
+ 'rest',
+ 'chassis',
+ 'requested_chassis',
+ 'bmc',
+ 'requested_bmc',
+ 'boot_progress',
+ 'operating_system',
+ 'host',
+ 'requested_host',
+ 'attempts_left',
+ 'os_ping',
+ 'os_login',
+ 'os_run_cmd']
+
# default_state is an initial value which may be of use to callers.
default_state = DotDict([('rest', '1'),
('chassis', 'On'),
@@ -184,41 +182,74 @@
('operating_system', '^$'),
('host', '^$')])
else:
+ # When a user calls get_state w/o specifying req_states, default_req_states
+ # is used as its value.
+ default_req_states = ['redfish',
+ 'chassis',
+ 'bmc',
+ 'boot_progress',
+ 'host',
+ 'os_ping',
+ 'os_login',
+ 'os_run_cmd']
+
+ # valid_req_states is a list of sub states supported by the get_state function.
+ # valid_req_states, default_req_states and master_os_up_match are used by the
+ # get_state function.
+
+ valid_req_states = ['ping',
+ 'packet_loss',
+ 'uptime',
+ 'epoch_seconds',
+ 'elapsed_boot_time',
+ 'redfish',
+ 'chassis',
+ 'requested_chassis',
+ 'bmc',
+ 'requested_bmc',
+ 'boot_progress',
+ 'host',
+ 'requested_host',
+ 'attempts_left',
+ 'os_ping',
+ 'os_login',
+ 'os_run_cmd']
+
# default_state is an initial value which may be of use to callers.
- default_state = DotDict([('rest', '1'),
+ default_state = DotDict([('redfish', '1'),
('chassis', 'On'),
- ('bmc', 'Ready'),
- ('boot_progress', 'SystemInitComplete|OSRunning'),
- ('host', 'Running'),
+ ('bmc', 'Enabled'),
+ ('boot_progress', 'SystemHardwareInitializationComplete|OSRunning'),
+ ('host', 'Enabled'),
('os_ping', '1'),
('os_login', '1'),
('os_run_cmd', '1')])
# A match state for checking that the system is at "standby".
- standby_match_state = DotDict([('rest', '^1$'),
+ standby_match_state = DotDict([('redfish', '^1$'),
('chassis', '^Off$'),
- ('bmc', '^Ready$'),
- ('boot_progress', '^Off|Unspecified$'),
- ('host', '^Off$')])
+ ('bmc', '^Enabled$'),
+ ('boot_progress', '^None$'),
+ ('host', '^Disabled$')])
# A match state for checking that the system is at "os running".
os_running_match_state = DotDict([('chassis', '^On$'),
- ('bmc', '^Ready$'),
+ ('bmc', '^Enabled$'),
('boot_progress',
- 'SystemInitComplete|OSRunning'),
- ('host', '^Running$'),
+ 'SystemHardwareInitializationComplete|OSRunning'),
+ ('host', '^Enabled$'),
('os_ping', '^1$'),
('os_login', '^1$'),
('os_run_cmd', '^1$')])
# A master dictionary to determine whether the os may be up.
master_os_up_match = DotDict([('chassis', '^On$'),
- ('bmc', '^Ready$'),
+ ('bmc', '^Enabled$'),
('boot_progress',
- 'SystemInitComplete|OSRunning'),
- ('host', '^Running|Quiesced$')])
+ 'SystemHardwareInitializationComplete|OSRunning'),
+ ('host', '^Enabled$')])
- invalid_state_match = DotDict([('rest', '^$'),
+ invalid_state_match = DotDict([('redfish', '^$'),
('chassis', '^$'),
('bmc', '^$'),
('boot_progress', '^$'),
@@ -537,6 +568,7 @@
epoch_seconds = ''
elapsed_boot_time = ''
rest = ''
+ redfish = ''
chassis = ''
requested_chassis = ''
bmc = ''
@@ -608,45 +640,71 @@
global start_boot_seconds
elapsed_boot_time = int(epoch_seconds) - start_boot_seconds
- master_req_rest = ['rest', 'host', 'requested_host', 'operating_system',
- 'attempts_left', 'boot_progress', 'chassis',
- 'requested_chassis' 'bmc' 'requested_bmc']
+ if not redfish_support_trans_state:
+ master_req_rest = ['rest', 'host', 'requested_host', 'operating_system',
+ 'attempts_left', 'boot_progress', 'chassis',
+ 'requested_chassis' 'bmc' 'requested_bmc']
- req_rest = [sub_state for sub_state in req_states if sub_state in
- master_req_rest]
- need_rest = (len(req_rest) > 0)
- state = DotDict()
- if need_rest:
- cmd_buf = ["Read Properties", SYSTEM_STATE_URI + "enumerate",
- "quiet=${" + str(quiet) + "}", "timeout=30"]
- gp.dprint_issuing(cmd_buf)
- status, ret_values = \
- BuiltIn().run_keyword_and_ignore_error(*cmd_buf)
- if status == "PASS":
- state['rest'] = '1'
- else:
- state['rest'] = '0'
+ req_rest = [sub_state for sub_state in req_states if sub_state in
+ master_req_rest]
+ need_rest = (len(req_rest) > 0)
+ state = DotDict()
+ if need_rest:
+ cmd_buf = ["Read Properties", SYSTEM_STATE_URI + "enumerate",
+ "quiet=${" + str(quiet) + "}", "timeout=30"]
+ gp.dprint_issuing(cmd_buf)
+ status, ret_values = \
+ BuiltIn().run_keyword_and_ignore_error(*cmd_buf)
+ if status == "PASS":
+ state['rest'] = '1'
+ else:
+ state['rest'] = '0'
- if int(state['rest']):
- for url_path in ret_values:
- for attr_name in ret_values[url_path]:
- # Create a state key value based on the attr_name.
- try:
- ret_values[url_path][attr_name] = \
- re.sub(r'.*\.', "",
- ret_values[url_path][attr_name])
- except TypeError:
- pass
- # Do some key name manipulations.
- new_attr_name = re.sub(r'^Current|(State|Transition)$',
- "", attr_name)
- new_attr_name = re.sub(r'BMC', r'Bmc', new_attr_name)
- new_attr_name = re.sub(r'([A-Z][a-z])', r'_\1',
- new_attr_name)
- new_attr_name = new_attr_name.lower().lstrip("_")
- new_attr_name = re.sub(r'power', r'chassis', new_attr_name)
- if new_attr_name in req_states:
- state[new_attr_name] = ret_values[url_path][attr_name]
+ if int(state['rest']):
+ for url_path in ret_values:
+ for attr_name in ret_values[url_path]:
+ # Create a state key value based on the attr_name.
+ try:
+ ret_values[url_path][attr_name] = \
+ re.sub(r'.*\.', "",
+ ret_values[url_path][attr_name])
+ except TypeError:
+ pass
+ # Do some key name manipulations.
+ new_attr_name = re.sub(r'^Current|(State|Transition)$',
+ "", attr_name)
+ new_attr_name = re.sub(r'BMC', r'Bmc', new_attr_name)
+ new_attr_name = re.sub(r'([A-Z][a-z])', r'_\1',
+ new_attr_name)
+ new_attr_name = new_attr_name.lower().lstrip("_")
+ new_attr_name = re.sub(r'power', r'chassis', new_attr_name)
+ if new_attr_name in req_states:
+ state[new_attr_name] = ret_values[url_path][attr_name]
+ else:
+ master_req_rf = ['redfish', 'host', 'requested_host',
+ 'attempts_left', 'boot_progress', 'chassis',
+ 'requested_chassis' 'bmc' 'requested_bmc']
+
+ req_rf = [sub_state for sub_state in req_states if sub_state in
+ master_req_rf]
+ need_rf = (len(req_rf) > 0)
+ state = DotDict()
+ if need_rf:
+ cmd_buf = ["Redfish Get States"]
+ gp.dprint_issuing(cmd_buf)
+ status, ret_values = \
+ BuiltIn().run_keyword_and_ignore_error(*cmd_buf)
+ gp.dprint_vars(status, ret_values)
+ if status == "PASS":
+ state['redfish'] = '1'
+ else:
+ state['redfish'] = '0'
+
+ if int(state['redfish']):
+ state['chassis'] = ret_values['chassis']
+ state['boot_progress'] = ret_values['boot_progress']
+ state['host'] = ret_values['host']
+ state['bmc'] = ret_values['bmc']
for sub_state in req_states:
if sub_state in state:
@@ -954,6 +1012,9 @@
(expressions_key(), [expr])])
wait_state(match_state, wait_time="12 mins", interval="5 seconds")
- gp.qprint_timen("Verifying that REST API interface is working.")
- match_state = DotDict([('rest', '^1$')])
+ gp.qprint_timen("Verifying that REST/Redfish API interface is working.")
+ if not redfish_support_trans_state:
+ match_state = DotDict([('rest', '^1$')])
+ else:
+ match_state = DotDict([('redfish', '^1$')])
state = wait_state(match_state, wait_time="5 mins", interval="2 seconds")