Class: Bcome::Node::Server::Dynamic

Inherits:
Base
  • Object
show all
Defined in:
lib/objects/node/server/dynamic.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

#origin_object_id

Attributes inherited from Base

#params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#bootstrap?, #cache_data, #close_ssh_connection, #cloud_tags, #do_run, #dup_with_new_parent, #dynamic_server?, #enabled_menu_items, #execute_script, #get, #has_description?, #has_no_ssh_connection?, #has_ssh_connection?, #has_tagged_value?, #initialize, #list_attributes, #local_port_forward, #ls, #machines, #menu_items, #open_ssh_connection, #ping, #print_ping_result, #pseudo_tty, #put, #requires_description?, #requires_type?, #rsync, #run, #server?, #set_view_attributes, #ssh, #static_server?, #tags, #toggle_bootstrap, #type, #update_identifier, #update_parent

Methods inherited from Base

#bootstrap?, #close_ssh_connections, #collection?, 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::Server::Base

Dynamic Method Handling

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

Class Method Details

.new_from_fog_instance(fog_instance, parent) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/objects/node/server/dynamic.rb', line 8

def new_from_fog_instance(fog_instance, parent)
  identifier = fog_instance.tags['Name']

  if parent.override_server_identifier?
    identifier =~ /#{parent.override_identifier}/
    identifier = Regexp.last_match(1) if Regexp.last_match(1)
  end

  params = {
    identifier: identifier,
    internal_ip_address: fog_instance.private_ip_address,
    public_ip_address: fog_instance.public_ip_address,
    role: fog_instance.tags['function'],
    description: "EC2 server - #{identifier}",
    ec2_server: fog_instance
  }

  new(parent: parent,
      views: params)
end

.to_sObject



4
5
6
# File 'lib/objects/node/server/dynamic.rb', line 4

def to_s
  'dynamic server'
end

Instance Method Details

#do_generate_cloud_tagsObject



30
31
32
33
# File 'lib/objects/node/server/dynamic.rb', line 30

def do_generate_cloud_tags
  raw_tags = ec2_server ? ec2_server.tags.deep_symbolize_keys : {}
  ::Bcome::Node::Meta::Cloud.new(raw_tags)
end

#ec2_serverObject



35
36
37
# File 'lib/objects/node/server/dynamic.rb', line 35

def ec2_server
  views[:ec2_server]
end