Git Product home page Git Product logo

redfish-profile-simulator's Introduction

Copyright 2016-2024 Distributed Management Task Force, Inc. All rights reserved.

Redfish Profile Simulator

deprecated

Deprecated

This tool is deprecated in favor of other mockup server tools:

About

Redfish Profile Simulator is a Python34 real simulator of the "simple monolithic server" feature profile.

  • A simple, minimal Redfish Service
  • For a monolithic Server
  • Aligned with: OCP Remote Machine Management Spec feature set

Description

  • Based on flask
  • Initial resources are loaded from a catfish mockup into python dictionary structures
    • After that, data is read/patched... to the dictionaries
  • Supports BasicAuth, as well as Redfish Session Auth (for one session, one user)
  • Uses:
    • easy to add new URIs for testing a client
    • easy to tweak behavior or add bad responses to test a client
    • allows testing of authentication -- which current mockup servers dont do
    • easy to insert print statements in service to see if data coming across good..etc

Current Limitation:

  • supports a single user/passwd and token
  • the user/passwd is: root/password123456
  • The authToken for Session Auth is: 123456SESSIONauthcode
  • Supports only HTTP (not HTTPS)
  • with redfishtool, use options: redfishtool.py -r127.0.0.1:5000 -u root -p password123456 -S Never

Usage

  • python redfishProfileSimulatorMain.py [options]

  • [Options]:

      -V,  --Version,--- the program version
      -h,  --help,   --- help
      -H<hostIP>,  --Host=<hostIp>   --- host IP address. dflt=127.0.0.1
      -P<port>,--Port=<port> --- the port to use. dflt=5000
      -p<profile_path>, --profile=<profile_path>   --- the path to the Redfish profile to use. dflt="SimpleOcpServerV1"
    

Implementation

  • The simulation includes an http server, RestEngine, and dynamic Redfish datamodel.
  • You can GET, PATCH,... to the service just like a real Redfish service.
  • Both Basic and Redfish Session/Token authentication are supported
    • for a single user/passwd and token
    • the user/passwd is: root/password123456
    • The authToken for Session Auth is: 123456SESSIONauthcode
    • these can be changed by editing the redfishURSs.py file---will make dynamic later.
  • The http service and Rest engine is built on Flask, and all code is Python 3.4+
  • The data model resources are "initialized" from the SPMF "SimpleOcpServerV1" Mockup.
    • and stored as python dictionaries
    • then the dictionaries are updated with patches, posts, deletes.
  • The program can be extended to support other mockup "profiles".
  • By default, the simulation runs on localhost (127.0.0.1), on port 5000.
    • These can be changed with CLI options: -P -H | --port= --host=

