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

Chargeback without C & U #13884

Merged
merged 7 commits into from
Feb 16, 2017
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: 2 additions & 0 deletions app/models/chargeback/consumption_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def self.for_report(cb_class, options)
yield(consumption) unless consumption.consumed_hours_in_interval.zero?
end

next unless options.include_metrics?

records = base_rollup.where(:timestamp => query_start_time...query_end_time, :capture_interval_name => 'hourly')
records = cb_class.where_clause(records, options)
records = Metric::Helper.remove_duplicate_timestamps(records)
Expand Down
6 changes: 6 additions & 0 deletions app/models/chargeback/report_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ class Chargeback
:groupby_tag,
:userid,
:ext_options,
:include_metrics, # enable charging allocated resources with C & U
) do
def self.new_from_h(hash)
new(*hash.values_at(*members))
end

# include_metrics = nil is default value(true)
def include_metrics?
include_metrics.nil? || include_metrics
end

def initialize(*)
super
self.interval ||= 'daily'
Expand Down
5 changes: 3 additions & 2 deletions app/models/chargeback_vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ def self.where_clause(records, options)
end

def self.extra_resources_without_rollups
# support hyper-v for which we do not collect metrics yet
scope = ManageIQ::Providers::Microsoft::InfraManager::Vm
# support hyper-v for which we do not collect metrics yet (also when we are including metrics in calculations)
scope = @options.include_metrics? ? ManageIQ::Providers::Microsoft::InfraManager::Vm : vms
Copy link
Member

Choose a reason for hiding this comment

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

aside: we need to get this class reference out of here.

scope = scope.eager_load(:hardware, :taggings, :tags, :host, :ems_cluster, :storage, :ext_management_system,
:tenant)

if @options[:tag] && (@report_user.nil? || !@report_user.self_service?)
scope.find_tagged_with(:any => @options[:tag], :ns => '*')
else
Expand Down
Loading