Class: Rancher::Shell::CLI
- Inherits:
-
Thor
- Object
- Thor
- Rancher::Shell::CLI
- Defined in:
- lib/rancher/shell/cli.rb
Instance Method Summary collapse
Instance Method Details
#exec(command = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rancher/shell/cli.rb', line 19 def exec command = nil Config.load( 'project' => [:project], 'container' => [:container], 'stack' => [:stack], 'command' => command, ) instance = Rancher::Shell::Commands::Exec.new instance.setup_api! instance.retrieve_containers! instance.setup_websocket! instance.listen! end |
#list_containers ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rancher/shell/cli.rb', line 48 def list_containers Config.load( 'project' => [: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 ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# 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 |