<commit_before>module Solusvm
  # Solusvm::Node is the class for working with nodes.
  class Node < Base

    # Lists existing nodes of a given type.
    #
    # Parameters:
    #
    # * +type+ - a valid virtualization type; e.g: [openvz|xen|xen hvm|kvm]
    def list(type)
      validate_server_type(type) do
        perform_request(:action => 'listnodes', :type => type)
        parse_returned_params_as_list('nodes')
      end
    end

    # Lists existing nodes ids of a given type.
    #
    # Parameters:
    #
    # * +type+ - a valid virtualization type; e.g: [openvz|xen|xen hvm|kvm]
    def ids(type)
      validate_server_type(type) do
        perform_request(:action => 'node-idlist', :type => type)
        returned_parameters['nodes'].split(',')
      end
    end

    # Retrieves statistics from a specific node.
    def statistics(nodeid)
      perform_request(:action => 'node-statistics', :nodeid => nodeid)
      returned_parameters
    end

    # Retrieves available xen resources from a specific node.
    def xenresources(nodeid)
      perform_request(:action => 'node-xenresources', :nodeid => nodeid)
      returned_parameters
    end

    # Retrieves a list of available IPs for a specific node.
    def available_ips(nodeid)
      perform_request(:action => 'node-iplist', :nodeid => nodeid)
      if statusmsg.match /no available ip/i
        []
      else
        returned_parameters['ips'].split(',')
      end
    end

    # Lists virtual servers from a specific node.
    def virtualservers(nodeid)
      perform_request({:action => "node-virtualservers", :nodeid => nodeid}, "virtualserver")

      if returned_parameters["virtualservers"] && returned_parameters["virtualservers"]["virtualserver"]
        returned_parameters["virtualservers"]["virtualserver"]
      elsif returned_parameters["virtualservers"]
        []
      end
    end
  end
end<commit_msg>Use the existing parse_returned_params_as_list method to avoid raising exceptions if the attribute is undefined.<commit_after>module Solusvm
  # Solusvm::Node is the class for working with nodes.
  class Node < Base

    # Lists existing nodes of a given type.
    #
    # Parameters:
    #
    # * +type+ - a valid virtualization type; e.g: [openvz|xen|xen hvm|kvm]
    def list(type)
      validate_server_type(type) do
        perform_request(:action => 'listnodes', :type => type)
        parse_returned_params_as_list('nodes')
      end
    end

    # Lists existing nodes ids of a given type.
    #
    # Parameters:
    #
    # * +type+ - a valid virtualization type; e.g: [openvz|xen|xen hvm|kvm]
    def ids(type)
      validate_server_type(type) do
        perform_request(:action => 'node-idlist', :type => type)
        parse_returned_params_as_list('nodes')
      end
    end

    # Retrieves statistics from a specific node.
    def statistics(nodeid)
      perform_request(:action => 'node-statistics', :nodeid => nodeid)
      returned_parameters
    end

    # Retrieves available xen resources from a specific node.
    def xenresources(nodeid)
      perform_request(:action => 'node-xenresources', :nodeid => nodeid)
      returned_parameters
    end

    # Retrieves a list of available IPs for a specific node.
    def available_ips(nodeid)
      perform_request(:action => 'node-iplist', :nodeid => nodeid)
      if statusmsg.match /no available ip/i
        []
      else
        parse_returned_params_as_list('ips')
      end
    end

    # Lists virtual servers from a specific node.
    def virtualservers(nodeid)
      perform_request({:action => "node-virtualservers", :nodeid => nodeid}, "virtualserver")

      if returned_parameters["virtualservers"] && returned_parameters["virtualservers"]["virtualserver"]
        returned_parameters["virtualservers"]["virtualserver"]
      elsif returned_parameters["virtualservers"]
        []
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10167310167310167, 'fraction_numerical': 0.0, 'mean_word_length': 3.0020597322348093, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6569848', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1160, 'n_words': 306}