Giter Site home page Giter Site logo

Comments (32)

billdodd avatar billdodd commented on September 7, 2024

The tool has several third-party python package prerequisites. Installation of python packages is done via pip.

The error you are getting is because one of those prerequisites, Flask, is not installed.

There is a requirements file that comes with this tool specifying all the required packages. The file is packageSets/Env-Local-Python3.5.2_requirements.txt. To install them, go to the directory where you installed the Emulator and run:

pip install -r packageSets/Env-Local-Python3.5.2_requirements.txt 

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

Hi Bill, thanks I have it working now... Am I right to think this Emulator can be loaded with static values for me to poll? I have tried a few things but am unable to see the actual data i'm looking for. Finally, my company (and this is why I am looking at this by the way) has recently released a monitoring solution supporting Redfish devices - I would like to poll this emulator with our product and return some data. Thank you!

from redfish-interface-emulator.

jcleung5549 avatar jcleung5549 commented on September 7, 2024

The emulator can be used in static mode (just HTTP GETS) by copying in a static mockup into the ./static folder. From the README:

Copying a mockup
The location for the static mockup is in the directory ./api_emulator/redfish/static. The emulator comes with a copy of an earlier Redfish mockup. This can be replaced with any new mockup file.
If the new mockup has additional resources off the ServiceRoot, then small modifications need to be made in resource_emulator.py to adds these new resources.

Note: the validity of the JSON in the mockup is not tested and will result in error message when you GET the resource. There are plenty of existing tools to check JSON file, beforehand.

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

Hi, thanks for your quick reply :)
I can see a bunch of directories already in the ./api_emulator/redfish/static location:
screenshot from 2019-02-27 15-19-45

  • is this what it should look like? or should I put these folders into the ./static directory? to me it looks like the same location and if this is true, why do I not see any values yet?
    Really sorry but I am really new to Linux and the terminologies you are using :)

from redfish-interface-emulator.

jcleung5549 avatar jcleung5549 commented on September 7, 2024

