Class: Galaxy::Agent
- Inherits:
-
Object
- Object
- Galaxy::Agent
- Defined in:
- lib/galaxy.rb
Overview
Agent Information
Instance Attribute Summary collapse
-
#agent_id ⇒ Object
readonly
Returns the value of attribute agent_id.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#instance_type ⇒ Object
readonly
Returns the value of attribute instance_type.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #columns(colors = false) ⇒ Object
-
#initialize(agent_id, status, url, location, instance_type) ⇒ Agent
constructor
A new instance of Agent.
Constructor Details
#initialize(agent_id, status, url, location, instance_type) ⇒ Agent
Returns a new instance of Agent.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/galaxy.rb', line 82 def initialize(agent_id, status, url, location, instance_type) @agent_id = agent_id @url = url @status = status @path = path unless url.nil? @host = URI.parse(url).host unless url.nil? @ip = IPSocket::getaddress(host) end @host ||= "unknown" @ip ||= "unknown" @location = location @instance_type = instance_type end |
Instance Attribute Details
#agent_id ⇒ Object (readonly)
Returns the value of attribute agent_id.
80 81 82 |
# File 'lib/galaxy.rb', line 80 def agent_id @agent_id end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
80 81 82 |
# File 'lib/galaxy.rb', line 80 def host @host end |
#instance_type ⇒ Object (readonly)
Returns the value of attribute instance_type.
80 81 82 |
# File 'lib/galaxy.rb', line 80 def instance_type @instance_type end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
80 81 82 |
# File 'lib/galaxy.rb', line 80 def ip @ip end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
80 81 82 |
# File 'lib/galaxy.rb', line 80 def location @location end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
80 81 82 |
# File 'lib/galaxy.rb', line 80 def path @path end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
80 81 82 |
# File 'lib/galaxy.rb', line 80 def status @status end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
80 81 82 |
# File 'lib/galaxy.rb', line 80 def url @url end |
Instance Method Details
#columns(colors = false) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/galaxy.rb', line 100 def columns(colors = false) status = @status if colors status = case status when "ONLINE" then Colorize::colorize(status, :bright, :green) when "OFFLINE" then Colorize::colorize(status, :bright, :red) when "PROVISIONING" then Colorize::colorize(status, :bright, :blue) else status end end return [@agent_id, @host, status, @instance_type, @location].map { |value| value || '' } end |