class Syntax
Public Class Methods
new(line)
click to toggle source
# File lib/sos.rb, line 43 def initialize(line) @command = nil @options = { :runlevel => 3, :selector => 'openstack,neutron', :all => false } @arguments = [] until line.empty? case line[0] when '-a', '--all' @options[:all] = true when '-s', '--selector' line.shift @options[:selector] = line[0].gsub(/\s*/,'') when '-r', '--run_level' line.shift @options[:runlevel] = line[0].to_i when /status/i, /start/i, /stop/i, /restart/i, /logs/i, /list/i, 'test' @command = line[0] line.shift @arguments = line break else self.usage end line.shift end self.usage unless @command end
Public Instance Methods
run()
click to toggle source
# File lib/sos.rb, line 74 def run services_list = Services.build_list(@options[:selector], @options[:runlevel], @arguments) services = Services.new(services_list, OpenStack::LOGS) case @command when /status/i, /start/i, /stop/i, /restart/i services.enabled.each { |service| system("service #{service.name} #{@command}") } when /logs/i logs = '' services.enabled.each { |service| logs << service.logs.join(' ') + ' ' } exec("tail -f #{logs}") if logs when /list/i services.by_name.each { |service| puts service } when 'test' p self end end
usage()
click to toggle source
# File lib/sos.rb, line 99 def usage puts SYNTAX exit end