Class: Galaxy::Agent

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

Overview

Agent Information

Instance Attribute Summary collapse

Instance Method Summary collapse

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_idObject (readonly)

Returns the value of attribute agent_id.



80
81
82
# File 'lib/galaxy.rb', line 80

def agent_id
  @agent_id
end

#hostObject (readonly)

Returns the value of attribute host.



80
81
82
# File 'lib/galaxy.rb', line 80

def host
  @host
end

#instance_typeObject (readonly)

Returns the value of attribute instance_type.



80
81
82
# File 'lib/galaxy.rb', line 80

def instance_type
  @instance_type
end

#ipObject (readonly)

Returns the value of attribute ip.



80
81
82
# File 'lib/galaxy.rb', line 80

def ip
  @ip
end

#locationObject (readonly)

Returns the value of attribute location.



80
81
82
# File 'lib/galaxy.rb', line 80

def location
  @location
end

#pathObject (readonly)

Returns the value of attribute path.



80
81
82
# File 'lib/galaxy.rb', line 80

def path
  @path
end

#statusObject (readonly)

Returns the value of attribute status.



80
81
82
# File 'lib/galaxy.rb', line 80

def status
  @status
end

#urlObject (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