Merge "image: Fix the default description of image visibility"
This commit is contained in:
@@ -163,6 +163,67 @@ def get_data_from_stdin():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _add_is_protected_args(parser):
|
||||||
|
protected_group = parser.add_mutually_exclusive_group()
|
||||||
|
protected_group.add_argument(
|
||||||
|
"--protected",
|
||||||
|
action="store_true",
|
||||||
|
dest="is_protected",
|
||||||
|
default=None,
|
||||||
|
help=_("Prevent image from being deleted"),
|
||||||
|
)
|
||||||
|
protected_group.add_argument(
|
||||||
|
"--unprotected",
|
||||||
|
action="store_false",
|
||||||
|
dest="is_protected",
|
||||||
|
default=None,
|
||||||
|
help=_("Allow image to be deleted (default)"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _add_visibility_args(parser):
|
||||||
|
public_group = parser.add_mutually_exclusive_group()
|
||||||
|
public_group.add_argument(
|
||||||
|
"--public",
|
||||||
|
action="store_const",
|
||||||
|
const="public",
|
||||||
|
dest="visibility",
|
||||||
|
help=_("Image is accessible and visisble to all users"),
|
||||||
|
)
|
||||||
|
public_group.add_argument(
|
||||||
|
"--private",
|
||||||
|
action="store_const",
|
||||||
|
const="private",
|
||||||
|
dest="visibility",
|
||||||
|
help=_(
|
||||||
|
"Image is only accessible by the owner "
|
||||||
|
"(default until --os-image-api-version 2.5)"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
public_group.add_argument(
|
||||||
|
"--community",
|
||||||
|
action="store_const",
|
||||||
|
const="community",
|
||||||
|
dest="visibility",
|
||||||
|
help=_(
|
||||||
|
"Image is accessible by all users but does not appear in the "
|
||||||
|
"default image list of any user except the owner "
|
||||||
|
"(requires --os-image-api-version 2.5 or later)"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
public_group.add_argument(
|
||||||
|
"--shared",
|
||||||
|
action="store_const",
|
||||||
|
const="shared",
|
||||||
|
dest="visibility",
|
||||||
|
help=_(
|
||||||
|
"Image is only accessible by the owner and image members "
|
||||||
|
"(requires --os-image-api-version 2.5 or later) "
|
||||||
|
"(default since --os-image-api-version 2.5)"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AddProjectToImage(command.ShowOne):
|
class AddProjectToImage(command.ShowOne):
|
||||||
_description = _("Associate project with image")
|
_description = _("Associate project with image")
|
||||||
|
|
||||||
@@ -322,50 +383,8 @@ class CreateImage(command.ShowOne):
|
|||||||
"Only use in combination with --sign-key-path"
|
"Only use in combination with --sign-key-path"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
protected_group = parser.add_mutually_exclusive_group()
|
_add_is_protected_args(parser)
|
||||||
protected_group.add_argument(
|
_add_visibility_args(parser)
|
||||||
"--protected",
|
|
||||||
action="store_true",
|
|
||||||
dest="is_protected",
|
|
||||||
default=None,
|
|
||||||
help=_("Prevent image from being deleted"),
|
|
||||||
)
|
|
||||||
protected_group.add_argument(
|
|
||||||
"--unprotected",
|
|
||||||
action="store_false",
|
|
||||||
dest="is_protected",
|
|
||||||
default=None,
|
|
||||||
help=_("Allow image to be deleted (default)"),
|
|
||||||
)
|
|
||||||
public_group = parser.add_mutually_exclusive_group()
|
|
||||||
public_group.add_argument(
|
|
||||||
"--public",
|
|
||||||
action="store_const",
|
|
||||||
const="public",
|
|
||||||
dest="visibility",
|
|
||||||
help=_("Image is accessible to the public"),
|
|
||||||
)
|
|
||||||
public_group.add_argument(
|
|
||||||
"--private",
|
|
||||||
action="store_const",
|
|
||||||
const="private",
|
|
||||||
dest="visibility",
|
|
||||||
help=_("Image is inaccessible to the public (default)"),
|
|
||||||
)
|
|
||||||
public_group.add_argument(
|
|
||||||
"--community",
|
|
||||||
action="store_const",
|
|
||||||
const="community",
|
|
||||||
dest="visibility",
|
|
||||||
help=_("Image is accessible to the community"),
|
|
||||||
)
|
|
||||||
public_group.add_argument(
|
|
||||||
"--shared",
|
|
||||||
action="store_const",
|
|
||||||
const="shared",
|
|
||||||
dest="visibility",
|
|
||||||
help=_("Image can be shared"),
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--property",
|
"--property",
|
||||||
dest="properties",
|
dest="properties",
|
||||||
@@ -726,14 +745,20 @@ class ListImage(command.Lister):
|
|||||||
action="store_const",
|
action="store_const",
|
||||||
const="community",
|
const="community",
|
||||||
dest="visibility",
|
dest="visibility",
|
||||||
help=_("List only community images"),
|
help=_(
|
||||||
|
"List only community images "
|
||||||
|
"(requires --os-image-api-version 2.5 or later)"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
public_group.add_argument(
|
public_group.add_argument(
|
||||||
"--shared",
|
"--shared",
|
||||||
action="store_const",
|
action="store_const",
|
||||||
const="shared",
|
const="shared",
|
||||||
dest="visibility",
|
dest="visibility",
|
||||||
help=_("List only shared images"),
|
help=_(
|
||||||
|
"List only shared images "
|
||||||
|
"(requires --os-image-api-version 2.5 or later)"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
public_group.add_argument(
|
public_group.add_argument(
|
||||||
"--all",
|
"--all",
|
||||||
@@ -1110,50 +1135,8 @@ class SetImage(command.Command):
|
|||||||
help=_("Image disk format. The supported options are: %s")
|
help=_("Image disk format. The supported options are: %s")
|
||||||
% ', '.join(DISK_CHOICES),
|
% ', '.join(DISK_CHOICES),
|
||||||
)
|
)
|
||||||
protected_group = parser.add_mutually_exclusive_group()
|
_add_is_protected_args(parser)
|
||||||
protected_group.add_argument(
|
_add_visibility_args(parser)
|
||||||
"--protected",
|
|
||||||
action="store_true",
|
|
||||||
dest="is_protected",
|
|
||||||
default=None,
|
|
||||||
help=_("Prevent image from being deleted"),
|
|
||||||
)
|
|
||||||
protected_group.add_argument(
|
|
||||||
"--unprotected",
|
|
||||||
action="store_false",
|
|
||||||
dest="is_protected",
|
|
||||||
default=None,
|
|
||||||
help=_("Allow image to be deleted (default)"),
|
|
||||||
)
|
|
||||||
public_group = parser.add_mutually_exclusive_group()
|
|
||||||
public_group.add_argument(
|
|
||||||
"--public",
|
|
||||||
action="store_const",
|
|
||||||
const="public",
|
|
||||||
dest="visibility",
|
|
||||||
help=_("Image is accessible to the public"),
|
|
||||||
)
|
|
||||||
public_group.add_argument(
|
|
||||||
"--private",
|
|
||||||
action="store_const",
|
|
||||||
const="private",
|
|
||||||
dest="visibility",
|
|
||||||
help=_("Image is inaccessible to the public (default)"),
|
|
||||||
)
|
|
||||||
public_group.add_argument(
|
|
||||||
"--community",
|
|
||||||
action="store_const",
|
|
||||||
const="community",
|
|
||||||
dest="visibility",
|
|
||||||
help=_("Image is accessible to the community"),
|
|
||||||
)
|
|
||||||
public_group.add_argument(
|
|
||||||
"--shared",
|
|
||||||
action="store_const",
|
|
||||||
const="shared",
|
|
||||||
dest="visibility",
|
|
||||||
help=_("Image can be shared"),
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--property",
|
"--property",
|
||||||
dest="properties",
|
dest="properties",
|
||||||
|
Reference in New Issue
Block a user