diff --git a/doc/source/command-objects/volume.rst b/doc/source/command-objects/volume.rst index 0b2e0db66a..3baae5d853 100644 --- a/doc/source/command-objects/volume.rst +++ b/doc/source/command-objects/volume.rst @@ -14,7 +14,7 @@ Create new volume os volume create --size - [--snapshot-id ] + [--snapshot ] [--description ] [--type ] [--user ] @@ -29,9 +29,9 @@ Create new volume New volume size in GB -.. option:: --snapshot-id +.. option:: --snapshot - Use as source of new volume + Use as source of new volume .. option:: --description diff --git a/openstackclient/volume/v1/volume.py b/openstackclient/volume/v1/volume.py index 3d26a5e9e5..ad9671e35f 100644 --- a/openstackclient/volume/v1/volume.py +++ b/openstackclient/volume/v1/volume.py @@ -15,6 +15,7 @@ """Volume v1 Volume action implementations""" +import argparse import logging import six @@ -45,10 +46,16 @@ class CreateVolume(show.ShowOne): type=int, help='New volume size in GB', ) - parser.add_argument( + snapshot_group = parser.add_mutually_exclusive_group() + snapshot_group.add_argument( + '--snapshot', + metavar='', + help='Use as source of new volume', + ) + snapshot_group.add_argument( '--snapshot-id', metavar='', - help='Use as source of new volume', + help=argparse.SUPPRESS, ) parser.add_argument( '--description', @@ -130,9 +137,11 @@ class CreateVolume(show.ShowOne): parsed_args.image, ).id + snapshot = parsed_args.snapshot or parsed_args.snapshot_id + volume = volume_client.volumes.create( parsed_args.size, - parsed_args.snapshot_id, + snapshot, source_volume, parsed_args.name, parsed_args.description,