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::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!, #each, #eql?, #exists?, find_by, find_with_pagination, from_file, get_all, #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



58
59
60
# File 'lib/oneview-sdk/resource/api200/id_pool.rb', line 58

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



49
50
51
# File 'lib/oneview-sdk/resource/api200/id_pool.rb', line 49

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:



67
68
69
70
71
# File 'lib/oneview-sdk/resource/api200/id_pool.rb', line 67

def check_range_availability(pool_type, *id_list)
  ensure_client
  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
# File 'lib/oneview-sdk/resource/api200/id_pool.rb', line 78

def collect_ids(pool_type, *id_list)
  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:



89
90
91
92
93
# File 'lib/oneview-sdk/resource/api200/id_pool.rb', line 89

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::API200::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:

Raises:



36
37
38
39
40
41
42
# 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)
  self
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:



100
101
102
103
104
105
# File 'lib/oneview-sdk/resource/api200/id_pool.rb', line 100

def validate_id_list(pool_type, *id_list)
  ensure_client
  response = @client.rest_put("#{BASE_URI}/#{pool_type}/validate", 'body' => { 'idList' => id_list.flatten })
  body = @client.response_handler(response)
  body['valid']
end