diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2015-12-18 14:16:45 -0600 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2016-01-15 09:24:48 -0600 |
| commit | cf2de9af79cedd51ca080f5a6521997c05647418 (patch) | |
| tree | fa476461d5fe4ae4edb7008ec71c070425f93d87 /openstackclient/image/v1 | |
| parent | 8654e3e366166372c8f114ad9463dbceb599cd3d (diff) | |
| download | python-openstackclient-cf2de9af79cedd51ca080f5a6521997c05647418.tar.gz | |
Change --owner to --project in image commands
* image create and image set now use --project to specify an alternate
project to own the image
* --owner is still silently accepted but deprecated, add warning messages
* --project and --owner are mutually exclusive to prevent precedence issues
Closes Bug: 1527833
Change-Id: Iccb1a1d9175ef9b5edcd79d294607db12641c1f0
Diffstat (limited to 'openstackclient/image/v1')
| -rw-r--r-- | openstackclient/image/v1/image.py | 65 |
1 files changed, 54 insertions, 11 deletions
diff --git a/openstackclient/image/v1/image.py b/openstackclient/image/v1/image.py index 0382501e..c18f3fc7 100644 --- a/openstackclient/image/v1/image.py +++ b/openstackclient/image/v1/image.py @@ -35,6 +35,7 @@ from glanceclient.common import utils as gc_utils from openstackclient.api import utils as api_utils from openstackclient.common import parseractions from openstackclient.common import utils +from openstackclient.i18n import _ # noqa DEFAULT_CONTAINER_FORMAT = 'bare' @@ -93,11 +94,6 @@ class CreateImage(show.ShowOne): "(default: %s)" % DEFAULT_DISK_FORMAT, ) parser.add_argument( - "--owner", - metavar="<project>", - help="Image owner project name or ID", - ) - parser.add_argument( "--size", metavar="<size>", help="Image size, in bytes (only used with --location and" @@ -178,12 +174,32 @@ class CreateImage(show.ShowOne): help="Set a property on this image " "(repeat option to set multiple properties)", ) + # NOTE(dtroyer): --owner is deprecated in Jan 2016 in an early + # 2.x release. Do not remove before Jan 2017 + # and a 3.x release. + project_group = parser.add_mutually_exclusive_group() + project_group.add_argument( + "--project", + metavar="<project>", + help="Set an alternate project on this image (name or ID)", + ) + project_group.add_argument( + "--owner", + metavar="<project>", + help=argparse.SUPPRESS, + ) return parser def take_action(self, parsed_args): self.log.debug("take_action(%s)", parsed_args) image_client = self.app.client_manager.image + if getattr(parsed_args, 'owner', None) is not None: + self.log.warning(_( + 'The --owner option is deprecated, ' + 'please use --project instead.' + )) + # Build an attribute dict from the parsed args, only include # attributes that were actually set on the command line kwargs = {} @@ -198,6 +214,12 @@ class CreateImage(show.ShowOne): # Only include a value in kwargs for attributes that are # actually present on the command line kwargs[attr] = val + + # Special case project option back to API attribute name 'owner' + val = getattr(parsed_args, 'project', None) + if val: + kwargs['owner'] = val + # Handle exclusive booleans with care # Avoid including attributes in kwargs if an option is not # present on the command line. These exclusive booleans are not @@ -383,7 +405,7 @@ class ListImage(lister.Lister): 'Status', 'Visibility', 'Protected', - 'Owner', + 'Project', 'Properties', ) else: @@ -477,11 +499,6 @@ class SetImage(command.Command): help="New image name", ) parser.add_argument( - "--owner", - metavar="<project>", - help="New image owner project (name or ID)", - ) - parser.add_argument( "--min-disk", metavar="<disk-gb>", type=int, @@ -590,12 +607,32 @@ class SetImage(command.Command): metavar="<checksum>", help="Image hash used for verification", ) + # NOTE(dtroyer): --owner is deprecated in Jan 2016 in an early + # 2.x release. Do not remove before Jan 2017 + # and a 3.x release. + project_group = parser.add_mutually_exclusive_group() + project_group.add_argument( + "--project", + metavar="<project>", + help="Set an alternate project on this image (name or ID)", + ) + project_group.add_argument( + "--owner", + metavar="<project>", + help=argparse.SUPPRESS, + ) return parser def take_action(self, parsed_args): self.log.debug("take_action(%s)", parsed_args) image_client = self.app.client_manager.image + if getattr(parsed_args, 'owner', None) is not None: + self.log.warning(_( + 'The --owner option is deprecated, ' + 'please use --project instead.' + )) + kwargs = {} copy_attrs = ('name', 'owner', 'min_disk', 'min_ram', 'properties', 'container_format', 'disk_format', 'size', 'store', @@ -607,6 +644,12 @@ class SetImage(command.Command): # Only include a value in kwargs for attributes that are # actually present on the command line kwargs[attr] = val + + # Special case project option back to API attribute name 'owner' + val = getattr(parsed_args, 'project', None) + if val: + kwargs['owner'] = val + # Handle exclusive booleans with care # Avoid including attributes in kwargs if an option is not # present on the command line. These exclusive booleans are not |
