Class: UU::OperationRegistry::Host

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

Overview

Host.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session = nil) ⇒ Host

Creates a new instance of Host.

Parameters:

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

    Session to use for remote calls.



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

def initialize(session = nil)
  super
end

Class Method Details

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

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

Parameters:

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

    ResourceGroup URI.

  • attributes (Hash)

    Host attributes.

Returns:

  • (UU::OS::UESURI)

    UESURI of the created host.



# File 'lib/uu/operation_registry/host.rb', line 44

.delete(host_uri) ⇒ void

This method returns an undefined value.

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

Parameters:

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

    Host URI.



# File 'lib/uu/operation_registry/host.rb', line 116

.get_attributes(host_uri) ⇒ Hash

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

Parameters:

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

    Host URI.

Returns:

  • (Hash)

    Host attributes.



# File 'lib/uu/operation_registry/host.rb', line 57

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

Returns list of hosts. This method is a convenience shortcut for the #get_host_list instance method.

Returns:

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

    Paged result set.

See Also:



145
146
147
# File 'lib/uu/operation_registry/host.rb', line 145

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

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

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

Parameters:

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

    Host URI.

Returns:

  • (UU::OS::UESURI)

    UESURI of the updated host.



# File 'lib/uu/operation_registry/host.rb', line 105

Instance Method Details

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

Creates a new host.

Parameters:

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

    ResourceGroup URI.

  • attributes (Hash)

    Host attributes.

Options Hash (attributes):

  • name (String)

    Host name. May be nil.

  • code (String)

    Host code. May be nil.

  • description (String)

    Host description. May be nil.

  • reinitStrategy (String)

    Flag to enable reinit for the host. The only supported value at the moment is “SUPPORTED”. May be nil.

  • hostname (String)

    Name of the physical host.

  • totalCapacity (Hash)

    Total capacity this host can provide for running nodes. 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).

  • labels (Hash)

    Hash of labels to attach to a Host. May be nil.

Returns:

  • (UU::OS::UESURI)

    UESURI of the created host.



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

#delete(host_uri) ⇒ void

This method returns an undefined value.

Deletes the specified host from the registry.

Parameters:

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

    Host URI.



# File 'lib/uu/operation_registry/host.rb', line 111

#get_attributes(host_uri) ⇒ Hash

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

Parameters:

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

    Host URI.

Returns:

  • (Hash)

    Host attributes.



# File 'lib/uu/operation_registry/host.rb', line 51

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

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

Parameters:

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

    ResourceGroup URI.

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

    Criteria for listing hosts.

Options Hash (criteria):

  • query (String)

    Mongo Query to filter the result set. See Mongo Query tutorial. Allowed query filter document fields: code, state, hostname, resourceGroupUri, totalCapacity, freeCapacity

  • pageIndex (Fixnum)

    Result set page index.

  • pageSize (Fixnum)

    Result set page size.

Returns:

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

    Paged result set.



136
137
138
# File 'lib/uu/operation_registry/host.rb', line 136

def get_host_list(resource_group_uri, criteria = {})
  @client.invoke(:getHostList, resource_group_uri, parameters: criteria)
end

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

Sets attributes of a host.

Examples:

Set labels

require 'uu_operation_registry'

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

labels = {
  :"uu.cloud.deployment-environment" => "group1"
}

UU::OperationRegistry::Host.set_attributes(
  'ues:HOST:URI',
   labels: labels
)

Parameters:

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

    Host URI.

  • attributes (Hash)

    Host attributes.

Options Hash (attributes):

  • name (String)

    Host name. May be nil.

  • code (String)

    Host code. May be nil.

  • description (String)

    Host description. May be nil.

  • reinitStrategy (String)

    Flag to enable reinit for the host. The only supported value at the moment is “SUPPORTED”. May be nil.

  • hostname (String)

    Name of the physical host. May be nil.

  • state (String)

    Host state. Value must be one from UU::OperationRegistry::HostState. Host must be in state ACTIVE for deployment. May be nil.

  • totalCapacity (Hash)

    Total capacity this host can provide for running nodes. May be nil. 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).

  • labels (Hash)

    Hash of labels to attach to a Host. May be nil.

Returns:

  • (UU::OS::UESURI)

    UESURI of the updated host.



# File 'lib/uu/operation_registry/host.rb', line 64