Merge "Fix i18n support for help and log.warning in image"

This commit is contained in:
Jenkins 2016-05-19 20:19:36 +00:00 committed by Gerrit Code Review
commit be081ebb44
3 changed files with 143 additions and 139 deletions

View File

@ -16,6 +16,7 @@
import logging import logging
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -82,7 +83,7 @@ def build_option_parser(parser):
'--os-image-api-version', '--os-image-api-version',
metavar='<image-api-version>', metavar='<image-api-version>',
default=utils.env('OS_IMAGE_API_VERSION'), default=utils.env('OS_IMAGE_API_VERSION'),
help='Image API version, default=' + help=_('Image API version, default=%s (Env: OS_IMAGE_API_VERSION)') %
DEFAULT_API_VERSION + DEFAULT_API_VERSION,
' (Env: OS_IMAGE_API_VERSION)') )
return parser return parser

View File

@ -61,112 +61,112 @@ class CreateImage(command.ShowOne):
parser.add_argument( parser.add_argument(
"name", "name",
metavar="<image-name>", metavar="<image-name>",
help="New image name", help=_("New image name"),
) )
parser.add_argument( parser.add_argument(
"--id", "--id",
metavar="<id>", metavar="<id>",
help="Image ID to reserve", help=_("Image ID to reserve"),
) )
parser.add_argument( parser.add_argument(
"--store", "--store",
metavar="<store>", metavar="<store>",
help="Upload image to this store", help=_("Upload image to this store"),
) )
parser.add_argument( parser.add_argument(
"--container-format", "--container-format",
default=DEFAULT_CONTAINER_FORMAT, default=DEFAULT_CONTAINER_FORMAT,
metavar="<container-format>", metavar="<container-format>",
help="Image container format " help=_("Image container format "
"(default: %s)" % DEFAULT_CONTAINER_FORMAT, "(default: %s)") % DEFAULT_CONTAINER_FORMAT,
) )
parser.add_argument( parser.add_argument(
"--disk-format", "--disk-format",
default=DEFAULT_DISK_FORMAT, default=DEFAULT_DISK_FORMAT,
metavar="<disk-format>", metavar="<disk-format>",
help="Image disk format " help=_("Image disk format "
"(default: %s)" % DEFAULT_DISK_FORMAT, "(default: %s)") % DEFAULT_DISK_FORMAT,
) )
parser.add_argument( parser.add_argument(
"--size", "--size",
metavar="<size>", metavar="<size>",
help="Image size, in bytes (only used with --location and" help=_("Image size, in bytes (only used with --location and"
" --copy-from)", " --copy-from)"),
) )
parser.add_argument( parser.add_argument(
"--min-disk", "--min-disk",
metavar="<disk-gb>", metavar="<disk-gb>",
type=int, type=int,
help="Minimum disk size needed to boot image, in gigabytes", help=_("Minimum disk size needed to boot image, in gigabytes"),
) )
parser.add_argument( parser.add_argument(
"--min-ram", "--min-ram",
metavar="<ram-mb>", metavar="<ram-mb>",
type=int, type=int,
help="Minimum RAM size needed to boot image, in megabytes", help=_("Minimum RAM size needed to boot image, in megabytes"),
) )
parser.add_argument( parser.add_argument(
"--location", "--location",
metavar="<image-url>", metavar="<image-url>",
help="Download image from an existing URL", help=_("Download image from an existing URL"),
) )
parser.add_argument( parser.add_argument(
"--copy-from", "--copy-from",
metavar="<image-url>", metavar="<image-url>",
help="Copy image from the data store (similar to --location)", help=_("Copy image from the data store (similar to --location)"),
) )
parser.add_argument( parser.add_argument(
"--file", "--file",
metavar="<file>", metavar="<file>",
help="Upload image from local file", help=_("Upload image from local file"),
) )
parser.add_argument( parser.add_argument(
"--volume", "--volume",
metavar="<volume>", metavar="<volume>",
help="Create image from a volume", help=_("Create image from a volume"),
) )
parser.add_argument( parser.add_argument(
"--force", "--force",
dest='force', dest='force',
action='store_true', action='store_true',
default=False, default=False,
help="Force image creation if volume is in use " help=_("Force image creation if volume is in use "
"(only meaningful with --volume)", "(only meaningful with --volume)"),
) )
parser.add_argument( parser.add_argument(
"--checksum", "--checksum",
metavar="<checksum>", metavar="<checksum>",
help="Image hash used for verification", help=_("Image hash used for verification"),
) )
protected_group = parser.add_mutually_exclusive_group() protected_group = parser.add_mutually_exclusive_group()
protected_group.add_argument( protected_group.add_argument(
"--protected", "--protected",
action="store_true", action="store_true",
help="Prevent image from being deleted", help=_("Prevent image from being deleted"),
) )
protected_group.add_argument( protected_group.add_argument(
"--unprotected", "--unprotected",
action="store_true", action="store_true",
help="Allow image to be deleted (default)", help=_("Allow image to be deleted (default)"),
) )
public_group = parser.add_mutually_exclusive_group() public_group = parser.add_mutually_exclusive_group()
public_group.add_argument( public_group.add_argument(
"--public", "--public",
action="store_true", action="store_true",
help="Image is accessible to the public", help=_("Image is accessible to the public"),
) )
public_group.add_argument( public_group.add_argument(
"--private", "--private",
action="store_true", action="store_true",
help="Image is inaccessible to the public (default)", help=_("Image is inaccessible to the public (default)"),
) )
parser.add_argument( parser.add_argument(
"--property", "--property",
dest="properties", dest="properties",
metavar="<key=value>", metavar="<key=value>",
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help="Set a property on this image " help=_("Set a property on this image "
"(repeat option to set multiple properties)", "(repeat option to set multiple properties)"),
) )
# NOTE(dtroyer): --owner is deprecated in Jan 2016 in an early # NOTE(dtroyer): --owner is deprecated in Jan 2016 in an early
# 2.x release. Do not remove before Jan 2017 # 2.x release. Do not remove before Jan 2017
@ -175,7 +175,7 @@ class CreateImage(command.ShowOne):
project_group.add_argument( project_group.add_argument(
"--project", "--project",
metavar="<project>", metavar="<project>",
help="Set an alternate project on this image (name or ID)", help=_("Set an alternate project on this image (name or ID)"),
) )
project_group.add_argument( project_group.add_argument(
"--owner", "--owner",
@ -282,7 +282,7 @@ class DeleteImage(command.Command):
"images", "images",
metavar="<image>", metavar="<image>",
nargs="+", nargs="+",
help="Image(s) to delete (name or ID)", help=_("Image(s) to delete (name or ID)"),
) )
return parser return parser
@ -307,14 +307,14 @@ class ListImage(command.Lister):
dest="public", dest="public",
action="store_true", action="store_true",
default=False, default=False,
help="List only public images", help=_("List only public images"),
) )
public_group.add_argument( public_group.add_argument(
"--private", "--private",
dest="private", dest="private",
action="store_true", action="store_true",
default=False, default=False,
help="List only private images", help=_("List only private images"),
) )
# Included for silent CLI compatibility with v2 # Included for silent CLI compatibility with v2
public_group.add_argument( public_group.add_argument(
@ -328,13 +328,13 @@ class ListImage(command.Lister):
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Filter output based on property', help=_('Filter output based on property'),
) )
parser.add_argument( parser.add_argument(
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
# --page-size has never worked, leave here for silent compatibility # --page-size has never worked, leave here for silent compatibility
@ -347,9 +347,9 @@ class ListImage(command.Lister):
parser.add_argument( parser.add_argument(
'--sort', '--sort',
metavar="<key>[:<direction>]", metavar="<key>[:<direction>]",
help="Sort output by selected keys and directions(asc or desc) " help=_("Sort output by selected keys and directions(asc or desc) "
"(default: asc), multiple keys and directions can be " "(default: asc), multiple keys and directions can be "
"specified separated by comma", "specified separated by comma"),
) )
return parser return parser
@ -442,12 +442,12 @@ class SaveImage(command.Command):
parser.add_argument( parser.add_argument(
"--file", "--file",
metavar="<filename>", metavar="<filename>",
help="Downloaded image save filename (default: stdout)", help=_("Downloaded image save filename (default: stdout)"),
) )
parser.add_argument( parser.add_argument(
"image", "image",
metavar="<image>", metavar="<image>",
help="Image to save (name or ID)", help=_("Image to save (name or ID)"),
) )
return parser return parser
@ -470,31 +470,31 @@ class SetImage(command.Command):
parser.add_argument( parser.add_argument(
"image", "image",
metavar="<image>", metavar="<image>",
help="Image to modify (name or ID)", help=_("Image to modify (name or ID)"),
) )
parser.add_argument( parser.add_argument(
"--name", "--name",
metavar="<name>", metavar="<name>",
help="New image name", help=_("New image name"),
) )
parser.add_argument( parser.add_argument(
"--min-disk", "--min-disk",
metavar="<disk-gb>", metavar="<disk-gb>",
type=int, type=int,
help="Minimum disk size needed to boot image, in gigabytes", help=_("Minimum disk size needed to boot image, in gigabytes"),
) )
parser.add_argument( parser.add_argument(
"--min-ram", "--min-ram",
metavar="<disk-ram>", metavar="<disk-ram>",
type=int, type=int,
help="Minimum RAM size needed to boot image, in megabytes", help=_("Minimum RAM size needed to boot image, in megabytes"),
) )
container_choices = ["ami", "ari", "aki", "bare", "ovf"] container_choices = ["ami", "ari", "aki", "bare", "ovf"]
parser.add_argument( parser.add_argument(
"--container-format", "--container-format",
metavar="<container-format>", metavar="<container-format>",
help=("Container format of image. Acceptable formats: %s" % help=_("Container format of image. Acceptable formats: %s") %
container_choices), container_choices,
choices=container_choices choices=container_choices
) )
disk_choices = ["ami", "ari", "aki", "vhd", "vmdk", "raw", "qcow2", disk_choices = ["ami", "ari", "aki", "vhd", "vmdk", "raw", "qcow2",
@ -502,89 +502,90 @@ class SetImage(command.Command):
parser.add_argument( parser.add_argument(
"--disk-format", "--disk-format",
metavar="<disk-format>", metavar="<disk-format>",
help="Disk format of image. Acceptable formats: %s" % disk_choices, help=_("Disk format of image. Acceptable formats: %s") %
disk_choices,
choices=disk_choices choices=disk_choices
) )
parser.add_argument( parser.add_argument(
"--size", "--size",
metavar="<size>", metavar="<size>",
type=int, type=int,
help="Size of image data (in bytes)" help=_("Size of image data (in bytes)")
) )
protected_group = parser.add_mutually_exclusive_group() protected_group = parser.add_mutually_exclusive_group()
protected_group.add_argument( protected_group.add_argument(
"--protected", "--protected",
action="store_true", action="store_true",
help="Prevent image from being deleted", help=_("Prevent image from being deleted"),
) )
protected_group.add_argument( protected_group.add_argument(
"--unprotected", "--unprotected",
action="store_true", action="store_true",
help="Allow image to be deleted (default)", help=_("Allow image to be deleted (default)"),
) )
public_group = parser.add_mutually_exclusive_group() public_group = parser.add_mutually_exclusive_group()
public_group.add_argument( public_group.add_argument(
"--public", "--public",
action="store_true", action="store_true",
help="Image is accessible to the public", help=_("Image is accessible to the public"),
) )
public_group.add_argument( public_group.add_argument(
"--private", "--private",
action="store_true", action="store_true",
help="Image is inaccessible to the public (default)", help=_("Image is inaccessible to the public (default)"),
) )
parser.add_argument( parser.add_argument(
"--property", "--property",
dest="properties", dest="properties",
metavar="<key=value>", metavar="<key=value>",
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help="Set a property on this image " help=_("Set a property on this image "
"(repeat option to set multiple properties)", "(repeat option to set multiple properties)"),
) )
parser.add_argument( parser.add_argument(
"--store", "--store",
metavar="<store>", metavar="<store>",
help="Upload image to this store", help=_("Upload image to this store"),
) )
parser.add_argument( parser.add_argument(
"--location", "--location",
metavar="<image-url>", metavar="<image-url>",
help="Download image from an existing URL", help=_("Download image from an existing URL"),
) )
parser.add_argument( parser.add_argument(
"--copy-from", "--copy-from",
metavar="<image-url>", metavar="<image-url>",
help="Copy image from the data store (similar to --location)", help=_("Copy image from the data store (similar to --location)"),
) )
parser.add_argument( parser.add_argument(
"--file", "--file",
metavar="<file>", metavar="<file>",
help="Upload image from local file", help=_("Upload image from local file"),
) )
parser.add_argument( parser.add_argument(
"--volume", "--volume",
metavar="<volume>", metavar="<volume>",
help="Create image from a volume", help=_("Create image from a volume"),
) )
parser.add_argument( parser.add_argument(
"--force", "--force",
dest='force', dest='force',
action='store_true', action='store_true',
default=False, default=False,
help="Force image change if volume is in use " help=_("Force image change if volume is in use "
"(only meaningful with --volume)", "(only meaningful with --volume)"),
) )
parser.add_argument( parser.add_argument(
"--stdin", "--stdin",
dest='stdin', dest='stdin',
action='store_true', action='store_true',
default=False, default=False,
help="Read image data from standard input", help=_("Read image data from standard input"),
) )
parser.add_argument( parser.add_argument(
"--checksum", "--checksum",
metavar="<checksum>", metavar="<checksum>",
help="Image hash used for verification", help=_("Image hash used for verification"),
) )
# NOTE(dtroyer): --owner is deprecated in Jan 2016 in an early # NOTE(dtroyer): --owner is deprecated in Jan 2016 in an early
# 2.x release. Do not remove before Jan 2017 # 2.x release. Do not remove before Jan 2017
@ -593,7 +594,7 @@ class SetImage(command.Command):
project_group.add_argument( project_group.add_argument(
"--project", "--project",
metavar="<project>", metavar="<project>",
help="Set an alternate project on this image (name or ID)", help=_("Set an alternate project on this image (name or ID)"),
) )
project_group.add_argument( project_group.add_argument(
"--owner", "--owner",
@ -682,8 +683,9 @@ class SetImage(command.Command):
# will do a chunked transfer # will do a chunked transfer
kwargs["data"] = sys.stdin kwargs["data"] = sys.stdin
else: else:
self.log.warning('Use --stdin to enable read image' self.log.warning(_('Use --stdin to enable read '
' data from standard input') 'image data from standard '
'input'))
if image.properties and parsed_args.properties: if image.properties and parsed_args.properties:
image.properties.update(kwargs['properties']) image.properties.update(kwargs['properties'])
@ -709,7 +711,7 @@ class ShowImage(command.ShowOne):
parser.add_argument( parser.add_argument(
"image", "image",
metavar="<image>", metavar="<image>",
help="Image to display (name or ID)", help=_("Image to display (name or ID)"),
) )
return parser return parser

View File

@ -72,12 +72,12 @@ class AddProjectToImage(command.ShowOne):
parser.add_argument( parser.add_argument(
"image", "image",
metavar="<image>", metavar="<image>",
help="Image to share (name or ID)", help=_("Image to share (name or ID)"),
) )
parser.add_argument( parser.add_argument(
"project", "project",
metavar="<project>", metavar="<project>",
help="Project to associate with image (name or ID)", help=_("Project to associate with image (name or ID)"),
) )
common.add_project_domain_option_to_parser(parser) common.add_project_domain_option_to_parser(parser)
return parser return parser
@ -119,94 +119,94 @@ class CreateImage(command.ShowOne):
parser.add_argument( parser.add_argument(
"name", "name",
metavar="<image-name>", metavar="<image-name>",
help="New image name", help=_("New image name"),
) )
parser.add_argument( parser.add_argument(
"--id", "--id",
metavar="<id>", metavar="<id>",
help="Image ID to reserve", help=_("Image ID to reserve"),
) )
parser.add_argument( parser.add_argument(
"--container-format", "--container-format",
default=DEFAULT_CONTAINER_FORMAT, default=DEFAULT_CONTAINER_FORMAT,
metavar="<container-format>", metavar="<container-format>",
help="Image container format " help=_("Image container format "
"(default: %s)" % DEFAULT_CONTAINER_FORMAT, "(default: %s)") % DEFAULT_CONTAINER_FORMAT,
) )
parser.add_argument( parser.add_argument(
"--disk-format", "--disk-format",
default=DEFAULT_DISK_FORMAT, default=DEFAULT_DISK_FORMAT,
metavar="<disk-format>", metavar="<disk-format>",
help="Image disk format " help=_("Image disk format "
"(default: %s)" % DEFAULT_DISK_FORMAT, "(default: %s)") % DEFAULT_DISK_FORMAT,
) )
parser.add_argument( parser.add_argument(
"--min-disk", "--min-disk",
metavar="<disk-gb>", metavar="<disk-gb>",
type=int, type=int,
help="Minimum disk size needed to boot image, in gigabytes", help=_("Minimum disk size needed to boot image, in gigabytes"),
) )
parser.add_argument( parser.add_argument(
"--min-ram", "--min-ram",
metavar="<ram-mb>", metavar="<ram-mb>",
type=int, type=int,
help="Minimum RAM size needed to boot image, in megabytes", help=_("Minimum RAM size needed to boot image, in megabytes"),
) )
parser.add_argument( parser.add_argument(
"--file", "--file",
metavar="<file>", metavar="<file>",
help="Upload image from local file", help=_("Upload image from local file"),
) )
parser.add_argument( parser.add_argument(
"--volume", "--volume",
metavar="<volume>", metavar="<volume>",
help="Create image from a volume", help=_("Create image from a volume"),
) )
parser.add_argument( parser.add_argument(
"--force", "--force",
dest='force', dest='force',
action='store_true', action='store_true',
default=False, default=False,
help="Force image creation if volume is in use " help=_("Force image creation if volume is in use "
"(only meaningful with --volume)", "(only meaningful with --volume)"),
) )
protected_group = parser.add_mutually_exclusive_group() protected_group = parser.add_mutually_exclusive_group()
protected_group.add_argument( protected_group.add_argument(
"--protected", "--protected",
action="store_true", action="store_true",
help="Prevent image from being deleted", help=_("Prevent image from being deleted"),
) )
protected_group.add_argument( protected_group.add_argument(
"--unprotected", "--unprotected",
action="store_true", action="store_true",
help="Allow image to be deleted (default)", help=_("Allow image to be deleted (default)"),
) )
public_group = parser.add_mutually_exclusive_group() public_group = parser.add_mutually_exclusive_group()
public_group.add_argument( public_group.add_argument(
"--public", "--public",
action="store_true", action="store_true",
help="Image is accessible to the public", help=_("Image is accessible to the public"),
) )
public_group.add_argument( public_group.add_argument(
"--private", "--private",
action="store_true", action="store_true",
help="Image is inaccessible to the public (default)", help=_("Image is inaccessible to the public (default)"),
) )
parser.add_argument( parser.add_argument(
"--property", "--property",
dest="properties", dest="properties",
metavar="<key=value>", metavar="<key=value>",
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help="Set a property on this image " help=_("Set a property on this image "
"(repeat option to set multiple properties)", "(repeat option to set multiple properties)"),
) )
parser.add_argument( parser.add_argument(
"--tag", "--tag",
dest="tags", dest="tags",
metavar="<tag>", metavar="<tag>",
action='append', action='append',
help="Set a tag on this image " help=_("Set a tag on this image "
"(repeat option to set multiple tags)", "(repeat option to set multiple tags)"),
) )
# NOTE(dtroyer): --owner is deprecated in Jan 2016 in an early # NOTE(dtroyer): --owner is deprecated in Jan 2016 in an early
# 2.x release. Do not remove before Jan 2017 # 2.x release. Do not remove before Jan 2017
@ -215,7 +215,7 @@ class CreateImage(command.ShowOne):
project_group.add_argument( project_group.add_argument(
"--project", "--project",
metavar="<project>", metavar="<project>",
help="Set an alternate project on this image (name or ID)", help=_("Set an alternate project on this image (name or ID)"),
) )
project_group.add_argument( project_group.add_argument(
"--owner", "--owner",
@ -239,8 +239,8 @@ class CreateImage(command.ShowOne):
for deadopt in self.deadopts: for deadopt in self.deadopts:
if getattr(parsed_args, deadopt.replace('-', '_'), None): if getattr(parsed_args, deadopt.replace('-', '_'), None):
raise exceptions.CommandError( raise exceptions.CommandError(
"ERROR: --%s was given, which is an Image v1 option" _("ERROR: --%s was given, which is an Image v1 option"
" that is no longer supported in Image v2" % deadopt) " that is no longer supported in Image v2") % deadopt)
# Build an attribute dict from the parsed args, only include # Build an attribute dict from the parsed args, only include
# attributes that were actually set on the command line # attributes that were actually set on the command line
@ -296,11 +296,12 @@ class CreateImage(command.ShowOne):
fp = gc_utils.get_data_file(parsed_args) fp = gc_utils.get_data_file(parsed_args)
info = {} info = {}
if fp is not None and parsed_args.volume: if fp is not None and parsed_args.volume:
raise exceptions.CommandError("Uploading data and using container " raise exceptions.CommandError(_("Uploading data and using "
"are not allowed at the same time") "container are not allowed at "
"the same time"))
if fp is None and parsed_args.file: if fp is None and parsed_args.file:
self.log.warning("Failed to get an image file.") self.log.warning(_("Failed to get an image file."))
return {}, {} return {}, {}
if parsed_args.owner: if parsed_args.owner:
@ -366,7 +367,7 @@ class DeleteImage(command.Command):
"images", "images",
metavar="<image>", metavar="<image>",
nargs="+", nargs="+",
help="Image(s) to delete (name or ID)", help=_("Image(s) to delete (name or ID)"),
) )
return parser return parser
@ -391,33 +392,33 @@ class ListImage(command.Lister):
dest="public", dest="public",
action="store_true", action="store_true",
default=False, default=False,
help="List only public images", help=_("List only public images"),
) )
public_group.add_argument( public_group.add_argument(
"--private", "--private",
dest="private", dest="private",
action="store_true", action="store_true",
default=False, default=False,
help="List only private images", help=_("List only private images"),
) )
public_group.add_argument( public_group.add_argument(
"--shared", "--shared",
dest="shared", dest="shared",
action="store_true", action="store_true",
default=False, default=False,
help="List only shared images", help=_("List only shared images"),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Filter output based on property', help=_('Filter output based on property'),
) )
parser.add_argument( parser.add_argument(
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
# --page-size has never worked, leave here for silent compatibility # --page-size has never worked, leave here for silent compatibility
@ -430,23 +431,23 @@ class ListImage(command.Lister):
parser.add_argument( parser.add_argument(
'--sort', '--sort',
metavar="<key>[:<direction>]", metavar="<key>[:<direction>]",
help="Sort output by selected keys and directions(asc or desc) " help=_("Sort output by selected keys and directions(asc or desc) "
"(default: asc), multiple keys and directions can be " "(default: asc), multiple keys and directions can be "
"specified separated by comma", "specified separated by comma"),
) )
parser.add_argument( parser.add_argument(
"--limit", "--limit",
metavar="<limit>", metavar="<limit>",
type=int, type=int,
help="Maximum number of images to display.", help=_("Maximum number of images to display."),
) )
parser.add_argument( parser.add_argument(
'--marker', '--marker',
metavar='<marker>', metavar='<marker>',
default=None, default=None,
help="The last image (name or ID) of the previous page. Display " help=_("The last image (name or ID) of the previous page. Display "
"list of images after marker. Display all images if not " "list of images after marker. Display all images if not "
"specified." "specified."),
) )
return parser return parser
@ -530,12 +531,12 @@ class RemoveProjectImage(command.Command):
parser.add_argument( parser.add_argument(
"image", "image",
metavar="<image>", metavar="<image>",
help="Image to unshare (name or ID)", help=_("Image to unshare (name or ID)"),
) )
parser.add_argument( parser.add_argument(
"project", "project",
metavar="<project>", metavar="<project>",
help="Project to disassociate with image (name or ID)", help=_("Project to disassociate with image (name or ID)"),
) )
common.add_project_domain_option_to_parser(parser) common.add_project_domain_option_to_parser(parser)
return parser return parser
@ -563,12 +564,12 @@ class SaveImage(command.Command):
parser.add_argument( parser.add_argument(
"--file", "--file",
metavar="<filename>", metavar="<filename>",
help="Downloaded image save filename (default: stdout)", help=_("Downloaded image save filename (default: stdout)"),
) )
parser.add_argument( parser.add_argument(
"image", "image",
metavar="<image>", metavar="<image>",
help="Image to save (name or ID)", help=_("Image to save (name or ID)"),
) )
return parser return parser
@ -603,66 +604,66 @@ class SetImage(command.Command):
parser.add_argument( parser.add_argument(
"image", "image",
metavar="<image>", metavar="<image>",
help="Image to modify (name or ID)" help=_("Image to modify (name or ID)")
) )
parser.add_argument( parser.add_argument(
"--name", "--name",
metavar="<name>", metavar="<name>",
help="New image name" help=_("New image name")
) )
parser.add_argument( parser.add_argument(
"--min-disk", "--min-disk",
type=int, type=int,
metavar="<disk-gb>", metavar="<disk-gb>",
help="Minimum disk size needed to boot image, in gigabytes" help=_("Minimum disk size needed to boot image, in gigabytes")
) )
parser.add_argument( parser.add_argument(
"--min-ram", "--min-ram",
type=int, type=int,
metavar="<ram-mb>", metavar="<ram-mb>",
help="Minimum RAM size needed to boot image, in megabytes", help=_("Minimum RAM size needed to boot image, in megabytes"),
) )
parser.add_argument( parser.add_argument(
"--container-format", "--container-format",
metavar="<container-format>", metavar="<container-format>",
help="Image container format " help=_("Image container format "
"(default: %s)" % DEFAULT_CONTAINER_FORMAT, "(default: %s)") % DEFAULT_CONTAINER_FORMAT,
) )
parser.add_argument( parser.add_argument(
"--disk-format", "--disk-format",
metavar="<disk-format>", metavar="<disk-format>",
help="Image disk format " help=_("Image disk format "
"(default: %s)" % DEFAULT_DISK_FORMAT, "(default: %s)") % DEFAULT_DISK_FORMAT,
) )
protected_group = parser.add_mutually_exclusive_group() protected_group = parser.add_mutually_exclusive_group()
protected_group.add_argument( protected_group.add_argument(
"--protected", "--protected",
action="store_true", action="store_true",
help="Prevent image from being deleted", help=_("Prevent image from being deleted"),
) )
protected_group.add_argument( protected_group.add_argument(
"--unprotected", "--unprotected",
action="store_true", action="store_true",
help="Allow image to be deleted (default)", help=_("Allow image to be deleted (default)"),
) )
public_group = parser.add_mutually_exclusive_group() public_group = parser.add_mutually_exclusive_group()
public_group.add_argument( public_group.add_argument(
"--public", "--public",
action="store_true", action="store_true",
help="Image is accessible to the public", help=_("Image is accessible to the public"),
) )
public_group.add_argument( public_group.add_argument(
"--private", "--private",
action="store_true", action="store_true",
help="Image is inaccessible to the public (default)", help=_("Image is inaccessible to the public (default)"),
) )
parser.add_argument( parser.add_argument(
"--property", "--property",
dest="properties", dest="properties",
metavar="<key=value>", metavar="<key=value>",
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help="Set a property on this image " help=_("Set a property on this image "
"(repeat option to set multiple properties)", "(repeat option to set multiple properties)"),
) )
parser.add_argument( parser.add_argument(
"--tag", "--tag",
@ -670,18 +671,18 @@ class SetImage(command.Command):
metavar="<tag>", metavar="<tag>",
default=[], default=[],
action='append', action='append',
help="Set a tag on this image " help=_("Set a tag on this image "
"(repeat option to set multiple tags)", "(repeat option to set multiple tags)"),
) )
parser.add_argument( parser.add_argument(
"--architecture", "--architecture",
metavar="<architecture>", metavar="<architecture>",
help="Operating system architecture", help=_("Operating system architecture"),
) )
parser.add_argument( parser.add_argument(
"--instance-id", "--instance-id",
metavar="<instance-id>", metavar="<instance-id>",
help="ID of server instance used to create this image", help=_("ID of server instance used to create this image"),
) )
parser.add_argument( parser.add_argument(
"--instance-uuid", "--instance-uuid",
@ -692,33 +693,33 @@ class SetImage(command.Command):
parser.add_argument( parser.add_argument(
"--kernel-id", "--kernel-id",
metavar="<kernel-id>", metavar="<kernel-id>",
help="ID of kernel image used to boot this disk image", help=_("ID of kernel image used to boot this disk image"),
) )
parser.add_argument( parser.add_argument(
"--os-distro", "--os-distro",
metavar="<os-distro>", metavar="<os-distro>",
help="Operating system distribution name", help=_("Operating system distribution name"),
) )
parser.add_argument( parser.add_argument(
"--os-version", "--os-version",
metavar="<os-version>", metavar="<os-version>",
help="Operating system distribution version", help=_("Operating system distribution version"),
) )
parser.add_argument( parser.add_argument(
"--ramdisk-id", "--ramdisk-id",
metavar="<ramdisk-id>", metavar="<ramdisk-id>",
help="ID of ramdisk image used to boot this disk image", help=_("ID of ramdisk image used to boot this disk image"),
) )
deactivate_group = parser.add_mutually_exclusive_group() deactivate_group = parser.add_mutually_exclusive_group()
deactivate_group.add_argument( deactivate_group.add_argument(
"--deactivate", "--deactivate",
action="store_true", action="store_true",
help="Deactivate the image", help=_("Deactivate the image"),
) )
deactivate_group.add_argument( deactivate_group.add_argument(
"--activate", "--activate",
action="store_true", action="store_true",
help="Activate the image", help=_("Activate the image"),
) )
# NOTE(dtroyer): --owner is deprecated in Jan 2016 in an early # NOTE(dtroyer): --owner is deprecated in Jan 2016 in an early
# 2.x release. Do not remove before Jan 2017 # 2.x release. Do not remove before Jan 2017
@ -727,7 +728,7 @@ class SetImage(command.Command):
project_group.add_argument( project_group.add_argument(
"--project", "--project",
metavar="<project>", metavar="<project>",
help="Set an alternate project on this image (name or ID)", help=_("Set an alternate project on this image (name or ID)"),
) )
project_group.add_argument( project_group.add_argument(
"--owner", "--owner",
@ -751,8 +752,8 @@ class SetImage(command.Command):
for deadopt in self.deadopts: for deadopt in self.deadopts:
if getattr(parsed_args, deadopt.replace('-', '_'), None): if getattr(parsed_args, deadopt.replace('-', '_'), None):
raise exceptions.CommandError( raise exceptions.CommandError(
"ERROR: --%s was given, which is an Image v1 option" _("ERROR: --%s was given, which is an Image v1 option"
" that is no longer supported in Image v2" % deadopt) " that is no longer supported in Image v2") % deadopt)
kwargs = {} kwargs = {}
copy_attrs = ('architecture', 'container_format', 'disk_format', copy_attrs = ('architecture', 'container_format', 'disk_format',
@ -804,7 +805,7 @@ class SetImage(command.Command):
# Checks if anything that requires getting the image # Checks if anything that requires getting the image
if not (kwargs or parsed_args.deactivate or parsed_args.activate): if not (kwargs or parsed_args.deactivate or parsed_args.activate):
self.log.warning("No arguments specified") self.log.warning(_("No arguments specified"))
return {}, {} return {}, {}
image = utils.find_resource( image = utils.find_resource(
@ -842,7 +843,7 @@ class ShowImage(command.ShowOne):
parser.add_argument( parser.add_argument(
"image", "image",
metavar="<image>", metavar="<image>",
help="Image to display (name or ID)", help=_("Image to display (name or ID)"),
) )
return parser return parser