Skip to content

Commit

Permalink
Refs #36745 - VM is not associated upon host registration
Browse files Browse the repository at this point in the history
  • Loading branch information
nadjaheitmann committed May 16, 2024
1 parent 6bdd117 commit 8dbfff0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
4 changes: 4 additions & 0 deletions app/models/compute_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ def associate_by(name, attributes)
first
end

def associated_vm(host)
vms(:eager_loading => true).find { |vm| associate_by_host("mac", vm.interfaces.map(&:mac), host) }
end

def associate_by_host(name, attributes, host)
attributes = Array.wrap(attributes).map { |mac| Net::Validations.normalize_mac(mac) } if name == 'mac'
Host.authorized(:view_hosts, Host).where(:id => host.id).joins(:primary_interface).
Expand Down
4 changes: 0 additions & 4 deletions app/models/compute_resources/foreman/model/libvirt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,6 @@ def associated_host(vm)
associate_by("mac", vm.interfaces.map(&:mac))
end

def associated_vm(host)
vms(:eager_loading => true).find { |vm| associate_by_host("mac", vm.interfaces.map(&:mac), host) }
end

def vm_compute_attributes_for(uuid)
vm_attrs = super
if vm_attrs[:memory_size].nil?
Expand Down
4 changes: 0 additions & 4 deletions app/models/compute_resources/foreman/model/ovirt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,6 @@ def associated_host(vm)
associate_by("mac", vm.interfaces.map(&:mac))
end

def associated_vm(host)
vms(:eager_loading => true).find { |vm| associate_by_host("mac", vm.interfaces.map(&:mac), host) }
end

def self.provider_friendly_name
"oVirt"
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/compute_resources/foreman/model/vmware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,6 @@ def associated_host(vm)
associate_by("mac", vm.interfaces.map(&:mac))
end

def associated_vm(host)
vms(:eager_loading => true).find { |vm| associate_by_host("mac", vm.interfaces.map(&:mac), host) }
end

def display_type
attrs[:display] || 'vmrc'
end
Expand Down

0 comments on commit 8dbfff0

Please sign in to comment.