Redfish-Interface-Emulator icon indicating copy to clipboard operation
Redfish-Interface-Emulator copied to clipboard

How to change the ComputerSystem.Status property when performing a ResetAction

Open jcleung5549 opened this issue 3 years ago • 1 comments

The emulation code for the ./Systems/{id}/ResetAction resource in located in the file ./api_emulator/redfish/ComputerSystem/ResetAction.py. A behavior of a reset action is to change the ComputerSystem.Status.State property. However, this requires the code import a module within the ComputerSystem.py code in the parent directory. Python 3.3 removed relative imports, so imports from a parent directory requires hacking PYTHONPATH or adding the parent-path to sys.path.

There is a request for a cleaner way.

jcleung5549 avatar Mar 22 '21 19:03 jcleung5549

The construct of the folders is to have a resource.py and resource_api.py code in ./redfish and the template files (resource_template.py) in the directory ./redfish/templates. This allowed the resource behavior code to import from each other modules from each other within their scope (and avoid running afoul with recursive imports). The creation of the ./redfish/ComputerSystem directory violates the above construct.

The fix is to move to resource.py, resource_api,py resource_template.py files to their proper directory and remove the ./ComputerSystem directory.

jcleung5549 avatar Mar 22 '21 19:03 jcleung5549