Class: Bcome::Node::Inventory::Subselect

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

Constant Summary

Constants inherited from Base

Base::DEFAULT_IDENTIFIER

Constants included from Draw

Draw::BLIP, Draw::BOTTOM_ANCHOR, Draw::BOX_BOTTOM_LEFT, Draw::BOX_BOTTOM_RIGHT, Draw::BOX_HORIZONTAL_LINE, Draw::BOX_SIDE, Draw::BOX_TOP_LEFT, Draw::BOX_TOP_RIGHT, Draw::BRANCH, Draw::INGRESS, Draw::LEFT_PADDING, Draw::MID_SHIPS

Constants included from LocalMetaDataFactory

LocalMetaDataFactory::META_DATA_FILE_PATH_PREFIX

Instance Attribute Summary

Attributes inherited from Base

#identifier, #params, #parent, #views

Instance Method Summary collapse

Methods inherited from Base

#cache_nodes_in_memory, #cloud_matches, #direct_invoke_all_servers, #direct_invoke_server, #inventory?, #list_key, #machine_by_identifier, #machines, #matches_for, #meta_matches, #override_server_identifier?, #ssh, #tags

Methods inherited from Base

#close_ssh_connections, #collection?, const_missing, #data_print_from_hash, #execute_local, #execute_script, #has_parent?, #has_proxy?, #hide?, #inspect, #inventory?, #invoke, #is_top_level_node?, #keyed_namespace, #list_attributes, #list_key, #method_missing, #namespace, #no_nodes?, #nodes_loaded!, #prompt_breadcrumb, #proxy, #proxy_chain, #proxy_chain_link, #put, #put_str, #recurse_resource_for_identifier, #requires_description?, #requires_type?, #resource_for_identifier, #rsync, #scoped_resources, #scp, #server?, #ssh_connect, #validate_attributes, #validate_identifier

Methods included from LoadingBar::Handler

#cursor, #do_signal, #fork_process, #signal_failure, #signal_stop, #signal_success, #start_indicator, #stop_indicator, #wrap_indicator

Methods included from Tree

#build_tree, #deduce_tree_structure, #namespace_tree_line, #network_namespace_tree_data, #recurse_tree_lines, #routes, #routing_tree_data, #routing_tree_line, #to_nested_hash, #tree

Methods included from Draw

#box_it, #max_box_line_length

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_group_names, #menu_item_spacing_length, #mode, #print_menu_items, #tab_spacing

Methods included from Attributes

#identifier, #network_data, #network_driver, #recurse_hash_data_for_instance_key, #ssh_data, #ssh_driver, #ssh_driver=

Methods included from WorkspaceCommands

#cd, #clear!, #disable, #disable!, #enable, #enable!, #interactive, #is_node_level_method?, #ls, #lsa, #method_in_registry?, #method_is_available_on_node?, #new_line, #parents, #ping, #pretty_description, #resource_identifiers, #run, #ssh_connect, #tree_descriptions, #visual_hierarchy, #workon

Methods included from Context

#current_context?, #irb_workspace=, #previous_irb_workspace=

Constructor Details

#initialize(*params) ⇒ Subselect

Returns a new instance of Subselect.



7
8
9
10
11
12
# File 'lib/objects/node/inventory/subselect.rb', line 7

def initialize(*params)
  super
  raise Bcome::Exception::MissingSubselectionKey, @views unless @views[:subselect_from]

  update_nodes
end

Dynamic Method Handling

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

Instance Method Details

#do_reloadObject



53
54
55
56
57
58
59
# File 'lib/objects/node/inventory/subselect.rb', line 53

def do_reload
  parent_inventory.resources.reset_duplicate_nodes!
  parent_inventory.do_reload
  resources.run_subselect
  update_nodes
  nil
end

#do_set_resourcesObject



37
38
39
# File 'lib/objects/node/inventory/subselect.rb', line 37

def do_set_resources
  ::Bcome::Node::Resources::SubselectInventory.new(origin_inventory: self, parent_inventory: parent_inventory, filters: filters)
end

#enabled_menu_itemsObject



14
15
16
# File 'lib/objects/node/inventory/subselect.rb', line 14

def enabled_menu_items
  super + %i[reload]
end

#filtersObject



45
46
47
# File 'lib/objects/node/inventory/subselect.rb', line 45

def filters
  @views[:sub_filter] || @views[:filters] || {}
end


18
19
20
21
22
23
24
25
26
27
# File 'lib/objects/node/inventory/subselect.rb', line 18

def menu_items
  base_items = super.dup

  base_items[:reload] = {
    description: 'Restock this inventory from remote',
    console_only: true,
    group: :miscellany
  }
  base_items
end

#nodes_loaded?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/objects/node/inventory/subselect.rb', line 41

def nodes_loaded?
  true
end

#reloadObject



49
50
51
# File 'lib/objects/node/inventory/subselect.rb', line 49

def reload
  do_reload
end

#resourcesObject



29
30
31
# File 'lib/objects/node/inventory/subselect.rb', line 29

def resources
  @resources ||= do_set_resources
end

#update_nodesObject



33
34
35
# File 'lib/objects/node/inventory/subselect.rb', line 33

def update_nodes
  resources.update_nodes(self)
end