Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add quick_stats support for RHEVM host #10505

Merged
merged 1 commit into from
Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ def set_custom_field(attribute, value)

def quickStats
return @qs if @qs
return {} unless is_vmware?
return {} unless supports_quick_stats?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, these are the nice one line changes that make me happy :)

cc @blomquisg @agrare

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


begin
raise _("Host has no EMS, unable to get host statistics") unless ext_management_system
Expand Down
13 changes: 13 additions & 0 deletions app/models/manageiq/providers/redhat/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ def self.event_monitor_class
self::EventCatcher
end

def host_quick_stats(host)
qs = {}
with_provider_connection(:version => 4) do |connection|
stats_list = connection.system_service.hosts_service.host_service(host.uid_ems)
.statistics_service.list
qs["overallMemoryUsage"] = stats_list.detect { |x| x.name == "memory.used" }
.values.first.datum
qs["overallCpuUsage"] = stats_list.detect { |x| x.name == "cpu.load.avg.5m" }
.values.first.datum
end
qs
end

def self.provision_class(via)
case via
when "iso" then self::ProvisionViaIso
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def api3_supported_features
end

def api4_supported_features
[:snapshots]
[:quick_stats, :snapshots]
end

def api_features
Expand Down
6 changes: 6 additions & 0 deletions app/models/manageiq/providers/redhat/infra_manager/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ def verify_credentials(auth_type = nil, options = {})

true
end

supports :quick_stats do
unless ext_management_system.supports_quick_stats?
unsupported_reason_add(:quick_stats, 'RHV API version does not support quick_stats')
end
end
end
2 changes: 2 additions & 0 deletions app/models/manageiq/providers/vmware/infra_manager/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ def reserve_next_available_vnc_port
port
end
end

supports :quick_stats
end
2 changes: 2 additions & 0 deletions app/models/manageiq/providers/vmware/infra_manager/vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ def cloneable?
def supports_snapshots?
true
end

supports :quick_stats
end
1 change: 1 addition & 0 deletions app/models/mixins/supports_feature_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ module SupportsFeatureMixin
:live_migrate => 'Live Migration',
:migrate => 'Migration',
:provisioning => 'Provisioning',
:quick_stats => 'Quick Stats',
:reboot_guest => 'Reboot Guest Operation',
:reconfigure => 'Reconfiguration',
:refresh_network_interfaces => 'Refresh Network Interfaces for a Host',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
describe ManageIQ::Providers::Redhat::InfraManager::Host do
require 'ovirtsdk4'
describe '#quickStats' do
let(:ems) { FactoryGirl.create(:ems_redhat_with_authentication) }
subject { FactoryGirl.create(:host_redhat, :ems_id => ems.id) }
before(:each) do
allow_any_instance_of(ManageIQ::Providers::Redhat::InfraManager)
.to receive(:supported_api_versions).and_return([4])
end
it '.supports_quick_stats?' do
expect(subject.supports_quick_stats?).to be true
end

it 'calls list on StatisticsService' do
expect_any_instance_of(OvirtSDK4::StatisticsService).to receive(:list)
subject.quickStats
end
end
end