Yes, this is exactly the folders and files you should see. If you traverse the folders, you will see the index.json files which are the mockups for the resources that are returned. The ./static folder holds the entire mockup hierarchy. The Redfish Forum has posted several of their mockups in DSP2043 (https://www.dmtf.org/sites/default/files/DSP2043_1.2.0.zip).

The only index.json file that doesn't exist is the one for ServiceRoot. This because the Emulator generates that GET response on the fly, since Flask intercepts the HTTP requests starting at root. This is programmatic needed when one uses the dynamic resources, that responds to the other HTTP requests (e.g. PATCH, POST, etc.)

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

Hi again and thanks for your help! I have removed all the directories from the ./static folder and replaced them with one of the mockups (public-rackmount1), Here is a screen shot of the new directories in the ./static directory:
/home/john/Pictures/Screenshot from 2019-02-27 16-27-26.png
should I be doing something else to make the new mockup work as I still don't see any values?
For example, when I navigate (in the web client) to http://localhost:5000/browse.html and drill into Chassis I cant see the values in the new mockup file. I can see values in the 'Chassis/1U/Power/index'json' file like:
Name": "Server Power Control",
"PowerConsumedWatts": 344,
"PowerRequestedWatts": 800,
"PowerAvailableWatts": 0,
"PowerCapacityWatts": 800,
"PowerAllocatedWatts": 800,
"PowerMetrics": {
"IntervalInMin": 30,
"MinConsumedWatts": 271,
"MaxConsumedWatts": 489,
"AverageConsumedWatts": 319
Thank you!

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024
  • sorry, I'm still getting the hang of this environment, here is the screen shot:
    screenshot from 2019-02-27 16-27-26

from redfish-interface-emulator.

jcleung5549 avatar jcleung5549 commented on September 7, 2024

You should issue an HTTP GET to http://localhost:5000/redfish/v1 (per the Redfish Specification).

from redfish-interface-emulator.

ddeel avatar ddeel commented on September 7, 2024

The emulator supports static resources and dynamic resources. Static resources are read-only, meaning you can only use GET operations with them. Dynamic resources respond to POST, PATCH, and DELETE operations, in addition to GET operations.

The only static resources currently being loaded from ./api_emulator/redfish/static are: AccountService, Registries, SessionService, and TaskService.

Chassis and several other resources in the emulator are defined as dynamic resources in ./api_emulator/resource_manager.py. These dynamic resources do not get loaded from ./api_emulator/redfish/static.

resource_manager.py can be edited to turn some (or all) of the dynamic resources into static resources that will be loaded from ./api_emulator/redfish/static. See lines 126-131 in resource_manager.py to see how static resources are loaded.

Note that if you turn some of the dynamic resources into static resources (in your copy of the emulator), then you must also comment out the lines of code that make the corresponding resources dynamic. See lines 137-222 in resource_manager.py to see how dynamic resources are defined by attaching APIs.

It is recommended that you review the emulator README.md file and also the comments within the resource_manager.py file before making any edits to the code.

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

Hi, thanks for your help guys... I'm going in circles so I will go back to the start and try again - just one more question while I'm doing that:
When I start the emulator, should I expect this comment as it runs "# python emulator.py

  • Redfish endpoint at localhost:5000
    (' * Running in', None, 'mode')"

from redfish-interface-emulator.

jcleung5549 avatar jcleung5549 commented on September 7, 2024

Nope. What are the contents of the emulator-config.json file?

from redfish-interface-emulator.

jcleung5549 avatar jcleung5549 commented on September 7, 2024

Specifically, it should include the line - "MODE": "Local"

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

Here is the contents of the 'emulator-config.json' file
{
"MODE": "Local",
"HTTPS": "Disable",
"SPECS" : "Redfish",
"TRAYS": [
"./Resources/Systems/1/index.json"
],
"POPULATE": "Emulator"
}

from redfish-interface-emulator.

ddeel avatar ddeel commented on September 7, 2024

In the emulator-config.json file, "SPECS" should be "SPEC". Other than that, the POPULATE property "Emulator" needs to be a JSON file, and I think the filename needs to include the .json file extension.

I'm assuming you want to use INFRAGEN to populate the emulator, since MOCKUPFOLDERS is not present in the emulator-config.json file.

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

Hi again, thank you for the guidance... I have been able to get it running and have been able to Postman - see the results snip-it below:
"Name": "Power",
"PowerSupplies": [
{
"Status": {
"State": "Enabled",
"Health": "Warning"
},
"LastPowerOutputWatts": 192,
"Name": "Power Supply Bay 1",
"SparePartNumber": "0000001A3a",
"SerialNumber": "1z0000001",
"MemberId": "0",
"@odata.id": "/redfish/v1/Chassis/Chassis-1/Power#/PowerSupplies/0",
"LineInputVoltageType": "DCNeg48V",
"PowerCapacityWatts": 400,
"PowerSupplyType": "DC",
"Model": "499253-B21",
"RelatedItem": [
{
"@odata.id": "/redfish/v1/Chassis/Chassis-1"
}
],
"LineInputVoltage": -48,
"PartNumber": "1z0000001A3a",
"FirmwareVersion": "1.00"
I am now very happy, I will test this with my monitoring tool tomorrow :)

from redfish-interface-emulator.

jcleung5549 avatar jcleung5549 commented on September 7, 2024

Excellent. I commend your diligence.

Did you root cause the original problem? I'd like to add error checking, so your issue could have been debugged more straightforwardly.

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

My success came when I replaced the 'emulator-config.json' with the supplied one and didn't modify it - but thank you.
I tested the discovery of this Emulator with my monitoring software which I now see needs to authenticate with user/pass combination but te Emulator is running on http not https. I tried to start the Emulator using the command 'python emulator_ssl.py' but it failed :(
Here is the error string:
"(' * Running in', u'Redfish', 'mode')
Traceback (most recent call last):
File "emulator_ssl.py", line 386, in
main()
File "emulator_ssl.py", line 383, in main
app.run(**kwargs)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 841, in run
run_simple(host, port, self, **options)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 739, in run_simple
inner()
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 699, in inner
fd=fd)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 593, in make_server
passthrough_errors, ssl_context, fd=fd)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 528, in init
self.socket = ssl_context.wrap_socket(sock, server_side=True)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 450, in wrap_socket
ssl_version=self._protocol, **kwargs)
File "/usr/lib64/python2.7/ssl.py", line 934, in wrap_socket
ciphers=ciphers)
File "/usr/lib64/python2.7/ssl.py", line 547, in init
self._context.load_cert_chain(certfile, keyfile)
IOError: [Errno 2] No such file or directory"

Grrr! Any ideas please?

Thank you!

from redfish-interface-emulator.

jcleung5549 avatar jcleung5549 commented on September 7, 2024

