Project

General

Profile

Actions

Bug #2130

closed

normalize_hostname appends domain to end of fqdn on Update

Added by Mikael Fridh about 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Web Interface
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

So, not sure if this is just my freaky environment, where I have hosts whose fqdn really is:
willy.freaky.com

but they have a hardcoded fqdn in puppet as:
willy.deaky.net

From Foreman and Puppets point of view, the hosts are named *.deaky.net.
When editing a Host, the normalize_hostname filter will append $domain to the end of the fqdn, thus renaming the host:
willy.deaky.net.freaky.com

Actions #1

Updated by Mikael Fridh about 11 years ago

I'm thinking either this patch, or simply matching one dot /\./

diff --git a/app/models/host.rb b/app/models/host.rb
index fcb8838..9e81b9a 100644
--- a/app/models/host.rb
+++ b/app/models/host.rb
@@ -819,7 +819,7 @@ class Host < Puppet::Rails::Host
         old_domain = Domain.find(changed_attributes["domain_id"])
         self.name.gsub(old_domain.to_s,"")
       end
-      self.name += ".#{domain}" unless name =~ /.#{domain}$/i
+      self.name += ".#{domain}" unless name =~ /\..*\./i
     end
   end

Actions #2

Updated by Mikael Fridh about 11 years ago

pullreq https://github.com/theforeman/foreman/pull/376 I opted for the single-dot patch.

Actions #3

Updated by Mikael Fridh about 11 years ago

  • Target version set to 1.2.0

I'll just set this to 1.2 for consideration as there was some agreement on #theforeman-dev that the patch does make some sense. Why should hosts be renamed if they already look like an fqdn style hostname. I'm unaware of an edge case where it would make sense but please enlighten me if you do!

Actions #4

Updated by Dominic Cleal almost 11 years ago

  • Status changed from New to Ready For Testing
  • Assignee changed from Ohad Levy to Mikael Fridh
Actions #5

Updated by Mikael Fridh almost 11 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF