~ubuntu-branches/ubuntu/trusty/python-cinderclient/trusty

« back to all changes in this revision

Viewing changes to cinderclient/v1/shell.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-03-06 15:15:14 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140306151514-ihbixyaopbhaqdju
Tags: 1:1.0.8-0ubuntu1
* New upstream release.
* debian/patches/fix-search-opts.patch: Dropped no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
311
311
                                      "specified volumes.")
312
312
 
313
313
 
314
 
@utils.arg('volume', metavar='<volume>',
 
314
@utils.arg('volume', metavar='<volume>', nargs='+',
315
315
           help='Name or ID of the volume to modify.')
316
316
@utils.arg('--state', metavar='<state>', default='available',
317
317
           help=('Indicate which state to assign the volume. Options include '
320
320
@utils.service_type('volume')
321
321
def do_reset_state(cs, args):
322
322
    """Explicitly update the state of a volume."""
323
 
    volume = utils.find_volume(cs, args.volume)
324
 
    volume.reset_state(args.state)
 
323
    failure_count = 0
 
324
 
 
325
    single = (len(args.volume) == 1)
 
326
 
 
327
    for volume in args.volume:
 
328
        try:
 
329
            utils.find_volume(cs, volume).reset_state(args.state)
 
330
        except Exception as e:
 
331
            failure_count += 1
 
332
            msg = "Reset state for volume %s failed: %s" % (volume, e)
 
333
            if not single:
 
334
                print(msg)
 
335
 
 
336
    if failure_count == len(args.volume):
 
337
        if not single:
 
338
            msg = "Unable to reset the state for any of the specified volumes."
 
339
        raise exceptions.CommandError(msg)
325
340
 
326
341
 
327
342
@utils.arg('volume', metavar='<volume>',
498
513
    _find_volume_snapshot(cs, args.snapshot).update(**kwargs)
499
514
 
500
515
 
501
 
@utils.arg('snapshot', metavar='<snapshot>',
 
516
@utils.arg('snapshot', metavar='<snapshot>', nargs='+',
502
517
           help='Name or ID of the snapshot to modify.')
503
518
@utils.arg('--state', metavar='<state>',
504
519
           default='available',
509
524
@utils.service_type('volume')
510
525
def do_snapshot_reset_state(cs, args):
511
526
    """Explicitly update the state of a snapshot."""
512
 
    snapshot = _find_volume_snapshot(cs, args.snapshot)
513
 
    snapshot.reset_state(args.state)
 
527
    failure_count = 0
 
528
 
 
529
    single = (len(args.snapshot) == 1)
 
530
 
 
531
    for snapshot in args.snapshot:
 
532
        try:
 
533
            _find_volume_snapshot(cs, snapshot).reset_state(args.state)
 
534
        except Exception as e:
 
535
            failure_count += 1
 
536
            msg = "Reset state for snapshot %s failed: %s" % (snapshot, e)
 
537
            if not single:
 
538
                print(msg)
 
539
 
 
540
    if failure_count == len(args.snapshot):
 
541
        if not single:
 
542
            msg = ("Unable to reset the state for any of the the specified "
 
543
                   "snapshots.")
 
544
        raise exceptions.CommandError(msg)
514
545
 
515
546
 
516
547
def _print_volume_type_list(vtypes):
962
993
@utils.service_type('volume')
963
994
def do_service_enable(cs, args):
964
995
    """Enable the service."""
965
 
    cs.services.enable(args.host, args.binary)
 
996
    result = cs.services.enable(args.host, args.binary)
 
997
    columns = ["Host", "Binary", "Status"]
 
998
    utils.print_list([result], columns)
966
999
 
967
1000
 
968
1001
@utils.arg('host', metavar='<hostname>', help='Name of host.')
970
1003
@utils.service_type('volume')
971
1004
def do_service_disable(cs, args):
972
1005
    """Disable the service."""
973
 
    cs.services.disable(args.host, args.binary)
 
1006
    result = cs.services.disable(args.host, args.binary)
 
1007
    columns = ["Host", "Binary", "Status"]
 
1008
    utils.print_list([result], columns)
974
1009
 
975
1010
 
976
1011
def _treeizeAvailabilityZone(zone):
1116
1151
    _print_volume_encryption_type_list([result])
1117
1152
 
1118
1153
 
 
1154
@utils.arg('volume_type',
 
1155
           metavar='<volume_type>',
 
1156
           type=str,
 
1157
           help="Name or ID of the volume type")
 
1158
@utils.service_type('volume')
 
1159
def do_encryption_type_delete(cs, args):
 
1160
    """Delete the encryption type for a volume type (Admin Only)."""
 
1161
    volume_type = _find_volume_type(cs, args.volume_type)
 
1162
    cs.volume_encryption_types.delete(volume_type)
 
1163
 
 
1164
 
1119
1165
@utils.arg('volume', metavar='<volume>', help='ID of the volume to migrate')
1120
1166
@utils.arg('host', metavar='<host>', help='Destination host')
1121
1167
@utils.arg('--force-host-copy', metavar='<True|False>',