A couple of things:

  • To enable HTTPS, change "HTTPS" to "Enable" in emulator-config.json and use emulator.py (emulator_ssl.py should have been removed when I merge the functionality - I will file an issue.)
  • HTTPS requires that key and cert (certificate) files exist in the root directory (specifically, the files named server.key and server.cert). For development, these can be self-signed.

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

Hi, THANKS! I have just installed 'yum install httpd' and modified the emulator-config.json.
How do I now do the key and cert part please?

from redfish-interface-emulator.

jcleung5549 avatar jcleung5549 commented on September 7, 2024

There are sites that will generate self signed key/cert files. You can find them with an internet search. (I prefer not to give a specific URI, less that be view as an endorsement.)

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

OK, got the two files :) where do they go specifically and is that all I have to do now? THANKS SO MUCH!

from redfish-interface-emulator.

jcleung5549 avatar jcleung5549 commented on September 7, 2024

Place the two files in the same directory as emulator.py.

Thanks for going through this. I wrote the README with full context, so I am sure some details are missing (which I considered intuitively obvious).

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

Please don't forget this is my first time on Linux so I am really grateful for all your guidance and maybe now I will be a little better at spotting intuitively obvious stuff - maybe :)
I'm going to move the files now and try it!

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

OK, I've moved the two files and tried to start the emulator - here is the result:

root@redfish-emulator Redfish-Interface-Emulator]# python emulator.py
[u'Redfish']

  • Redfish endpoint at localhost:5000
    {'sys_id': u'System-1', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-2', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-3', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-4', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-5', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-6', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-7', 'rb': '/redfish/v1/'}
    (' * Running in', u'Redfish', 'mode')
    Traceback (most recent call last):
    File "emulator.py", line 417, in
    main()
    File "emulator.py", line 413, in main
    g.app.run(**kwargs)
    File "/usr/lib/python2.7/site-packages/flask/app.py", line 841, in run
    run_simple(host, port, self, **options)
    File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 739, in run_simple
    inner()
    File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 699, in inner
    fd=fd)
    File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 593, in make_server
    passthrough_errors, ssl_context, fd=fd)
    File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 528, in init
    self.socket = ssl_context.wrap_socket(sock, server_side=True)
    File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 450, in wrap_socket
    ssl_version=self._protocol, **kwargs)
    File "/usr/lib64/python2.7/ssl.py", line 934, in wrap_socket
    ciphers=ciphers)
    File "/usr/lib64/python2.7/ssl.py", line 547, in init
    self._context.load_cert_chain(certfile, keyfile)
    IOError: [Errno 2] No such file or directory

Any ideas?

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

Here is a look in my root folder:

/home/john/Pictures/Screenshot from 2019-03-06 21-53-15.png

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

2nd try

screenshot from 2019-03-06 21-53-15

from redfish-interface-emulator.

jcleung5549 avatar jcleung5549 commented on September 7, 2024

Rename 81568817_redfish-emulator.cert to server.cert.
Rename 81568817_redfish-emulator.key to server.key

from redfish-interface-emulator.

billdodd avatar billdodd commented on September 7, 2024

A slight correction:
Rename 81568817_redfish-emulator.cert to server.crt. (.crt instead of .cert)

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

It failed, then I saw your second post - IT'S NOW WORKING!!!

[root@redfish-emulator Redfish-Interface-Emulator]# ls
api_emulator emulator.py packageSets server.crt
AUTHORS.md emulator_ssl.py Procfile server.key
CHANGELOG.md g.py README.md templates
codegen g.pyc requirements.txt test-composed.json
doc infragen Resources unittest_data
emulator-config.json LICENSE.md runtime.txt unittests.py
[root@redfish-emulator Redfish-Interface-Emulator]# python emulator.py
[u'Redfish']

  • Redfish endpoint at localhost:5000
    {'sys_id': u'System-1', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-2', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-3', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-4', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-5', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-6', 'rb': '/redfish/v1/'}
    {'sys_id': u'System-7', 'rb': '/redfish/v1/'}
    (' * Running in', u'Redfish', 'mode')

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

I'm going to test Postman now with authentication... THANK YOU for your perseverance and patience, I am so very HAPPY!

from redfish-interface-emulator.

jomacdon69 avatar jomacdon69 commented on September 7, 2024

Working perfectly, thank you just once more!

from redfish-interface-emulator.

mraineri avatar mraineri commented on September 7, 2024

Addressed in latest PR

from redfish-interface-emulator.

Related Issues (20)

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.