Skip to content

Vendor Passthru support for Subscriptions#2201

Merged
jtopjian merged 1 commit intogophercloud:masterfrom
iurygregory:vendor_passthru
Aug 10, 2021
Merged

Vendor Passthru support for Subscriptions#2201
jtopjian merged 1 commit intogophercloud:masterfrom
iurygregory:vendor_passthru

Conversation

@iurygregory
Copy link
Copy Markdown
Contributor

For #1429
This PR adds support for the following vendor passthru methods:

  • create_subscription
  • delete_subscription
  • get_subscription
  • get_all_subscriptions

This methods are only supported by redfish implementations in ironic
that are using the vendor passthru.

Introduced in Ironic in change 801064

@iurygregory iurygregory changed the title Vendor Passthru support Vendor Passthru support for Subscriptions Aug 5, 2021
@coveralls
Copy link
Copy Markdown

coveralls commented Aug 5, 2021

Coverage Status

Coverage decreased (-0.005%) to 79.821% when pulling d9ea55c on iurygregory:vendor_passthru into 1e1b375 on gophercloud:master.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Aug 5, 2021

Build failed.

@iurygregory
Copy link
Copy Markdown
Contributor Author

openlab-ci seems to be broken =(

@jtopjian
Copy link
Copy Markdown
Contributor

jtopjian commented Aug 5, 2021

Indeed. I've been meaning to open an Issue about this. I'll try to get to that today.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Aug 5, 2021

Build failed.

@jtopjian
Copy link
Copy Markdown
Contributor

jtopjian commented Aug 6, 2021

@iurygregory Thanks for submitting this.

At first review, I think the pattern being used here is too "high level" for Gophercloud and I couldn't find an existing similar implementation.

Gophercloud should have relatively simple and low level API calls with little logic used to build the request. In this case, I suggest having each function require a CallVendorPassthruOpts in addition to the per-method (create, delete, etc) opts. Once these are in place, helper functions that simplify the interaction with these low-level functions could be added to gophercloud/utils to help make this interaction easier.

Another possible option would be to combine CallVendorPassthruOpts and the per-function opts like this:

type CreateSubscriptionOpts struct {
        Method      string   `q:"method"`
	Destination string   `json:"Destination"`
	EventTypes  []string `json:"EventTypes,omitempty"`
	Context     string   `json:"Context,omitempty"`
	Protocol    string   `json:"Protocol,omitempty"`
}

You can then call two methods on the struct: one to create the query string and one to create the request body. It's still not a clean, intuitive solution, though.

I understand that this makes calling the functions rather awkward, but the way these routes are designed seem to be a little different than most.

Let me know if you have any questions or would like to discuss further.

@iurygregory
Copy link
Copy Markdown
Contributor Author

Hi @jtopjian , thanks for the feedback!
I will give a try to the approach you mentioned of having a single struct including the method.

@iurygregory
Copy link
Copy Markdown
Contributor Author

Having the Method inside the same struct was causing gophercloud to send as part of the request, I'm trying now to add CallVendorPassthruOpts as parameter for each function.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Aug 6, 2021

Build failed.

@jtopjian
Copy link
Copy Markdown
Contributor

jtopjian commented Aug 7, 2021

@iurygregory Thanks for making those changes. This code looks good to me, though I'm not familiar with Ironic. Have you been able to test this on a running Ironic service? If it works the way you're expecting, I can go ahead and merge this.

This commit adds support for the following vendor passthru methods:
- create_subscription
- delete_subscription
- get_subscription
- get_all_subscriptions

This methods are only supported by redfish implementations in ironic
that are using the vendor passthru.
@iurygregory
Copy link
Copy Markdown
Contributor Author

Hi @jtopjian

I've tested and I've found one small issue in the delete - ironic returns 200, so I've added
OkCodes: []int{200, 202, 204},
to it just to avoid the message

Expected HTTP response code [202 204] when accessing [DELETE http://192.168.122.1:6385/nodes/c5a2bcdb-0ead-4162-a5ce-ea3f23929a87/vendor_passthru?method=delete_subscription], but got 200 instead

All other actions are working as expected, I'm pushing a new commit to address the problem with delete and it should be fine.

Thanks!

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Aug 7, 2021

Build failed.

@iurygregory
Copy link
Copy Markdown
Contributor Author

@jtopjian let me know if there is something else I should do, thanks! =)

@jtopjian
Copy link
Copy Markdown
Contributor

@iurygregory Everything looks good. Sorry for the delay!

Copy link
Copy Markdown
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thank you!

@jtopjian jtopjian merged commit ad8066c into gophercloud:master Aug 10, 2021
@iurygregory
Copy link
Copy Markdown
Contributor Author

@jtopjian Thanks! If possible can you publish a tag with this feature? It would make things easier to do the changes in metal3.

@jtopjian
Copy link
Copy Markdown
Contributor

@iurygregory Sure, I don't mind making a release for this. Do you have any additional PRs planned? If so, I can wait. But if not, I will create a release now.

@iurygregory
Copy link
Copy Markdown
Contributor Author

@jtopjian I've checked with some folks today, for now this would be the only PR we need to start working on the feature =)

@jtopjian
Copy link
Copy Markdown
Contributor

@iurygregory Sounds good. v0.20.0 has been created.

@iurygregory iurygregory deleted the vendor_passthru branch October 13, 2023 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants