app/controllers/resource_pool_controller.rb
# Build the tree object to display the resource_pool datacenter info
Build the tree object to display the resource_pool datacenter info
Build the tree object to display the resource_pool datacenter info
def build_dc_tree
    @sb[:tree_hosts_hash] = {} 
    @sb[:tree_vms_hash]   = {} 
    @sb[:rp_id] = @record.id if @record 
    unless @record
      @record = ResourcePool.find(@sb[:rp_id])
    end
    rp_node = TreeNodeBuilder.generic_tree_node(
      "resource_pool-#{to_cid(@record.id)}",
      @record.name,
      @record.vapp ? "vapp.png" : "resource_pool.png",
      _("Resource Pool: %{name}") % {:name => @record.name},
      :cfme_no_click => true,
      :expand        => true,
      :style_class   => "cfme-no-cursor-node"
    )
    rp_kids = []
    @sb[:vat] = false if params[:action] != "treesize"        
    vat = params[:vat] ? true : (@sb[:vat] ? true : false)    
    @sb[:open_tree_nodes] = [] if params[:action] != "treesize"
    @record.resource_pools.each do |rp|   
      rp_kids += get_dc_node(rp, rp_node[:key], vat)
    end
    @record.vms.each do |v|               
      rp_kids += get_dc_node(v, rp_node[:key], vat)
    end
    rp_node[:children] = rp_kids unless rp_kids.empty?
    session[:dc_tree]    = [rp_node].to_json
    session[:tree]       = "dc"
    session[:tree_name]  = "rp_dc_tree"
  end
def build_dc_tree @sb [ :tree_hosts_hash ] = { } @sb [ :tree_vms_hash ] = { } @sb [ :rp_id ] = @record . id if @record unless @record @record = ResourcePool . find ( @sb [ :rp_id ] ) end rp_node = TreeNodeBuilder . generic_tree_node ( "resource_pool-#{to_cid(@record.id)}" , @record . name , @record . vapp ? "vapp.png" : "resource_pool.png" , _ ( "Resource Pool: %{name}" ) % { :name => @record . name } , :cfme_no_click => true , :expand => true , :style_class => "cfme-no-cursor-node" ) rp_kids = [ ] @sb [ :vat ] = false if params [ :action ] != "treesize" vat = params [ :vat ] ? true : ( @sb [ :vat ] ? true : false ) @sb [ :open_tree_nodes ] = [ ] if params [ :action ] != "treesize" @record . resource_pools . each do | rp | rp_kids += get_dc_node ( rp , rp_node [ :key ] , vat ) end @record . vms . each do | v | rp_kids += get_dc_node ( v , rp_node [ :key ] , vat ) end rp_node [ :children ] = rp_kids unless rp_kids . empty? session [ :dc_tree ] = [ rp_node ] . to_json session [ :tree ] = "dc" session [ :tree_name ] = "rp_dc_tree" end
Build the tree object to display the resource_pool datacenter info
Build the tree object to display the resource_pool datacenter info
# Capture all Host ids in the tree # Capture all VM ids in the tree # do not want to store ems object in session hash, need to get record incase coming from treesize to rebuild refreshed tree # need to set this, to remember vat, treesize doesnt pass in param[:vat] # use @sb[:vat] when coming from treesize # Get the resource pool nodes # Get VMs