core/rails/app/controllers/nodes_controller.rb
# Get the addresses allocated to a node on a network.
Get the addresses allocated to a node on a network.
Get the addresses allocated to a node on a network .
def addresses
    if params[:network]
      res = {}
      model.transaction do
        @node = find_key_cap(model, params[:node_id], cap("READ"))
        @net = find_key_cap(Network, params[:network], cap("READ","NETWORK"))
        res = {
          "node" => @node.name,
          "network" => @net.name,
          "category" => @net.category,
          "addresses" => @net.node_allocations(@node).map{|a|a.to_s}
        }
      end
      render :json => res, :content_type=>cb_content_type(:addresses, "object")
      return
    end
    res = []
    model.transaction do
      nets = if params[:category]
               visible(Network,cap("READ","NETWORK")).in_category(params[:category])
             else
               visible(Network,cap("READ","NETWORK"))
             end
      nets.each do |n|
        ips = n.node_allocations(@node)
        next if ips.empty?
        res << {
          "node" => @node.name,
          "network" => n.name,
          "category" => n.category,
        "addresses" => ips.map{|a|a.to_s}
        }
      end
    end
    render :json => res, :content_type=>cb_content_type(:addresses, "array")
  end
def addresses if params [ :network ] res = { } model . transaction do @node = find_key_cap ( model , params [ :node_id ] , cap ( "READ" ) ) @net = find_key_cap ( Network , params [ :network ] , cap ( "READ" , "NETWORK" ) ) res = { "node" => @node . name , "network" => @net . name , "category" => @net . category , "addresses" => @net . node_allocations ( @node ) . map { | a | a . to_s } } end render :json => res , :content_type => cb_content_type ( :addresses , "object" ) return end res = [ ] model . transaction do nets = if params [ :category ] visible ( Network , cap ( "READ" , "NETWORK" ) ) . in_category ( params [ :category ] ) else visible ( Network , cap ( "READ" , "NETWORK" ) ) end nets . each do | n | ips = n . node_allocations ( @node ) next if ips . empty? res << { "node" => @node . name , "network" => n . name , "category" => n . category , "addresses" => ips . map { | a | a . to_s } } end end render :json => res , :content_type => cb_content_type ( :addresses , "array" ) end
Get the addresses allocated to a node on a network.
Get the addresses allocated to a node on a network .