Class: Bcome::Stack::Instance

Inherits:
Object
  • Object
show all
Includes:
BecomeObject, InstanceCommand, InstanceSsh
Defined in:
lib/stack/instance.rb

Constant Summary

Constants included from BecomeObject

BecomeObject::CONFIGS_PATH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InstanceCommand

#execute_command, #rsync, #run, #scp

Methods included from InstanceSsh

#bastion_ip_address, #direct_ssh_command, #do_ssh, #execute_task, #is_direct_ssh?, #is_jump_ssh?, #is_ssh_jump_host?, #keys, #ssh, #ssh_jump_command_to_bastion, #ssh_jump_command_to_internal_node, #ssh_key_path, #ssh_user

Methods included from BecomeObject

#all_items, #become_identifier, #do_load_resources, #has_main_context?, #list, #main_context, #main_context=, #previous_workspace_object, #previous_workspace_object=, #resource_for_identifier, #resources

Constructor Details

#initialize(meta_data, parent) ⇒ Instance

Returns a new instance of Instance.



36
37
38
39
# File 'lib/stack/instance.rb', line 36

def initialize(, parent)
   = 
  @environment = parent
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



34
35
36
# File 'lib/stack/instance.rb', line 34

def environment
  @environment
end

Class Method Details

.collection_from_config(parent, configuration) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/stack/instance.rb', line 24

def collection_from_config(parent, configuration)
  conf_for_env = configuration[:instances]
  collection = []
  conf_for_env.each do ||
    collection << new(, parent) 
  end
  return collection
end

.collection_from_fog_data(parent, fog_instances) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/stack/instance.rb', line 9

def collection_from_fog_data(parent, fog_instances)
  collection = []
  fog_instances.each do |f_instance|

     = {
      :identifier => f_instance.tags["Name"],
      :external_network_interface_address => f_instance.private_ip_address,
      :public_ip_address => f_instance.public_ip_address,
      :role => f_instance.tags["function"]
    }
    collection << new(, parent)
  end
  return collection
end

Instance Method Details

#do_describeObject



82
83
84
85
86
87
88
89
# File 'lib/stack/instance.rb', line 82

def do_describe
  description = "#{identifier}"
  description += "\n\t* Internal IP #{@meta_data[:external_network_interface_address]}"
  description += "\n\t* External IP #{public_ip_address}" if public_ip_address
  description += "\n\t* #{role}" if role 
  description += "\n"
  return description    
end

#highlight?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/stack/instance.rb', line 78

def highlight?
  @environment.object_in_selections?(self)
end

#identifierObject



58
59
60
# File 'lib/stack/instance.rb', line 58

def identifier
  [:identifier] 
end

#ip_addressObject



62
63
64
# File 'lib/stack/instance.rb', line 62

def ip_address
 @environment.ssh_mode_type == ::SSH_DIRECT_MODE_IDENTIFIER ? public_ip_address : [:external_network_interface_address]
end


41
42
43
44
45
46
47
48
# File 'lib/stack/instance.rb', line 41

def menu_items
  super + [
    { :command => "rsync", :description => "Rsync files.", :usage => "rsync 'localpath', 'remotepath'" },
    { :command => "run", :description => "Execute a command.", :usage => "run 'command'" },
    { :command => "scp", :description => "SCP files.", :usage => "scp ['array','of', 'file', 'paths'], 'remote_path'" },
    { :command => "ssh", :description => "Initiate an SSH connection." }
  ]
end

#platformObject



50
51
52
# File 'lib/stack/instance.rb', line 50

def platform
  @environment.platform
end

#public_ip_addressObject



66
67
68
# File 'lib/stack/instance.rb', line 66

def public_ip_address
  [:public_ip_address]
end

#reference_keyObject



74
75
76
# File 'lib/stack/instance.rb', line 74

def reference_key
  :instances
end

#responds_to_list?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/stack/instance.rb', line 54

def responds_to_list?
  false
end

#roleObject



70
71
72
# File 'lib/stack/instance.rb', line 70

def role
  [:role]
end