Class: Bcome::Node::Instance

Inherits:
Base show all
Includes:
InstanceCommand, InstanceSsh
Defined in:
lib/nodes/instance.rb

Instance Attribute Summary

Attributes inherited from Base

#meta_data, #stack_peer

Instance Method Summary collapse

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, #nat_user, #non_bootstrapped_ssh_command, #ssh, #ssh_jump_command_to_bastion, #ssh_jump_command_to_internal_node, #ssh_key_path, #ssh_user

Methods included from InstanceCommand

#direct_rsync, #direct_rsync_bootstrap, #execute_command, #get, #jump_host_rsync, #jump_host_rsync_bootstrap, #put, #rsync_is_sudo, #run

Methods inherited from Base

#initialize, #interactive, #method_missing, #run, #set_parent_reference, #set_stack_peer

Methods included from CommandHelper

#run_local

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::Node::Base

Instance Method Details

#bootstrap_settingsObject



30
31
32
# File 'lib/nodes/instance.rb', line 30

def bootstrap_settings
  environment.bootstrap_settings
end

#ec2_hostnameObject



46
47
48
# File 'lib/nodes/instance.rb', line 46

def ec2_hostname
  return "#{hostname_map}.ec2.internal"
end

#environmentObject



7
8
9
10
# File 'lib/nodes/instance.rb', line 7

def environment
  @environment = (@environment ? @environment : stack_peer.environment.node)
  @environment
end

#hostname_mapObject



42
43
44
# File 'lib/nodes/instance.rb', line 42

def hostname_map
  return "ip-#{ip_address.to_s.gsub(".","-")}"
end

#identifierObject



16
17
18
# File 'lib/nodes/instance.rb', line 16

def identifier
  stack_peer.override_instance_identifier_for_wbz_stacks? ? wbz_overriden_identifier : @identifier
end

#ip_addressObject



26
27
28
# File 'lib/nodes/instance.rb', line 26

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

#local_download_pathObject



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

def local_download_path
  "#{Dir.pwd}#{environment.namespace}/#{identifier}"
end

#machinesObject



12
13
14
# File 'lib/nodes/instance.rb', line 12

def machines
  [self]  # for completion
end

#namespaceObject



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

def namespace
  "#{environment.namespace}/#{identifier}"
end

#proxy(bootstrap = false) ⇒ Object



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

def proxy(bootstrap = false)
  environment.proxy(bootstrap)
end

#public_ip_addressObject



38
39
40
# File 'lib/nodes/instance.rb', line 38

def public_ip_address
  @public_ip_address
end

#roleObject



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

def role
  @role
end

#wbz_overriden_identifierObject



20
21
22
23
24
# File 'lib/nodes/instance.rb', line 20

def wbz_overriden_identifier
  prefix = stack_peer.overriden_identifier_prefix
  @identifier =~ /#{prefix}(.+)/
  return $1 ? $1 : @identifier
end