opennebula-cli 3.8.0 → 3.9.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/oneacct +10 -5
- data/bin/oneacl +5 -1
- data/bin/onecluster +5 -1
- data/bin/onedatastore +5 -1
- data/bin/onegroup +40 -1
- data/bin/onehost +5 -1
- data/bin/oneimage +31 -2
- data/bin/onetemplate +24 -4
- data/bin/oneuser +43 -21
- data/bin/onevm +47 -9
- data/bin/onevnet +15 -1
- data/lib/cli_helper.rb +50 -9
- data/lib/command_parser.rb +79 -37
- data/lib/one_helper/oneacct_helper.rb +4 -4
- data/lib/one_helper/onedatastore_helper.rb +8 -2
- data/lib/one_helper/onegroup_helper.rb +41 -4
- data/lib/one_helper/onehost_helper.rb +9 -0
- data/lib/one_helper/oneimage_helper.rb +15 -10
- data/lib/one_helper/onequota_helper.rb +134 -72
- data/lib/one_helper/oneuser_helper.rb +50 -14
- data/lib/one_helper.rb +210 -16
- metadata +55 -29
data/bin/oneacct
CHANGED
@@ -37,11 +37,17 @@ cmd = CommandParser::CmdParser.new(ARGV) do
|
|
37
37
|
description ""
|
38
38
|
version OpenNebulaHelper::ONE_VERSION
|
39
39
|
|
40
|
+
helper=OpenNebulaHelper::OneHelper.new
|
40
41
|
|
41
|
-
|
42
|
+
before_proc do
|
43
|
+
helper.set_client(options)
|
44
|
+
end
|
45
|
+
|
46
|
+
option AcctHelper::ACCT_OPTIONS + CommandParser::OPTIONS +
|
47
|
+
OpenNebulaHelper::CLIENT_OPTIONS
|
42
48
|
|
43
49
|
main do
|
44
|
-
filter_flag = (options[:
|
50
|
+
filter_flag = (options[:userfilter] || VirtualMachinePool::INFO_ALL)
|
45
51
|
start_time = options[:start] ? options[:start].to_i : -1
|
46
52
|
end_time = options[:end] ? options[:end].to_i : -1
|
47
53
|
|
@@ -53,9 +59,7 @@ cmd = CommandParser::CmdParser.new(ARGV) do
|
|
53
59
|
:xpath => options[:xpath]
|
54
60
|
}
|
55
61
|
|
56
|
-
|
57
|
-
pool = OpenNebula::VirtualMachinePool.new(client)
|
58
|
-
|
62
|
+
pool = OpenNebula::VirtualMachinePool.new(helper.client)
|
59
63
|
|
60
64
|
if options[:json] || options[:xml]
|
61
65
|
xml_str = pool.accounting_xml(filter_flag, common_opts)
|
@@ -85,6 +89,7 @@ cmd = CommandParser::CmdParser.new(ARGV) do
|
|
85
89
|
exit -1
|
86
90
|
end
|
87
91
|
|
92
|
+
|
88
93
|
if ( start_time != -1 or end_time != -1 )
|
89
94
|
AcctHelper.print_start_end_time_header(start_time, end_time)
|
90
95
|
end
|
data/bin/oneacl
CHANGED
@@ -36,10 +36,14 @@ cmd = CommandParser::CmdParser.new(ARGV) do
|
|
36
36
|
|
37
37
|
helper = OneAclHelper.new
|
38
38
|
|
39
|
+
before_proc do
|
40
|
+
helper.set_client(options)
|
41
|
+
end
|
42
|
+
|
39
43
|
########################################################################
|
40
44
|
# Global Options
|
41
45
|
########################################################################
|
42
|
-
set :option, CommandParser::OPTIONS
|
46
|
+
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
43
47
|
|
44
48
|
########################################################################
|
45
49
|
# Formatters for arguments
|
data/bin/onecluster
CHANGED
@@ -36,10 +36,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
36
36
|
|
37
37
|
helper = OneClusterHelper.new
|
38
38
|
|
39
|
+
before_proc do
|
40
|
+
helper.set_client(options)
|
41
|
+
end
|
42
|
+
|
39
43
|
########################################################################
|
40
44
|
# Global Options
|
41
45
|
########################################################################
|
42
|
-
set :option, CommandParser::OPTIONS
|
46
|
+
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
43
47
|
|
44
48
|
list_options = CLIHelper::OPTIONS
|
45
49
|
list_options << OpenNebulaHelper::XML
|
data/bin/onedatastore
CHANGED
@@ -37,10 +37,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
37
37
|
|
38
38
|
helper = OneDatastoreHelper.new
|
39
39
|
|
40
|
+
before_proc do
|
41
|
+
helper.set_client(options)
|
42
|
+
end
|
43
|
+
|
40
44
|
########################################################################
|
41
45
|
# Global Options
|
42
46
|
########################################################################
|
43
|
-
set :option, CommandParser::OPTIONS
|
47
|
+
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
44
48
|
|
45
49
|
list_options = CLIHelper::OPTIONS
|
46
50
|
list_options << OpenNebulaHelper::XML
|
data/bin/onegroup
CHANGED
@@ -36,10 +36,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
36
36
|
|
37
37
|
helper = OneGroupHelper.new
|
38
38
|
|
39
|
+
before_proc do
|
40
|
+
helper.set_client(options)
|
41
|
+
end
|
42
|
+
|
39
43
|
########################################################################
|
40
44
|
# Global Options
|
41
45
|
########################################################################
|
42
|
-
set :option, CommandParser::OPTIONS
|
46
|
+
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
43
47
|
|
44
48
|
list_options = CLIHelper::OPTIONS
|
45
49
|
list_options << OpenNebulaHelper::XML
|
@@ -105,6 +109,13 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
105
109
|
|
106
110
|
command :quota, quota_desc, :groupid, [:file, nil] do
|
107
111
|
helper.perform_action(args[0], options, "modified") do |group|
|
112
|
+
rc = group.info
|
113
|
+
|
114
|
+
if OpenNebula.is_error?(rc)
|
115
|
+
puts rc.message
|
116
|
+
exit -1
|
117
|
+
end
|
118
|
+
|
108
119
|
str = OneQuotaHelper.set_quota(group, args[1])
|
109
120
|
rc = group.set_quota(str)
|
110
121
|
|
@@ -134,4 +145,32 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
134
145
|
end
|
135
146
|
end
|
136
147
|
end
|
148
|
+
|
149
|
+
|
150
|
+
defaultquota_desc = <<-EOT.unindent
|
151
|
+
Sets the default quota limits for the groups. If a path is not provided
|
152
|
+
the editor will be launched to modify the current default quotas.
|
153
|
+
EOT
|
154
|
+
|
155
|
+
command :defaultquota, defaultquota_desc, [:file, nil] do
|
156
|
+
system = System.new(OneGroupHelper.get_client(options))
|
157
|
+
|
158
|
+
default_quotas = system.get_group_quotas()
|
159
|
+
|
160
|
+
if OpenNebula.is_error?(default_quotas)
|
161
|
+
puts default_quotas.message
|
162
|
+
exit(-1)
|
163
|
+
end
|
164
|
+
|
165
|
+
str = OneQuotaHelper.set_quota(default_quotas, args[0])
|
166
|
+
|
167
|
+
rc = system.set_group_quotas(str)
|
168
|
+
|
169
|
+
if OpenNebula.is_error?(rc)
|
170
|
+
puts rc.message
|
171
|
+
exit(-1)
|
172
|
+
end
|
173
|
+
|
174
|
+
exit 0
|
175
|
+
end
|
137
176
|
end
|
data/bin/onehost
CHANGED
@@ -37,10 +37,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
37
37
|
|
38
38
|
helper = OneHostHelper.new
|
39
39
|
|
40
|
+
before_proc do
|
41
|
+
helper.set_client(options)
|
42
|
+
end
|
43
|
+
|
40
44
|
########################################################################
|
41
45
|
# Global Options
|
42
46
|
########################################################################
|
43
|
-
set :option, CommandParser::OPTIONS
|
47
|
+
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
44
48
|
|
45
49
|
IM = {
|
46
50
|
:name => "im",
|
data/bin/oneimage
CHANGED
@@ -37,10 +37,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
37
37
|
|
38
38
|
helper = OneImageHelper.new
|
39
39
|
|
40
|
+
before_proc do
|
41
|
+
helper.set_client(options)
|
42
|
+
end
|
43
|
+
|
40
44
|
########################################################################
|
41
45
|
# Global Options
|
42
46
|
########################################################################
|
43
|
-
set :option, CommandParser::OPTIONS
|
47
|
+
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
44
48
|
|
45
49
|
list_options = CLIHelper::OPTIONS
|
46
50
|
list_options << OpenNebulaHelper::XML
|
@@ -72,6 +76,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
72
76
|
helper.filterflag_to_i(arg)
|
73
77
|
end
|
74
78
|
|
79
|
+
format(:type, "Image type: #{Image::IMAGE_TYPES.join(", ")}") do |arg|
|
80
|
+
type=arg.strip.upcase
|
81
|
+
if Image::IMAGE_TYPES.include? type
|
82
|
+
[0, type]
|
83
|
+
else
|
84
|
+
[1, "Image type not supported. Must be #{Image::IMAGE_TYPES.join(", ")}."]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
75
88
|
########################################################################
|
76
89
|
# Commands
|
77
90
|
########################################################################
|
@@ -103,7 +116,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
103
116
|
command :create, create_desc, [:file, nil], :options=>CREATE_OPTIONS +
|
104
117
|
OneImageHelper::TEMPLATE_OPTIONS do
|
105
118
|
|
106
|
-
if options[:datastore].nil?
|
119
|
+
if options[:datastore].nil? && !options[:dry]
|
107
120
|
STDERR.puts "Datastore to save the image is mandatory: "
|
108
121
|
STDERR.puts "\t -d datastore_id"
|
109
122
|
exit -1
|
@@ -130,6 +143,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
130
143
|
template = res.last
|
131
144
|
end
|
132
145
|
|
146
|
+
if options[:dry]
|
147
|
+
puts template
|
148
|
+
exit 0
|
149
|
+
end
|
150
|
+
|
133
151
|
image.allocate(template, options[:datastore])
|
134
152
|
rescue => e
|
135
153
|
STDERR.puts e.messsage
|
@@ -150,6 +168,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
150
168
|
puts "ID: #{res}"
|
151
169
|
else
|
152
170
|
puts res.message
|
171
|
+
exit -1
|
153
172
|
end
|
154
173
|
end
|
155
174
|
end
|
@@ -285,6 +304,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
285
304
|
end
|
286
305
|
end
|
287
306
|
|
307
|
+
rename_desc = <<-EOT.unindent
|
308
|
+
Renames the Image
|
309
|
+
EOT
|
310
|
+
|
311
|
+
command :rename, rename_desc, :imageid, :name do
|
312
|
+
helper.perform_action(args[0],options,"renamed") do |o|
|
313
|
+
o.rename(args[1])
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
288
317
|
list_desc = <<-EOT.unindent
|
289
318
|
Lists Images in the pool
|
290
319
|
EOT
|
data/bin/onetemplate
CHANGED
@@ -36,10 +36,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
36
36
|
|
37
37
|
helper = OneTemplateHelper.new
|
38
38
|
|
39
|
+
before_proc do
|
40
|
+
helper.set_client(options)
|
41
|
+
end
|
42
|
+
|
39
43
|
########################################################################
|
40
44
|
# Global Options
|
41
45
|
########################################################################
|
42
|
-
set :option, CommandParser::OPTIONS
|
46
|
+
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
43
47
|
|
44
48
|
list_options = CLIHelper::OPTIONS
|
45
49
|
list_options << OpenNebulaHelper::XML
|
@@ -93,12 +97,13 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
93
97
|
|
94
98
|
- using two disks:
|
95
99
|
|
96
|
-
|
100
|
+
onetempate create --name "test vm" --memory 128 --cpu 1 --disk arch,data
|
97
101
|
|
98
102
|
EOT
|
99
103
|
|
100
104
|
command :create, create_desc, [:file, nil], :options =>
|
101
|
-
[OneTemplateHelper::VM_NAME]+OpenNebulaHelper::TEMPLATE_OPTIONS
|
105
|
+
[OneTemplateHelper::VM_NAME]+OpenNebulaHelper::TEMPLATE_OPTIONS+
|
106
|
+
[OpenNebulaHelper::DRY] do
|
102
107
|
|
103
108
|
if args[0] && OpenNebulaHelper.create_template_options_used?(options)
|
104
109
|
STDERR.puts "You can not use both template file and template"<<
|
@@ -121,7 +126,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
121
126
|
template = res.last
|
122
127
|
end
|
123
128
|
|
124
|
-
|
129
|
+
if options[:dry]
|
130
|
+
puts template
|
131
|
+
exit 0
|
132
|
+
else
|
133
|
+
tmpl.allocate(template)
|
134
|
+
end
|
125
135
|
rescue => e
|
126
136
|
STDERR.puts e.messsage
|
127
137
|
exit -1
|
@@ -255,6 +265,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
255
265
|
Lists Templates in the pool
|
256
266
|
EOT
|
257
267
|
|
268
|
+
rename_desc = <<-EOT.unindent
|
269
|
+
Renames the Template
|
270
|
+
EOT
|
271
|
+
|
272
|
+
command :rename, rename_desc, :templateid, :name do
|
273
|
+
helper.perform_action(args[0],options,"renamed") do |o|
|
274
|
+
o.rename(args[1])
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
258
278
|
command :list, list_desc, [:filterflag, nil], :options=>list_options do
|
259
279
|
helper.list_pool(options, false, args[0])
|
260
280
|
end
|
data/bin/oneuser
CHANGED
@@ -37,10 +37,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
37
37
|
usage "`oneuser` <command> [<args>] [<options>]"
|
38
38
|
version OpenNebulaHelper::ONE_VERSION
|
39
39
|
|
40
|
+
helper = OneUserHelper.new
|
41
|
+
|
42
|
+
before_proc do
|
43
|
+
helper.set_client(options)
|
44
|
+
end
|
45
|
+
|
40
46
|
########################################################################
|
41
47
|
# Global Options
|
42
48
|
########################################################################
|
43
|
-
set :option, CommandParser::OPTIONS
|
49
|
+
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
44
50
|
|
45
51
|
list_options = CLIHelper::OPTIONS
|
46
52
|
list_options << OpenNebulaHelper::XML
|
@@ -57,7 +63,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
57
63
|
SHA1={
|
58
64
|
:name => "sha1",
|
59
65
|
:large => "--sha1",
|
60
|
-
:description => "The password will be hashed using the sha1
|
66
|
+
:description => "The password will be hashed using the sha1\n"<<
|
67
|
+
" "*31<<"algorithm"
|
61
68
|
}
|
62
69
|
|
63
70
|
SSH={
|
@@ -135,12 +142,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
135
142
|
end
|
136
143
|
|
137
144
|
set :format, :userid, OneUserHelper.to_id_desc do |arg|
|
138
|
-
helper = OneUserHelper.new
|
139
145
|
helper.to_id(arg)
|
140
146
|
end
|
141
147
|
|
142
148
|
set :format, :userid_list, OneUserHelper.list_to_id_desc do |arg|
|
143
|
-
helper = OneUserHelper.new
|
144
149
|
helper.list_to_id(arg)
|
145
150
|
end
|
146
151
|
|
@@ -164,8 +169,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
164
169
|
|
165
170
|
command :create, create_desc, :username, [:password, nil],
|
166
171
|
:options=>create_options do
|
167
|
-
helper = OneUserHelper.new
|
168
|
-
|
169
172
|
if args[1]
|
170
173
|
pass = args[1]
|
171
174
|
else
|
@@ -190,8 +193,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
190
193
|
EOT
|
191
194
|
|
192
195
|
command :update, update_desc, :userid, [:file, nil] do
|
193
|
-
helper = OneUserHelper.new
|
194
|
-
|
195
196
|
helper.perform_action(args[0],options,"modified") do |user|
|
196
197
|
str = OpenNebulaHelper.update_template(args[0], user, args[1])
|
197
198
|
user.update(str)
|
@@ -204,9 +205,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
204
205
|
EOT
|
205
206
|
|
206
207
|
command :quota, quota_desc, :userid, [:file, nil] do
|
207
|
-
helper = OneUserHelper.new
|
208
|
-
|
209
208
|
helper.perform_action(args[0], options, "modified") do |user|
|
209
|
+
rc = user.info
|
210
|
+
|
211
|
+
if OpenNebula.is_error?(rc)
|
212
|
+
puts rc.message
|
213
|
+
exit -1
|
214
|
+
end
|
215
|
+
|
210
216
|
str = OneQuotaHelper.set_quota(user, args[1])
|
211
217
|
rc = user.set_quota(str)
|
212
218
|
|
@@ -214,7 +220,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
214
220
|
puts rc.message
|
215
221
|
exit -1
|
216
222
|
end
|
217
|
-
|
218
223
|
end
|
219
224
|
end
|
220
225
|
|
@@ -224,8 +229,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
224
229
|
EOT
|
225
230
|
|
226
231
|
command :batchquota, batchquota_desc, [:range, :userid_list], [:file, nil] do
|
227
|
-
helper = OneUserHelper.new
|
228
|
-
|
229
232
|
batch_str = OneQuotaHelper.get_batch_quota(args[1])
|
230
233
|
|
231
234
|
helper.perform_actions(args[0], options, "modified") do |user|
|
@@ -240,6 +243,33 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
240
243
|
end
|
241
244
|
end
|
242
245
|
|
246
|
+
defaultquota_desc = <<-EOT.unindent
|
247
|
+
Sets the default quota limits for the users. If a path is not provided
|
248
|
+
the editor will be launched to modify the current default quotas.
|
249
|
+
EOT
|
250
|
+
|
251
|
+
command :defaultquota, defaultquota_desc, [:file, nil] do
|
252
|
+
system = System.new(OneUserHelper.get_client(options))
|
253
|
+
|
254
|
+
default_quotas = system.get_user_quotas()
|
255
|
+
|
256
|
+
if OpenNebula.is_error?(default_quotas)
|
257
|
+
puts default_quotas.message
|
258
|
+
exit(-1)
|
259
|
+
end
|
260
|
+
|
261
|
+
str = OneQuotaHelper.set_quota(default_quotas, args[0])
|
262
|
+
|
263
|
+
rc = system.set_user_quotas(str)
|
264
|
+
|
265
|
+
if OpenNebula.is_error?(rc)
|
266
|
+
puts rc.message
|
267
|
+
exit(-1)
|
268
|
+
end
|
269
|
+
|
270
|
+
exit 0
|
271
|
+
end
|
272
|
+
|
243
273
|
login_desc = <<-EOT.unindent
|
244
274
|
Creates the Login token for authentication
|
245
275
|
Examples:
|
@@ -282,7 +312,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
282
312
|
EOT
|
283
313
|
|
284
314
|
command :delete, delete_desc, [:range, :userid_list] do
|
285
|
-
helper = OneUserHelper.new
|
286
315
|
helper.perform_actions(args[0], options, "deleted") do |user|
|
287
316
|
user.delete
|
288
317
|
end
|
@@ -294,8 +323,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
294
323
|
|
295
324
|
command :passwd, passwd_desc, :userid, [:password, nil],
|
296
325
|
:options=>create_options do
|
297
|
-
helper = OneUserHelper.new
|
298
|
-
|
299
326
|
if args[1]
|
300
327
|
pass = args[1]
|
301
328
|
else
|
@@ -317,7 +344,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
317
344
|
EOT
|
318
345
|
|
319
346
|
command :chgrp, chgrp_desc, [:range, :userid_list], :groupid do
|
320
|
-
helper = OneUserHelper.new
|
321
347
|
helper.perform_actions(args[0],options,"Group changed") do |user|
|
322
348
|
user.chgrp(args[1].to_i)
|
323
349
|
end
|
@@ -344,8 +370,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
344
370
|
exit_with_code 0, "An Auth driver should be specified"
|
345
371
|
end
|
346
372
|
|
347
|
-
helper = OneUserHelper.new
|
348
|
-
|
349
373
|
if args[2]
|
350
374
|
pass = args[2]
|
351
375
|
else
|
@@ -369,7 +393,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
369
393
|
EOT
|
370
394
|
|
371
395
|
command :list, list_desc, :options=>list_options do
|
372
|
-
helper = OneUserHelper.new
|
373
396
|
helper.list_pool(options)
|
374
397
|
end
|
375
398
|
|
@@ -380,7 +403,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
380
403
|
command :show, show_desc, [:userid, nil],
|
381
404
|
:options=>OpenNebulaHelper::XML do
|
382
405
|
user=args[0] || OpenNebula::User::SELF
|
383
|
-
helper = OneUserHelper.new
|
384
406
|
helper.show_resource(user,options)
|
385
407
|
end
|
386
408
|
|
data/bin/onevm
CHANGED
@@ -36,6 +36,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
36
36
|
|
37
37
|
helper = OneVMHelper.new
|
38
38
|
|
39
|
+
before_proc do
|
40
|
+
helper.set_client(options)
|
41
|
+
end
|
39
42
|
|
40
43
|
TYPE={
|
41
44
|
:name => "type",
|
@@ -47,16 +50,23 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
47
50
|
|
48
51
|
TARGET={
|
49
52
|
:name => "target",
|
50
|
-
:short => "-t
|
51
|
-
:large => "--target
|
53
|
+
:short => "-t target",
|
54
|
+
:large => "--target target",
|
52
55
|
:format => String,
|
53
56
|
:description => "Device where the image will be attached"
|
54
57
|
}
|
55
58
|
|
59
|
+
ENFORCE={
|
60
|
+
:name => "enforce",
|
61
|
+
:short => "-e",
|
62
|
+
:large => "--enforce",
|
63
|
+
:description => "Enforce that the host capacity is not exceeded"
|
64
|
+
}
|
65
|
+
|
56
66
|
########################################################################
|
57
67
|
# Global Options
|
58
68
|
########################################################################
|
59
|
-
set :option, CommandParser::OPTIONS
|
69
|
+
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
60
70
|
|
61
71
|
########################################################################
|
62
72
|
# Formatters for arguments
|
@@ -139,11 +149,17 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
139
149
|
|
140
150
|
template = res.last
|
141
151
|
end
|
152
|
+
|
142
153
|
rescue Exception => e
|
143
154
|
STDERR.puts "Error reading template."
|
144
155
|
next -1
|
145
156
|
end
|
146
157
|
|
158
|
+
if options[:dry]
|
159
|
+
puts template
|
160
|
+
exit 0
|
161
|
+
end
|
162
|
+
|
147
163
|
number.times do
|
148
164
|
exit_code = helper.create_resource(options) do |vm|
|
149
165
|
error = vm.allocate(template)
|
@@ -278,12 +294,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
278
294
|
States: PENDING
|
279
295
|
EOT
|
280
296
|
|
281
|
-
command :deploy, deploy_desc, [:range,:vmid_list], :hostid do
|
297
|
+
command :deploy, deploy_desc, [:range,:vmid_list], :hostid, :options=>[ENFORCE] do
|
282
298
|
host_id = args[1]
|
283
299
|
verbose = "deploying in host #{host_id}"
|
284
300
|
|
285
301
|
helper.perform_actions(args[0],options,verbose) do |vm|
|
286
|
-
|
302
|
+
if !options[:enforce].nil?
|
303
|
+
vm.deploy(host_id, options[:enforce])
|
304
|
+
else
|
305
|
+
vm.deploy(host_id)
|
306
|
+
end
|
287
307
|
end
|
288
308
|
end
|
289
309
|
|
@@ -293,12 +313,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
293
313
|
States: RUNNING
|
294
314
|
EOT
|
295
315
|
|
296
|
-
command :livemigrate, livemigrate_desc, [:range,:vmid_list], :hostid do
|
316
|
+
command :livemigrate, livemigrate_desc, [:range,:vmid_list], :hostid, :options=>[ENFORCE] do
|
297
317
|
host_id = args[1]
|
298
318
|
verbose = "live migrating to #{host_id}"
|
299
319
|
|
300
320
|
helper.perform_actions(args[0],options,verbose) do |vm|
|
301
|
-
|
321
|
+
if !options[:enforce].nil?
|
322
|
+
vm.live_migrate(host_id, options[:enforce])
|
323
|
+
else
|
324
|
+
vm.live_migrate(host_id)
|
325
|
+
end
|
302
326
|
end
|
303
327
|
end
|
304
328
|
|
@@ -308,12 +332,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
308
332
|
States: RUNNING
|
309
333
|
EOT
|
310
334
|
|
311
|
-
command :migrate, migrate_desc, [:range,:vmid_list], :hostid do
|
335
|
+
command :migrate, migrate_desc, [:range,:vmid_list], :hostid, :options=>[ENFORCE] do
|
312
336
|
host_id = args[1]
|
313
337
|
verbose = "migrating to #{host_id}"
|
314
338
|
|
315
339
|
helper.perform_actions(args[0],options,verbose) do |vm|
|
316
|
-
|
340
|
+
if !options[:enforce].nil?
|
341
|
+
vm.migrate(host_id, options[:enforce])
|
342
|
+
else
|
343
|
+
vm.migrate(host_id)
|
344
|
+
end
|
317
345
|
end
|
318
346
|
end
|
319
347
|
|
@@ -506,6 +534,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
506
534
|
Lists VMs in the pool
|
507
535
|
EOT
|
508
536
|
|
537
|
+
rename_desc = <<-EOT.unindent
|
538
|
+
Renames the VM
|
539
|
+
EOT
|
540
|
+
|
541
|
+
command :rename, rename_desc, :vmid, :name do
|
542
|
+
helper.perform_action(args[0],options,"renamed") do |o|
|
543
|
+
o.rename(args[1])
|
544
|
+
end
|
545
|
+
end
|
546
|
+
|
509
547
|
command :list, list_desc, [:filterflag, nil],
|
510
548
|
:options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS+
|
511
549
|
[OpenNebulaHelper::DESCRIBE] do
|
data/bin/onevnet
CHANGED
@@ -37,10 +37,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
37
37
|
|
38
38
|
helper = OneVNetHelper.new
|
39
39
|
|
40
|
+
before_proc do
|
41
|
+
helper.set_client(options)
|
42
|
+
end
|
43
|
+
|
40
44
|
########################################################################
|
41
45
|
# Global Options
|
42
46
|
########################################################################
|
43
|
-
set :option, CommandParser::OPTIONS
|
47
|
+
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
44
48
|
|
45
49
|
CREATE_OPTIONS = [OneClusterHelper::CLUSTER]
|
46
50
|
|
@@ -224,4 +228,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
224
228
|
vnet.update(str)
|
225
229
|
end
|
226
230
|
end
|
231
|
+
|
232
|
+
rename_desc = <<-EOT.unindent
|
233
|
+
Renames the Virtual Network
|
234
|
+
EOT
|
235
|
+
|
236
|
+
command :rename, rename_desc, :vnetid, :name do
|
237
|
+
helper.perform_action(args[0],options,"renamed") do |o|
|
238
|
+
o.rename(args[1])
|
239
|
+
end
|
240
|
+
end
|
227
241
|
end
|