Skip to content

Commit

Permalink
add task evm:inventory
Browse files Browse the repository at this point in the history
this outputs general counts for all inventories
  • Loading branch information
kbrock committed Feb 9, 2018
1 parent f0e6634 commit c5e6e55
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,21 @@ def tenant_identity
User.super_admin.tap { |u| u.current_group = tenant.default_miq_group }
end

def self.output_inventory_status
data = includes(:zone)
.select(:id, :zone_id, :name, :total_hosts, :total_vms, :total_clusters)
.map do |ems|
[
ems.region_id, ems.zone.name, ems.name,
ems.total_clusters, ems.total_hosts, ems.total_vms, ems.total_storages
]
end
data = data.sort_by { |e| [e[1], e[2], e[3]] }

header = %w(region zone ems clusters hosts vms storages)
puts data.unshift(header).tableize unless data.empty?
end

private

def build_connection(options = {})
Expand Down
5 changes: 5 additions & 0 deletions lib/tasks/evm.rake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ namespace :evm do
EvmApplication.status(true)
end

desc "Describe inventory of the ManageIQ EVM Application"
task :inventory => :environment do
ExtManagementSystem.output_inventory_status
end

desc "Write a remote region id to this server's REGION file"
task :join_region => :environment do
configured_region = ApplicationRecord.region_number_from_sequence.to_i
Expand Down

0 comments on commit c5e6e55

Please sign in to comment.