Class: CloudstackClient::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/cloudstack_client/cli.rb

Instance Method Summary collapse

Instance Method Details

#consoleObject



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/cloudstack_client/cli.rb', line 80

def console
  cs_client = client(options)

  print "cloudstack_client version #{CloudstackClient::VERSION}"
  puts " (CloudStack API version #{cs_client.api.api_version})"
  puts "  try: list_virtual_machines state: \"running\""

  ARGV.clear
  env = options[:env] ? options[:env] : load_configuration.last
  Ripl.config[:prompt] = "#{env} >> "
  Ripl.start binding: cs_client.instance_eval{ binding }
end

#list_apisObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/cloudstack_client/cli.rb', line 52

def list_apis
  apis = client(no_api_methods: true).send_request('command' => 'listApis')
  apis.each do |command|
    command.delete("response") if options[:remove_response]
    if options[:remove_description]
      command.delete("description")
      command["params"].each {|param| param.delete("description")}
    end
  end

  print case options[:format]
  when "yaml"
    apis.to_yaml
  else
    options[:pretty_print] ? JSON.pretty_generate(apis) : JSON.generate(apis)
  end
end

#versionObject



38
39
40
# File 'lib/cloudstack_client/cli.rb', line 38

def version
  say "cloudstack_client version #{CloudstackClient::VERSION}"
end