Skip to content

Commit

Permalink
Archived Openstack instances only in "Archived" tree
Browse files Browse the repository at this point in the history
  • Loading branch information
romanblanco committed Mar 7, 2016
1 parent 1d801be commit c7e2540
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -141,8 +141,8 @@ def change_tab

def build_targets_hash(items, typ = true)
@targets_hash ||= {}
# if array of objects came in
if typ
# if array of objects came in
items.each do |item|
@targets_hash[item.id.to_i] = item
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/miq_report/search.rb
Expand Up @@ -100,6 +100,8 @@ def paged_view_search(options = {})

if options[:parent]
targets = get_parent_targets(options[:parent], options[:association] || options[:parent_method])
# filter out archived VMs
targets = targets.select { |target| !Vm.find_by(:id => target).archived? unless Vm.find_by(:id => target).nil? }
if targets.empty?
search_results, attrs = [targets, {:auth_count => 0, :total_count => 0}]
else
Expand Down
4 changes: 0 additions & 4 deletions app/presenters/tree_builder.rb
Expand Up @@ -404,10 +404,6 @@ def x_build_node(object, pid, options) # Called with object, tree node parent
((object.kind_of?(MiqServer) && MiqServer.my_server(true).id == object.id) ||
(object.kind_of?(Zone) && MiqServer.my_server(true).my_zone == object.name))

# # open nodes to show selected automate entry point
# x_tree[:open_nodes] = @temp[:open_nodes].dup if @temp && @temp[:open_nodes]
# x_tree[:open_nodes] = @open_nodes.dup if @open_nodes

node = x_build_single_node(object, pid, options)

if [:policy_profile_tree, :policy_tree].include?(options[:tree])
Expand Down
1 change: 1 addition & 0 deletions app/presenters/tree_builder_instances.rb
Expand Up @@ -33,6 +33,7 @@ def x_get_tree_ems_kids(object, count_only)
# Get AvailabilityZone children count/array
def x_get_tree_az_kids(object, count_only)
objects = rbac_filtered_objects(object.vms.order("name"))
objects = objects.select { |obj| !obj.archived? }
count_only ? objects.length : objects
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_x_gtl.html.haml
Expand Up @@ -5,7 +5,7 @@

#gtl_div
- view ||= @view
- table = view.sub_table ? view.sub_table : view.table unless view.nil?
- table = view.sub_table ? view.sub_table : view.table unless view.nil?
- action_url ||= "explorer"
- @gtl_type = "grid" if @gtl_type.nil?
- if view.nil? || table.data.length == 0
Expand Down
2 changes: 2 additions & 0 deletions spec/models/miq_report_spec.rb
Expand Up @@ -191,7 +191,9 @@ def invoke_ae

host2 = FactoryGirl.create(:host)
vmb = FactoryGirl.create(:vm_vmware, :host => host2, :name => "b")
vmb.stub(:archived?) { false }
vmc = FactoryGirl.create(:vm_vmware, :host => host2, :name => "c")
vmc.stub(:archived?) { false }

report = MiqReport.new(:db => "Vm", :sortby => "name", :order => "Descending")
results, = report.paged_view_search(
Expand Down

0 comments on commit c7e2540

Please sign in to comment.