Class: UU::OperationRegistry::ResourcePool

Inherits:
BaseMethods
  • Object
show all
Defined in:
lib/uu/operation_registry/resource_pool.rb

Overview

Resource pool.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session = nil) ⇒ ResourcePool

Creates a new instance of Resource pool.

Parameters:

  • session (UU::OS::Security::Session) (defaults to: nil)

    Session to use for remote calls.



18
19
20
# File 'lib/uu/operation_registry/resource_pool.rb', line 18

def initialize(session = nil)
  super
end

Class Method Details

.allocate_capacity(resource_pool_uri, criteria = {}) ⇒ NilClass

Allocates new capacity in ResourcePool and ResourceGroup. This method is a convenience shortcut for the #allocate_capacity instance method.

Returns:

  • (NilClass)

See Also:



194
195
196
# File 'lib/uu/operation_registry/resource_pool.rb', line 194

def self.allocate_capacity(resource_pool_uri, criteria = {})
  self.new(UU::OS::Security::Session.current_session).allocate_capacity(resource_pool_uri, criteria)
end

.create(tenant_uri, attributes) ⇒ UU::OS::UESURI

Creates a new resource pool. This method is a convenience shortcut for the #create instance method.

Parameters:

  • tenant_uri (String, UU::OS::UESURI)

    Tenant URI.

  • attributes (Hash)

    Resource pool attributes.

Returns:

  • (UU::OS::UESURI)

    UESURI of the created pool.



# File 'lib/uu/operation_registry/resource_pool.rb', line 48

.deallocate_capacity(resource_pool_uri, criteria = {}) ⇒ NilClass

Releases capacity allocated in ResourcePool and ResourceGroup. This method is a convenience shortcut for the #deallocate_capacity instance method.

Returns:

  • (NilClass)

See Also:



216
217
218
# File 'lib/uu/operation_registry/resource_pool.rb', line 216

def self.deallocate_capacity(resource_pool_uri, criteria = {})
  self.new(UU::OS::Security::Session.current_session).deallocate_capacity(resource_pool_uri, criteria)
end

.delete(resource_pool_uri) ⇒ void

This method returns an undefined value.

Deletes the specified pool from the registry. This method is a convenience shortcut for the #delete instance method.

Parameters:

  • resource_pool_uri (String, UU::OS::UESURI)

    Resource pool URI.



# File 'lib/uu/operation_registry/resource_pool.rb', line 143

.get_attributes(resource_pool_uri) ⇒ Hash

Gets the attributes of the pool specified by pool URI and returns its detail. This method is a convenience shortcut for the #get_attributes instance method.

Parameters:

  • resource_pool_uri (String, UU::OS::UESURI)

    Resource pool URI.

Returns:

  • (Hash)

    Resource pool attributes.



# File 'lib/uu/operation_registry/resource_pool.rb', line 61

.get_resource_pool_list(tenant_uri, criteria = {}) ⇒ UU::OS::Persistence::PagedResult<Hash>

Returns list of resource pools. This method is a convenience shortcut for the #get_resource_pool_list instance method.

Returns:

  • (UU::OS::Persistence::PagedResult<Hash>)

    Paged result set.

See Also:



172
173
174
# File 'lib/uu/operation_registry/resource_pool.rb', line 172

def self.get_resource_pool_list(tenant_uri, criteria = {})
  self.new(UU::OS::Security::Session.current_session).get_resource_pool_list(tenant_uri, criteria)
end

.set_attributes(resource_pool_uri, attributes) ⇒ UU::OS::UESURI

Sets attributes of a pool. This method is a convenience shortcut for the #set_attributes instance method.

Parameters:

  • resource_pool_uri (String, UU::OS::UESURI)

    Resource pool URI.

Returns:

  • (UU::OS::UESURI)

    UESURI of the updated pool.



# File 'lib/uu/operation_registry/resource_pool.rb', line 132

Instance Method Details

#allocate_capacity(resource_pool_uri, criteria = {}) ⇒ NilClass