Simple OCP Server V1 Mockup Description

  • A Monolithic server:

    • One ComputerSystem
    • One Chassis
    • One Manager
  • Provides basic management features aligned with OCP Remote Machine Management Spec 1.01:

    • Power-on/off/reset
    • Boot to PXE, HDD, BIOS setup (boot override)
    • 4 temp sensors per DCMI (CPU1, CPU2, Board, Inlet)
    • Simple Power Reading, and DCMI Power Limiting
    • Fan Monitoring w/ redundancy
    • Set asset tag and Indicator LED
    • Basic inventory (serial#, model, SKU, Vendor, BIOS ver…)
    • User Management
    • BMC management: get/set IP, version, enable/disable protocol
  • What it does NOT have -- that the Redfish 1.0 model supports

    • No PSUs in model (RMM spec did not include PSUs)
    • No ProcessorInfo, MemoryInfo, StorageInfo, System-EthernetInterfaceInfo
    • No Tasks
    • JsonSchema and Registries collections left out (since that is optional)
    • No EventService--Remote Machine Management spec used basic PET alerts
    • Uses only the pre-defined privileges and roles

TO DO

Some limitations to be extended in current implementation

  • Auth supports a single hard-coded username, password, and AuthToken, although the protocol is 100% compliant with respect to testing clients trying to authenticate
    • ex with basic auth, you have to use the hard coded user/password
    • ex with Session Auth, you just use the hard coded AuthToken
  • adding and deleting users not implemented--has 3 or 4 users predefined
  • accountService properties can be written, but failed logins, lockouts, etc is not implemented
  • system log not implemented yet

redfish-profile-simulator's People

Contributors

billdodd avatar cshia avatar jautor avatar mraineri avatar pwvancil avatar rp- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redfish-profile-simulator's Issues

Problems with /redfish/v1/$metadata

While investigating DMTF/Redfish-Service-Validator#234 I found a few of issues with the handling of /redfish/v1/$metadata in the simulator.

  1. Doing a GET on /redfish/v1/$metadata results in a failure with this exception callstack:
[2018-05-24 11:12:51,896] ERROR in app: Exception on /redfish/v1/$metadata/ [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1974, in make_response
    rv = self.response_class.force_type(rv, request.environ)
  File "/usr/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 921, in force_type
    response = BaseResponse(*_run_wsgi_app(response, environ))
  File "/usr/local/lib/python3.6/site-packages/werkzeug/test.py", line 923, in run_wsgi_app
    app_rv = app(environ, start_response)
TypeError: 'RfOdataMetadata' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1816, in full_dispatch_request
    return self.finalize_request(rv)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1831, in finalize_request
    response = self.make_response(rv)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1982, in make_response
    reraise(TypeError, new_error, sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 34, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1974, in make_response
    rv = self.response_class.force_type(rv, request.environ)
  File "/usr/local/lib/python3.6/site-packages/werkzeug/wrappers.py", line 921, in force_type
    response = BaseResponse(*_run_wsgi_app(response, environ))
  File "/usr/local/lib/python3.6/site-packages/werkzeug/test.py", line 923, in run_wsgi_app
    app_rv = app(environ, start_response)
TypeError: 'RfOdataMetadata' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a RfOdataMetadata.
127.0.0.1 - - [24/May/2018 11:12:51] "GET /redfish/v1/%24metadata/ HTTP/1.1" 500 -
  1. After correcting that problem, the $metadata is returned, but with a Content-Type header of text/html instead of application/xml.

  2. Also, the simulator is requiring authentication for the $metadata URI access. It should not.

RedfishExtensions instead of Redfish in index.html ?

Hi,

I ran the Redfish Validator on the Redfish Simulator.

I had 2 error messages:

In the resource $metadata, the RedfishExtensions.v1_0_0 namespace must have an alias of 'Redfish'. The alias is 'RedfishExtensions'. This may cause properties of the form [PropertyName]@Redfish.TermName to be unrecognized.

And:

No such reference Redfish in /redfish/v1/$metadata

I changed the Alias from "RedfishExtensions" to "Redfish" as indicated
and now I have no error message

in file Redfish-Profile-Simulator/MockupData/SimpleOcpServerV1/redfish/v1/$metadata/index.xml

=> isn't it a bug in $metadata/index.html page in the Simulator ?

Regards,
Francine

How to perform PATCH

Hello

How to perform patch operation on the service?
Can you please provide the procedure?

Thanks.

redfishProfileSimulator error?

Tried changing the BootOverride:

redfishtool -r 127.0.0.1:5000 -u root -p password123456 -S Never Systems --all setBootOverride Disabled Once
redfishtool: Transport: Response Error: status_code: 500 -- Internal Server Error

But the RedfishProfileSimulator gave an error saying it can not find root.systems

127.0.0.1 - - [19/Jul/2022 18:03:43] "GET /redfish/v1/Systems/2M220100SL/ HTTP/1.1" 200 -
in rfAuthRequired
headers: Host: 127.0.0.1:5000
Accept-Encoding: identity
User-Agent: python-requests/2.27.1
Accept: application/json
Connection: keep-alive
Odata-Version: 4.0
Content-Type: application/json
Content-Length: 51
Authorization: Basic cm9vdDpwYXNzd29yZDEyMzQ1Ng==

rdata:{'Boot': {'BootSourceOverrideEnabled': 'Disabled'}}
[2022-07-19 18:03:43,830] ERROR in app: Exception on /redfish/v1/Systems/2M220100SL/ [PATCH]
Traceback (most recent call last):
File "/gsa/yktgsa-h3/13/jimlund/venv/lib64/python3.6/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/gsa/yktgsa-h3/13/jimlund/venv/lib64/python3.6/site-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/gsa/yktgsa-h3/13/jimlund/venv/lib64/python3.6/site-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/gsa/yktgsa-h3/13/jimlund/venv/lib64/python3.6/site-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/gsa/yktgsa-h3/13/jimlund/redfish/Redfish-Profile-Simulator/v1sim/flask_redfish_auth.py", line 139, in decorated
return (f(*args, **kwargs))
File "/gsa/yktgsa-h3/13/jimlund/redfish/Redfish-Profile-Simulator/v1sim/redfishURIs.py", line 86, in rf_computer_systempatch
obj = patch_path(root.systems, sys_path)
AttributeError: 'RfServiceRoot' object has no attribute 'systems'
127.0.0.1 - - [19/Jul/2022 18:03:43] "PATCH /redfish/v1/Systems/2M220100SL/ HTTP/1.1" 500 -

Failed to get the some resources under ComputerSystem from the Redfish-Profile-Simulator

Below is the code in the Redfish-Profile-Simulator\v1sim\systems.py, which is used to walk through the mockup folders under Systems in order to get the json files.

We can see some strings which doesn’t match the properties under ComputerSystem in ComputerSystem.json: “bios” should be “Bios”, NetworkAdapters should be “NetworkInterfaces “,”PCIDevices” should be “PCIeDevices”.

class RfSystemObj(RfResource):
def create_sub_objects(self, base_path, rel_path):
resource_path = os.path.join(base_path, rel_path)
contents = os.listdir(resource_path)
for item in contents:
if item == "bios":
self.components[item] = RfBios(base_path, os.path.join(rel_path, item), parent=self)
elif item == "EthernetInterfaces":
self.components[item] = RfEthernetCollection(base_path, os.path.join(rel_path, item), parent=self)
elif item == "LogServices":
self.components[item] = RfLogServiceCollection(base_path, os.path.join(rel_path, item), parent=self)
elif item == "Memory":
self.components[item] = RfMemoryCollection(base_path, os.path.join(rel_path, item), parent=self)
elif item == "Processors":
self.components[item] = RfProcessorCollection(base_path, os.path.join(rel_path, item), parent=self)
elif item == "SimpleStorage":
self.components[item] = RfSimpleStorageCollection(base_path, os.path.join(rel_path, item), parent=self)
elif item == "SmartStorage":
self.components[item] = RfSmartStorage(base_path, os.path.join(rel_path, item), parent=self)
elif item == "SecureBoot":
self.components[item] = RfSecureBoot(base_path, os.path.join(rel_path, item), parent=self)
elif item == "NetworkAdapters":
self.components[item] = RfNetworkAdapterCollection(base_path, os.path.join(rel_path, item), parent=self)
elif item == "PCIDevices":
self.components[item] = RfPCIDeviceCollection(base_path, os.path.join(rel_path, item), parent=self)
elif item == "PCISlots":
self.components[item] = RfPCISlotCollection(base_path, os.path.join(rel_path, item), parent=self)
elif item == "FirmwareInventory":
self.components[item] = RfSystemFirmwareInventory(base_path, os.path.join(rel_path, item), parent=self)
elif item == "USBDevices":
self.components[item] = RfUSBDeviceCollection(base_path, os.path.join(rel_path, item), parent=self)
elif item == "USBPorts":
self.components[item] = RfUSBPortCollection(base_path, os.path.join(rel_path, item), parent=self)

redfish/v1/Systems does not work

Hi,

I ran the Redfish Profile Simulator (RPS).
I ran the Redfish Interop Validator (RIV) on it.

Result:

/redfish/v1/Systems does not exist in $metadata so RPS returns :

{ "@odata.id": "/redfish/v1/Systems" }

instead of its /MockupData/.../Systems/index.json file.

Expected result

`
{
"@odata.type": "#ComputerSystemCollection.ComputerSystemCollection",
"Name": "Computer System Collection",
"[email protected]": 1,
"Members": [
{
"@odata.id": "/redfish/v1/Systems/2M220100SL"
}
],
"@odata.context": "/redfish/v1/$metadata#ComputerSystemCollection.ComputerSystemCollection",
"@odata.id": "/redfish/v1/Systems",
"@Redfish.Copyright": "Copyright 2014-2016 Distributed Management Task Force, Inc. (DMTF). For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright."
}

`

possible issue

line 45 of resource.py

image

component Systems is not in $metadata components

What did I miss?

Regards,
Francine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.