summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-09-30 22:39:59 +0000
committerGerrit Code Review <review@openstack.org>2015-09-30 22:40:00 +0000
commit030f9e3263fdc760766a47077456850d39a0a2e2 (patch)
tree310f3e2203a0b1c7d68a9cdaac029ae27af0b107 /openstackclient
parentfe2d9f479fc869491131f94c5bc598fa11e143f3 (diff)
parent599905e51217aee686f5738ee778257a0fc1d6cc (diff)
downloadpython-openstackclient-030f9e3263fdc760766a47077456850d39a0a2e2.tar.gz
Merge "Release notes 1.7.1" into stable/liberty
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/compute/client.py10
-rw-r--r--openstackclient/image/v2/image.py64
-rw-r--r--openstackclient/shell.py4
-rw-r--r--openstackclient/tests/image/v2/test_image.py3
4 files changed, 66 insertions, 15 deletions
diff --git a/openstackclient/compute/client.py b/openstackclient/compute/client.py
index 8ac5f324..23a4deca 100644
--- a/openstackclient/compute/client.py
+++ b/openstackclient/compute/client.py
@@ -34,13 +34,8 @@ _compute_api_version = None
def make_client(instance):
"""Returns a compute service client."""
- # Defer client imports until we actually need them
+ # Defer client import until we actually need them
from novaclient import client as nova_client
- from novaclient import extension
- try:
- from novaclient.v2.contrib import list_extensions
- except ImportError:
- from novaclient.v1_1.contrib import list_extensions
if _compute_api_version is not None:
version = _compute_api_version
@@ -52,7 +47,8 @@ def make_client(instance):
# Set client http_log_debug to True if verbosity level is high enough
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
- extensions = [extension.Extension('list_extensions', list_extensions)]
+ extensions = [ext for ext in nova_client.discover_extensions(version)
+ if ext.name == "list_extensions"]
# Remember interface only if it is set
kwargs = utils.build_kwargs_dict('endpoint_type', instance._interface)
diff --git a/openstackclient/image/v2/image.py b/openstackclient/image/v2/image.py
index 3e1c824f..fff26c02 100644
--- a/openstackclient/image/v2/image.py
+++ b/openstackclient/image/v2/image.py
@@ -553,9 +553,22 @@ class SetImage(show.ShowOne):
"""Set image properties"""
log = logging.getLogger(__name__ + ".SetImage")
+ deadopts = ('size', 'store', 'location', 'copy-from', 'checksum')
def get_parser(self, prog_name):
parser = super(SetImage, self).get_parser(prog_name)
+ # TODO(bunting): There are additional arguments that v1 supported
+ # --size - does not exist in v2
+ # --store - does not exist in v2
+ # --location - maybe location add?
+ # --copy-from - does not exist in v2
+ # --file - should be able to upload file
+ # --volume - needs adding
+ # --force - needs adding
+ # --checksum - maybe could be done client side
+ # --stdin - could be implemented
+ # --property - needs adding
+ # --tags - needs adding
parser.add_argument(
"image",
metavar="<image>",
@@ -571,12 +584,28 @@ class SetImage(show.ShowOne):
metavar="<architecture>",
help="Operating system Architecture"
)
- parser.add_argument(
+ protected_group = parser.add_mutually_exclusive_group()
+ protected_group.add_argument(
"--protected",
- dest="protected",
action="store_true",
help="Prevent image from being deleted"
)
+ protected_group.add_argument(
+ "--unprotected",
+ action="store_true",
+ help="Allow image to be deleted (default)"
+ )
+ public_group = parser.add_mutually_exclusive_group()
+ public_group.add_argument(
+ "--public",
+ action="store_true",
+ help="Image is accessible to the public",
+ )
+ public_group.add_argument(
+ "--private",
+ action="store_true",
+ help="Image is inaccessible to the public (default)",
+ )
parser.add_argument(
"--instance-uuid",
metavar="<instance_uuid>",
@@ -589,12 +618,11 @@ class SetImage(show.ShowOne):
help="Minimum disk size needed to boot image, in gigabytes"
)
visibility_choices = ["public", "private"]
- parser.add_argument(
+ public_group.add_argument(
"--visibility",
metavar="<visibility>",
choices=visibility_choices,
- help="Scope of image accessibility. Valid values: %s"
- % visibility_choices
+ help=argparse.SUPPRESS
)
help_msg = ("ID of image in Glance that should be used as the kernel"
" when booting an AMI-style image")
@@ -649,12 +677,25 @@ class SetImage(show.ShowOne):
choices=container_choices,
help=help_msg
)
+ for deadopt in self.deadopts:
+ parser.add_argument(
+ "--%s" % deadopt,
+ metavar="<%s>" % deadopt,
+ dest=deadopt.replace('-', '_'),
+ 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
+ for deadopt in self.deadopts:
+ if getattr(parsed_args, deadopt.replace('-', '_'), None):
+ raise exceptions.CommandError(
+ "ERROR: --%s was given, which is an Image v1 option"
+ " that is no longer supported in Image v2" % deadopt)
+
kwargs = {}
copy_attrs = ('architecture', 'container_format', 'disk_format',
'file', 'kernel_id', 'locations', 'name',
@@ -668,10 +709,21 @@ class SetImage(show.ShowOne):
# Only include a value in kwargs for attributes that are
# actually present on the command line
kwargs[attr] = 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
+ # a single value for the pair of options because the default must be
+ # to do nothing when no options are present as opposed to always
+ # setting a default.
if parsed_args.protected:
kwargs['protected'] = True
- else:
+ if parsed_args.unprotected:
kwargs['protected'] = False
+ if parsed_args.public:
+ kwargs['visibility'] = 'public'
+ if parsed_args.private:
+ kwargs['visibility'] = 'private'
if not kwargs:
self.log.warning("No arguments specified")
diff --git a/openstackclient/shell.py b/openstackclient/shell.py
index d3a7d8a5..5b36b8b2 100644
--- a/openstackclient/shell.py
+++ b/openstackclient/shell.py
@@ -79,6 +79,10 @@ class OpenStackShell(app.App):
help.HelpCommand.auth_required = False
complete.CompleteCommand.auth_required = False
+ # Slight change to the meaning of --debug
+ self.DEFAULT_DEBUG_VALUE = None
+ self.DEFAULT_DEBUG_HELP = 'Set debug logging and traceback on errors.'
+
super(OpenStackShell, self).__init__(
description=__doc__.strip(),
version=openstackclient.__version__,
diff --git a/openstackclient/tests/image/v2/test_image.py b/openstackclient/tests/image/v2/test_image.py
index bb720d79..65d5e555 100644
--- a/openstackclient/tests/image/v2/test_image.py
+++ b/openstackclient/tests/image/v2/test_image.py
@@ -713,8 +713,7 @@ class TestImageSet(TestImage):
'name': 'new-name',
'owner': 'new-owner',
'min_disk': 2,
- 'min_ram': 4,
- 'protected': False
+ 'min_ram': 4
}
# ImageManager.update(image, **kwargs)
self.images_mock.update.assert_called_with(