Skip to content

Commit

Permalink
Only check for duplicate endpoints for CloudManagers
Browse files Browse the repository at this point in the history
Fix hostname_uniqueness_valid? failing if an `Openstack::InfraManager`
has the same connection details as an `Openstack::CloudManager`
  • Loading branch information
agrare committed Mar 12, 2024
1 parent e6e32c0 commit 17a4c6a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/models/manageiq/providers/openstack/cloud_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -518,14 +518,15 @@ def hostname_uniqueness_valid?
return unless hostname_required?
return unless hostname.present? # Presence is checked elsewhere

existing_providers = Endpoint.where(:hostname => hostname.downcase)
.where.not(:resource_id => id).includes(:resource)
.select do |endpoint|
unless endpoint.resource.nil?
endpoint.resource.uid_ems == keystone_v3_domain_id &&
endpoint.resource.provider_region == provider_region
end
end
existing_providers =
self.class
.joins(:endpoints)
.where.not(:id => id)
.where(
:endpoints => {:hostname => hostname.downcase},
:uid_ems => keystone_v3_domain_id,
:provider_region => provider_region
)

errors.add(:hostname, "has already been taken") if existing_providers.any?
end
Expand Down

0 comments on commit 17a4c6a

Please sign in to comment.