File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -253,14 +253,26 @@ CommandParser::CmdParser.new(ARGV) do
253253
254254 number = options [ :multiple ] || 1
255255 user_inputs = options [ :user_inputs ]
256+ persistent = !options [ :persistent ] . nil?
257+ flag = nil
258+
259+ if persistent && ( number > 1 )
260+ if options [ :name ] && !options [ :name ] . include? ( '%i' )
261+ flag = '-%i'
262+ elsif !options [ :name ]
263+ STDERR . puts 'Persistent template cannot be instantiated multiple times ' <<
264+ "without including a name (use '%i' to chose where to insert the index)."
265+ next -1
266+ end
267+ end
256268
257269 number . times . each_with_index do |i , index |
258270 exit_code = helper . perform_action (
259271 args [ 0 ] ,
260272 options ,
261273 'instantiated'
262274 ) do |t |
263- name = options [ :name ]
275+ name = " #{ options [ :name ] } #{ flag } " if options [ :name ]
264276 prefix = options [ :prefix ]
265277 c_i = nil
266278 p = nil
@@ -325,8 +337,6 @@ CommandParser::CmdParser.new(ARGV) do
325337
326338 extra_template . strip!
327339
328- persistent = !options [ :persistent ] . nil?
329-
330340 res = t . instantiate ( name , on_hold , extra_template , persistent )
331341
332342 if !OpenNebula . is_error? ( res )
You can’t perform that action at this time.
0 commit comments