Project

General

Profile

Bug #23173

Provision interface MAC uniquess does not work

Added by Lukas Zapletal over 4 years ago. Updated almost 4 years ago.

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

Description

We have this code:

    validate :mac_uniqueness,
             :if => Proc.new { |nic| nic.managed? && nic.host && nic.host.managed? && !nic.host.compute? && !nic.virtual? && nic.mac.present? }

    def interface_attribute_uniqueness(attr, base = Nic::Base.where(nil))
      in_memory_candidates = self.host.present? ? self.host.interfaces.select { |i| i.persisted? && !i.marked_for_destruction? } : [self]
      db_candidates = base.where(attr => self.public_send(attr))
      db_candidates = db_candidates.select { |c| c.id != self.id && in_memory_candidates.map(&:id).include?(c.id) }
      errors.add(attr, :taken) if db_candidates.present?
    end

It does not seem to work, one can create two hosts with two managed NICs with same MACs.

This is not an issue, but it surprised me and we should explicitly either allow creating same MAC addresses everywhere and inform the user about consequences (preferred) or disallow same MAC addresses everywhere (in database).


Related issues

Related to Discovery - Bug #23174: Do not prevent host discovery for existing MAC/IP addressesClosed2018-04-09
Related to Foreman - Bug #23177: Issue warning when multiple hosts with same MAC are foundClosed2018-04-09

History

#2 Updated by Lukas Zapletal over 4 years ago

  • Related to Bug #23174: Do not prevent host discovery for existing MAC/IP addresses added

#3 Updated by Lukas Zapletal over 4 years ago

  • Related to Bug #23177: Issue warning when multiple hosts with same MAC are found added

Also available in: Atom PDF