Revert "black: re-format"
This reverts commit 5731818de0ce446ceaafc7e75ae39da1b69942ae.
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
Change-Id: Ie61cdc8c7f2825b0d9d66be87a6a3a058de2b372
diff --git a/lib/state_map.py b/lib/state_map.py
index cdd1014..f8353de 100644
--- a/lib/state_map.py
+++ b/lib/state_map.py
@@ -7,94 +7,101 @@
"""
+import gen_robot_keyword as keyword
+import variables as var
+
import os
import re
import sys
-import gen_robot_keyword as keyword
-import variables as var
from robot.libraries.BuiltIn import BuiltIn
robot_pgm_dir_path = os.path.dirname(__file__) + os.sep
-repo_data_dir_path = re.sub("/lib", "/data", robot_pgm_dir_path)
+repo_data_dir_path = re.sub('/lib', '/data', robot_pgm_dir_path)
sys.path.append(repo_data_dir_path)
BuiltIn().import_resource("state_manager.robot")
BuiltIn().import_resource("rest_client.robot")
-platform_arch_type = os.environ.get(
- "PLATFORM_ARCH_TYPE", ""
-) or BuiltIn().get_variable_value("${PLATFORM_ARCH_TYPE}", default="power")
+platform_arch_type = os.environ.get('PLATFORM_ARCH_TYPE', '') or \
+ BuiltIn().get_variable_value("${PLATFORM_ARCH_TYPE}", default="power")
# We will build eventually the mapping for warm, cold reset as well.
VALID_STATES = {
- "reboot": {
+ 'reboot':
+ {
# (Power Policy, BMC state, Chassis State, Host State)
- ("LEAVE_OFF", "Ready", "Off", "Off"),
- ("ALWAYS_POWER_ON", "Ready", "On", "Running"),
- ("ALWAYS_POWER_ON", "Ready", "On", "Off"),
- ("RESTORE_LAST_STATE", "Ready", "On", "Running"),
- ("RESTORE_LAST_STATE", "Ready", "On", "Off"),
- ("ALWAYS_POWER_OFF", "Ready", "On", "Running"),
- ("ALWAYS_POWER_OFF", "Ready", "Off", "Off"),
+ ('LEAVE_OFF', 'Ready', 'Off', 'Off'),
+ ('ALWAYS_POWER_ON', 'Ready', 'On', 'Running'),
+ ('ALWAYS_POWER_ON', 'Ready', 'On', 'Off'),
+ ('RESTORE_LAST_STATE', 'Ready', 'On', 'Running'),
+ ('RESTORE_LAST_STATE', 'Ready', 'On', 'Off'),
+ ('ALWAYS_POWER_OFF', 'Ready', 'On', 'Running'),
+ ('ALWAYS_POWER_OFF', 'Ready', 'Off', 'Off'),
},
}
VALID_BOOT_STATES = {
- "Off": { # Valid states when Host is Off.
+ 'Off': # Valid states when Host is Off.
+ {
# (BMC , Chassis , Host , BootProgress, OperatingSystemState)
(
"xyz.openbmc_project.State.BMC.BMCState.Ready",
"xyz.openbmc_project.State.Chassis.PowerState.Off",
"xyz.openbmc_project.State.Host.HostState.Off",
"xyz.openbmc_project.State.Boot.Progress.ProgressStages.Unspecified",
- "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive",
+ "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive"
),
},
- "Reboot": { # Valid states when BMC reset to standby.
+ 'Reboot': # Valid states when BMC reset to standby.
+ {
# (BMC , Chassis , Host , BootProgress, OperatingSystemState)
(
"xyz.openbmc_project.State.BMC.BMCState.Ready",
"xyz.openbmc_project.State.Chassis.PowerState.Off",
"xyz.openbmc_project.State.Host.HostState.Off",
"xyz.openbmc_project.State.Boot.Progress.ProgressStages.Unspecified",
- "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive",
+ "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive"
),
},
- "Running": { # Valid states when Host is powering on.
+ 'Running': # Valid states when Host is powering on.
+ {
# (BMC , Chassis , Host , BootProgress, OperatingSystemState)
(
"xyz.openbmc_project.State.BMC.BMCState.Ready",
"xyz.openbmc_project.State.Chassis.PowerState.On",
"xyz.openbmc_project.State.Host.HostState.Running",
"xyz.openbmc_project.State.Boot.Progress.ProgressStages.MotherboardInit",
- "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive",
+ "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive"
),
},
- "Booted": { # Valid state when Host is booted.
+ 'Booted': # Valid state when Host is booted.
+ {
# (BMC , Chassis , Host , BootProgress, OperatingSystemState)
(
"xyz.openbmc_project.State.BMC.BMCState.Ready",
"xyz.openbmc_project.State.Chassis.PowerState.On",
"xyz.openbmc_project.State.Host.HostState.Running",
"xyz.openbmc_project.State.Boot.Progress.ProgressStages.OSStart",
- "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.BootComplete",
+ "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.BootComplete"
),
},
- "ResetReload": { # Valid state BMC reset reload when host is booted.
+ 'ResetReload': # Valid state BMC reset reload when host is booted.
+ {
# (BMC , Chassis , Host , BootProgress, OperatingSystemState)
(
"xyz.openbmc_project.State.BMC.BMCState.Ready",
"xyz.openbmc_project.State.Chassis.PowerState.On",
"xyz.openbmc_project.State.Host.HostState.Running",
"xyz.openbmc_project.State.Boot.Progress.ProgressStages.OSStart",
- "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.BootComplete",
+ "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.BootComplete"
),
},
}
REDFISH_VALID_BOOT_STATES = {
- "Off": { # Valid states when Host is Off.
+ 'Off': # Valid states when Host is Off.
+ {
# (BMC , Chassis , Host , BootProgress)
(
"Enabled",
@@ -103,7 +110,8 @@
"None",
),
},
- "Reboot": { # Valid states when BMC reset to standby.
+ 'Reboot': # Valid states when BMC reset to standby.
+ {
# (BMC , Chassis , Host , BootProgress)
(
"Enabled",
@@ -112,7 +120,8 @@
"None",
),
},
- "Running": { # Valid states when Host is powering on.
+ 'Running': # Valid states when Host is powering on.
+ {
# (BMC , Chassis , Host , BootProgress)
(
"Enabled",
@@ -121,7 +130,8 @@
"OSRunning",
),
},
- "Booted": { # Valid state when Host is booted.
+ 'Booted': # Valid state when Host is booted.
+ {
# (BMC , Chassis , Host , BootProgress)
(
"Enabled",
@@ -130,7 +140,8 @@
"OSRunning",
),
},
- "ResetReload": { # Valid state BMC reset reload when host is booted.
+ 'ResetReload': # Valid state BMC reset reload when host is booted.
+ {
# (BMC , Chassis , Host , BootProgress)
(
"Enabled",
@@ -151,45 +162,41 @@
for x in state_tuple
if not (
x.startswith("xyz.openbmc_project.State.Boot.Progress")
- or x.startswith(
- "xyz.openbmc_project.State.OperatingSystem"
- )
+ or x.startswith("xyz.openbmc_project.State.OperatingSystem")
)
)
VALID_BOOT_STATES_X86[state_name].add(state_tuple_new)
VALID_BOOT_STATES = VALID_BOOT_STATES_X86
-class state_map:
+class state_map():
+
def get_boot_state(self):
r"""
Return the system state as a tuple of bmc, chassis, host state,
BootProgress and OperatingSystemState.
"""
- status, state = keyword.run_key(
- "Read Properties " + var.SYSTEM_STATE_URI + "enumerate"
- )
- bmc_state = state[var.SYSTEM_STATE_URI + "bmc0"]["CurrentBMCState"]
- chassis_state = state[var.SYSTEM_STATE_URI + "chassis0"][
- "CurrentPowerState"
- ]
- host_state = state[var.SYSTEM_STATE_URI + "host0"]["CurrentHostState"]
+ status, state = keyword.run_key("Read Properties "
+ + var.SYSTEM_STATE_URI + "enumerate")
+ bmc_state = state[var.SYSTEM_STATE_URI + 'bmc0']['CurrentBMCState']
+ chassis_state = \
+ state[var.SYSTEM_STATE_URI + 'chassis0']['CurrentPowerState']
+ host_state = state[var.SYSTEM_STATE_URI + 'host0']['CurrentHostState']
if platform_arch_type == "x86":
- return (str(bmc_state), str(chassis_state), str(host_state))
+ return (str(bmc_state),
+ str(chassis_state),
+ str(host_state))
else:
- boot_state = state[var.SYSTEM_STATE_URI + "host0"]["BootProgress"]
- os_state = state[var.SYSTEM_STATE_URI + "host0"][
- "OperatingSystemState"
- ]
+ boot_state = state[var.SYSTEM_STATE_URI + 'host0']['BootProgress']
+ os_state = \
+ state[var.SYSTEM_STATE_URI + 'host0']['OperatingSystemState']
- return (
- str(bmc_state),
- str(chassis_state),
- str(host_state),
- str(boot_state),
- str(os_state),
- )
+ return (str(bmc_state),
+ str(chassis_state),
+ str(host_state),
+ str(boot_state),
+ str(os_state))
def valid_boot_state(self, boot_type, state_set):
r"""
@@ -217,9 +224,7 @@
state_dict State dictionary.
"""
- if set(state_dict.values()) in set(
- REDFISH_VALID_BOOT_STATES[boot_type]
- ):
+ if set(state_dict.values()) in set(REDFISH_VALID_BOOT_STATES[boot_type]):
return True
else:
return False