From ab73cb1394d385ef75aced6b9a5303c1d6158403 Mon Sep 17 00:00:00 2001 From: Moti Asayag Date: Thu, 16 Nov 2017 00:26:49 +0200 Subject: [PATCH] Save host 'maintenance' value The host 'maintenance' attribute was added to provision vm dialog by https://github.com/ManageIQ/manageiq/pull/16464 RHV should store this information which is already available during host refresh. https://bugzilla.redhat.com/show_bug.cgi?id=1513413 --- .../providers/redhat/infra_manager/refresh/parse/parser.rb | 1 + .../infra_manager/refresh/parse/strategies/host_inventory.rb | 1 + .../providers/redhat/inventory/parser/infra_manager.rb | 1 + .../redhat/inventory_collection_default/infra_manager.rb | 3 ++- .../redhat/infra_manager/refresh/refresher_3_1_spec.rb | 1 + .../infra_manager/refresh/refresher_4_async_graph_spec.rb | 1 + .../redhat/infra_manager/refresh/refresher_4_async_spec.rb | 1 + 7 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/parser.rb b/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/parser.rb index 500b51ffe..b58be6862 100644 --- a/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/parser.rb +++ b/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/parser.rb @@ -138,6 +138,7 @@ def self.host_inv_to_hashes(inv, ems_inv, cluster_uids, _storage_uids) :vmm_buildnumber => (host_os_version[:build] if host_os_version), :connection_state => connection_state, :power_state => power_state, + :maintenance => power_state == 'maintenance', :operating_system => host_inv_to_os_hash(host_inv, hostname), diff --git a/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/strategies/host_inventory.rb b/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/strategies/host_inventory.rb index ee1f629d9..6fedead41 100644 --- a/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/strategies/host_inventory.rb +++ b/app/models/manageiq/providers/redhat/infra_manager/refresh/parse/strategies/host_inventory.rb @@ -68,6 +68,7 @@ def host_inv_to_hashes(inv, ems_inv, cluster_uids, _storage_uids) :vmm_buildnumber => (host_os_version.build if host_os_version), :connection_state => connection_state, :power_state => power_state, + :maintenance => power_state == 'maintenance', :operating_system => host_inv_to_os_hash(host_inv, hostname), :ems_cluster => cluster_uids[host_inv.dig(:cluster, :id)], :hardware => hardware, diff --git a/app/models/manageiq/providers/redhat/inventory/parser/infra_manager.rb b/app/models/manageiq/providers/redhat/inventory/parser/infra_manager.rb index e17eea84f..7defc748a 100644 --- a/app/models/manageiq/providers/redhat/inventory/parser/infra_manager.rb +++ b/app/models/manageiq/providers/redhat/inventory/parser/infra_manager.rb @@ -151,6 +151,7 @@ def hosts :vmm_buildnumber => (host_os_version.build if host_os_version), :connection_state => connection_state, :power_state => power_state, + :maintenance => power_state == 'maintenance', :ems_cluster => persister.ems_clusters.lazy_find(ManageIQ::Providers::Redhat::InfraManager.make_ems_ref(cluster.href)), :ipmi_address => ipmi_address, ) diff --git a/app/models/manageiq/providers/redhat/inventory_collection_default/infra_manager.rb b/app/models/manageiq/providers/redhat/inventory_collection_default/infra_manager.rb index 34f9cd581..fec249cc4 100644 --- a/app/models/manageiq/providers/redhat/inventory_collection_default/infra_manager.rb +++ b/app/models/manageiq/providers/redhat/inventory_collection_default/infra_manager.rb @@ -328,7 +328,8 @@ def hosts(extra_attributes = {}) :connection_state, :power_state, :ems_cluster, - :ipmi_address + :ipmi_address, + :maintenance ] } diff --git a/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_3_1_spec.rb b/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_3_1_spec.rb index c1e10aea4..803f628c0 100644 --- a/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_3_1_spec.rb +++ b/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_3_1_spec.rb @@ -185,6 +185,7 @@ def assert_specific_host :vmm_product => "rhel", :vmm_buildnumber => nil, :power_state => "on", + :maintenance => false, :connection_state => "connected" ) diff --git a/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_graph_spec.rb b/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_graph_spec.rb index 99f2f310a..8be44c629 100644 --- a/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_graph_spec.rb +++ b/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_graph_spec.rb @@ -193,6 +193,7 @@ def assert_specific_host :vmm_product => "rhel", :vmm_buildnumber => nil, :power_state => "on", + :maintenance => false, :connection_state => "connected" ) diff --git a/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_spec.rb b/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_spec.rb index 714acea15..1322e0953 100644 --- a/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_spec.rb +++ b/spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_async_spec.rb @@ -192,6 +192,7 @@ def assert_specific_host :vmm_product => "rhel", :vmm_buildnumber => nil, :power_state => "on", + :maintenance => false, :connection_state => "connected" )