Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Archived Openstack instances #5410

Merged
merged 4 commits into from Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions app/controllers/vm_common.rb
Expand Up @@ -1471,6 +1471,10 @@ def get_node_info(treenodeid)
else
rec = TreeBuilder.get_model_for_prefix(@nodetype).constantize.find(from_cid(id))
options.merge!({:association => "#{@nodetype == "az" ? "vms" : "all_vms_and_templates"}", :parent => rec})
options[:where_clause] = MiqExpression.merge_where_clauses(
options[:where_clause],
"NOT #{VmOrTemplate::ARCHIVED_CONDITIONS} OR #{VmOrTemplate::ORPHANED_CONDITIONS}"
)
process_show_list(options)
model_name = @nodetype == "d" ? "Datacenter" : ui_lookup(:model => rec.class.base_class.to_s)
@is_redhat = case model_name
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.reject { |obj| obj.archived? || obj.orphaned? }
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
6 changes: 6 additions & 0 deletions spec/models/miq_report_spec.rb
Expand Up @@ -136,7 +136,10 @@ def invoke_ae
it "filters vms in folders" do
host = FactoryGirl.create(:host)
vm1 = FactoryGirl.create(:vm_vmware, :host => host)
allow(vm1).to receive(:archived?).and_return(false)
vm2 = FactoryGirl.create(:vm_vmware, :host => host)
allow(vm2).to receive(:archived?).and_return(false)
allow(Vm).to receive(:find_by).and_return(vm1)

root = FactoryGirl.create(:ems_folder, :name => "datacenters")
root.parent = host
Expand Down Expand Up @@ -191,7 +194,10 @@ def invoke_ae

host2 = FactoryGirl.create(:host)
vmb = FactoryGirl.create(:vm_vmware, :host => host2, :name => "b")
allow(vmb).to receive(:archived?).and_return(false)
vmc = FactoryGirl.create(:vm_vmware, :host => host2, :name => "c")
allow(vmc).to receive(:archived?).and_return(false)
allow(Vm).to receive(:find_by).and_return(vmb)

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