Allocates new capacity in ResourcePool and ResourceGroup. Also creates a new record to CapacityLog. Usable for ResourceGroup and ResourcePool managed by SwarmNodeProvider.

Parameters:

  • resource_pool_uri (String, UU::OS::UESURI)

    ResourcePool URI.

  • criteria (Hash) (defaults to: {})

    Criteria for allocating capacity.

Options Hash (criteria):

  • nodeSetUri (String)

    NodeSet URI.

  • nodeCount (String)

    Number of a new allocated nodes.

Returns:

  • (NilClass)


185
186
187
# File 'lib/uu/operation_registry/resource_pool.rb', line 185

def allocate_capacity(resource_pool_uri, criteria = {})
  @client.invoke(:allocateCapacity, resource_pool_uri, parameters: criteria)
end

#create(tenant_uri, attributes) ⇒ UU::OS::UESURI

Creates a new resource pool.

Parameters:

  • tenant_uri (String, UU::OS::UESURI)

    Tenant URI.

  • attributes (Hash)

    Resource pool attributes.

Options Hash (attributes):

  • name (String)

    Resource pool name. May be nil.

  • code (String)

    Resource pool code. May be nil.

  • description (String)

    Resource pool description. May be nil.

  • accessGroupUri (UU::OS::UESURI)

    URI of group used to verify access rights manipulate with the resource pool (e.g. deploy apps to it).

  • auditorsUri (UU::OS::UESURI)

    URI of group used to verify auditors rights (e.g. read logs from deployed apps). May be nil.

  • contractedCapacity (Hash)

    Contracted capacity for this resource pool. Supported keys and value types: {cpu: Numeric, mem: Fixnum, storage: Fixnum}. All keys must have values.

    • cpu (Fixnum) Number of virtual CPU cores.

    • mem (Fixnum) Memory limit in MB (Megabytes).

    • storage (Fixnum) Maximum storage limit in MB (Megabytes).

  • resourceGroupUri (UU::OS::UESURI)

    URI of resource group that resources in this pool belong to.

  • env (String)

    Env configuration JSON. Contains configuration (gemrc, uu-client.properties) for nodes deployed in the context of the Region. May be nil.

Returns:

  • (UU::OS::UESURI)

    UESURI of the created pool.



# File 'lib/uu/operation_registry/resource_pool.rb', line 22

#deallocate_capacity(resource_pool_uri, criteria = {}) ⇒ NilClass

Releases capacity allocated in ResourcePool and ResourceGroup. Also creates a new record to CapacityLog. Usable for ResourceGroup and ResourcePool managed by SwarmNodeProvider.

Parameters:

  • resource_pool_uri (String, UU::OS::UESURI)

    ResourcePool URI.

  • criteria (Hash) (defaults to: {})

    Criteria for allocating capacity.

Options Hash (criteria):

  • nodeSetUri (String)

    NodeSet URI.

  • nodeCount (String)

    Number of a released nodes.

Returns:

  • (NilClass)


207
208
209
# File 'lib/uu/operation_registry/resource_pool.rb', line 207

def deallocate_capacity(resource_pool_uri, criteria = {})
  @client.invoke(:deallocateCapacity, resource_pool_uri, parameters: criteria)
end

#delete(resource_pool_uri) ⇒ void

This method returns an undefined value.

Deletes the specified pool from the registry.

Parameters:

  • resource_pool_uri (String, UU::OS::UESURI)

    Resource pool URI.



# File 'lib/uu/operation_registry/resource_pool.rb', line 138

#get_attributes(resource_pool_uri) ⇒ Hash

Gets the attributes of the pool specified by pool URI and returns its detail.

Parameters:

  • resource_pool_uri (String, UU::OS::UESURI)

    Resource pool URI.

Returns:

  • (Hash)

    Resource pool attributes.



# File 'lib/uu/operation_registry/resource_pool.rb', line 55

