status = 10
elif options.action == 'rebase':
    print_detail("Rebasing LUN...", 1)
    lun = LUN(args[0], proxy=backend_proxy)
    rebasedLUN = lun.rebase()
    # If an error occured, it has already been signaled.
    # If it succeeds, rebasedLUN should always be defined...
    if rebasedLUN:
        print rebasedLUN
        status = 0
    else:
        status = 10
elif options.action == 'snapshot':
    print_detail("Doing a LUN snapshot...", 1)
    lun = LUN(args[0], size=args[2], proxy=backend_proxy)
    snapshot_lun = LUN(args[1], proxy=backend_proxy)
    # Only the last error is returned
    status = lun.snapshot(snapshot_lun)
elif options.action == 'map':
    print_detail("Mapping LUN...", 1)
    lun = LUN(args[0], proxy=backend_proxy)
    status = lun.map()
elif options.action == 'unmap':
    print_detail("Unmapping LUN...", 1)
    lun = LUN(args[0], proxy=backend_proxy)
    status = lun.unmap()
else:
    abort("Internal error: unimplemented action (%s)" % options.action)

sys.exit(status)
        status = 10
elif options.action == 'rebase':
    print_detail("Rebasing LUN...", 1)
    lun = LUN(args[0], proxy=backend_proxy)
    rebasedLUN = lun.rebase()
    # If an error occured, it has already been signaled.
    # If it succeeds, rebasedLUN should always be defined...
    if rebasedLUN:
        print rebasedLUN
        status = 0
    else:
        status = 10
elif options.action == 'snapshot':
    print_detail("Doing a LUN snapshot...", 1)
    lun = LUN(args[0],size=args[2],proxy=backend_proxy)
    snapshot_lun = LUN(args[1],proxy=backend_proxy)
    # Only the last error is returned
    status = lun.snapshot(snapshot_lun)
elif options.action == 'map':
    print_detail("Mapping LUN...", 1)
    lun = LUN(args[0],proxy=backend_proxy)
    status = lun.map()
elif options.action == 'unmap':
    print_detail("Unmapping LUN...", 1)
    lun = LUN(args[0],proxy=backend_proxy)
    status = lun.unmap()
else:
    abort("Internal error: unimplemented action (%s)" % options.action)

sys.exit(status)