1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Feature #1285: Change the quotas output for oneuser and onegroup

(cherry picked from commit 82cbf0ff6569029c1922994149f98c2532f947b4)
This commit is contained in:
Carlos Martín 2012-07-05 12:10:02 +02:00
parent 9dcba5ddf1
commit a93ba1502d
6 changed files with 72 additions and 81 deletions

View File

@ -5,24 +5,29 @@
:NAME:
:desc: Name of the Group
:size: 25
:size: 29
:left: true
:USERS:
:desc: Number of Users in this group
:size: 5
:VMS:
:desc: Number of VMS
:size: 6
:size: 9
:MEMORY:
:desc: Total memory allocated to user VMs
:size: 8
:size: 17
:CPU:
:desc: Total CPU allocated to user VMs
:size: 8
:size: 11
:default:
- :ID
- :NAME
- :USERS
- :VMS
- :MEMORY
- :CPU

View File

@ -5,30 +5,30 @@
:NAME:
:desc: Name of the User
:size: 18
:size: 15
:left: true
:GROUP:
:desc: Group of the User
:size: 15
:size: 10
:left: true
:AUTH:
:desc: Auth driver of the User
:size: 15
:size: 8
:left: true
:VMS:
:desc: Number of VMS
:size: 6
:size: 9
:MEMORY:
:desc: Total memory allocated to user VMs
:size: 8
:size: 17
:CPU:
:desc: Total CPU allocated to user VMs
:size: 8
:size: 11
:PASSWORD:
:desc: Password of the User

View File

@ -53,35 +53,44 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
d["ID"]
end
column :NAME, "Name of the Group", :left, :size=>25 do |d|
column :NAME, "Name of the Group", :left, :size=>29 do |d|
d["NAME"]
end
column :VMS, "Total number of VMS", :size=>6 do |d|
if d.has_key?('VM_QUOTA') and d['VM_QUOTA'].has_key?('VM')
d['VM_QUOTA']['VM']['VMS_USED']
column :USERS, "Number of Users in this group", :size=>5 do |d|
if d["USERS"]["ID"].nil?
"0"
else
"-"
end
d["USERS"]["ID"].size
end
end
column :MEMORY, "Total memory allocated to group VMs", :size=>8 do |d|
column :VMS , "Number of VMS", :size=>9 do |d|
if d.has_key?('VM_QUOTA') and d['VM_QUOTA'].has_key?('VM')
d['VM_QUOTA']['VM']['MEMORY_USED']
"%3d / %3d" % [d['VM_QUOTA']['VM']["VMS_USED"], d['VM_QUOTA']['VM']["VMS"]]
else
"-"
end
end
column :CPU, "Total CPU allocated to group VMs", :size=>8 do |d|
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')
d['VM_QUOTA']['VM']['CPU_USED']
"%7s / %7s" % [OpenNebulaHelper.unit_to_str(d['VM_QUOTA']['VM']["MEMORY_USED"].to_i,{},"M"),
OpenNebulaHelper.unit_to_str(d['VM_QUOTA']['VM']["MEMORY"].to_i,{},"M")]
else
"-"
end
end
default :ID, :NAME, :VMS, :MEMORY, :CPU
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')
"%4d / %4d" % [d['VM_QUOTA']['VM']["CPU_USED"], d['VM_QUOTA']['VM']["CPU"]]
else
"-"
end
end
default :ID, :NAME, :USERS, :VMS, :MEMORY, :CPU
end
table

View File

