Class: UU::OperationRegistry::Node

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

Overview

Node.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session = nil) ⇒ Node

Creates a new instance of Node.

Parameters:

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

    Session to use for remote calls.



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

def initialize(session = nil)
  super
end

Class Method Details

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

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

Parameters:

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

    Host URI.

  • attributes (Hash)

    Node attributes.

Returns:

  • (UU::OS::UESURI)

    UESURI of the created node.



# File 'lib/uu/operation_registry/node.rb', line 40

.delete(node_uri, parameters = {}) ⇒ void

This method returns an undefined value.

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

Parameters:

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

    Node URI.



140
141
142
# File 'lib/uu/operation_registry/node.rb', line 140

def self.delete(node_uri, parameters = {})
  self.new(UU::OS::Security::Session.current_session).delete(node_uri, parameters)
end

.get_attributes(node_uri) ⇒ Hash

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

Parameters:

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

    Node URI.

Returns:

  • (Hash)

    Node attributes.



# File 'lib/uu/operation_registry/node.rb', line 53

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

Returns list of nodes. This method is a convenience shortcut for the #get_node_list instance method.

Returns:

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

    Paged result set.

See Also:



166
167
168
# File 'lib/uu/operation_registry/node.rb', line 166

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

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

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

Parameters:

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

    Node URI.

Returns:

  • (UU::OS::UESURI)

    UESURI of the updated node.



# File 'lib/uu/operation_registry/node.rb', line 77

Instance Method Details

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

Creates a new node.

Parameters:

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

    Host URI.

  • attributes (Hash)

    Node attributes.

Options Hash (attributes):

  • name (String)

    Node name. May be nil.

  • code (String)

    Node code. May be nil.

  • description (String)

    Node description. May be nil.

  • nodeSizeUri (UU::OS::UESURI)

    Node size URI.

  • nodeSetUri (UU::OS::UESURI)

    NodeSet URI.

  • resourcePoolUri (UU::OS::UESURI)

    Resource pool this node belongs to.

  • hostname (String)

    Hostname of the host where the node is running. May be nil.

  • appDeploymentUri (UU::OS::UESURI)

    UESURI of deployment that this node belongs to. May be nil.

Returns:

  • (UU::OS::UESURI)

    UESURI of the created node.



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

#delete(node_uri, parameters = {}) ⇒ void

This method returns an undefined value.

Deletes the specified node from the registry.

Node can be successfully deleted if all these conditions are met:

  1. no container exists referencing this node (via nodeUri)

  2. nodeSizeUri on this node is set

  3. node size referenced (via nodeSizeUri) from this node exists

  4. resourcePoolUri on this node is set

  5. resource pool referenced (via resourcePoolUri) from this node exists

Note: Condition 1 ensures data consistency, conditions 2-5 ensure that a proper capacity log record can be created to terminate billing of the deleted node.

Under special circumstances, a node can eventually be deleted even if the afforementioned conditions 2-5 are not met. This is possible setting force parameter to true.

Note: If condition 1 is not met, the node cannot be deleted, not even if force is true.

Examples:

Node deletion

require "uu_operation_registry"

UU::OS::Security::Session.("operation_registry_authority")

node = UU::OperationRegistry::Node.new(UU::OS::Security::Session.current_session)
node.delete("ues:OT-BT[99923616732452117]:5819e14581e8a357881e5996[5819e14581e8a357881e5996]")

Node deletion (forced)

require "uu_operation_registry"

UU::OS::Security::Session.("operation_registry_authority")

node = UU::OperationRegistry::Node.new(UU::OS::Security::Session.current_session)
node.delete("ues:OT-BT[99923616732452117]:5819e14581e8a357881e5996[5819e14581e8a357881e5996]", force: true)

Parameters:

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

    Node URI.

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

    Node deletion parameters.

Options Hash (parameters):

  • force (TrueClass, FalseClass)

    Flag determining whether node deletion is forced. May be nil (false is assumed if the parameter is not specified).

    Use with caution! - force: true deletes the node even if a proper capacity log record cannot be created (to terminate billing of the node) and/or free capacity of the related resource pool and/or host cannot be updated.



132
133
134
# File 'lib/uu/operation_registry/node.rb', line 132

def delete(node_uri, parameters = {})
  client.invoke(:delete, node_uri, parameters: parameters)
end

#get_attributes(node_uri) ⇒ Hash

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

Parameters:

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

    Node URI.

Returns:

  • (Hash)

    Node attributes.



# File 'lib/uu/operation_registry/node.rb', line 47

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

Returns a list of nodes on the given host. Command does not return all nodes, only a sublist. The list of returned nodes could be filtered using Mongo Query.

Parameters:

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

    Host URI.

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

    Criteria for listing nodes.

Options Hash (criteria):

  • query (String)

    Mongo Query to filter the result set. See Mongo Query tutorial. Allowed query filter document fields: code, nodeSizeUri, hostUri, resourcePoolUri

  • pageIndex (Fixnum)

    Result set page index.

  • pageSize (Fixnum)

    Result set page size.

Returns:

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

    Paged result set.



157
158
159
# File 'lib/uu/operation_registry/node.rb', line 157

def get_node_list(host_uri, criteria = {})
  @client.invoke(:getNodeList, host_uri, parameters: criteria)
end

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

Sets attributes of an node.

Parameters:

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

    Node URI.

  • attributes (Hash)

    Node attributes.

Options Hash (attributes):

  • name (String)

    Node name. May be nil.

  • code (String)

    Node code. May be nil.

  • description (String)

    Node description. May be nil.

  • nodeSizeUri (UU::OS::UESURI)

    Node size URI. May be nil.

  • hostname (String)

    Hostname of the host where the node is running. May be nil.

  • appDeploymentUri (UU::OS::UESURI)

    UESURI of deployment that this node belongs to. May be nil.

  • nodeSetUri (UU::OS::UESURI)

    NodeSet URI.

Returns:

  • (UU::OS::UESURI)

    UESURI of the updated node.



# File 'lib/uu/operation_registry/node.rb', line 60