Revision 4feb1576
Added by Marek Hulán over 9 years ago
app/models/nic/interface.rb | ||
---|---|---|
:allow_blank => true,
|
||
:format => {:with => Net::Validations::HOST_REGEXP}
|
||
|
||
# aliases and vlans require identifiers so we can differentiate and properly configure them
|
||
validates :identifier, :presence => true, :if => Proc.new { |o| o.virtual? && o.managed? && o.instance_of?(Nic::Managed) }
|
||
|
||
delegate :network, :to => :subnet
|
||
|
||
def vlanid
|
test/unit/nic_test.rb | ||
---|---|---|
assert another_physical_on_unmanaged.save
|
||
end
|
||
|
||
test "VLAN requires identifier" do
|
||
nic = FactoryGirl.build(:nic_managed, :virtual => true, :attached_to => 'eth0', :tag => 5, :managed => true, :identifier => '')
|
||
refute nic.valid?
|
||
assert_includes nic.errors.keys, :identifier
|
||
end
|
||
|
||
test "Alias requires identifier" do
|
||
nic = FactoryGirl.build(:nic_managed, :virtual => true, :attached_to => 'eth0', :managed => true, :identifier => '')
|
||
refute nic.valid?
|
||
assert_includes nic.errors.keys, :identifier
|
||
end
|
||
|
||
test "Bond does not require identifier" do
|
||
nic = FactoryGirl.build(:nic_bond, :attached_devices => 'eth0,eth1', :managed => true, :identifier => '')
|
||
nic.valid?
|
||
refute_includes nic.errors.keys, :identifier
|
||
end
|
||
|
||
test "BMC does not require identifier" do
|
||
nic = FactoryGirl.build(:nic_bmc, :managed => true, :identifier => '')
|
||
nic.valid?
|
||
refute_includes nic.errors.keys, :identifier
|
||
end
|
||
|
||
context 'BMC' do
|
||
setup do
|
||
disable_orchestration
|
Also available in: Unified diff
Fixes #9429 - identifier is required for Alias and VLAN