Sha256: 959e88e0654b6f436d1d5807d307da8155e52d2c4f15733cce617ab9570e6cc9
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
#encoding: utf-8 module Vagabond module Actions module Status class << self def included(klass) klass.class_eval do class << self def _status_desc if(defined?(Server) && self == Server) ['status', 'Status of server'] else ['status [NODE]', 'Status of NODE or all nodes'] end end end end end end def _status status = [ ui.color('Name', :bold), ui.color('State', :bold), ui.color('PID', :bold), ui.color('IP', :bold) ] if(name) status += status_for(name) else if(self.is_a?(Vagabond)) names = (Array(vagabondfile[:boxes].keys) | Array(internal_config[mappings_key].keys)) else names = Array(internal_config[mappings_key].keys) end names.sort.each do |n| status += status_for(n) end end puts ui.list(status, :uneven_columns_across, 4) end private def status_for(c_name) m_name = internal_config[mappings_key][c_name] state = nil status = [] if(Lxc.exists?(m_name)) @lxc = Lxc.new(m_name) unless defined?(lxc) && lxc.name == m_name info = Lxc.info(m_name) case info[:state] when :running color = :green when :frozen color = :blue when :stopped color = :yellow else color = :red end status << ui.color(c_name, color) status << (info[:state] || 'N/A').to_s status << (info[:pid] == -1 ? 'N/A' : info[:pid]).to_s status << (@lxc.container_ip || 'unknown') else status << ui.color(c_name, :red) status += ['N/A'] * 3 end status end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagabond-0.2.10 | lib/vagabond/actions/status.rb |