class Rancher::Shell::CLI
Public Instance Methods
exec(command = nil)
click to toggle source
# File lib/rancher/shell/cli.rb, line 19 def exec command = nil Config.load( 'project' => options[:project], 'container' => options[:container], 'stack' => options[:stack], 'command' => command, ) instance = Rancher::Shell::Commands::Exec.new instance.setup_api! instance.retrieve_containers! instance.setup_websocket! instance.listen! end
list_containers()
click to toggle source
# File lib/rancher/shell/cli.rb, line 48 def list_containers Config.load( 'project' => options[:project], ) project = Config.get('project') api = Rancher::Shell::Api.new( host: project['api']['host'], user: project['api']['key'], pass: project['api']['secret'], ) containers = api.get('containers?state=running').json['data'] containers.each do |container| print container['id'].ljust 12 print container['state'].ljust 12 print container['name'].ljust 40 print container['imageUuid'][7..-1].ljust 48 print container['ports'] if container['ports'] && container['ports'] != '' print "\n" end end
list_projects()
click to toggle source
# File lib/rancher/shell/cli.rb, line 34 def list_projects Config.load projects = Config.get('projects') projects.each do |key, project| print key.ljust 24 print project['name'].ljust 32 print project['api']['host'].ljust 32 print project['stacks'].keys.join(', ') unless project['stacks'].nil? print "\n" end end
version()
click to toggle source
# File lib/rancher/shell/cli.rb, line 11 def version puts "Rancher::Shell #{Rancher::Shell::VERSION}" end