class OneviewSDK::API200::IDPool

Id Pool resource implementation

Constants

BASE_URI

Public Instance Methods

allocate_count(pool_type, count) click to toggle source

Allocates a specific amount of IDs from a pool @param [String] pool_type The type of the pool. Values: (ipv4, vmac, vsn, vwwn) @param [Integer] count The amount of IDs to allocate @return [Hash] The list of allocated IDs @note This API cannot be used to allocate IPv4 IDs. Allocation of IPv4 IDs is allowed only at the range level allocator.

# File lib/oneview-sdk/resource/api200/id_pool.rb, line 57
def allocate_count(pool_type, count)
  allocate(pool_type, count: count)
end
allocate_id_list(pool_type, *id_list) click to toggle source

Allocates one or more IDs from a according the amount informed @param [String] pool_type The type of the pool. Values: (ipv4, vmac, vsn, vwwn) @param [Array<String>] id_list The IDs list (or IDs separeted by comma) @return [Hash] The list of allocated IDs @note This API cannot be used to allocate IPv4 IDs. Allocation of IPv4 IDs is allowed only at the range level allocator.

# File lib/oneview-sdk/resource/api200/id_pool.rb, line 48
def allocate_id_list(pool_type, *id_list)
  allocate(pool_type, idList: id_list.flatten)
end
check_range_availability(pool_type, *id_list) click to toggle source

Checks the range availability in the ID pool @param [String] pool_type The type of the pool. Values: (ipv4, vmac, vsn, vwwn) @param [Array<String>] id_list The IDs list (or IDs separeted by comma) @raise [OneviewSDK::IncompleteResource] if the client is not set @return [Hash] The hash with eTag and list of ID's

# File lib/oneview-sdk/resource/api200/id_pool.rb, line 66
def check_range_availability(pool_type, *id_list)
  ensure_client
  return {} if id_list.flatten.empty?
  response = @client.rest_get("#{BASE_URI}/#{pool_type}/checkrangeavailability?idList=#{id_list.flatten.join('&idList=')}")
  @client.response_handler(response)
end
collect_ids(pool_type, *id_list) click to toggle source

Collects one or more IDs to be returned to a pool @param [String] pool_type The type of the pool. Values: (ipv4, vmac, vsn, vwwn) @param [Array<String>] id_list The list of IDs (or IDs separeted by comma) to be collected @raise [OneviewSDK::IncompleteResource] if the client is not set @return [Hash] The list of IDs collected

# File lib/oneview-sdk/resource/api200/id_pool.rb, line 78
def collect_ids(pool_type, *id_list)
  raise IncompleteResource, 'The list of IDs informed is empty.' if id_list.flatten.empty?
  ensure_client
  response = @client.rest_put("#{BASE_URI}/#{pool_type}/collector", 'body' => { 'idList' => id_list.flatten })
  @client.response_handler(response)
end
create(*) click to toggle source

Method is not available @raise [OneviewSDK::MethodUnavailable] method is not available

# File lib/oneview-sdk/resource/api200/id_pool.rb, line 22
def create(*)
  unavailable_method
end
delete(*) click to toggle source

Method is not available @raise [OneviewSDK::MethodUnavailable] method is not available

# File lib/oneview-sdk/resource/api200/id_pool.rb, line 28
def delete(*)
  unavailable_method
end
generate_random_range(pool_type) click to toggle source

Generates and returns a random range @param [String] pool_type The type of the pool. Values: (ipv4, vmac, vsn, vwwn) @raise [OneviewSDK::IncompleteResource] if the client is not set @return [Hash] A random range @note This API is not applicable for the IPv4 IDs.

# File lib/oneview-sdk/resource/api200/id_pool.rb, line 90
def generate_random_range(pool_type)
  ensure_client
  response = @client.rest_get("#{BASE_URI}/#{pool_type}/generate")
  @client.response_handler(response)
end
get_pool(pool_type) click to toggle source

Gets a pool along with the list of ranges present in it. @param [String] pool_type The type of the pool. Values: (ipv4, vmac, vsn, vwwn) @raise [OneviewSDK::IncompleteResource] if the client @return [OneviewSDK::IDPool] The response with IDs list, count and if this is a valid allocator

# File lib/oneview-sdk/resource/api200/id_pool.rb, line 36
def get_pool(pool_type)
  ensure_client
  response = @client.rest_get("#{BASE_URI}/#{pool_type}")
  body = @client.response_handler(response)
  set_all(body)
end
validate_id_list(pool_type, *id_list) click to toggle source

Validates a set of user specified IDs to reserve in the pool @param [String] pool_type The type of the pool. Values: (ipv4, vmac, vsn, vwwn) @param [Array<String>] id_list The list of IDs (or IDs separeted by comma) @raise [OneviewSDK::IncompleteResource] if the client is not set @return [Boolean] Returns true if is valid

# File lib/oneview-sdk/resource/api200/id_pool.rb, line 101
def validate_id_list(pool_type, *id_list)
  ensure_client
  return {} if id_list.flatten.empty?
  response = @client.rest_put("#{BASE_URI}/#{pool_type}/validate", 'body' => { 'idList' => id_list.flatten })
  body = @client.response_handler(response)
  body['valid']
end

Private Instance Methods

allocate(pool_type, params) click to toggle source

Allocates one or more IDs from a pool @param [String] pool_type The type of the pool. Values: (ipv4, vmac, vsn, vwwn) @param [Hash] params The parameters used to allocate IDs @raise [OneviewSDK::IncompleteResource] if the client is not set @return [Hash] The list of allocated IDs @note This API cannot be used to allocate IPv4 IDs. Allocation of IPv4 IDs is allowed only at the range level allocator.

# File lib/oneview-sdk/resource/api200/id_pool.rb, line 117
def allocate(pool_type, params)
  ensure_client
  response = @client.rest_put("#{BASE_URI}/#{pool_type}/allocator", 'body' => params)
  @client.response_handler(response)
end