You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -10,30 +10,52 @@ Dynamic emulator is accomplished by creating the Python files. The code for an
10
10
11
11
The Swordfish model has been emulate using this emulator. The repository is available at [Swordfish API Emulator](https://github.com/SNIA/Swordfish-API-Emulator). The repository provides a good example of the Python files for dynamic resources.
12
12
13
-
The emulator is structure so it can be hosted on a standalone system or multiple instances in a Cloud Foundry. Note: the cloud foundry method has be successful within a company internal cloud foundry service. It has not be attempted on a public cloud foundry service.
13
+
The program has been verified on 3.5.2 and 3.9.1. Use the packet sets to install the correct packages.
14
14
15
-
This program is a python35 program. The program has been verified on 3.5.2.
15
+
The emulator is structure so it can be ran locally, in a Cloud Foundry, or as a Docker file.
16
16
17
-
## Installation
17
+
## Execute Locally
18
18
19
-
Before the emulator can be executed locally, specific Python packages need to be installed.
19
+
When executing the Emulator locally, the Redfish service appears at port 5000, by default. The Redfish client uses the following URL to access the emulator Redfish server - http://localhost:5000. To run a second instance must a different 'port'. The port number can be changed via the command line parameters or the config.json file.
20
20
21
-
### Local Standalone
21
+
### Package Installation
22
22
23
-
The required python packages for a local environment are listed in the file **./packageSets/Env-Local-Python3.5.2_requirements.txt**. The file lists the Python package and revision.
23
+
The required python packages are listed in the files in the **./packageSets** directory.
24
24
25
25
The 'pip' command can be used to install the environment.
26
26
27
27
pip install -r [packageSet]
28
28
29
-
The 'pip freeze' command can be used to display the installed packages and their revision.
29
+
If you are able to execute this emulator on later versions of Python, please issue the 'pip freeze' command. Then place the output into a Github issue. We can add the package set to this repository.
30
30
31
-
### Cloud
31
+
### Invocation
32
+
33
+
Edit the emulator-config.json file and set **"MODE": "Local"**, then start the emulator.
34
+
35
+
python emulator.py
36
+
37
+
## Execute on a Cloud Foundry
38
+
39
+
The cloud foundry method has be successful within a company internal cloud foundry service. It has not be attempted on a public cloud foundry service.
40
+
41
+
### Package Installation
32
42
33
43
The required python packages for a Cloud Foundry environment are listed in the file **./requirements.txt**. The file lists the Python package, without the revision.
34
44
The packages will be installed automatically during invocation.
35
45
36
-
### Docker
46
+
The cloud foundry makes use of the following files: requirements.txt, runtime.txt, and Profile. So they should exists in the same directory as emulator.py.
47
+
48
+
### Invocation
49
+
50
+
Edit the emulator-config.json file and set **"MODE": "Cloud"**, then push the emulator to the foundry.
51
+
52
+
cf push [foundry-app-name]
53
+
54
+
The **foundry-app-name** determines the URL for the Redfish service.
55
+
56
+
## Execute via Docker
57
+
58
+
### Installation
37
59
38
60
Use one of these actions to pull or build the container:
39
61
@@ -53,25 +75,7 @@ Use one of these actions to pull or build the container:
Edit the emulator-config.json file and set**"MODE": "Local"**, then start the emulator.
61
-
62
-
python emulator.py
63
-
64
-
### Cloud Foundry
65
-
66
-
Edit the emulator-config.json file and set**"MODE": "Cloud"**, then push the emulator to the foundry.
67
-
68
-
cf push [foundry-app-name]
69
-
70
-
The **foundry-app-name** determines the URL for the Redfish service.
71
-
72
-
The cloud foundry makes use of the following files: requirements.txt, runtime.txt, and Profile. So they should exists in the same directory as emulator.py.
73
-
74
-
### Docker
78
+
### Invocation
75
79
76
80
This command runs the container with the built-in mockup:
77
81
@@ -133,31 +137,33 @@ When HTTPS is enabled, the emulator looks for the files: **server.crt** and **se
133
137
134
138
## Static emulation of a mockup
135
139
136
-
The emulator can be used to support mockups, statically. The means on HTTP GETs will work. This can be done by just copying the mockup hierarchy to the ./static folder.
140
+
The emulator can be used to support static mockups. In a static mock, only HTTP GETs will work. Other Redfish simulators support static mockups.
137
141
138
-
The static mockup is found in the directory ./api_emulator/redfish/static. The emulator comes with a sample Redfish mockup. This can be replaced with any mockup folder. The Redfish Forum has posted several of their mockups in [DSP2043](https://www.dmtf.org/sites/default/files/DSP2043_1.2.0.zip).
142
+
The static mockup is found in the directory ./api_emulator/redfish/static. The emulator comes with a sample Redfish mockup already in the directory. This can be replaced with any mockup folder hierarchy. The Redfish Forum has posted several of their mockups in [DSP2043](https://www.dmtf.org/sites/default/files/DSP2043_1.2.0.zip).
139
143
140
144
Note: If the new mockup has additional resources in the ServiceRoot, then modifications need to be made in static_resource_emulator.py to adds these new resources.
141
145
142
146
## Dynamic emulation
143
-
The emulator was designed to support dynamic resources. This requires that Python code exists for each dynamic resource. Resources can be incremental recasted as dynamic, so one can straddle static vs dynamic emulation, with some resources static while others are dynamic.
147
+
The emulator was designed to support dynamic resources. This requires that Python code exists foreach dynamic resource. Resources which are static and dynamic can co-existin an emulator. This means one can straddle static vs dynamic emulation, with some resources static while others are dynamic.
148
+
149
+
Dynamic resource implementations which have been implemented are provided in the Appendix.
144
150
145
-
The following outlines the overall process. More complete documentation is in a Word document in the ./doc directory. An example forthe Chassis resource is includedinthe sourcecode.
151
+
The following outlines the overall process. More complete documentation is in a Word document in the ./doc directory. To expedite the creation of the API-file and template file, the code generators for both files are described.
146
152
147
-
1. Create an API file (e.g. Chassis\_api.py)
148
-
* The file is placed in the ./api\_emulator/Redfish directory
149
-
* The file contain the behavior of each HTTP command, of interest
150
-
* The file contains the API for both the singleton resource and the collection resource (if collection exists)
151
-
2. Create a template file (e.g. Chassis.py)
152
-
* The file is placed in ./api\_emulator/Redfish/template directory
153
-
* The file should contain the same properties as the mockup file for the resource
* Comment out the line which loads the static mockup for the Chassis resource
156
-
* Add the line to add the resource API defined in chassis_api.py
153
+
### Manually creating a dynamic resource
154
+
A dynamic resource is made by creating a template-file and an API-file for the resource.
157
155
158
-
To automate step #1 and #2, above, a code generator exists in the ./codegen directory.
156
+
* The template-file contain the properties of the resource. The file is used when a new instance of the resource is created.
157
+
* The API-file contain the behavior of the resource for each HTTP command. If there is an associated collection resource, the file also contains the behavior of the collection resource.
159
158
160
-
#### Auto-generate the API file
159
+
Once the files are created, they are placed in the emulator directory structure.
160
+
161
+
* The template-file is placed in the directory ./api\_emulator/Redfish/template
162
+
* The API-file is placed in the directory ./api\_emulator/Redfish
163
+
* If the resource in the Service Root, the the emulator.py file needs to be edited.
164
+
* If the dynamic resource replaces a static resource, then replace the line which loads the static mockup with the line to add to dynamic resource API.
165
+
166
+
### Auto-generate the API file
161
167
To generate a API file, execute the following command
162
168
163
169
codegen_api [mockup] [outputdir]
@@ -172,7 +178,7 @@ The generated code supports the HTTP GET, PATCH, POST and DELETE commands
172
178
173
179
If the resource has subordinate resources that need to be instantiated when this resource is instantiated, that code will need to be manually added.
174
180
175
-
#### Auto-generate the template file
181
+
### Auto-generate the template file
176
182
To generate a template file, execute the following command
177
183
178
184
codegen_template [mockup] [outputdir]
@@ -187,7 +193,7 @@ Where
187
193
188
194
The codegen_template source file contains a dictionary with the names of Redfish collections and their corresponding wildcard. This dictionary needs to be manually updated to the keep in sync with Redfish modeling.
189
195
190
-
## Populating the dynamic emulator - INFRAGEN Module
196
+
## Auto-populating the dynamic emulator
191
197
192
198
Once a resource is made dynamic, the emulator can either start up with no members in its collections or some initial set of members.
193
199
@@ -308,3 +314,80 @@ sh release.sh <NewVersion>
308
314
```
309
315
310
316
Enter the release notes when prompted; an empty line signifies no more notes to add.
317
+
318
+
# Appendix - Available Dynamic Resources implementations
319
+
320
+
The emulator is made dynamic by added python code to emulate a resources RESTful behavior, call the API-file.
321
+
322
+
Dynamic resources implementations can be found in the Redfish Interface Emulator repository and the SNIA API Emulator repository.
323
+
324
+
The repository also had the codegen_api code generator for creating an API-file for a resource with some default behaviors. The code generator takes a mockup file as input.
325
+
326
+
## Redfish Interface Emulator
327
+
328
+
The Redfish Interface Emulator comes with a small set of API-files to demonstrate the code structure. The repository also had the codegen_api code generator for creating an API-file for a resource with some default behaviors. The code generator takes a mockup file as input.
329
+
330
+
These dynamic resources are available in the [Redfish Interface Emulator repository](https://github.com/dmtf/Redfish-Interface-Emulator) in the api_emulator/redfish directory.
The Swordfish API Emulator added the API-files to emulate the Swordfish schema.
351
+
352
+
These dynamic resources are available in the [SNIA API Emulator repository](https://github.com/SNIA/Swordfish-API-Emulator) in the api_emulator/redfish directory.
0 commit comments