Class: SISFC::Evaluator
- Inherits:
-
Object
- Object
- SISFC::Evaluator
- Includes:
- Logging
- Defined in:
- lib/sisfc/evaluation.rb
Instance Method Summary collapse
- #evaluate_business_impact(all_kpis, per_workflow_and_customer_kpis, vm_allocation) ⇒ Object
-
#initialize(conf) ⇒ Evaluator
constructor
A new instance of Evaluator.
Methods included from Logging
Constructor Details
#initialize(conf) ⇒ Evaluator
Returns a new instance of Evaluator.
10 11 12 13 14 15 16 17 |
# File 'lib/sisfc/evaluation.rb', line 10 def initialize(conf) @vm_hourly_cost = conf.evaluation[:vm_hourly_cost] raise ArgumentError, 'No VM hourly costs provided!' unless @vm_hourly_cost @fixed_hourly_cost = conf.evaluation[:fixed_hourly_cost] || {} @penalties_func = conf.evaluation[:penalties] end |
Instance Method Details
#evaluate_business_impact(all_kpis, per_workflow_and_customer_kpis, vm_allocation) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sisfc/evaluation.rb', line 19 def evaluate_business_impact(all_kpis, per_workflow_and_customer_kpis, vm_allocation) # evaluate variable hourly costs related to VM allocation cost = vm_allocation.inject(0.0) do |s,x| hc = @vm_hourly_cost.find{|i| i[:data_center] == x[:dc_id] and i[:vm_type] == x[:vm_size] } raise "Cannot find hourly cost for data center #{x[:dc_id]} and VM size #{x[:vm_size]}!" unless hc s += x[:vm_num] * hc[:cost] end # evaluate fixed hourly costs (for private Cloud data centers) @fixed_hourly_cost.values.each do |fixed_cost| cost += fixed_cost end # calculate daily cost cost *= 24.0 # consider SLO violation penalties penalties = (@penalties_func.nil? ? 0.0 : (@penalties_func.call(all_kpis, per_workflow_and_customer_kpis) or 0.0)) { it_cost: cost, penalties: penalties } end |