Class: Bcome::Node::Collection

Inherits:
Base
  • Object
show all
Defined in:
lib/objects/node/collection.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_IDENTIFIER

Constants included from LocalMetaDataFactory

LocalMetaDataFactory::META_DATA_FILE_PATH_PREFIX

Instance Attribute Summary

Attributes inherited from Base

#params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#bootstrap?, #close_ssh_connections, const_missing, #data_print_from_hash, #enabled_menu_items, #execute_local, #execute_script, #has_parent?, #has_proxy?, #identifier=, #initialize, #inventory?, #invoke, #is_top_level_node?, #keyed_namespace, #list_attributes, #list_key, #namespace, #no_nodes?, #nodes_loaded?, #open_ssh_connections, #pack_metadata, #prompt_breadcrumb, #proxy, #put, #recurse_resource_for_identifier, #requires_description?, #requires_type?, #resource_for_identifier, #resources, #rsync, #scp, #server?, #unpack_metadata, #validate_attributes, #validate_identifier

Methods included from RegistryManagement

#registry, #user_command_wrapper

Methods included from LocalMetaDataFactory

#do_create_metadata, #meta, #metadata, #metadata_for_namespace, #raw_metadata

Methods included from WorkspaceMenu

#item_spacing, #menu, #menu_item_spacing_length, #menu_items, #mode, #tab_spacing

Methods included from Attributes

#description, #filters, #identifier, #network_data, #network_driver, #recurse_hash_data_for_instance_var, #ssh_data, #ssh_driver, #type

Methods included from WorkspaceCommands

#back, #cd, #clear!, #disable, #disable!, #enable, #enable!, #interactive, #is_node_level_method?, #list_in_tree, #ls, #lsa, #method_in_registry?, #method_is_available_on_node?, #method_missing, #new_line, #parents, #ping, #pretty_description, #print_tree_view_for_resource, #resource_identifiers, #run, #tree, #tree_descriptions, #visual_hierarchy, #workon

Methods included from Context

#irb_workspace=, #is_current_context?, #previous_irb_workspace=

Constructor Details

This class inherits a constructor from Bcome::Node::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bcome::WorkspaceCommands

Class Method Details

.to_sObject



3
4
5
# File 'lib/objects/node/collection.rb', line 3

def self.to_s
  'collection'
end

Instance Method Details

#collection?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/objects/node/collection.rb', line 47

def collection?
  true
end

#filter_duplicates(original_set) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/objects/node/collection.rb', line 19

def filter_duplicates(original_set)
  instance_lookup = []
  filtered_set = []
  original_set.each do |server|
    unless instance_lookup.include?(server.origin_object_id)
      filtered_set << server
      instance_lookup << server.origin_object_id
    end
  end
  filtered_set
end

#inventoriesObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/objects/node/collection.rb', line 7

def inventories
  inv = []
  @resources.active.each do |r|
    inv << if r.inventory?
             r
           else
             r.inventories
           end
  end
  inv.flatten
end

#machinesObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/objects/node/collection.rb', line 31

def machines
  set = []
  @resources.active.each do |resource|
    if resource.inventory?
      resource.load_nodes unless resource.nodes_loaded?
      set << resource.resources.active
    else
      set << resource.machines
    end
  end

  set.flatten!

  filter_duplicates(set)
end