diff --git a/app/models/concerns/fog_extensions/xenserver/server.rb b/app/models/concerns/fog_extensions/xenserver/server.rb index 570af14..5559b1e 100644 --- a/app/models/concerns/fog_extensions/xenserver/server.rb +++ b/app/models/concerns/fog_extensions/xenserver/server.rb @@ -13,6 +13,10 @@ def id uuid end + def identity + uuid + end + def to_s name end diff --git a/app/models/foreman_xen/xenserver.rb b/app/models/foreman_xen/xenserver.rb index 1ddd56f..1808159 100644 --- a/app/models/foreman_xen/xenserver.rb +++ b/app/models/foreman_xen/xenserver.rb @@ -52,8 +52,11 @@ def cleanup_configdrive(uuid) end end + # rubocop:disable Rails/DynamicFindBy + # Fog::XenServer::Compute (client) isn't an ActiveRecord model which + # supports find_by() def find_vm_by_uuid(uuid) - client.servers.find_by(uuid: uuid) + client.servers.find_by_uuid(uuid) rescue Fog::XenServer::RequestFailed => e Foreman::Logging.exception("Failed retrieving xenserver vm by uuid #{uuid}", e) raise(ActiveRecord::RecordNotFound) if e.message.include?('HANDLE_INVALID') @@ -61,6 +64,7 @@ def find_vm_by_uuid(uuid) raise e end + # rubocop:enable Rails/DynamicFindBy # we default to destroy the VM's storage as well. def destroy_vm(ref, args = {}) @@ -526,13 +530,17 @@ def xenstore_hash_flatten(nested_hash, _key = nil, keychain = nil, out_hash = {} out_hash end + # rubocop:disable Rails/DynamicFindBy + # Fog::XenServer::Compute (client) isn't an ActiveRecord model which + # supports find_by() def set_vm_affinity(vm, hypervisor) if hypervisor.empty? vm.set_attribute('affinity', '') else - vm.set_attribute('affinity', client.hosts.find_by(uuid: hypervisor)) + vm.set_attribute('affinity', client.hosts.find_by_uuid(hypervisor)) end end + # rubocop:enable Rails/DynamicFindBy def create_and_attach_configdrive(vm, attr) network_data = add_mac_to_network_data(attr[:network_data], vm) diff --git a/app/views/compute_resources_vms/index/_xenserver.html.erb b/app/views/compute_resources_vms/index/_xenserver.html.erb index bb90731..3c3bbf3 100644 --- a/app/views/compute_resources_vms/index/_xenserver.html.erb +++ b/app/views/compute_resources_vms/index/_xenserver.html.erb @@ -11,7 +11,7 @@
<% @vms.each do |vm| -%>