From 83e69d01cd4d2c34614b8cd6c0b202042bf371af Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Fri, 16 Nov 2018 16:46:05 -0500 Subject: [PATCH] Always set vm_or_template.connection_state Instead of defaulting to nil always set vm_or_template.connection_state --- .../providers/vmware/cloud_manager/refresh_parser.rb | 2 ++ app/models/manageiq/providers/vmware/cloud_manager/vm.rb | 8 -------- .../providers/vmware/inventory/parser/cloud_manager.rb | 2 ++ .../providers/vmware/cloud_manager/refresher_spec.rb | 6 +++--- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/models/manageiq/providers/vmware/cloud_manager/refresh_parser.rb b/app/models/manageiq/providers/vmware/cloud_manager/refresh_parser.rb index 9343a7e19..934424215 100644 --- a/app/models/manageiq/providers/vmware/cloud_manager/refresh_parser.rb +++ b/app/models/manageiq/providers/vmware/cloud_manager/refresh_parser.rb @@ -143,6 +143,7 @@ def parse_vm(vm) :hostname => hostname, :location => uid, :vendor => "vmware", + :connection_state => "connected", :raw_power_state => status, :snapshots => [parse_snapshot(vm)].compact, :cpu_hot_add_enabled => cpu_hot_add, @@ -196,6 +197,7 @@ def parse_image(image, is_public) :name => name, :location => uid, :vendor => "vmware", + :connection_state => "connected", :raw_power_state => "never", :publicly_available => is_public } diff --git a/app/models/manageiq/providers/vmware/cloud_manager/vm.rb b/app/models/manageiq/providers/vmware/cloud_manager/vm.rb index 314764434..813b45caa 100644 --- a/app/models/manageiq/providers/vmware/cloud_manager/vm.rb +++ b/app/models/manageiq/providers/vmware/cloud_manager/vm.rb @@ -27,14 +27,6 @@ def provider_object(connection = nil) "suspended" => "suspended" }.freeze - def disconnected - false - end - - def disconnected? - false - end - def self.calculate_power_state(raw_power_state) # https://github.com/xlab-si/fog-vcloud-director/blob/master/lib/fog/vcloud_director/parsers/compute/vm.rb#L70 POWER_STATES[raw_power_state.to_s] || "terminated" diff --git a/app/models/manageiq/providers/vmware/inventory/parser/cloud_manager.rb b/app/models/manageiq/providers/vmware/inventory/parser/cloud_manager.rb index bf9b0cbc8..acedb4214 100644 --- a/app/models/manageiq/providers/vmware/inventory/parser/cloud_manager.rb +++ b/app/models/manageiq/providers/vmware/inventory/parser/cloud_manager.rb @@ -35,6 +35,7 @@ def vms :hostname => vm[:hostname], :location => vm[:vm].id, :vendor => 'vmware', + :connection_state => "connected", :raw_power_state => vm[:vm].status, :orchestration_stack => persister.orchestration_stacks.lazy_find(vm[:vm].vapp_id), :snapshots => [], @@ -101,6 +102,7 @@ def images :name => image[:image].name, :location => image[:image].id, :vendor => 'vmware', + :connection_state => "connected", :raw_power_state => 'never', :publicly_available => image[:is_published] ) diff --git a/spec/models/manageiq/providers/vmware/cloud_manager/refresher_spec.rb b/spec/models/manageiq/providers/vmware/cloud_manager/refresher_spec.rb index 5f960abf0..21db0ac9c 100644 --- a/spec/models/manageiq/providers/vmware/cloud_manager/refresher_spec.rb +++ b/spec/models/manageiq/providers/vmware/cloud_manager/refresher_spec.rb @@ -176,7 +176,7 @@ def assert_specific_template :tools_status => nil, :boot_time => nil, :standby_action => nil, - :connection_state => nil, + :connection_state => "connected", :cpu_affinity => nil, :memory_reserve => nil, :memory_reserve_expand => nil, @@ -209,7 +209,7 @@ def assert_specific_vm_powered_on :tools_status => nil, :boot_time => nil, :standby_action => nil, - :connection_state => nil, + :connection_state => "connected", :cpu_affinity => nil, :memory_reserve => nil, :memory_reserve_expand => nil, @@ -299,7 +299,7 @@ def assert_specific_vm_powered_off :tools_status => nil, :boot_time => nil, :standby_action => nil, - :connection_state => nil, + :connection_state => "connected", :cpu_affinity => nil, :memory_reserve => nil, :memory_reserve_expand => nil,