Class: CloudstackStats::Collect
- Inherits:
-
Object
- Object
- CloudstackStats::Collect
- Defined in:
- lib/cloudstack_stats/collect.rb
Instance Method Summary collapse
- #account_stats ⇒ Object
-
#initialize(settings) ⇒ Collect
constructor
A new instance of Collect.
- #project_stats ⇒ Object
Constructor Details
#initialize(settings) ⇒ Collect
Returns a new instance of Collect.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cloudstack_stats/collect.rb', line 8 def initialize(settings) @settings = settings.dup @config = if @settings[:cloudstack_url] && @settings[:cloudstack_api_key] && @settings[:cloudstack_secret_key] { url: @settings[:cloudstack_url], api_key: @settings[:cloudstack_api_key], secret_key: @settings[:cloudstack_secret_key] } else @settings[:config_file] = @settings[:cloudstack_config] CloudstackClient::Configuration.load(@settings) end @cs ||= CloudstackClient::Client.new( @config[:url], @config[:api_key], @config[:secret_key] ) @cs.debug = true if @settings[:debug] @cs end |
Instance Method Details
#account_stats ⇒ Object
31 32 33 34 35 36 |
# File 'lib/cloudstack_stats/collect.rb', line 31 def account_stats { type: "account", stats: @cs.list_accounts() } end |
#project_stats ⇒ Object
38 39 40 41 42 43 |
# File 'lib/cloudstack_stats/collect.rb', line 38 def project_stats { type: "project", stats: @cs.list_projects() } end |