49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/one_helper/onedatastore_helper.rb', line 49
def format_pool(options)
config_file = self.class.table_conf
table = CLIHelper::ShowTable.new(config_file, self) do
column :ID, "ONE identifier for the Datastore", :size=>4 do |d|
d["ID"]
end
column :USER, "Username of the Datastore owner", :left,
:size=>10 do |d|
helper.user_name(d, options)
end
column :GROUP, "Group of the Datastore", :left,
:size=>10 do |d|
helper.group_name(d, options)
end
column :NAME, "Name of the Datastore", :left, :size=>13 do |d|
d["NAME"]
end
column :SIZE, "Datastore total size", :size =>10 do |d|
shared = d['TEMPLATE']['SHARED']
if shared != nil && shared.upcase == 'NO'
"-"
else
OpenNebulaHelper.unit_to_str(d['TOTAL_MB'].to_i, {}, 'M')
end
end
column :AVAIL, "Datastore free size", :left, :size =>5 do |d|
if d['TOTAL_MB'].to_i == 0
"-"
else
"#{((d['FREE_MB'].to_f/d['TOTAL_MB'].to_f) * 100).round()}%"
end
end
column :CLUSTERS, "Cluster IDs", :left, :size=>12 do |d|
OpenNebulaHelper.clusters_str(d["CLUSTERS"]["ID"])
end
column :IMAGES, "Number of Images", :size=>6 do |d|
if d["IMAGES"]["ID"].nil?
"0"
else
[d["IMAGES"]["ID"]].flatten.size
end
end
column :TYPE, "Datastore type", :left, :size=>4 do |d|
type = OpenNebula::Datastore::DATASTORE_TYPES[d["TYPE"].to_i]
OpenNebula::Datastore::SHORT_DATASTORE_TYPES[type]
end
column :DS, "Datastore driver", :left, :size=>7 do |d|
d["DS_MAD"]
end
column :TM, "Transfer driver", :left, :size=>7 do |d|
d["TM_MAD"]
end
column :STAT, "State of the Datastore", :left, :size=>3 do |d|
state = OpenNebula::Datastore::DATASTORE_STATES[d["STATE"].to_i]
OpenNebula::Datastore::SHORT_DATASTORE_STATES[state]
end
default :ID, :USER, :GROUP, :NAME, :SIZE, :AVAIL, :CLUSTERS, :IMAGES,
:TYPE, :DS, :TM, :STAT
end
table
end
|