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 #14232 - make generic helpers available for global PXE template #3335

Closed
wants to merge 1 commit into from

Conversation

ares
Copy link
Member

@ares ares commented Mar 16, 2016

No description provided.

@@ -121,7 +121,8 @@ def self.build_pxe_default(renderer)
if error_msg.empty?
begin
@profiles = pxe_default_combos
menu = renderer.render_safe(default_template.template, [:default_template_url], {:profiles => @profiles})
allowed_helpers = ALLOWED_GENERIC_HELPERS + [ :default_template_url ]
Copy link
Contributor

Choose a reason for hiding this comment

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

I receive an error building the default PXE menu, I think from here: failed to process template: uninitialized constant ProvisioningTemplate::ALLOWED_GENERIC_HELPERS

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm sorry, last second change which I somehow didn't test

@domcleal
Copy link
Contributor

This doesn't appear to fix the described bug, it only permits safemode access to the existing method and doesn't give the "name" (FQDN, presumably). Should this also address #7828?

@ares
Copy link
Member Author

ares commented Mar 16, 2016

This doesn't appear to fix the described bug, it only permits safemode access to the existing method

In the linked BZ reporter was ok with just using foreman_url in his use-case. But you're right, since we're touching this we can add new method returning just the FQDN of foreman.

and doesn't give the "name" (FQDN, presumably).

added foreman_server_fqdn, if it get's in, I'll document it at http://projects.theforeman.org/projects/foreman/wiki/templatewriting

Should this also address #7828?

partly yes, #7828 seems to be solved by #11723 already, it just doesn't work with safe mode enabled, I've marked it as duplicate

@lzap
Copy link
Member

lzap commented Mar 17, 2016

I will test #7828 as it's important feature for Discovery, thanks!

@@ -57,6 +59,11 @@ def foreman_url(action = "built")
:token => (@host.token.value unless @host.try(:token).nil?), :kind => action
end

def foreman_server_fqdn
config = URI.parse(Setting[:unattended_url])
config.host || request.host
Copy link
Contributor

Choose a reason for hiding this comment

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

Using the host only is perhaps not quite enough to help with #7828, where it's needed to build a URL for say, Discovery - the protocol, port and path specified in :unattended_url are relevant too.

While a plethora of helpers is a bad thing, I can see a case for having helpers for either the FQDN and the base URL, or the base URL only. If the former, we can merge this as-is to provide the FQDN and re-open #7828 - I'm just unsure this fully solves it as-is.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, FQDN is not enough, but it's a good start. Scheme is always https in our case and port is either 443 or 8443 depending on connection type. I filed a ticket that could provide the rest via settings: http://projects.theforeman.org/issues/14245. And if we can get full URL with scheme and port, at least for Discovery case we can detect what we need.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd much prefer to provide a helper that simply returns the URL rather than have users write against specific setting names, because it provides a good layer of abstraction against internal changes and features. (For example, foreman_url supports template proxies, which is more complex than just checking the value of a setting.)

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I can add foreman_server_url that will add protocol and port too (no path, no template proxies in this one), would that help?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me.

Copy link
Member

Choose a reason for hiding this comment

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

Templating port is irrelevant for Discovery as it always uses HTTPS port and HTTP port (which is utilized for templating). Therefore this won't solve the discovery case at all. Maybe if you could add a param force_https that could be used in Discovery global PXELinux section to force it.

Copy link
Contributor

Choose a reason for hiding this comment

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

It sounds incorrect to force HTTPS, but what you're actually describing is that you prefer the value of :foreman_url setting and not the :unattended_url.

Copy link
Member Author

Choose a reason for hiding this comment

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

Which seems to make sense for both new helpers. The only thing that makes it confusing is that our existing foreman_url helper uses unattended_url setting while the new one would use foreman_url setting. Anyway I've added two new helpers, please take a look.

EDIT: and asked @lzap for his comments after short discussion

@lzap
Copy link
Member

lzap commented Mar 21, 2016

After short call with @ares I confirm what's implemented now is enough for discovery. Since we don't support multiple PXELinux default templates per subnet, the only sane default for discovery is to use foreman URL. And for this, foreman_server_fqdn can be leveraged (port is explicit in discovery case). I will change instructions to make a change in case user wants to have Proxy in the middle.

@ares
Copy link
Member Author

ares commented Mar 21, 2016

tests failures do not seem to be related

@domcleal
Copy link
Contributor

Merged as e4ed4a0, thanks @ares. Please update http://projects.theforeman.org/projects/foreman/wiki/TemplateWriting with the new features and feel free to use them in the community-templates develop branch.

@domcleal domcleal closed this Mar 22, 2016
@ares
Copy link
Member Author

ares commented Mar 22, 2016

Thanks, I'll do it later today.

@lzap
Copy link
Member

lzap commented Mar 22, 2016

Created patch for discovery global PXELinux default one.

@ares
Copy link
Member Author

ares commented Mar 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants