Class: CloudCostTracker::Billing::Compute::AWS::VolumeBillingPolicy

Inherits:
ResourceBillingPolicy show all
Defined in:
lib/cloud_cost_tracker/billing/compute/aws/volumes.rb

Overview

The default billing policy for Amazon EBS Volumes

Constant Summary collapse

CENTS_PER_GB_PER_MONTH =

The YAML pricing data is read from config/billing

YAML.load(File.read File.join(
CONSTANTS_DIR, 'compute-aws-volumes.yml'))

Constants included from CloudCostTracker

VERSION

Instance Method Summary collapse

Methods inherited from ResourceBillingPolicy

#initialize, #setup, #write_billing_record_for

Methods included from CloudCostTracker

account_coding_class, connect_to_database, create_billing_agents, create_coding_agents, env, read_accounts

Constructor Details

This class inherits a constructor from CloudCostTracker::Billing::ResourceBillingPolicy

Instance Method Details

#billing_typeObject



24
# File 'lib/cloud_cost_tracker/billing/compute/aws/volumes.rb', line 24

def billing_type ; "EBS volume storage" end

#get_cost_for_duration(volume, duration) ⇒ Object

Returns the storage cost for a given EBS Volume over some duration (in seconds)



13
14
15
16
17
# File 'lib/cloud_cost_tracker/billing/compute/aws/volumes.rb', line 13

def get_cost_for_duration(volume, duration)
  return 0.0 if volume.state =~ /(deleting|deleted)/
  CENTS_PER_GB_PER_MONTH[zone(volume)] * volume.size *
  duration / SECONDS_PER_MONTH
end

#zone(resource) ⇒ Object

Chops the availability zone letter from the region



20
21
22
# File 'lib/cloud_cost_tracker/billing/compute/aws/volumes.rb', line 20

def zone(resource)
  resource.availability_zone.chop
end