Collect quotas details for each tenant


#1

Im trying to create an automation script that for each execution will collect quotas details for each tenant in a specific provider and than will save it into a csv.

I was able to iterate through the tenants and was able to extract their defined quotas values.

  1. Any Ideas about how can I get the value of the used resource for each defined quota?
  2. Any ideas about how to save the data to a csv file that will be updated on each execution?
  3. Thoughts of the best way to execute this automation? schedule? event? a button?

thanks(:


#2

@Or_Granit

There should be a “used” association for each quota object that you can access.

eg;

tenant = $evm.vmdb(:cloud_tenant).find_by_name("tenant1")
quotas = tenant.cloud_resource_quotas
quotas.each {|quota| puts "used " << quota.used << " of " << quota.value }

#3

@jockey10 Thank you! btw where can I find a documentation for these kind of stuff? association/attributes for specific objects?

ideas about #2 and #3?


#4

#2 I’ve never used it, but there seems to be quite a good CSV Gem: https://ruby-doc.org/stdlib-2.0.0/libdoc/csv/rdoc/CSV.html (you’d need to install this to your appliance first).

#3 This depends whether you wanted it updated automatically on a schedule, or manually. A button on the provider is probably the simplest if you’re happy to manually trigger this.

Many of the methods are documented here: http://manageiq.org/docs/reference/latest/doc-Methods_Available_for_Automation/miq/#_chap_methods_available_for_use_with_cloudforms_management_engine, but you might also want to checkout the “Investigative Debugging” chapter here: https://pemcg.gitbooks.io/mastering-automation-in-cloudforms-and-manageiq/content/chapter10.html (I also presented a session on this at the ManageIQ Summit, video here: https://www.youtube.com/watch?v=PbnYj4lXDn8)

Hope this helps,
pemcg


#5

@pemcg wow that’s a great help! Great book! thank you!