Revision f9d9220f src/onedb/onedb

View differences:

src/onedb/onedb
226 226
    :format => Array
227 227
}
228 228

  
229
###############################################################################
230
# Live operation options
231
###############################################################################
232

  
229 233
START_TIME = {
230 234
    :name   => "start_time",
231 235
    :short  => "-s TIME",
......
242 246
    :format => Time
243 247
}
244 248

  
249
ID = {
250
    :name   => "id",
251
    :short  => "-i ID",
252
    :large  => "--id ID" ,
253
    :description => "Filter by ID",
254
    :format => Numeric
255
}
256

  
257
XPATH = {
258
    :name   => "xpath",
259
    :short  => "-x ID",
260
    :large  => "--xpath ID" ,
261
    :description => "Filter by xpath",
262
    :format => String
263
}
264

  
265
EXPR= {
266
    :name   => "expr",
267
    :short  => "-e ID",
268
    :large  => "--expr ID" ,
269
    :description => "Filter by expression (UNAME=oneadmin)",
270
    :format => String
271
}
272

  
273
DRY= {
274
    :name   => "dry",
275
    :large  => "--dry" ,
276
    :description => "Do not write in the database, output xml"
277
}
278

  
279
DELETE= {
280
    :name   => "delete",
281
    :short  => "-d",
282
    :large  => "--delete" ,
283
    :description => "Delete all matched xpaths"
284
}
285

  
245 286
cmd=CommandParser::CmdParser.new(ARGV) do
246 287
    description <<-EOT.unindent
247 288
        This command enables the user to manage the OpenNebula database. It
......
439 480
        Deletes all but the last history records from non DONE VMs
440 481
    EOT
441 482

  
442
    command :'purge-history' , purge_history_desc,
483
    command :'purge-history', purge_history_desc,
443 484
            :options => [BACKUP, START_TIME, END_TIME] do
444 485
        begin
445 486
            action = OneDBLive.new
......
459 500
        Deletes all VMs in DONE state
460 501
    EOT
461 502

  
462
    command :'purge-done' , purge_done_desc,
503
    command :'purge-done', purge_done_desc,
463 504
            :options => [BACKUP, START_TIME, END_TIME] do
464 505
        begin
465 506
            action = OneDBLive.new
......
472 513

  
473 514
        0 # exit code
474 515
    end
516

  
517
    ###########################################################################
518
    # Change value in object body
519
    ###########################################################################
520
    change_body_desc = <<-EOT.unindent
521
        Changes a value from the body of an object. The possible objects are:
522
            vm, host, vnet, image, cluster, document, group, marketplace,
523
            marketplaceapp, secgroup, template, vrouter or zone
524

  
525
        You can filter the objects to modify using one of these options:
526

  
527
            * --id: object id, example: 156
528
            * --xpath: xpath expression, example: TEMPLATE[count(NIC)>1]
529
            * --expr: xpath expression, can use operators =, !=, <, >, <= or >=
530
                example: TEMPLATE/NIC/NIC_ID>0
531

  
532
        If you want to change a value use a third parameter. In case you want
533
        to delete it use --delete option.
534
    EOT
535

  
536
    command :'change-body', change_body_desc, :object, :xpath, [:value, nil],
537
            :options => [BACKUP, ID, XPATH, EXPR, DRY, DELETE] do
538
        begin
539
            action = OneDBLive.new
540
            action.change_body(args[0], args[1], args[2], options)
541
        rescue Exception => e
542
            puts e.message
543
            pp e.backtrace
544
            [-1, e.message]
545
        end
546

  
547
        0 # exit code
548
    end
475 549
end

Also available in: Unified diff