mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 03:12:55 +09:00
Feature #2632: Fix quotas for oneuser/group list
This commit is contained in:
1 parent
c2f1a6d1c4
commit
043a8a7410
2 files changed
+56
-28
No files matched your search
@@ -65,6 +65,15 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
|
||||
prefix = '/GROUP_POOL/DEFAULT_GROUP_QUOTAS/'
|
||||
group_pool = @group_pool
|
||||
|
||||
quotas = group_pool.to_hash()['GROUP_POOL']['QUOTAS']
|
||||
quotas_hash = Hash.new
|
||||
|
||||
if (!quotas.nil?)
|
||||
quotas.each do |q|
|
||||
quotas_hash[q['ID']] = q
|
||||
end
|
||||
end
|
||||
|
||||
table = CLIHelper::ShowTable.new(config_file, self) do
|
||||
column :ID, "ONE identifier for the Group", :size=>4 do |d|
|
||||
d["ID"]
|
||||
@@ -88,48 +97,53 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
|
||||
end
|
||||
|
||||
column :VMS , "Number of VMS", :size=>9 do |d|
|
||||
if d.has_key?('VM_QUOTA') and d['VM_QUOTA'].has_key?('VM')
|
||||
limit = d['VM_QUOTA']['VM']["VMS"]
|
||||
begin
|
||||
q = quotas_hash[d['ID']]
|
||||
limit = q['VM_QUOTA']['VM']["VMS"]
|
||||
|
||||
if limit == "-1"
|
||||
limit = group_pool["#{prefix}VM_QUOTA/VM/VMS"]
|
||||
limit = "0" if limit.nil? || limit == ""
|
||||
end
|
||||
|
||||
"%3d / %3d" % [d['VM_QUOTA']['VM']["VMS_USED"], limit]
|
||||
else
|
||||
"%3d / %3d" % [q['VM_QUOTA']['VM']["VMS_USED"], limit]
|
||||
|
||||
rescue NoMethodError
|
||||
"-"
|
||||
end
|
||||
end
|
||||
|
||||
column :MEMORY, "Total memory allocated to user VMs", :size=>17 do |d|
|
||||
if d.has_key?('VM_QUOTA') and d['VM_QUOTA'].has_key?('VM')
|
||||
limit = d['VM_QUOTA']['VM']["MEMORY"]
|
||||
begin
|
||||
q = quotas_hash[d['ID']]
|
||||
limit = q['VM_QUOTA']['VM']["MEMORY"]
|
||||
|
||||
if limit == "-1"
|
||||
limit = group_pool["#{prefix}VM_QUOTA/VM/MEMORY"]
|
||||
limit = "0" if limit.nil? || limit == ""
|
||||
end
|
||||
|
||||
d['VM_QUOTA']['VM']['MEMORY_USED']
|
||||
"%7s / %7s" % [OpenNebulaHelper.unit_to_str(d['VM_QUOTA']['VM']["MEMORY_USED"].to_i,{},"M"),
|
||||
"%7s / %7s" % [OpenNebulaHelper.unit_to_str(q['VM_QUOTA']['VM']["MEMORY_USED"].to_i,{},"M"),
|
||||
OpenNebulaHelper.unit_to_str(limit.to_i,{},"M")]
|
||||
else
|
||||
|
||||
rescue NoMethodError
|
||||
"-"
|
||||
end
|
||||
end
|
||||
|
||||
column :CPU, "Total CPU allocated to user VMs", :size=>11 do |d|
|
||||
if d.has_key?('VM_QUOTA') and d['VM_QUOTA'].has_key?('VM')
|
||||
limit = d['VM_QUOTA']['VM']["CPU"]
|
||||
begin
|
||||
q = quotas_hash[d['ID']]
|
||||
limit = q['VM_QUOTA']['VM']["CPU"]
|
||||
|
||||
if limit == "-1"
|
||||
limit = group_pool["#{prefix}VM_QUOTA/VM/CPU"]
|
||||
limit = "0" if limit.nil? || limit == ""
|
||||
end
|
||||
|
||||
"%3.1f / %3.1f" % [d['VM_QUOTA']['VM']["CPU_USED"], limit]
|
||||
else
|
||||
"%3.1f / %3.1f" % [q['VM_QUOTA']['VM']["CPU_USED"], limit]
|
||||
|
||||
rescue NoMethodError
|
||||
"-"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -151,6 +151,15 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
||||
prefix = '/USER_POOL/DEFAULT_USER_QUOTAS/'
|
||||
user_pool = @user_pool
|
||||
|
||||
quotas = user_pool.to_hash()['USER_POOL']['QUOTAS']
|
||||
quotas_hash = Hash.new
|
||||
|
||||
if (!quotas.nil?)
|
||||
quotas.each do |q|
|
||||
quotas_hash[q['ID']] = q
|
||||
end
|
||||
end
|
||||
|
||||
table = CLIHelper::ShowTable.new(config_file, self) do
|
||||
column :ID, "ONE identifier for the User", :size=>4 do |d|
|
||||
d["ID"]
|
||||
@@ -168,49 +177,54 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
||||
d["AUTH_DRIVER"]
|
||||
end
|
||||
|
||||
column :VMS , "Number of VMS", :size=>9 do |d|
|
||||
if d.has_key?('VM_QUOTA') and d['VM_QUOTA'].has_key?('VM')
|
||||
limit = d['VM_QUOTA']['VM']["VMS"]
|
||||
column :VMS , "Number of VMS", :size=>9 do |d|
|
||||
begin
|
||||
q = quotas_hash[d['ID']]
|
||||
limit = q['VM_QUOTA']['VM']["VMS"]
|
||||
|
||||
if limit == "-1"
|
||||
limit = user_pool["#{prefix}VM_QUOTA/VM/VMS"]
|
||||
limit = "0" if limit.nil? || limit == ""
|
||||
end
|
||||
|
||||
"%3d / %3d" % [d['VM_QUOTA']['VM']["VMS_USED"], limit]
|
||||
else
|
||||
"%3d / %3d" % [q['VM_QUOTA']['VM']["VMS_USED"], limit]
|
||||
|
||||
rescue NoMethodError
|
||||
"-"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
column :MEMORY, "Total memory allocated to user VMs", :size=>17 do |d|
|
||||
if d.has_key?('VM_QUOTA') and d['VM_QUOTA'].has_key?('VM')
|
||||
limit = d['VM_QUOTA']['VM']["MEMORY"]
|
||||
begin
|
||||
q = quotas_hash[d['ID']]
|
||||
limit = q['VM_QUOTA']['VM']["MEMORY"]
|
||||
|
||||
if limit == "-1"
|
||||
limit = user_pool["#{prefix}VM_QUOTA/VM/MEMORY"]
|
||||
limit = "0" if limit.nil? || limit == ""
|
||||
end
|
||||
|
||||
d['VM_QUOTA']['VM']['MEMORY_USED']
|
||||
"%7s / %7s" % [OpenNebulaHelper.unit_to_str(d['VM_QUOTA']['VM']["MEMORY_USED"].to_i,{},"M"),
|
||||
"%7s / %7s" % [OpenNebulaHelper.unit_to_str(q['VM_QUOTA']['VM']["MEMORY_USED"].to_i,{},"M"),
|
||||
OpenNebulaHelper.unit_to_str(limit.to_i,{},"M")]
|
||||
else
|
||||
|
||||
rescue NoMethodError
|
||||
"-"
|
||||
end
|
||||
end
|
||||
|
||||
column :CPU, "Total CPU allocated to user VMs", :size=>11 do |d|
|
||||
if d.has_key?('VM_QUOTA') and d['VM_QUOTA'].has_key?('VM')
|
||||
limit = d['VM_QUOTA']['VM']["CPU"]
|
||||
begin
|
||||
q = quotas_hash[d['ID']]
|
||||
limit = q['VM_QUOTA']['VM']["CPU"]
|
||||
|
||||
if limit == "-1"
|
||||
limit = user_pool["#{prefix}VM_QUOTA/VM/CPU"]
|
||||
limit = "0" if limit.nil? || limit == ""
|
||||
end
|
||||
|
||||
"%3.1f / %3.1f" % [d['VM_QUOTA']['VM']["CPU_USED"], limit]
|
||||
else
|
||||
"%3.1f / %3.1f" % [q['VM_QUOTA']['VM']["CPU_USED"], limit]
|
||||
|
||||
rescue NoMethodError
|
||||
"-"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user