diff --git a/Gemfile b/Gemfile index 2905b9e3f11..7b88dc6a7bd 100644 --- a/Gemfile +++ b/Gemfile @@ -46,7 +46,7 @@ gem "manageiq-messaging", :require => false, :git = gem "manageiq-network_discovery", "~>0.1.2", :require => false gem "memoist", "~>0.15.0", :require => false gem "mime-types", "~>2.6.1", :path => "mime-types-redirector" -gem "more_core_extensions", "~>3.3" +gem "more_core_extensions", "~>3.5" gem "nakayoshi_fork", "~>0.0.3" # provides a more CoW friendly fork (GC a few times before fork) gem "net-ldap", "~>0.14.0", :require => false gem "net-ping", "~>1.7.4", :require => false diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index e9b01b6e8c0..2bf22ab2aed 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -76,7 +76,7 @@ def self.supported_types_and_descriptions_hash validates :name, :presence => true, :uniqueness => {:scope => [:tenant_id]} validates :hostname, :presence => true, :if => :hostname_required? - validate :hostname_uniqueness_valid?, :if => :hostname_required? + validate :hostname_uniqueness_valid?, :hostname_format_valid?, :if => :hostname_required? scope :with_eligible_manager_types, ->(eligible_types) { where(:type => eligible_types) } @@ -92,6 +92,11 @@ def hostname_uniqueness_valid? errors.add(:hostname, N_("has to be unique per provider type")) if existing_hostnames.include?(hostname.downcase) end + def hostname_format_valid? + return if hostname.ipaddress? || hostname.hostname? + errors.add(:hostname, _("format is invalid.")) + end + include NewWithTypeStiMixin include UuidMixin include EmsRefresh::Manager