Class: Chimp::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/right_chimp/resources/server.rb

Overview

This class holds all necessary information regarding an instance and provides a way of executing a script on it via the run_executable method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServer

Returns a new instance of Server.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/right_chimp/resources/server.rb', line 16

def initialize
  @params = {
    "href"                    => "dummy href",
    "current_instance_href"   => nil,
    "current-instance-href "  => nil,
    "name"                    => "dummy name",
    "nickname"                => "dummy nickname",
    "ip_address"              => nil,
    "ip-address"              => nil,
    "private-ip-address"      => nil,
    "aws-id"                  => "",
    "ec2-instance-type"       => "",
    "dns-name"                => "",
    "locked"                  => "",
    "state"                   => "",
    "datacenter"              => nil
  }
  @object = nil
end

Instance Attribute Details

#objectObject

Returns the value of attribute object.



12
13
14
# File 'lib/right_chimp/resources/server.rb', line 12

def object
  @object
end

#paramsObject

Returns the value of attribute params.



12
13
14
# File 'lib/right_chimp/resources/server.rb', line 12

def params
  @params
end

#run_executable(exec, options) ⇒ Object

In order to run the task, we need to call run_executable on ourselves



63
64
65
# File 'lib/right_chimp/resources/server.rb', line 63

def run_executable
  @run_executable
end

Instance Method Details

#encode_with(coder) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/right_chimp/resources/server.rb', line 52

def encode_with(coder)
  vars = instance_variables.map{|x| x.to_s}
  vars = vars - ['@object']

  vars.each do |var|
    var_val = eval(var)
    coder[var.gsub('@', '')] = var_val
  end
end

#hrefObject



36
37
38
# File 'lib/right_chimp/resources/server.rb', line 36

def href
  @params['href']
end

#ip_addressObject



48
49
50
# File 'lib/right_chimp/resources/server.rb', line 48

def ip_address
  @params['ip_address']
end

#nameObject



40
41
42
# File 'lib/right_chimp/resources/server.rb', line 40

def name
  @params['name']
end

#nicknameObject



44
45
46
# File 'lib/right_chimp/resources/server.rb', line 44

def nickname
  @params['nickname']
end