Project

General

Profile

Actions

Bug #23173

open

Provision interface MAC uniquess does not work

Added by Lukas Zapletal almost 6 years ago. Updated over 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
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 2 (0 open2 closed)

Related to Discovery - Bug #23174: Do not prevent host discovery for existing MAC/IP addressesClosedLukas Zapletal04/09/2018Actions
Related to Foreman - Bug #23177: Issue warning when multiple hosts with same MAC are foundClosedLukas Zapletal04/09/2018Actions
Actions #1

Updated by Lukas Zapletal almost 6 years ago

Actions #2

Updated by Lukas Zapletal almost 6 years ago

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

Updated by Lukas Zapletal almost 6 years ago

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

Also available in: Atom PDF