Hi all,

No one replied on this thread. So before the next meeting, I took the liberty of creating my own go client library for redfish.  I have implemented, all the basic functions which sushy-emulator supports. Rest of the operations can be added on a need basis. I guess this can serve our purpose for now. I have to add authentication support and then I will add helper utility to do common operations easily using current primitive functions.

Please try it out and give feedback.
https://github.com/nordix-airship/go-redfish

Br,
Kanwar Saad
Ericsson



On Thu, Sep 5, 2019 at 3:33 PM Kanwar Saad <kanwar.sbl@gmail.com> wrote:
Hi,

I spent some time on generating go client code for redfish spec using openapi generator. But it is failing to generate code for that. I guess code generator do not cover all scenarios of openapi. The redfish openapi specification is huge(around 1200 documents) and it is failing for few hundred. I dont want to spend time investigating that because that is another rabbit hole. In that case we are left with these options.

Gofish:
- only contains functions for getting redfish resources but not setting.
- The resources we want like virtualmedia is not even supported for reading.
- It is not very well maintained.
- Extending It is not feasible since they create all datastructures by hand and then we have to create Marshall/Unmarshall functions for each datastructure.

GoRackHD:
- It is made to work with Dell's RackHD.
- Last commit was done in 2016.
- They have used a similar approach which I was trying. They created their own subset of swagger specification and generate client code using that swagger spec. The spec is old and do not support virtualmedia actions which we want.
- Extending this is complicated since we dont know whether that will be compatible with RackHD(or we need to make a fork continue ourself). Secondly, it uses old swagger spec than openapi and conversion to openapi is not straightforward. 

Use Containerized Tool:

One option is to use a well tested, well maintained redfish client in any language in a container just like isogen. this option also requires writing wrappers around that library inside contianer.

Create our own redfish go client :

1. We can use a similar approach as of goRackHD. We can create our own openapi spec for redfish only for the resources which we need in the start and extend later. And generate client code using that. This might also require maintaining the openapi spec parallel to the redfish standard spec but since the redfish spec is not changing too fast so we can live with it.

2. Second option is to create a really lightweight utility functions which will just perform the operations which we want using standard http library. Since we might not need too much redfish functions so it could be a viable option. If we want to rely heavily on redfish for validations(i have not seen what kind of validations you want so its vague for me), then this option might not work very well.


Br,
Kanwar Saad
Ericsson