opennebula-cli 4.4.0 → 4.5.80.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NOTICE +1 -1
- data/bin/oneacct +28 -4
- data/bin/oneacl +3 -3
- data/bin/onecluster +1 -1
- data/bin/onedatastore +1 -1
- data/bin/oneflow +1 -1
- data/bin/oneflow-template +1 -1
- data/bin/onegroup +103 -5
- data/bin/onehost +2 -2
- data/bin/oneimage +1 -1
- data/bin/onetemplate +1 -1
- data/bin/oneuser +2 -2
- data/bin/onevm +1 -1
- data/bin/onevnet +1 -1
- data/bin/onezone +145 -0
- data/lib/cli_helper.rb +73 -17
- data/lib/command_parser.rb +1 -1
- data/lib/one_helper.rb +136 -21
- data/lib/one_helper/oneacct_helper.rb +7 -3
- data/lib/one_helper/oneacl_helper.rb +11 -5
- data/lib/one_helper/onecluster_helper.rb +1 -1
- data/lib/one_helper/onedatastore_helper.rb +1 -1
- data/lib/one_helper/onegroup_helper.rb +114 -25
- data/lib/one_helper/onehost_helper.rb +2 -2
- data/lib/one_helper/oneimage_helper.rb +1 -1
- data/lib/one_helper/onequota_helper.rb +1 -1
- data/lib/one_helper/onetemplate_helper.rb +1 -1
- data/lib/one_helper/oneuser_helper.rb +44 -22
- data/lib/one_helper/onevm_helper.rb +1 -1
- data/lib/one_helper/onevnet_helper.rb +1 -1
- data/lib/one_helper/onezone_helper.rb +104 -0
- metadata +14 -10
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -44,7 +44,7 @@ private
|
|
44
44
|
def self.resource_mask(str)
|
45
45
|
resource_type=str.split("/")[0]
|
46
46
|
|
47
|
-
mask = "
|
47
|
+
mask = "-----------"
|
48
48
|
|
49
49
|
resource_type.split("+").each{|type|
|
50
50
|
case type
|
@@ -68,6 +68,8 @@ private
|
|
68
68
|
mask[8] = "C"
|
69
69
|
when "DOCUMENT"
|
70
70
|
mask[9] = "O"
|
71
|
+
when "ZONE"
|
72
|
+
mask[10] = "Z"
|
71
73
|
end
|
72
74
|
}
|
73
75
|
mask
|
@@ -107,8 +109,8 @@ private
|
|
107
109
|
d['STRING'].split(" ")[0]
|
108
110
|
end
|
109
111
|
|
110
|
-
column :
|
111
|
-
:size =>
|
112
|
+
column :RES_VHNIUTGDCOZ, "Resource to which the rule applies",
|
113
|
+
:size => 15 do |d|
|
112
114
|
OneAclHelper::resource_mask d['STRING'].split(" ")[1]
|
113
115
|
end
|
114
116
|
|
@@ -116,12 +118,16 @@ private
|
|
116
118
|
d['STRING'].split(" ")[1].split("/")[1]
|
117
119
|
end
|
118
120
|
|
121
|
+
column :ZONE, "Zone ID", :right, :size=>5 do |d|
|
122
|
+
d['STRING'].split(" ")[3]
|
123
|
+
end
|
124
|
+
|
119
125
|
column :OPE_UMAC,
|
120
126
|
"Operation to which the rule applies", :size =>8 do |d|
|
121
127
|
OneAclHelper::right_mask d['STRING'].split(" ")[2]
|
122
128
|
end
|
123
129
|
|
124
|
-
default :ID, :USER, :
|
130
|
+
default :ID, :USER, :RES_VHNIUTGDCOZ, :RID, :OPE_UMAC, :ZONE
|
125
131
|
end
|
126
132
|
|
127
133
|
table
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -30,28 +30,63 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
|
|
30
30
|
group = factory
|
31
31
|
|
32
32
|
rc = block.call(group)
|
33
|
+
|
33
34
|
if OpenNebula.is_error?(rc)
|
34
35
|
return -1, rc.message
|
35
36
|
else
|
36
37
|
puts "ID: #{group.id.to_s}"
|
37
38
|
end
|
38
39
|
|
39
|
-
puts "Creating default ACL rules
|
40
|
+
puts "Creating default ACL rules: #{GROUP_DEFAULT_ACLS}" if options[:verbose]
|
41
|
+
|
42
|
+
exit_code , msg = group.create_default_acls
|
43
|
+
|
44
|
+
if OpenNebula.is_error?(exit_code)
|
45
|
+
return -1, exit_code.message
|
46
|
+
end
|
47
|
+
|
48
|
+
exit_code.to_i
|
49
|
+
end
|
40
50
|
|
41
|
-
|
51
|
+
def create_complete_resource(group_hash)
|
52
|
+
group = factory
|
53
|
+
exit_code , msg = group.create(group_hash)
|
42
54
|
|
43
|
-
puts msg
|
55
|
+
puts msg if msg && !msg.empty?
|
44
56
|
|
45
|
-
exit_code
|
57
|
+
if (exit_code.class==Fixnum and exit_code < 0) or OpenNebula.is_error?(exit_code)
|
58
|
+
puts exit_code.message if OpenNebula.is_error?(exit_code) && exit_code.message
|
59
|
+
return -1
|
60
|
+
else
|
61
|
+
puts "ID: #{group.id}"
|
62
|
+
return 0
|
63
|
+
end
|
46
64
|
end
|
47
65
|
|
48
66
|
def format_pool(options)
|
49
67
|
config_file = self.class.table_conf
|
50
68
|
|
51
|
-
prefix = '/GROUP_POOL/DEFAULT_GROUP_QUOTAS/'
|
52
|
-
group_pool = @group_pool
|
53
|
-
|
54
69
|
table = CLIHelper::ShowTable.new(config_file, self) do
|
70
|
+
def pool_default_quotas(path)
|
71
|
+
@data.dsearch('/GROUP_POOL/DEFAULT_GROUP_QUOTAS/'+path)
|
72
|
+
end
|
73
|
+
|
74
|
+
def quotas
|
75
|
+
if !defined?(@quotas)
|
76
|
+
quotas = @data.dsearch('GROUP_POOL/QUOTAS')
|
77
|
+
@quotas = Hash.new
|
78
|
+
|
79
|
+
if (!quotas.nil?)
|
80
|
+
quotas = [quotas].flatten
|
81
|
+
|
82
|
+
quotas.each do |q|
|
83
|
+
@quotas[q['ID']] = q
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
@quotas
|
88
|
+
end
|
89
|
+
|
55
90
|
column :ID, "ONE identifier for the Group", :size=>4 do |d|
|
56
91
|
d["ID"]
|
57
92
|
end
|
@@ -73,49 +108,54 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
|
|
73
108
|
end
|
74
109
|
end
|
75
110
|
|
76
|
-
column :VMS , "Number of VMS", :size=>9 do |d|
|
77
|
-
|
78
|
-
|
111
|
+
column :VMS , "Number of VMS", :size=>9 do |d|
|
112
|
+
begin
|
113
|
+
q = quotas[d['ID']]
|
114
|
+
limit = q['VM_QUOTA']['VM']["VMS"]
|
79
115
|
|
80
116
|
if limit == "-1"
|
81
|
-
limit =
|
117
|
+
limit = pool_default_quotas("VM_QUOTA/VM/VMS")
|
82
118
|
limit = "0" if limit.nil? || limit == ""
|
83
119
|
end
|
84
120
|
|
85
|
-
"%3d / %3d" % [
|
86
|
-
|
121
|
+
"%3d / %3d" % [q['VM_QUOTA']['VM']["VMS_USED"], limit]
|
122
|
+
|
123
|
+
rescue NoMethodError
|
87
124
|
"-"
|
88
125
|
end
|
89
126
|
end
|
90
127
|
|
91
128
|
column :MEMORY, "Total memory allocated to user VMs", :size=>17 do |d|
|
92
|
-
|
93
|
-
|
129
|
+
begin
|
130
|
+
q = quotas[d['ID']]
|
131
|
+
limit = q['VM_QUOTA']['VM']["MEMORY"]
|
94
132
|
|
95
133
|
if limit == "-1"
|
96
|
-
limit =
|
134
|
+
limit = pool_default_quotas("VM_QUOTA/VM/MEMORY")
|
97
135
|
limit = "0" if limit.nil? || limit == ""
|
98
136
|
end
|
99
137
|
|
100
|
-
|
101
|
-
"%7s / %7s" % [OpenNebulaHelper.unit_to_str(d['VM_QUOTA']['VM']["MEMORY_USED"].to_i,{},"M"),
|
138
|
+
"%7s / %7s" % [OpenNebulaHelper.unit_to_str(q['VM_QUOTA']['VM']["MEMORY_USED"].to_i,{},"M"),
|
102
139
|
OpenNebulaHelper.unit_to_str(limit.to_i,{},"M")]
|
103
|
-
|
140
|
+
|
141
|
+
rescue NoMethodError
|
104
142
|
"-"
|
105
143
|
end
|
106
144
|
end
|
107
145
|
|
108
146
|
column :CPU, "Total CPU allocated to user VMs", :size=>11 do |d|
|
109
|
-
|
110
|
-
|
147
|
+
begin
|
148
|
+
q = quotas[d['ID']]
|
149
|
+
limit = q['VM_QUOTA']['VM']["CPU"]
|
111
150
|
|
112
151
|
if limit == "-1"
|
113
|
-
limit =
|
152
|
+
limit = pool_default_quotas("VM_QUOTA/VM/CPU")
|
114
153
|
limit = "0" if limit.nil? || limit == ""
|
115
154
|
end
|
116
155
|
|
117
|
-
"%3.1f / %3.1f" % [
|
118
|
-
|
156
|
+
"%3.1f / %3.1f" % [q['VM_QUOTA']['VM']["CPU_USED"], limit]
|
157
|
+
|
158
|
+
rescue NoMethodError
|
119
159
|
"-"
|
120
160
|
end
|
121
161
|
end
|
@@ -126,6 +166,35 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
|
|
126
166
|
table
|
127
167
|
end
|
128
168
|
|
169
|
+
# Parses a OpenNebula template string and turns it into a Hash
|
170
|
+
# @param [String] tmpl_str template
|
171
|
+
# @return [Hash, Zona::Error] Hash or Error
|
172
|
+
def parse_template(tmpl_str)
|
173
|
+
name_reg =/[\w\d_-]+/
|
174
|
+
variable_reg =/\s*(#{name_reg})\s*=\s*/
|
175
|
+
single_variable_reg =/^#{variable_reg}([^\[]+?)(#.*)?$/
|
176
|
+
|
177
|
+
tmpl = Hash.new
|
178
|
+
tmpl['user'] = Hash.new
|
179
|
+
|
180
|
+
tmpl_str.scan(single_variable_reg) do | m |
|
181
|
+
key = m[0].strip.downcase
|
182
|
+
value = m[1].strip.gsub("\"","")
|
183
|
+
case key
|
184
|
+
when "admin_user_name"
|
185
|
+
tmpl['user']['name']=value
|
186
|
+
when "admin_user_password"
|
187
|
+
tmpl['user']['password']=value
|
188
|
+
when "admin_user_auth_driver"
|
189
|
+
tmpl['user']['auth_driver']=value
|
190
|
+
else
|
191
|
+
tmpl[key] = value
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
return tmpl
|
196
|
+
end
|
197
|
+
|
129
198
|
private
|
130
199
|
|
131
200
|
def factory(id=nil)
|
@@ -154,6 +223,10 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
|
|
154
223
|
puts str % ["NAME", group.name]
|
155
224
|
puts
|
156
225
|
|
226
|
+
CLIHelper.print_header(str_h1 % "GROUP TEMPLATE",false)
|
227
|
+
puts group.template_str
|
228
|
+
puts
|
229
|
+
|
157
230
|
CLIHelper.print_header(str_h1 % "USERS", false)
|
158
231
|
CLIHelper.print_header("%-15s" % ["ID"])
|
159
232
|
group.user_ids.each do |uid|
|
@@ -162,6 +235,22 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
|
|
162
235
|
|
163
236
|
group_hash = group.to_hash
|
164
237
|
|
238
|
+
providers = group_hash['GROUP']['RESOURCE_PROVIDER']
|
239
|
+
if(providers != nil)
|
240
|
+
puts
|
241
|
+
CLIHelper.print_header(str_h1 % "RESOURCE PROVIDERS", false)
|
242
|
+
|
243
|
+
CLIHelper::ShowTable.new(nil, self) do
|
244
|
+
column :"ZONE", "", :right, :size=>7 do |d|
|
245
|
+
d['ZONE_ID']
|
246
|
+
end
|
247
|
+
|
248
|
+
column :"CLUSTER", "", :right, :size=>7 do |d|
|
249
|
+
d['CLUSTER_ID'] == '10' ? 'ALL' : d['CLUSTER_ID']
|
250
|
+
end
|
251
|
+
end.show([providers].flatten, {})
|
252
|
+
end
|
253
|
+
|
165
254
|
default_quotas = nil
|
166
255
|
|
167
256
|
group.each('/GROUP/DEFAULT_GROUP_QUOTAS') { |elem|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -307,7 +307,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
|
307
307
|
str="#{bar} #{info} "
|
308
308
|
name=host[0..(79-str.length)]
|
309
309
|
str=str+name
|
310
|
-
str=str+" "*(
|
310
|
+
str=str+" "*(80-str.length)
|
311
311
|
|
312
312
|
print "#{str}\r"
|
313
313
|
STDOUT.flush
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -148,10 +148,27 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
|
148
148
|
def format_pool(options)
|
149
149
|
config_file = self.class.table_conf
|
150
150
|
|
151
|
-
prefix = '/USER_POOL/DEFAULT_USER_QUOTAS/'
|
152
|
-
user_pool = @user_pool
|
153
|
-
|
154
151
|
table = CLIHelper::ShowTable.new(config_file, self) do
|
152
|
+
def pool_default_quotas(path)
|
153
|
+
@data.dsearch('/USER_POOL/DEFAULT_USER_QUOTAS/'+path)
|
154
|
+
end
|
155
|
+
|
156
|
+
def quotas
|
157
|
+
if !defined?(@quotas)
|
158
|
+
quotas = @data.dsearch('USER_POOL/QUOTAS')
|
159
|
+
@quotas = Hash.new
|
160
|
+
|
161
|
+
if (!quotas.nil?)
|
162
|
+
quotas = [quotas].flatten
|
163
|
+
|
164
|
+
quotas.each do |q|
|
165
|
+
@quotas[q['ID']] = q
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
@quotas
|
170
|
+
end
|
171
|
+
|
155
172
|
column :ID, "ONE identifier for the User", :size=>4 do |d|
|
156
173
|
d["ID"]
|
157
174
|
end
|
@@ -168,49 +185,54 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
|
168
185
|
d["AUTH_DRIVER"]
|
169
186
|
end
|
170
187
|
|
171
|
-
column :VMS , "Number of VMS", :size=>9 do |d|
|
172
|
-
|
173
|
-
|
188
|
+
column :VMS , "Number of VMS", :size=>9 do |d|
|
189
|
+
begin
|
190
|
+
q = quotas[d['ID']]
|
191
|
+
limit = q['VM_QUOTA']['VM']["VMS"]
|
174
192
|
|
175
193
|
if limit == "-1"
|
176
|
-
limit =
|
194
|
+
limit = pool_default_quotas("VM_QUOTA/VM/VMS")
|
177
195
|
limit = "0" if limit.nil? || limit == ""
|
178
196
|
end
|
179
197
|
|
180
|
-
"%3d / %3d" % [
|
181
|
-
|
198
|
+
"%3d / %3d" % [q['VM_QUOTA']['VM']["VMS_USED"], limit]
|
199
|
+
|
200
|
+
rescue NoMethodError
|
182
201
|
"-"
|
183
|
-
end
|
202
|
+
end
|
184
203
|
end
|
185
204
|
|
186
205
|
column :MEMORY, "Total memory allocated to user VMs", :size=>17 do |d|
|
187
|
-
|
188
|
-
|
206
|
+
begin
|
207
|
+
q = quotas[d['ID']]
|
208
|
+
limit = q['VM_QUOTA']['VM']["MEMORY"]
|
189
209
|
|
190
210
|
if limit == "-1"
|
191
|
-
limit =
|
211
|
+
limit = pool_default_quotas("VM_QUOTA/VM/MEMORY")
|
192
212
|
limit = "0" if limit.nil? || limit == ""
|
193
213
|
end
|
194
214
|
|
195
|
-
|
196
|
-
"%7s / %7s" % [OpenNebulaHelper.unit_to_str(d['VM_QUOTA']['VM']["MEMORY_USED"].to_i,{},"M"),
|
215
|
+
"%7s / %7s" % [OpenNebulaHelper.unit_to_str(q['VM_QUOTA']['VM']["MEMORY_USED"].to_i,{},"M"),
|
197
216
|
OpenNebulaHelper.unit_to_str(limit.to_i,{},"M")]
|
198
|
-
|
217
|
+
|
218
|
+
rescue NoMethodError
|
199
219
|
"-"
|
200
220
|
end
|
201
221
|
end
|
202
222
|
|
203
223
|
column :CPU, "Total CPU allocated to user VMs", :size=>11 do |d|
|
204
|
-
|
205
|
-
|
224
|
+
begin
|
225
|
+
q = quotas[d['ID']]
|
226
|
+
limit = q['VM_QUOTA']['VM']["CPU"]
|
206
227
|
|
207
228
|
if limit == "-1"
|
208
|
-
limit =
|
229
|
+
limit = pool_default_quotas("VM_QUOTA/VM/CPU")
|
209
230
|
limit = "0" if limit.nil? || limit == ""
|
210
231
|
end
|
211
232
|
|
212
|
-
"%3.1f / %3.1f" % [
|
213
|
-
|
233
|
+
"%3.1f / %3.1f" % [q['VM_QUOTA']['VM']["CPU_USED"], limit]
|
234
|
+
|
235
|
+
rescue NoMethodError
|
214
236
|
"-"
|
215
237
|
end
|
216
238
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|