Skip to content

Commit

Permalink
Include as datastore also CloudVolume for selecting proper rate
Browse files Browse the repository at this point in the history
tag_class is overwritten on ChargebackRate
  • Loading branch information
lpichler committed Dec 12, 2017
1 parent 9da6220 commit 3c942a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/models/chargeback_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class ChargebackRate < ApplicationRecord
scope :with_rate_type, ->(rate_type) { where(:rate_type => rate_type) }

VALID_CB_RATE_TYPES = ["Compute", "Storage"]
DATASTORE_MAPPING = {'CloudVolume' => 'Storage'}.freeze

def self.tag_class(klass)
klass = ChargebackRate::DATASTORE_MAPPING[klass] || klass
super(klass)
end

def rate_details_relevant_to(report_cols)
# we can memoize, as we get the same report_cols thrrough the life of the object
Expand Down
4 changes: 2 additions & 2 deletions app/models/metric/chargeback_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def tag_list_with_prefix
def resource_parents
[parent_host || resource.try(:host),
parent_ems_cluster || resource.try(:ems_cluster),
parent_storage || resource.try(:storage),
parent_storage || resource.try(:storage) || resource.try(:cloud_volumes),
parent_ems || resource.try(:ext_management_system),
resource.try(:tenant)
].compact
].flatten.compact
end

def parents_determining_rate
Expand Down

0 comments on commit 3c942a4

Please sign in to comment.