class SISFC::Configuration

Attributes

filename[RW]

Public Class Methods

load_from_file(filename) click to toggle source
# File lib/sisfc/configuration.rb, line 109
def self.load_from_file(filename)
  # allow filename, string, and IO objects as input
  raise ArgumentError, "File #{filename} does not exist!" unless File.exists?(filename)

  # create configuration object
  conf = Configuration.new(filename)

  # take the file content and pass it to instance_eval
  conf.instance_eval(File.new(filename, 'r').read)

  # validate and finalize configuration
  conf.validate

  # return new object
  conf
end
new(filename) click to toggle source
# File lib/sisfc/configuration.rb, line 70
def initialize(filename)
  @filename = filename
end

Public Instance Methods

end_time() click to toggle source
# File lib/sisfc/configuration.rb, line 74
def end_time
  @start_time + @duration
end
validate() click to toggle source
# File lib/sisfc/configuration.rb, line 78
def validate
  # convert datetimes and integers into floats
  @start_time      = @start_time.to_f
  @duration        = @duration.to_f
  @warmup_duration = @warmup_duration.to_f

  # initialize kpi_customization to empty hash if needed
  @kpi_customization ||= {}

  # TODO: might want to restrict this substitution only to the :filename
  # and :command keys
  @request_generation.each do |k,v|
    v = v.gsub('<pwd>', File.expand_path(File.dirname(@filename)))
  end

  # freeze everything!
  IceNine.deep_freeze(@constraints)
  IceNine.deep_freeze(@customers)
  IceNine.deep_freeze(@custom_stats)
  IceNine.deep_freeze(@data_centers)
  IceNine.deep_freeze(@duration)
  IceNine.deep_freeze(@evaluation)
  IceNine.deep_freeze(@kpi_customization)
  IceNine.deep_freeze(@latency_models)
  IceNine.deep_freeze(@request_generation)
  IceNine.deep_freeze(@service_component_types)
  IceNine.deep_freeze(@start_time)
  IceNine.deep_freeze(@warmup_duration)
  IceNine.deep_freeze(@workflow_types)
end