Created
August 1, 2017 07:04
-
-
Save Ladas/046084154188176661ec15dda7b488b4 to your computer and use it in GitHub Desktop.
Count ovirt records, run as: bundle exec rails r ovirt_count_records.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
classes = [ | |
ManageIQ::Providers::Redhat::InfraManager, | |
EmsFolder, | |
EmsCluster, | |
ResourcePool, | |
Host, | |
Vm, | |
Relationship, | |
Storage, | |
MiqEventDefinition, | |
OperatingSystem, | |
Switch, | |
HostSwitch, | |
Lan, | |
Hardware, | |
GuestDevice, | |
Network, | |
VmOrTemplate, | |
User, | |
ExtManagementSystem, | |
Tenant, | |
MiqGroup, | |
Disk, | |
CustomAttribute, | |
Snapshot, | |
] | |
total = 0 | |
classes.each do |k| | |
total += k.count | |
end | |
puts "------------- sorted by counts ------------" | |
sorted = {} | |
classes.each do |k| | |
sorted[k] = k.count | |
end | |
sorted.sort_by { |_key, value| value }.reverse.to_h.each do |k, v| | |
puts "#{k.name}: #{k.count}" | |
end | |
puts "-------------------------------------------" | |
puts "Total: #{total} records" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment