app/controllers/ems_cluster_controller.rb
# Build the tree object to display the ems_cluster datacenter info
Build the tree object to display the ems_cluster datacenter info
Build the tree object to display the ems_cluster datacenter info
def build_dc_tree
    @sb[:tree_hosts]    = []                    
    @sb[:tree_vms_hash] = {}                    
    @sb[:cl_id] = @ems_cluster.id if @ems_cluster   
    unless @ems_cluster
      @ems_cluster = EmsCluster.find(@sb[:cl_id])
    end
    cluster_node = TreeNodeBuilder.generic_tree_node(
      "cluster-#{to_cid(@ems_cluster.id)}",
      @ems_cluster.name,
      "cluster.png",
      _("Cluster: %{name}") % {:name => @ems_cluster.name},
      :cfme_no_click => true,
      :expand        => true,
      :style_class   => "cfme-no-cursor-node"
    )
    cl_kids = []
    @sb[:vat] = false if params[:action] != "treesize"        
    vat = params[:vat] ? true : (@sb[:vat] ? true : false)    
    @sb[:open_tree_nodes] = [] if params[:action] != "treesize"
    @ems_cluster.hosts.each do |h|                  
      cl_kids += get_dc_node(h, cluster_node[:key], vat)
    end
    @ems_cluster.resource_pools.each do |rp|        
      cl_kids += get_dc_node(rp, cluster_node[:key], vat)
    end
    @ems_cluster.vms.each do |v|                    
      cl_kids += get_dc_node(v, cluster_node[:key], vat)
    end
    cluster_node[:children] = cl_kids unless cl_kids.empty?
    session[:dc_tree] = [cluster_node].to_json
    session[:tree] = "dc"
    session[:tree_name] = "cluster_dc_tree"
  end
def build_dc_tree @sb [ :tree_hosts ] = [ ] @sb [ :tree_vms_hash ] = { } @sb [ :cl_id ] = @ems_cluster . id if @ems_cluster unless @ems_cluster @ems_cluster = EmsCluster . find ( @sb [ :cl_id ] ) end cluster_node = TreeNodeBuilder . generic_tree_node ( "cluster-#{to_cid(@ems_cluster.id)}" , @ems_cluster . name , "cluster.png" , _ ( "Cluster: %{name}" ) % { :name => @ems_cluster . name } , :cfme_no_click => true , :expand => true , :style_class => "cfme-no-cursor-node" ) cl_kids = [ ] @sb [ :vat ] = false if params [ :action ] != "treesize" vat = params [ :vat ] ? true : ( @sb [ :vat ] ? true : false ) @sb [ :open_tree_nodes ] = [ ] if params [ :action ] != "treesize" @ems_cluster . hosts . each do | h | cl_kids += get_dc_node ( h , cluster_node [ :key ] , vat ) end @ems_cluster . resource_pools . each do | rp | cl_kids += get_dc_node ( rp , cluster_node [ :key ] , vat ) end @ems_cluster . vms . each do | v | cl_kids += get_dc_node ( v , cluster_node [ :key ] , vat ) end cluster_node [ :children ] = cl_kids unless cl_kids . empty? session [ :dc_tree ] = [ cluster_node ] . to_json session [ :tree ] = "dc" session [ :tree_name ] = "cluster_dc_tree" end
Build the tree object to display the ems_cluster datacenter info
Build the tree object to display the ems_cluster datacenter info
# Capture all Host ids in the tree # Capture all VM ids in the tree # do not want to store cl 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 hosts # Get the resource pool nodes # Get VMs