Project

General

Profile

Feature #23729

Provide better hostname generator examples

Added by Lukas Zapletal 12 months ago. Updated 5 months ago.

Status:
New
Priority:
Normal
Category:
-
Target version:
-
Difficulty:
trivial
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Our discovery rule hostname example with rand() method do not work: abc-<%= @host.facts['bios_vendor'] + '-' + rand(99999) %>

Errors out with: TypeError (no implicit conversion of Integer into String) and "to_s" call must be added. Let's add that to the example screen.

We should also provide some new helpers and allow them in safemode:

- rand_hex(n) - returns SecureRandom.hex(n)
- rand_name - returns NameGenerator.new.next_random_name
- mac_name(mac_address) - returns NameGenerator.new.next_mac_name(mac_address)

Add those to the examples. Note NameGenerator is part of Foreman Core.


Related issues

Related to Discovery - Feature #16330: Give reasonable names to discovered hosts via deaconClosed2016-08-26
Related to Foreman - Feature #25679: Provide better hostname generator examples with safemode enabledClosed

History

#1 Updated by Lukas Zapletal 12 months ago

  • Related to Feature #16330: Give reasonable names to discovered hosts via deacon added

#2 Updated by Aditi Puntambekar 6 months ago

  • Assignee set to Aditi Puntambekar

#3 Updated by Aditi Puntambekar 6 months ago

I think the discovery rule hostname example with rand() method has already been taken care of in [[https://github.com/theforeman/foreman_discovery/commit/fe346a413d3a69fc9e878e768caea1119d055d10]].
So will this issue focus only on new helpers for name generation ? How do we plan to go ahead ?

#4 Updated by Lukas Zapletal 6 months ago

Yes, test the rest and add it to the doc text please.

#5 Updated by Aditi Puntambekar 5 months ago

  • Related to Feature #25679: Provide better hostname generator examples with safemode enabled added

#6 Updated by Aditi Puntambekar 5 months ago

This issue has been fixed in Foreman core as [[https://projects.theforeman.org/issues/25679]]. Can this be closed then ?

Also available in: Atom PDF