Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #12212 - Import addtitionnal informations from DHCP smart proxy #2846

Conversation

bagasse
Copy link
Member

@bagasse bagasse commented Oct 20, 2015

Add ability to import some subnet options (gateway, dns servers, IP addr range...) from the dhcp smart-proxy.

next if first(:conditions => attrs)
if s["options"]
attrs.merge!({:gateway => s["options"]["gateway"],
Copy link
Member

Choose a reason for hiding this comment

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

There's a PR in smart-proxy (theforeman/smart-proxy#330) that introduces support for this in isc provider, but not for the MS windows one. We either need: add similar functionality on Windows, or be able to handle response that doesn't contain these newly introduced fields.

Could you add a test for this?

Copy link
Member

Choose a reason for hiding this comment

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

nm, I see that options hash has been added in the smart-proxy PR. I'd change this end to iterate over all keys available in options and append them to attrs.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, true. nm, then!

Copy link
Member

Choose a reason for hiding this comment

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

Having said that, on the smart-proxy side I suggested to keep option names and format of values similar to the original ones. This would require explicit handling of each option (renaming, extracting of values, etc) here.

@dLobatog
Copy link
Member

[test]

@bagasse
Copy link
Member Author

bagasse commented Oct 20, 2015

@witlessbird

I didn't see any test on the import subnet part in the foreman (i used grep, so maybe i've missed something). I wil take a look to test cases with and without the options part.

@dmitri-d
Copy link
Member

@bagasse: I was thinking that mapping of the options hash to model attributes is worth a test (esp. so if hash keys will be renamed).

@dLobatog
Copy link
Member

Setting this to WoC until a test comes 😄

next if first(:conditions => attrs)
if s["options"]
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick - What do you think about extracting this handling of attrs to a separate method?

@dLobatog
Copy link
Member

@bagasse Any updates?

@bagasse
Copy link
Member Author

bagasse commented Nov 2, 2015

@dLobatog Yes i've refactored options in a separate method, but i didn't see any test on subnet import in the codebase. Any pointers to test output from smartproxy on foreman side ?
Any advices on theforeman/smart-proxy#330 about the namming of attributes ?

@bagasse bagasse force-pushed the Fixes_12212_-_Import_addtitionnal_informations_from_DHCP_smart_proxy branch from 9eca744 to e966f88 Compare November 2, 2015 11:21
@@ -212,6 +214,18 @@ def as_json(options = {})

private

def parse_dhcp_options!(options)
Copy link
Member

Choose a reason for hiding this comment

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

Typo - parse_dhcp_options, without the exclamation mark

@dLobatog
Copy link
Member

dLobatog commented Nov 2, 2015

@bagasse Alright, there are a few comments inline - it contains a typo basically. I can write a test for this and you can rebase it in your commit if that works for you?

@dmitri-d
Copy link
Member

dmitri-d commented Nov 2, 2015

@dLobatog: any thoughts on naming of dhcp options? Atm they are named after db schema in foreman, my suggestion was to use names similar to rfc, and convert them here. This way smart-proxy code will be easier to understand/need fewer comments...

@bagasse bagasse force-pushed the Fixes_12212_-_Import_addtitionnal_informations_from_DHCP_smart_proxy branch from e966f88 to ad8cc1a Compare November 2, 2015 12:43
@bagasse
Copy link
Member Author

bagasse commented Nov 2, 2015

@dLobatog: oops... done.

@dLobatog
Copy link
Member

dLobatog commented Nov 2, 2015

[test]

@dLobatog
Copy link
Member

dLobatog commented Nov 3, 2015

@witlessbird I agree using the RFC names is more appropriate, we can do the mapping here - I'll set this to WoC until the Smart proxy PR is merged and we have set of options to map to here.

@bagasse The PR is ready IMO - except for the functional tests part, which I can do after theforeman/smart-proxy#330 is merged and we have a stable options hash convention. After it's merged make sure to ping me or comment here to ensure this gets reviewers attention again. Thanks 😄

@bagasse
Copy link
Member Author

bagasse commented Nov 3, 2015

@dLobatog, @witlessbird : thank for comments, i will do these changes on both sides.

@bagasse
Copy link
Member Author

bagasse commented Nov 3, 2015

@dLobatog @witlessbird, just one point to clarify, RFC2132 don't define standard names but codes for the dhcp options. I can create an hash-table with RFC2132 options codes as index. but it's not really readable, so when you talk about 'using the RFC names', do you mean 'use ISC dhcpd config names' for these options or use RFC2132 codes ?

@dmitri-d
Copy link
Member

dmitri-d commented Nov 3, 2015

@bagasse: apologies, I meant isc dhcpd config names.

@bagasse bagasse force-pushed the Fixes_12212_-_Import_addtitionnal_informations_from_DHCP_smart_proxy branch from ad8cc1a to c530cbd Compare November 4, 2015 15:49
@dLobatog
Copy link
Member

dLobatog commented Nov 5, 2015

@bagasse Thank you. I wrote two tests to check importing works with and without options. Please add this to your Pull request - 5bf8064

@bagasse bagasse force-pushed the Fixes_12212_-_Import_addtitionnal_informations_from_DHCP_smart_proxy branch from c530cbd to 302d777 Compare November 5, 2015 15:57
@domcleal
Copy link
Contributor

domcleal commented Nov 9, 2015

[test]

@dLobatog
Copy link
Member

@bagasse @witlessbird Thanks, I'll leave this PR open until the other side of the equation (theforeman/smart-proxy#330) is merged. It's ready to merge after that.

@dLobatog dLobatog added Reached an impasse Needs broader discussion and removed Needs re-review Needs testing labels Nov 11, 2015
@dLobatog
Copy link
Member

Merged as 302d777, thanks @bagasse!

@dLobatog dLobatog closed this Nov 12, 2015
@bagasse
Copy link
Member Author

bagasse commented Nov 12, 2015

@dLobatog @witlessbird, thanks.

@bagasse bagasse deleted the Fixes_12212_-_Import_addtitionnal_informations_from_DHCP_smart_proxy branch June 1, 2016 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reached an impasse Needs broader discussion
Projects
None yet
6 participants