summaryrefslogtreecommitdiff
path: root/openstackclient/volume
diff options
context:
space:
mode:
authorAlan Bishop <abishop@redhat.com>2018-08-10 10:20:34 -0400
committerAlan Bishop <abishop@redhat.com>2018-08-10 10:20:34 -0400
commit030fd71390e8e4b8413e916e64076337035f9aa7 (patch)
tree49c75eb0224148002aa3919e7439e006d39d6ce0 /openstackclient/volume
parenta051bda1118158cef219cddf94a24483f6b1513b (diff)
downloadpython-openstackclient-030fd71390e8e4b8413e916e64076337035f9aa7.tar.gz
Deprecate volume create --project and --user options
Cinder's volume create API does not support overriding the project_id and user_id, and it silently igores those API inputs. Cinder always uses the project and user info in the keystone identity associated with the API request. If a user specifies the --project or --user option, the volume create is aborted and a CommandError exception is raised. This prevents a volume from being created, but without the desired project/user values. A user wishing to specify alternate values can still do so using identity overrides (e.g. --os-username, --os-project-id). Story: 2002583 Task: 22192 Change-Id: Ia9f910ea1b0e61797e8c8c463fa28e7390f15bf9
Diffstat (limited to 'openstackclient/volume')
-rw-r--r--openstackclient/volume/v2/volume.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py
index fc648cef..8ab61d2a 100644
--- a/openstackclient/volume/v2/volume.py
+++ b/openstackclient/volume/v2/volume.py
@@ -96,12 +96,12 @@ class CreateVolume(command.ShowOne):
parser.add_argument(
'--user',
metavar='<user>',
- help=_('Specify an alternate user (name or ID)'),
+ help=argparse.SUPPRESS,
)
parser.add_argument(
'--project',
metavar='<project>',
- help=_('Specify an alternate project (name or ID)'),
+ help=argparse.SUPPRESS,
)
parser.add_argument(
"--availability-zone",
@@ -159,7 +159,6 @@ class CreateVolume(command.ShowOne):
def take_action(self, parsed_args):
_check_size_arg(parsed_args)
- identity_client = self.app.client_manager.identity
volume_client = self.app.client_manager.volume
image_client = self.app.client_manager.image
@@ -197,17 +196,22 @@ class CreateVolume(command.ShowOne):
# snapshot size.
size = max(size or 0, snapshot_obj.size)
- project = None
+ # NOTE(abishop): Cinder's volumes.create() has 'project_id' and
+ # 'user_id' args, but they're not wired up to anything. The only way
+ # to specify an alternate project or user for the volume is to use
+ # the identity overrides (e.g. "--os-project-id").
+ #
+ # Now, if the project or user arg is specified then the command is
+ # rejected. Otherwise, Cinder would actually create a volume, but
+ # without the specified property.
if parsed_args.project:
- project = utils.find_resource(
- identity_client.projects,
- parsed_args.project).id
-
- user = None
+ raise exceptions.CommandError(
+ _("ERROR: --project is deprecated, please use"
+ " --os-project-name or --os-project-id instead."))
if parsed_args.user:
- user = utils.find_resource(
- identity_client.users,
- parsed_args.user).id
+ raise exceptions.CommandError(
+ _("ERROR: --user is deprecated, please use"
+ " --os-username instead."))
volume = volume_client.volumes.create(
size=size,
@@ -215,8 +219,6 @@ class CreateVolume(command.ShowOne):
name=parsed_args.name,
description=parsed_args.description,
volume_type=parsed_args.type,
- user_id=user,
- project_id=project,
availability_zone=parsed_args.availability_zone,
metadata=parsed_args.property,
imageRef=image,