lib/cloudstack-cli/commands/resource_limit.rb in cloudstack-cli-0.15.1 vs lib/cloudstack-cli/commands/resource_limit.rb in cloudstack-cli-1.0.0.rc1

- old
+ new

@@ -17,10 +17,12 @@ desc "list", "list resource limits" option :account option :project option :type, desc: "specify type, see types for a list of types" def list + resolve_account + resolve_project limits = client.list_resource_limits(options) table = [] header = options[:project] ? ["Project"] : ["Account"] header += ["Type", "Resource Name", "Max"] limits.each do |limit| @@ -40,11 +42,13 @@ option :domain, desc: "refresh resource for a specified domain" option :account, desc: "refresh resource for a specified account" option :project, desc: "refresh resource for a specified project" option :type, desc: "specify type, see types for a list of types" def refresh - set_domain_id if options[:domain] + resolve_domain + resolve_account + resolve_project options[:resource_type] = options[:type] if options[:type] unless ['domain_id', 'account', 'project'].any? {|k| options.key?(k)} say "Error: Please provide domain, account or project.", :red exit 1 @@ -67,11 +71,13 @@ required: true option :max, desc: "Maximum resource limit.", required: true def update - set_domain_id if options[:domain] + resolve_domain + resolve_account + resolve_project options[:resource_type] = options[:type] unless ['domain_id', 'account', 'project'].any? {|k| options.key?(k)} say "Error: Please provide domain, account or project.", :red exit 1 @@ -102,19 +108,9 @@ (limit[entity] / RESOURCE_TYPES[limit['resourcetype']][:divider]).round(1) : limit[entity] RESOURCE_TYPES[limit['resourcetype']][:unit] ? "#{value} #{RESOURCE_TYPES[limit['resourcetype']][:unit]}" : value.to_s - end - - def set_domain_id - domains = client.list_domains(options[:domain]) - if domains.size < 1 - say "Domain #{options[:domain]} not found.", :red - exit -1 - else - options[:domain_id] = domains.first['id'] - end end end end