Class: Standup::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/standup/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Node

Returns a new instance of Node.



5
6
7
8
9
10
11
12
13
# File 'lib/standup/node.rb', line 5

def initialize name
  @name = name
  
  @scripts = ActiveSupport::HashWithIndifferentAccess.new
  Standup.scripts.each do |sname, script|
    @scripts[sname] = script.new self
  end
  @remoting = nil
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/standup/node.rb', line 15

def name
  @name
end

#scriptsObject (readonly)

Returns the value of attribute scripts.



15
16
17
# File 'lib/standup/node.rb', line 15

def scripts
  @scripts
end

Instance Method Details

#id_groupObject



40
41
42
# File 'lib/standup/node.rb', line 40

def id_group
  "standup_node_#{@name}"
end

#instanceObject



23
24
25
# File 'lib/standup/node.rb', line 23

def instance
  @instance ||= EC2::Instance.group_running[id_group].try(:first)
end

#paramsObject



32
33
34
# File 'lib/standup/node.rb', line 32

def params
  Settings.nodes[@name] || ActiveSupport::HashWithIndifferentAccess.new
end

#remotingObject



36
37
38
# File 'lib/standup/node.rb', line 36

def remoting
  @remoting ||= Remoting.new self
end

#run_script(script_name) ⇒ Object



17
18
19
20
21
# File 'lib/standup/node.rb', line 17

def run_script script_name
  scripts[script_name].put_title
  scripts[script_name].run
  close_remoting
end

#ssh_stringObject



27
28
29
30
# File 'lib/standup/node.rb', line 27

def ssh_string
  return '' unless instance
  "ssh -i #{Settings.aws.keypair_file} -C -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null #{scripts.ec2.params.ssh_user}@#{instance.external_ip}"
end