@ -24,78 +24,53 @@ class OneQuotaHelper
# Tables to format user quotas
#---------------------------------------------------------------------------
TABLE_DS = CLIHelper::ShowTable.new(nil, self) do
column :"DATASTORE ID", "", :left, :size=>12 do |d|
column :"DATASTORE ID", "", :size=>12 do |d|
d["ID"] if !d.nil?
end
column :"IMAGES (used)", "", :right, :size=>14 do |d|
d["IMAGES_USED"] if !d.nil?
column :"IMAGES", "", :right, :size=>20 do |d|
"%8d / %8d" % [d["IMAGES_USED"], d["IMAGES"]] if !d.nil?
end
column :"IMAGES (limit)", "", :right, :size=>14 do |d|
d["IMAGES"] if !d.nil?
end
column :"SIZE (used)", "", :right, :size=>14 do |d|
d["SIZE_USED"] if !d.nil?
end
column :"SIZE (limit)", "", :right, :size=>14 do |d|
d["SIZE"] if !d.nil?
column :"SIZE", "", :right, :size=>19 do |d|
"%8s / %8s" % [OpenNebulaHelper.unit_to_str(d["SIZE_USED"].to_i,{},"M"),
OpenNebulaHelper.unit_to_str(d["SIZE"].to_i,{},"M")] if !d.nil?
end
end
TABLE_NET = CLIHelper::ShowTable.new(nil, self) do
column :"NETWORK ID", "", :left, :size=>12 do |d|
column :"NETWORK ID", "", :size=>12 do |d|
d["ID"] if !d.nil?
end
column :"LEASES (used)", "", :right, :size=>14 do |d|
d["LEASES_USED"] if !d.nil?
end
column :"LEASES (limit)", "", :right, :size=>14 do |d|
d["LEASES"] if !d.nil?
column :"LEASES", "", :right, :size=>20 do |d|
"%8d / %8d" % [d["LEASES_USED"], d["LEASES"]] if !d.nil?
end
end
TABLE_VM = CLIHelper::ShowTable.new(nil, self) do
column :"VMS (used)", "", :left, :size=>12 do |d|
d["VMS_USED"] if !d.nil?
column :"NUMBER OF VMS", "", :right, :size=>20 do |d|
"%8d / %8d" % [d["VMS_USED"], d["VMS"]] if !d.nil?
end
column :"VMS (limit)", "", :left, :size=>12 do |d|
d["VMS"] if !d.nil?
column :"MEMORY", "", :right, :size=>20 do |d|
"%8s / %8s" % [OpenNebulaHelper.unit_to_str(d["MEMORY_USED"].to_i,{},"M"),
OpenNebulaHelper.unit_to_str(d["MEMORY"].to_i,{},"M")] if !d.nil?
end
column :"MEMORY (used)", "", :right, :size=>14 do |d|
d["MEMORY_USED"] if !d.nil?
end
column :"MEMORY (limit)", "", :right, :size=>14 do |d|
d["MEMORY"] if !d.nil?
end
column :"CPU (used)", "", :right, :size=>14 do |d|
d["CPU_USED"] if !d.nil?
end
column :"CPU (limit)", "", :right, :size=>14 do |d|
d["CPU"] if !d.nil?
column :"CPU", "", :right, :size=>20 do |d|
"%4d / %4d" % [d["CPU_USED"], d["CPU"]] if !d.nil?
end
end
TABLE_IMG = CLIHelper::ShowTable.new(nil, self) do
column :"IMAGE ID", "", :left, :size=>12 do |d|
column :"IMAGE ID", "", :size=>12 do |d|
d["ID"] if !d.nil?
end
column :"RVMS (used)", "", :right, :size=>14 do |d|
d["RVMS_USED"] if !d.nil?
end
column :"RVMS (limit)", "", :right, :size=>14 do |d|
d["RVMS"] if !d.nil?
column :"RUNNING VMS", "", :right, :size=>20 do |d|
"%8d / %8d" % [d["RVMS_USED"], d["RVMS"]] if !d.nil?
end
end
@ -189,18 +164,18 @@ class OneQuotaHelper
puts
ds_quotas = [qh['DATASTORE_QUOTA']['DATASTORE']].flatten
if !ds_quotas[0].nil?
TABLE_DS.show(ds_quotas, {})
puts
end
vm_quotas = [qh['VM_QUOTA']['VM']].flatten
if !vm_quotas[0].nil?
TABLE_VM.show(vm_quotas, {})
puts
end
ds_quotas = [qh['DATASTORE_QUOTA']['DATASTORE']].flatten
if !ds_quotas[0].nil?
TABLE_DS.show(ds_quotas, {})
puts
end
net_quotas = [qh['NETWORK_QUOTA']['NETWORK']].flatten
if !net_quotas[0].nil?
TABLE_NET.show(net_quotas, {})

View File

@ -152,37 +152,39 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
d["ID"]
end
column :NAME, "Name of the User", :left, :size=>18 do |d|
column :NAME, "Name of the User", :left, :size=>15 do |d|
d["NAME"]
end
column :GROUP, "Group of the User", :left, :size=>15 do |d|
column :GROUP, "Group of the User", :left, :size=>10 do |d|
helper.group_name(d, options)
end
column :AUTH, "Auth driver of the User", :left, :size=>15 do |d|
column :AUTH, "Auth driver of the User", :left, :size=>8 do |d|
d["AUTH_DRIVER"]
end
column :VMS, "Number of VMS", :size=>6 do |d|
column :VMS , "Number of VMS", :size=>9 do |d|
if d.has_key?('VM_QUOTA') and d['VM_QUOTA'].has_key?('VM')
d['VM_QUOTA']['VM']['VMS_USED']
"%3d / %3d" % [d['VM_QUOTA']['VM']["VMS_USED"], d['VM_QUOTA']['VM']["VMS"]]
else
"-"
end
end
column :MEMORY, "Total memory allocated to user VMs", :size=>8 do |d|
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')
d['VM_QUOTA']['VM']['MEMORY_USED']
"%7s / %7s" % [OpenNebulaHelper.unit_to_str(d['VM_QUOTA']['VM']["MEMORY_USED"].to_i,{},"M"),
OpenNebulaHelper.unit_to_str(d['VM_QUOTA']['VM']["MEMORY"].to_i,{},"M")]
else
"-"
end
end
column :CPU, "Total CPU allocated to user VMs", :size=>8 do |d|
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')
d['VM_QUOTA']['VM']['CPU_USED']
"%4d / %4d" % [d['VM_QUOTA']['VM']["CPU_USED"], d['VM_QUOTA']['VM']["CPU"]]
else
"-"
end

View File

@ -235,7 +235,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
d["HOSTNAME"]
end
column :REASON, "VM state change reason", :size=>6 do |d|
column :REASON, "VM state change reason", :left, :size=>6 do |d|
VirtualMachine.get_reason d["REASON"]
end