Sha256: 9633f0352e630a7708b46807c115a2eea87226b7a9c28363092192c1256b4393

Contents?: true

Size: 1.78 KB

Versions: 3

Compression:

Stored size: 1.78 KB

Contents

ServerType.class_eval do
  data_miner do
    schema Earth.database_options do
      string 'name'
      string 'data_center_company_name'
      float  'cpu'
      string 'cpu_units'
      float  'memory'
      string 'memory_units'
      float  'electricity_draw'
      string 'electricity_draw_units'
    end
    
    import "a list of server types and their characteristics",
           :url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdGExaW1ic2c0d2s1ZmpzeUdOa2kyRlE&hl=en&single=true&gid=0&output=csv' do
      key   'name'
      store 'data_center_company_name'
      store 'cpu',              :units_field_name => 'cpu_units'
      store 'memory',           :units_field_name => 'memory_units'
      store 'electricity_draw', :units_field_name => 'electricity_draw_units'
    end
    
    # FIXME TODO verify that data center company name appears in data_center_companies
    
    verify "Data center company name should never be missing" do
      ServerType.all.each do |server|
        if server.data_center_company_name.nil?
          raise "Invalid data center company name for ServerType #{server.name}: #{server.data_center_company_name}"
        end
      end
    end
    
    verify "Electricity draw should be more than zero" do
      ServerType.all.each do |server|
        unless server.electricity_draw > 0
          raise "Invalid electricity draw for ServerType #{server.name}: #{server.electricity_draw} (should be > 0)"
        end
      end
    end
    
    verify "Electricity draw units should be kilowatts" do
      ServerType.all.each do |server|
        unless server.electricity_draw_units == 'kilowatts'
          raise "Invalid electricity draw units for ServerType #{server.name}: #{server.electricity_draw_units} (should be kilowatts)"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
earth-0.3.15 lib/earth/computation/server_type/data_miner.rb
earth-0.3.14 lib/earth/computation/server_type/data_miner.rb
earth-0.3.13 lib/earth/computation/server_type/data_miner.rb