Class: UU::OperationRegistry::ResourceGroup

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

Overview

Resource group.

Defined Under Namespace

Classes: NodeProviderType

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session = nil) ⇒ ResourceGroup

Creates a new instance of ResourceGroup.

Parameters:

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

    Session to use for remote calls.



26
27
28
# File 'lib/uu/operation_registry/resource_group.rb', line 26

def initialize(session = nil)
  super
end

Class Method Details

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

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

Parameters:

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

    Region URI.

  • attributes (Hash)

    ResourceGroup attributes.

Returns:

  • (UU::OS::UESURI)

    UESURI of the created resource group.



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

.delete(resource_group_uri) ⇒ void

This method returns an undefined value.

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

Parameters:

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

    ResourceGroup URI.



# File 'lib/uu/operation_registry/resource_group.rb', line 156

.get_attributes(resource_group_uri) ⇒ Hash

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

Parameters:

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

    ResourceGroup URI.

Returns:

  • (Hash)

    ResourceGroup attributes.



# File 'lib/uu/operation_registry/resource_group.rb', line 66

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

Returns list of resource groups. This method is a convenience shortcut for the #get_resource_group_list instance method.

Returns:

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

    Paged result set.

See Also:



183
184
185
# File 'lib/uu/operation_registry/resource_group.rb', line 183

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

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

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

Parameters:

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

    ResourceGroup URI.

Returns:

  • (UU::OS::UESURI)

    UESURI of the updated resource group.



# File 'lib/uu/operation_registry/resource_group.rb', line 145

Instance Method Details

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

Creates a new resource group.

Parameters:

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

    Region URI.

  • attributes (Hash)

    ResourceGroup attributes.

Options Hash (attributes):

  • name (String)

    ResourceGroup name. May be nil.

  • code (String)

    ResourceGroup code. May be nil.

  • nodeProvider (UU::OperationRegistry::ResourceGroup::NodeProviderType)

    Type of NodeProvider.

  • nodeProviderParameters (Hash)

    Parameters for NodeProvider.

    • url (String) Url to Docker Swarm.

    • connectionParameters (Hash) Additional connection parameters compatible with Excon gem.

  • description (String)

    ResourceGroup description. May be nil.

  • env (String)

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

  • labels (Hash)

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

  • slotMapping (Hash)

    Hash where keys are slot names. Values of those two keys must be again Hashes containing mapping of label keys to values. May be nil.

  • state (String)

    ResourceGroup state. Value must be one from UU::OperationRegistry::ResourceGroupState. May be nil in which case it will set the ResourceGroup into ACTIVE state.

Returns:

  • (UU::OS::UESURI)

    UESURI of the created resource group.



# File 'lib/uu/operation_registry/resource_group.rb', line 30

#delete(resource_group_uri) ⇒ void

This method returns an undefined value.

Deletes the specified resource group from the registry.

Parameters:

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

    ResourceGroup URI.



# File 'lib/uu/operation_registry/resource_group.rb', line 151

#get_attributes(resource_group_uri) ⇒ Hash

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

Parameters:

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

    ResourceGroup URI.

Returns:

  • (Hash)

    ResourceGroup attributes.



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

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

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

Parameters:

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

    Region URI.

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

    Criteria for listing resource groups.

Options Hash (criteria):

  • query (String)

    Mongo Query to filter the result set. See Mongo Query tutorial.

  • pageIndex (Fixnum)

    Result set page index.

  • pageSize (Fixnum)

    Result set page size.

Returns:

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

    Paged result set.



174
175
176
# File 'lib/uu/operation_registry/resource_group.rb', line 174

def get_resource_group_list(region_uri, criteria = {})
  client.invoke(:getResourceGroupList, region_uri, parameters: criteria)
end

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

Sets attributes of a resource group.

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::ResourceGroup.set_attributes(
  'ues:RESOURCEGROUP:URI',
  :env => env.to_json
)

Set labels and slotMapping

require 'uu_operation_registry'

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

labels = {
  :"shared-label" => "value"
}

slot_mapping = {
  PRODUCTION: { :"uu.cloud.deployment-environment" => "group1" },
  BETA: { :"uu.cloud.deployment-environment" => "group2" }
}

UU::OperationRegistry::ResourceGroup.set_attributes(
  'ues:RESOURCEGROUP:URI',
   labels: labels,
   slotMapping: slot_mapping
)

Parameters:

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

    ResourceGroup URI.

  • attributes (Hash)

    ResourceGroup attributes.

Options Hash (attributes):

  • name (String)

    ResourceGroup name. May be nil.

  • code (String)

    ResourceGroup code. May be nil.

  • description (String)

    ResourceGroup description. May be nil.

  • env (String)

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

  • labels (Hash)

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

  • slotMapping (Hash)

    Hash where keys are slot names. Values of those two keys must be again Hashes containing mapping of label keys to values. May be nil.

  • state (String)

    ResourceGroup state. Value must be one from UU::OperationRegistry::ResourceGroupState. May be nil.

Returns:

  • (UU::OS::UESURI)

    UESURI of the updated resource group.



# File 'lib/uu/operation_registry/resource_group.rb', line 73