Class: OneviewSDK::API200::IDPool

Inherits:
Resource
  • Object
show all
Defined in:
lib/oneview-sdk/resource/api200/id_pool.rb

Overview

Id Pool resource implementation

Constant Summary collapse

BASE_URI =
'/rest/id-pools'.freeze

Constants inherited from Resource

Resource::DEFAULT_REQUEST_HEADER, Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #[]=, build_query, #create!, #deep_merge!, #each, #eql?, #exists?, find_by, find_with_pagination, from_file, get_all, get_all_with_query, #initialize, #like?, #refresh, #retrieve!, #schema, schema, #set, #set_all, #to_file, #update

Constructor Details

This class inherits a constructor from OneviewSDK::Resource

Instance Method Details

#allocate_count(pool_type, count) ⇒ Hash

Note:

This API cannot be used to allocate IPv4 IDs. Allocation of IPv4 IDs is allowed only at the range level allocator.

Allocates a specific amount of IDs from a pool

Parameters:

  • pool_type (String)

    The type of the pool. Values: (ipv4, vmac, vsn, vwwn)

  • count (Integer)

    The amount of IDs to allocate

Returns:

  • (Hash)

    The list of allocated IDs



57
58
59
# 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) ⇒ Hash

Note:

This API cannot be used to allocate IPv4 IDs. Allocation of IPv4 IDs is allowed only at the range level allocator.

Allocates one or more IDs from a according the amount informed

Parameters:

  • pool_type (String)

    The type of the pool. Values: (ipv4, vmac, vsn, vwwn)

  • id_list (Array<String>)

    The IDs list (or IDs separeted by comma)

Returns:

  • (Hash)

    The list of allocated IDs



48
49
50
# 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) ⇒ Hash

Checks the range availability in the ID pool

Parameters:

  • pool_type (String)

    The type of the pool. Values: (ipv4, vmac, vsn, vwwn)

  • id_list (Array<String>)

    The IDs list (or IDs separeted by comma)

Returns:

  • (Hash)

    The hash with eTag and list of ID’s

Raises:



66
67
68
69
70
71
# 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) ⇒ Hash

Collects one or more IDs to be returned to a pool

Parameters:

  • pool_type (String)

    The type of the pool. Values: (ipv4, vmac, vsn, vwwn)

  • id_list (Array<String>)

    The list of IDs (or IDs separeted by comma) to be collected

Returns:

  • (Hash)

    The list of IDs collected

Raises:



78
79
80
81
82
83
# 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

#createObject

Method is not available

Raises:



22
23
24
# File 'lib/oneview-sdk/resource/api200/id_pool.rb', line 22

def create(*)
  unavailable_method
end

#deleteObject

Method is not available

Raises:



28
29
30
# File 'lib/oneview-sdk/resource/api200/id_pool.rb', line 28

def delete(*)
  unavailable_method
end

#generate_random_range(pool_type) ⇒ Hash

Note:

This API is not applicable for the IPv4 IDs.

Generates and returns a random range

Parameters:

  • pool_type (String)

    The type of the pool. Values: (ipv4, vmac, vsn, vwwn)

Returns:

  • (Hash)

    A random range

Raises:



90
91
92
93
94
# 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) ⇒ OneviewSDK::IDPool

Gets a pool along with the list of ranges present in it.

Parameters:

  • pool_type (String)

    The type of the pool. Values: (ipv4, vmac, vsn, vwwn)

Returns:

  • (OneviewSDK::IDPool)

    The response with IDs list, count and if this is a valid allocator

Raises:



36
37
38
39
40
41
# 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) ⇒ Boolean

Validates a set of user specified IDs to reserve in the pool

Parameters:

  • pool_type (String)

    The type of the pool. Values: (ipv4, vmac, vsn, vwwn)

  • id_list (Array<String>)

    The list of IDs (or IDs separeted by comma)

Returns:

  • (Boolean)

    Returns true if is valid

Raises:



101
102
103
104
105
106
107
# 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