Actions
Bug #23173
openProvision interface MAC uniquess does not work
Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
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).
Updated by Lukas Zapletal almost 7 years ago
Some pastes from my debugging session: https://gist.github.com/lzap/1bcb465a4722166f1e4cc2904e334f53
Updated by Lukas Zapletal almost 7 years ago
- Related to Bug #23174: Do not prevent host discovery for existing MAC/IP addresses added
Updated by Lukas Zapletal almost 7 years ago
- Related to Bug #23177: Issue warning when multiple hosts with same MAC are found added
Actions