#get_resource_pool_list(tenant_uri, criteria = {}) ⇒ UU::OS::Persistence::PagedResult<Hash>

Returns a list of resource pools in the given tenant. Command does not return all resource pools, only a sublist. The list of returned resource pools could be filtered using Mongo Query.

Parameters:

  • tenant_uri (String, UU::OS::UESURI)

    Tenant URI.

  • criteria (Hash) (defaults to: {})

    Criteria for listing pools.

Options Hash (criteria):

  • query (String)

    Mongo Query to filter the result set. See Mongo Query tutorial. Allowed query filter document fields:

    code, tenantUri, contractedCapacity, freeCapacity, accessGroupUri, resourceGroupUri
  • pageIndex (Fixnum)

    Result set page index.

  • pageSize (Fixnum)

    Result set page size.

Returns:

  • (UU::OS::Persistence::PagedResult<Hash>)

    Paged result set.



163
164
165
# File 'lib/uu/operation_registry/resource_pool.rb', line 163

def get_resource_pool_list(tenant_uri, criteria = {})
  @client.invoke(:getResourcePoolList, tenant_uri, parameters: criteria)
end

#set_attributes(resource_pool_uri, attributes) ⇒ UU::OS::UESURI

Sets attributes of a pool.

Examples:

Set env JSON

require 'uu_operation_registry'
require 'json'

UU::OS::Security::Session.('...')

env = {
  "uuClientProperties" => {
    "uu.server-url" => "https://api.plus4u.net",
    "uu.c3.base_url" => "https://sys.plus4u.net",
    "uu.c3.append_routing_data" => "false",
    "uu.operation.registry.base_url" => "https://sys.plus4u.net",
    "uu.operation.registry.append_routing_data" => "false"
  },
  "gemrc" => {
    ":backtrace" => "false",
    ":benchmark" => "false",
    ":bulk_threshold" => "100",
    ":sources" => [
      "http://rubygems.org",
      "http://gems.plus4u.net"
    ],
    ":update_sources" => "true",
    ":verbose" => "false",
    "gem" => "--env-shebang --no-doc --no-ri --no-document"
  }
}

UU::OperationRegistry::ResourcePool.set_attributes('ues:DEV1234-BT:DEV',
  env: env.to_json
)

Set monitoring base URL

UU::OperationRegistry::ResourcePool.set_attributes('ues:DEV1234-BT:DEV',
  monitoringBaseUrl: 'https://telemetry.plus4u.net/uu-cloudg01-monitoring/1234-59955e0d123ddbdfe046c6f8/'
)

Parameters:

  • resource_pool_uri (String, UU::OS::UESURI)

    Resource pool URI.

  • attributes (Hash)

    Resource pool attributes.

Options Hash (attributes):

  • name (String)

    Resource pool name. May be nil.

  • code (String)

    Resource pool code. May be nil.

  • description (String)

    Resource pool description. May be nil.

  • accessGroupUri (UU::OS::UESURI)

    URI of group used to verify access rights manipulate with the resource pool (e.g. deploy apps to it).

  • auditorsUri (UU::OS::UESURI)

    URI of group used to verify auditors rights (e.g. read logs from deployed apps). May be nil.

  • contractedCapacity (Hash)

    Contracted capacity for this resource pool. Supported keys and value types: {cpu: Numeric, mem: Fixnum, storage: Fixnum}. All values are optional.

    • cpu (Fixnum) Number of virtual CPU cores.

    • mem (Fixnum) Memory limit in MB (Megabytes).

    • storage (Fixnum) Maximum storage limit in MB (Megabytes).

  • env (String)

    Env configuration JSON. Contains configuration (gemrc, uu-client.properties) for nodes deployed in the context of the Region. May be nil.

  • monitoringBaseUrl (String)

    URL of uuCloudg01Monitoring instance, if deployed. May be nil.

Returns:

  • (UU::OS::UESURI)

    UESURI of the updated pool.



# File 'lib/uu/operation_registry/resource_pool.rb', line 68