opennebula-cli 5.6.2 → 5.7.80.pre
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/bin/oneacct +37 -35
- data/bin/oneacl +15 -15
- data/bin/onecluster +31 -31
- data/bin/onedatastore +35 -35
- data/bin/oneflow +274 -237
- data/bin/oneflow-template +161 -138
- data/bin/onegroup +32 -30
- data/bin/onehost +68 -63
- data/bin/oneimage +92 -81
- data/bin/onemarket +31 -29
- data/bin/onemarketapp +83 -75
- data/bin/onesecgroup +37 -33
- data/bin/oneshowback +40 -43
- data/bin/onetemplate +73 -70
- data/bin/oneuser +171 -158
- data/bin/onevcenter +70 -64
- data/bin/onevdc +61 -45
- data/bin/onevm +396 -260
- data/bin/onevmgroup +47 -47
- data/bin/onevnet +94 -158
- data/bin/onevntemplate +361 -0
- data/bin/onevrouter +76 -70
- data/bin/onezone +30 -31
- data/lib/one_helper.rb +106 -22
- data/lib/one_helper/oneacl_helper.rb +6 -4
- data/lib/one_helper/onevcenter_helper.rb +1 -1
- data/lib/one_helper/onevm_helper.rb +134 -91
- data/lib/one_helper/onevnet_helper.rb +20 -8
- data/lib/one_helper/onevntemplate_helper.rb +104 -0
- metadata +9 -6
data/bin/onevntemplate
ADDED
@@ -0,0 +1,361 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# -------------------------------------------------------------------------- #
|
4
|
+
# Copyright 2002-2018, OpenNebula Project, OpenNebula Systems #
|
5
|
+
# #
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
7
|
+
# not use this file except in compliance with the License. You may obtain #
|
8
|
+
# a copy of the License at #
|
9
|
+
# #
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
|
+
# #
|
12
|
+
# Unless required by applicable law or agreed to in writing, software #
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
15
|
+
# See the License for the specific language governing permissions and #
|
16
|
+
# limitations under the License. #
|
17
|
+
#--------------------------------------------------------------------------- #
|
18
|
+
|
19
|
+
ONE_LOCATION = ENV['ONE_LOCATION']
|
20
|
+
|
21
|
+
if !ONE_LOCATION
|
22
|
+
RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
|
23
|
+
else
|
24
|
+
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
|
25
|
+
end
|
26
|
+
|
27
|
+
$LOAD_PATH << RUBY_LIB_LOCATION
|
28
|
+
$LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
|
29
|
+
|
30
|
+
require 'command_parser'
|
31
|
+
require 'one_helper/onevntemplate_helper'
|
32
|
+
require 'one_helper/onevnet_helper'
|
33
|
+
require 'pry'
|
34
|
+
|
35
|
+
CommandParser::CmdParser.new(ARGV) do
|
36
|
+
usage '`onevntemplate` <command> [<args>] [<options>]'
|
37
|
+
version OpenNebulaHelper::ONE_VERSION
|
38
|
+
|
39
|
+
helper = OneVNTemplateHelper.new
|
40
|
+
|
41
|
+
before_proc do
|
42
|
+
helper.set_client(options)
|
43
|
+
end
|
44
|
+
|
45
|
+
USE = {
|
46
|
+
:name => 'use',
|
47
|
+
:large => '--use',
|
48
|
+
:description => 'lock use actions'
|
49
|
+
}
|
50
|
+
|
51
|
+
MANAGE = {
|
52
|
+
:name => 'manage',
|
53
|
+
:large => '--manage',
|
54
|
+
:description => 'lock manage actions'
|
55
|
+
}
|
56
|
+
|
57
|
+
ADMIN = {
|
58
|
+
:name => 'admin',
|
59
|
+
:large => '--admin',
|
60
|
+
:description => 'lock admin actions'
|
61
|
+
}
|
62
|
+
|
63
|
+
ALL = {
|
64
|
+
:name => 'all',
|
65
|
+
:large => '--all',
|
66
|
+
:description => 'lock all actions'
|
67
|
+
}
|
68
|
+
|
69
|
+
########################################################################
|
70
|
+
# Global Options
|
71
|
+
########################################################################
|
72
|
+
set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
|
73
|
+
|
74
|
+
list_options = CLIHelper::OPTIONS
|
75
|
+
list_options << OpenNebulaHelper::XML
|
76
|
+
list_options << OpenNebulaHelper::NUMERIC
|
77
|
+
list_options << OpenNebulaHelper::DESCRIBE
|
78
|
+
|
79
|
+
instantiate_options = [
|
80
|
+
OneVNTemplateHelper::VN_NAME,
|
81
|
+
OneVNTemplateHelper::MULTIPLE,
|
82
|
+
OneVNTemplateHelper::EXTENDED,
|
83
|
+
OpenNebulaHelper::AS_USER,
|
84
|
+
OpenNebulaHelper::AS_GROUP
|
85
|
+
]
|
86
|
+
|
87
|
+
########################################################################
|
88
|
+
# Formatters for arguments
|
89
|
+
########################################################################
|
90
|
+
set :format, :groupid, OpenNebulaHelper.rname_to_id_desc('GROUP') do |arg|
|
91
|
+
OpenNebulaHelper.rname_to_id(arg, 'GROUP')
|
92
|
+
end
|
93
|
+
|
94
|
+
set :format, :userid, OpenNebulaHelper.rname_to_id_desc('USER') do |arg|
|
95
|
+
OpenNebulaHelper.rname_to_id(arg, 'USER')
|
96
|
+
end
|
97
|
+
|
98
|
+
set :format, :templateid, OneVNTemplateHelper.to_id_desc do |arg|
|
99
|
+
helper.to_id(arg)
|
100
|
+
end
|
101
|
+
|
102
|
+
set :format, :templateid_list, OneVNTemplateHelper.list_to_id_desc do |arg|
|
103
|
+
helper.list_to_id(arg)
|
104
|
+
end
|
105
|
+
|
106
|
+
set :format, :filterflag, OneVNTemplateHelper.filterflag_to_i_desc do |arg|
|
107
|
+
helper.filterflag_to_i(arg)
|
108
|
+
end
|
109
|
+
|
110
|
+
########################################################################
|
111
|
+
# Commands
|
112
|
+
########################################################################
|
113
|
+
|
114
|
+
create_desc = <<-EOT.unindent
|
115
|
+
Creates a new Virtual Network Template from the given description
|
116
|
+
|
117
|
+
Examples:
|
118
|
+
- using a Virtual Network Template description file:
|
119
|
+
|
120
|
+
onevntemplate create vn_description.tmpl
|
121
|
+
|
122
|
+
EOT
|
123
|
+
|
124
|
+
command :create, create_desc, [:file, nil], :options =>
|
125
|
+
[OpenNebulaHelper::DRY] do
|
126
|
+
|
127
|
+
helper.create_resource(options) do |tmpl|
|
128
|
+
begin
|
129
|
+
if args[0]
|
130
|
+
template = File.read(args[0])
|
131
|
+
end
|
132
|
+
|
133
|
+
if options[:dry]
|
134
|
+
puts template
|
135
|
+
exit 0
|
136
|
+
else
|
137
|
+
tmpl.allocate(template)
|
138
|
+
end
|
139
|
+
rescue StandardError => e
|
140
|
+
STDERR.puts e.messsage
|
141
|
+
exit(-1)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
clone_desc = <<-EOT.unindent
|
147
|
+
Creates a new VN Template from an existing one
|
148
|
+
EOT
|
149
|
+
|
150
|
+
command :clone, clone_desc, :templateid, :name do
|
151
|
+
helper.perform_action(args[0], options, 'cloned') do |t|
|
152
|
+
res = t.clone(args[1])
|
153
|
+
|
154
|
+
if !OpenNebula.is_error?(res)
|
155
|
+
puts "ID: #{res}"
|
156
|
+
else
|
157
|
+
puts res.message
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
delete_desc = <<-EOT.unindent
|
163
|
+
Deletes the given VN Template
|
164
|
+
EOT
|
165
|
+
|
166
|
+
command :delete, delete_desc, [:range, :templateid_list] do
|
167
|
+
helper.perform_actions(args[0], options, 'deleted') do |t|
|
168
|
+
t.delete
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
instantiate_desc = <<-EOT.unindent
|
173
|
+
Creates a new VN instance from the given VN Template. This VN can be
|
174
|
+
managed with the 'onevnet' command.
|
175
|
+
|
176
|
+
The source Template can be modified adding or replacing attributes with
|
177
|
+
the optional file argument, or with the options.
|
178
|
+
EOT
|
179
|
+
|
180
|
+
command :instantiate, instantiate_desc, :templateid, [:file, nil],
|
181
|
+
:options => instantiate_options + OneVNetHelper::ADDAR_OPTIONS do
|
182
|
+
exit_code = 0
|
183
|
+
|
184
|
+
number = options[:multiple] || 1
|
185
|
+
|
186
|
+
number.times do |i|
|
187
|
+
exit_code = helper.perform_action(args[0], options,
|
188
|
+
'instantiated') do |t|
|
189
|
+
name = options[:name]
|
190
|
+
name = name.gsub('%i', i.to_s) if name
|
191
|
+
|
192
|
+
extra_template = ''
|
193
|
+
rc = t.info
|
194
|
+
|
195
|
+
if OpenNebula.is_error?(rc)
|
196
|
+
STDERR.puts rc.message
|
197
|
+
exit(-1)
|
198
|
+
end
|
199
|
+
|
200
|
+
if args[1]
|
201
|
+
extra_template = File.read(args[1])
|
202
|
+
else
|
203
|
+
res = OpenNebulaHelper.create_template(options, t)
|
204
|
+
|
205
|
+
if res.first != 0
|
206
|
+
STDERR.puts res.last
|
207
|
+
next -1
|
208
|
+
end
|
209
|
+
|
210
|
+
extra_template = res.last
|
211
|
+
|
212
|
+
if OneVNetHelper.add_ar_options_used?(options)
|
213
|
+
extra_template << OpenNebulaHelper.create_ar(options)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
res = t.instantiate(name, extra_template)
|
218
|
+
|
219
|
+
if !OpenNebula.is_error?(res)
|
220
|
+
puts "VN ID: #{res}"
|
221
|
+
end
|
222
|
+
|
223
|
+
res
|
224
|
+
end
|
225
|
+
|
226
|
+
break if exit_code == -1
|
227
|
+
end
|
228
|
+
|
229
|
+
exit_code
|
230
|
+
end
|
231
|
+
|
232
|
+
chgrp_desc = <<-EOT.unindent
|
233
|
+
Changes the VN Template group
|
234
|
+
EOT
|
235
|
+
|
236
|
+
command :chgrp, chgrp_desc, [:range, :templateid_list], :groupid do
|
237
|
+
helper.perform_actions(args[0], options, 'Group changed') do |t|
|
238
|
+
t.chown(-1, args[1].to_i)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
chown_desc = <<-EOT.unindent
|
243
|
+
Changes the VN Template owner and group
|
244
|
+
EOT
|
245
|
+
|
246
|
+
command :chown, chown_desc, [:range, :templateid_list], :userid,
|
247
|
+
[:groupid, nil] do
|
248
|
+
args[2].nil? ? gid = -1 : gid = args[2].to_i
|
249
|
+
helper.perform_actions(args[0], options, 'Owner/Group changed') do |t|
|
250
|
+
t.chown(args[1].to_i, gid)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
chmod_desc = <<-EOT.unindent
|
255
|
+
Changes the VN Template permissions
|
256
|
+
EOT
|
257
|
+
|
258
|
+
command :chmod, chmod_desc, [:range, :templateid_list], :octet do
|
259
|
+
recursive = (options[:recursive] == true)
|
260
|
+
|
261
|
+
helper.perform_actions(args[0], options, 'Permissions changed') do |t|
|
262
|
+
t.chmod_octet(args[1], recursive)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
update_desc = <<-EOT.unindent
|
267
|
+
Update the VN template contents. If a path is not provided the editor will
|
268
|
+
be launched to modify the current content.
|
269
|
+
EOT
|
270
|
+
|
271
|
+
command :update, update_desc, :templateid, [:file, nil],
|
272
|
+
:options => OpenNebulaHelper::APPEND do
|
273
|
+
helper.perform_action(args[0], options, 'modified') do |obj|
|
274
|
+
if options[:append]
|
275
|
+
str = OpenNebulaHelper.append_template(args[0], obj, args[1])
|
276
|
+
else
|
277
|
+
str = OpenNebulaHelper.update_template(args[0], obj, args[1])
|
278
|
+
end
|
279
|
+
|
280
|
+
helper.set_client(options)
|
281
|
+
obj = helper.retrieve_resource(obj.id)
|
282
|
+
|
283
|
+
obj.update(str, options[:append])
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
list_desc = <<-EOT.unindent
|
288
|
+
Lists VN Templates in the pool
|
289
|
+
EOT
|
290
|
+
|
291
|
+
rename_desc = <<-EOT.unindent
|
292
|
+
Renames the VN Template
|
293
|
+
EOT
|
294
|
+
|
295
|
+
command :rename, rename_desc, :templateid, :name do
|
296
|
+
helper.perform_action(args[0], options, 'renamed') do |o|
|
297
|
+
o.rename(args[1])
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
command :list, list_desc, [:filterflag, nil], :options => list_options do
|
302
|
+
helper.list_pool(options, false, args[0])
|
303
|
+
end
|
304
|
+
|
305
|
+
show_desc = <<-EOT.unindent
|
306
|
+
Shows information for the given VN Template
|
307
|
+
EOT
|
308
|
+
|
309
|
+
command :show, show_desc, :templateid,
|
310
|
+
:options => [OpenNebulaHelper::XML, OneTemplateHelper::EXTENDED] do
|
311
|
+
|
312
|
+
helper.show_resource(args[0], options)
|
313
|
+
end
|
314
|
+
|
315
|
+
top_desc = <<-EOT.unindent
|
316
|
+
Lists Templates continuously
|
317
|
+
EOT
|
318
|
+
|
319
|
+
command :top, top_desc, [:filterflag, nil], :options => list_options do
|
320
|
+
helper.list_pool(options, true, args[0])
|
321
|
+
end
|
322
|
+
|
323
|
+
lock_desc = <<-EOT.unindent
|
324
|
+
Locks a VN template with differents levels for lock any actions with this VN template,
|
325
|
+
show and monitoring never will be locked.
|
326
|
+
Valid states are: All.
|
327
|
+
Levels:
|
328
|
+
[Use]: locks Admin, Manage and Use actions.
|
329
|
+
[Manage]: locks Manage and Use actions.
|
330
|
+
[Admin]: locks only Admin actions.
|
331
|
+
EOT
|
332
|
+
|
333
|
+
command :lock, lock_desc, :templateid,
|
334
|
+
:options => [USE, MANAGE, ADMIN, ALL] do
|
335
|
+
helper.perform_action(args[0], options, 'VN Template locked') do |t|
|
336
|
+
if !options[:use].nil?
|
337
|
+
level = 1
|
338
|
+
elsif !options[:manage].nil?
|
339
|
+
level = 2
|
340
|
+
elsif !options[:admin].nil?
|
341
|
+
level = 3
|
342
|
+
elsif !options[:all].nil?
|
343
|
+
level = 4
|
344
|
+
else
|
345
|
+
level = 1
|
346
|
+
end
|
347
|
+
t.lock(level)
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
unlock_desc = <<-EOT.unindent
|
352
|
+
Unlocks a VN template for unlock any actions with this VN template.
|
353
|
+
Valid states are: All.
|
354
|
+
EOT
|
355
|
+
|
356
|
+
command :unlock, unlock_desc, :templateid do
|
357
|
+
helper.perform_action(args[0], options, 'VN Template unlocked') do |t|
|
358
|
+
t.unlock
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
data/bin/onevrouter
CHANGED
@@ -16,24 +16,24 @@
|
|
16
16
|
# limitations under the License. #
|
17
17
|
#--------------------------------------------------------------------------- #
|
18
18
|
|
19
|
-
ONE_LOCATION=ENV[
|
19
|
+
ONE_LOCATION = ENV['ONE_LOCATION']
|
20
20
|
|
21
21
|
if !ONE_LOCATION
|
22
|
-
RUBY_LIB_LOCATION=
|
22
|
+
RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
|
23
23
|
else
|
24
|
-
RUBY_LIB_LOCATION=ONE_LOCATION+
|
24
|
+
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
$LOAD_PATH << RUBY_LIB_LOCATION
|
28
|
+
$LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
|
29
29
|
|
30
30
|
require 'command_parser'
|
31
31
|
require 'one_helper/onevrouter_helper'
|
32
32
|
require 'one_helper/onetemplate_helper'
|
33
33
|
require 'one_helper/onevm_helper'
|
34
34
|
|
35
|
-
|
36
|
-
usage
|
35
|
+
CommandParser::CmdParser.new(ARGV) do
|
36
|
+
usage '`onevrouter` <command> [<args>] [<options>]'
|
37
37
|
version OpenNebulaHelper::ONE_VERSION
|
38
38
|
|
39
39
|
helper = OneVirtualRouterHelper.new
|
@@ -42,34 +42,34 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
42
42
|
helper.set_client(options)
|
43
43
|
end
|
44
44
|
|
45
|
-
USE={
|
46
|
-
:name
|
47
|
-
:large =>
|
48
|
-
:description =>
|
45
|
+
USE = {
|
46
|
+
:name => 'use',
|
47
|
+
:large => '--use',
|
48
|
+
:description => 'lock use actions'
|
49
49
|
}
|
50
50
|
|
51
|
-
MANAGE={
|
52
|
-
:name
|
53
|
-
:large =>
|
54
|
-
:description =>
|
51
|
+
MANAGE = {
|
52
|
+
:name => 'manage',
|
53
|
+
:large => '--manage',
|
54
|
+
:description => 'lock manage actions'
|
55
55
|
}
|
56
56
|
|
57
|
-
ADMIN={
|
58
|
-
:name
|
59
|
-
:large =>
|
60
|
-
:description =>
|
57
|
+
ADMIN = {
|
58
|
+
:name => 'admin',
|
59
|
+
:large => '--admin',
|
60
|
+
:description => 'lock admin actions'
|
61
61
|
}
|
62
62
|
|
63
|
-
ALL={
|
64
|
-
:name
|
65
|
-
:large =>
|
66
|
-
:description =>
|
63
|
+
ALL = {
|
64
|
+
:name => 'all',
|
65
|
+
:large => '--all',
|
66
|
+
:description => 'lock all actions'
|
67
67
|
}
|
68
68
|
|
69
69
|
########################################################################
|
70
70
|
# Global Options
|
71
71
|
########################################################################
|
72
|
-
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
72
|
+
set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
|
73
73
|
|
74
74
|
list_options = CLIHelper::OPTIONS
|
75
75
|
list_options << OpenNebulaHelper::XML
|
@@ -79,28 +79,31 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
79
79
|
########################################################################
|
80
80
|
# Formatters for arguments
|
81
81
|
########################################################################
|
82
|
-
set :format, :groupid, OpenNebulaHelper.rname_to_id_desc(
|
83
|
-
OpenNebulaHelper.rname_to_id(arg,
|
82
|
+
set :format, :groupid, OpenNebulaHelper.rname_to_id_desc('GROUP') do |arg|
|
83
|
+
OpenNebulaHelper.rname_to_id(arg, 'GROUP')
|
84
84
|
end
|
85
85
|
|
86
|
-
set :format, :userid, OpenNebulaHelper.rname_to_id_desc(
|
87
|
-
OpenNebulaHelper.rname_to_id(arg,
|
86
|
+
set :format, :userid, OpenNebulaHelper.rname_to_id_desc('USER') do |arg|
|
87
|
+
OpenNebulaHelper.rname_to_id(arg, 'USER')
|
88
88
|
end
|
89
89
|
|
90
90
|
set :format, :vrouterid, OneVirtualRouterHelper.to_id_desc do |arg|
|
91
91
|
helper.to_id(arg)
|
92
92
|
end
|
93
93
|
|
94
|
-
set :format, :vrouterid_list,
|
94
|
+
set :format, :vrouterid_list,
|
95
|
+
OneVirtualRouterHelper.list_to_id_desc do |arg|
|
95
96
|
helper.list_to_id(arg)
|
96
97
|
end
|
97
98
|
|
98
|
-
set :format, :filterflag,
|
99
|
+
set :format, :filterflag,
|
100
|
+
OneVirtualRouterHelper.filterflag_to_i_desc do |arg|
|
99
101
|
helper.filterflag_to_i(arg)
|
100
102
|
end
|
101
103
|
|
102
|
-
set :format, :templateid,
|
103
|
-
OpenNebulaHelper.
|
104
|
+
set :format, :templateid,
|
105
|
+
OpenNebulaHelper.rname_to_id_desc('VMTEMPLATE') do |arg|
|
106
|
+
OpenNebulaHelper.rname_to_id(arg, 'VMTEMPLATE')
|
104
107
|
end
|
105
108
|
|
106
109
|
########################################################################
|
@@ -117,9 +120,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
117
120
|
template = File.read(args[0])
|
118
121
|
|
119
122
|
obj.allocate(template)
|
120
|
-
rescue => e
|
123
|
+
rescue StandardError => e
|
121
124
|
STDERR.puts e.messsage
|
122
|
-
exit
|
125
|
+
exit(-1)
|
123
126
|
end
|
124
127
|
end
|
125
128
|
end
|
@@ -139,27 +142,28 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
139
142
|
OneVMHelper::HOLD
|
140
143
|
]
|
141
144
|
|
142
|
-
command :instantiate, instantiate_desc,
|
143
|
-
:
|
144
|
-
|
145
|
+
command :instantiate, instantiate_desc,
|
146
|
+
:vrouterid, :templateid, [:file, nil],
|
147
|
+
:options => instantiate_options +
|
148
|
+
OpenNebulaHelper::TEMPLATE_OPTIONS do
|
145
149
|
|
146
150
|
if args[2] && OpenNebulaHelper.create_template_options_used?(options)
|
147
|
-
STDERR.puts
|
148
|
-
|
149
|
-
|
151
|
+
STDERR.puts 'You cannot use both template file and template' \
|
152
|
+
' creation options.'
|
153
|
+
exit(-1)
|
150
154
|
end
|
151
155
|
|
152
156
|
number = options[:multiple] || 1
|
153
157
|
user_inputs = nil
|
154
158
|
|
155
|
-
helper.perform_action(args[0], options,
|
156
|
-
name = options[:name] ||
|
159
|
+
helper.perform_action(args[0], options, 'instantiated') do |vr|
|
160
|
+
name = options[:name] || ''
|
157
161
|
|
158
162
|
t = OpenNebula::Template.new_with_id(args[1], helper.client)
|
159
163
|
|
160
|
-
on_hold = options[:hold]
|
164
|
+
on_hold = !options[:hold].nil?
|
161
165
|
|
162
|
-
extra_template =
|
166
|
+
extra_template = ''
|
163
167
|
rc = t.info
|
164
168
|
|
165
169
|
if OpenNebula.is_error?(rc)
|
@@ -180,7 +184,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
180
184
|
extra_template = res.last
|
181
185
|
end
|
182
186
|
|
183
|
-
user_inputs
|
187
|
+
user_inputs ||= OneTemplateHelper.get_user_inputs(t.to_hash)
|
184
188
|
|
185
189
|
extra_template << "\n" << user_inputs
|
186
190
|
|
@@ -193,7 +197,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
193
197
|
EOT
|
194
198
|
|
195
199
|
command :delete, delete_desc, [:range, :vrouterid_list] do
|
196
|
-
helper.perform_actions(args[0],options,
|
200
|
+
helper.perform_actions(args[0], options, 'deleted') do |obj|
|
197
201
|
obj.delete
|
198
202
|
end
|
199
203
|
end
|
@@ -202,8 +206,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
202
206
|
Changes the Virtual Router group
|
203
207
|
EOT
|
204
208
|
|
205
|
-
command :chgrp, chgrp_desc,[:range, :vrouterid_list], :groupid do
|
206
|
-
helper.perform_actions(args[0],options,
|
209
|
+
command :chgrp, chgrp_desc, [:range, :vrouterid_list], :groupid do
|
210
|
+
helper.perform_actions(args[0], options, 'Group changed') do |obj|
|
207
211
|
obj.chown(-1, args[1].to_i)
|
208
212
|
end
|
209
213
|
end
|
@@ -213,9 +217,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
213
217
|
EOT
|
214
218
|
|
215
219
|
command :chown, chown_desc, [:range, :vrouterid_list], :userid,
|
216
|
-
[:groupid,nil] do
|
217
|
-
|
218
|
-
helper.perform_actions(args[0],options,
|
220
|
+
[:groupid, nil] do
|
221
|
+
args[2].nil? ? gid = -1 : gid = args[2].to_i
|
222
|
+
helper.perform_actions(args[0], options, 'Owner/Group changed') do |obj|
|
219
223
|
obj.chown(args[1].to_i, gid)
|
220
224
|
end
|
221
225
|
end
|
@@ -225,7 +229,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
225
229
|
EOT
|
226
230
|
|
227
231
|
command :chmod, chmod_desc, [:range, :vrouterid_list], :octet do
|
228
|
-
helper.perform_actions(args[0],options,
|
232
|
+
helper.perform_actions(args[0], options, 'Permissions changed') do |obj|
|
229
233
|
obj.chmod_octet(args[1])
|
230
234
|
end
|
231
235
|
end
|
@@ -236,8 +240,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
236
240
|
EOT
|
237
241
|
|
238
242
|
command :update, update_desc, :vrouterid, [:file, nil],
|
239
|
-
|
240
|
-
helper.perform_action(args[0],options,
|
243
|
+
:options => OpenNebulaHelper::APPEND do
|
244
|
+
helper.perform_action(args[0], options, 'modified') do |obj|
|
241
245
|
if options[:append]
|
242
246
|
str = OpenNebulaHelper.append_template(args[0], obj, args[1])
|
243
247
|
else
|
@@ -253,7 +257,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
253
257
|
EOT
|
254
258
|
|
255
259
|
command :rename, rename_desc, :vrouterid, :name do
|
256
|
-
helper.perform_action(args[0],options,
|
260
|
+
helper.perform_action(args[0], options, 'renamed') do |obj|
|
257
261
|
obj.rename(args[1])
|
258
262
|
end
|
259
263
|
end
|
@@ -267,14 +271,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
267
271
|
EOT
|
268
272
|
|
269
273
|
command :"nic-attach", nic_attach_desc, :vrouterid,
|
270
|
-
:options => [OneVMHelper::FILE,
|
274
|
+
:options => [OneVMHelper::FILE,
|
275
|
+
OneVMHelper::NETWORK,
|
276
|
+
OneVMHelper::IP,
|
271
277
|
OneVirtualRouterHelper::FLOAT] do
|
272
278
|
|
273
|
-
if options[:file].nil?
|
274
|
-
STDERR.puts
|
279
|
+
if options[:file].nil? && options[:network].nil?
|
280
|
+
STDERR.puts 'Provide a template file or a network:'
|
275
281
|
STDERR.puts "\t--file <file>"
|
276
282
|
STDERR.puts "\t--network <network>"
|
277
|
-
exit
|
283
|
+
exit(-1)
|
278
284
|
end
|
279
285
|
|
280
286
|
if options[:file]
|
@@ -291,13 +297,13 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
291
297
|
end
|
292
298
|
|
293
299
|
if float
|
294
|
-
template +=
|
300
|
+
template += ', FLOATING_IP ="yes"'
|
295
301
|
end
|
296
302
|
|
297
|
-
template +=
|
303
|
+
template += ' ]'
|
298
304
|
end
|
299
305
|
|
300
|
-
helper.perform_action(args[0],options,
|
306
|
+
helper.perform_action(args[0], options, 'Attach NIC') do |vr|
|
301
307
|
vr.nic_attach(template)
|
302
308
|
end
|
303
309
|
end
|
@@ -309,7 +315,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
309
315
|
command :"nic-detach", nic_detach_desc, :vrouterid, :nicid do
|
310
316
|
nicid = args[1].to_i
|
311
317
|
|
312
|
-
helper.perform_action(args[0],options,
|
318
|
+
helper.perform_action(args[0], options, 'Detach NIC') do |vr|
|
313
319
|
vr.nic_detach(nicid)
|
314
320
|
end
|
315
321
|
end
|
@@ -318,7 +324,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
318
324
|
Lists the Virtual Routers in the pool
|
319
325
|
EOT
|
320
326
|
|
321
|
-
command :list, list_desc, [:filterflag, nil], :options=>list_options do
|
327
|
+
command :list, list_desc, [:filterflag, nil], :options => list_options do
|
322
328
|
helper.list_pool(options, false, args[0])
|
323
329
|
end
|
324
330
|
|
@@ -327,15 +333,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
327
333
|
EOT
|
328
334
|
|
329
335
|
command :show, show_desc, :vrouterid,
|
330
|
-
:options=>[OpenNebulaHelper::XML, OneVMHelper::ALL_TEMPLATE] do
|
331
|
-
helper.show_resource(args[0],options)
|
336
|
+
:options => [OpenNebulaHelper::XML, OneVMHelper::ALL_TEMPLATE] do
|
337
|
+
helper.show_resource(args[0], options)
|
332
338
|
end
|
333
339
|
|
334
340
|
top_desc = <<-EOT.unindent
|
335
341
|
Lists Virtual Routers continuously
|
336
342
|
EOT
|
337
343
|
|
338
|
-
command :top, top_desc, [:filterflag, nil], :options=>list_options do
|
344
|
+
command :top, top_desc, [:filterflag, nil], :options => list_options do
|
339
345
|
helper.list_pool(options, true, args[0])
|
340
346
|
end
|
341
347
|
|
@@ -350,8 +356,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
350
356
|
EOT
|
351
357
|
|
352
358
|
command :lock, lock_desc, :vrouterid,
|
353
|
-
|
354
|
-
helper.perform_action(args[0],options,
|
359
|
+
:options => [USE, MANAGE, ADMIN, ALL] do
|
360
|
+
helper.perform_action(args[0], options, 'VRouter locked') do |vr|
|
355
361
|
if !options[:use].nil?
|
356
362
|
level = 1
|
357
363
|
elsif !options[:manage].nil?
|
@@ -373,7 +379,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
373
379
|
EOT
|
374
380
|
|
375
381
|
command :unlock, unlock_desc, :vrouterid do
|
376
|
-
helper.perform_action(args[0],options,
|
382
|
+
helper.perform_action(args[0], options, 'VRouter unlocked') do |vr|
|
377
383
|
vr.unlock
|
378
384
|
end
|
379
385
|
end
|