diff options
Diffstat (limited to 'openstackclient')
28 files changed, 116 insertions, 33 deletions
diff --git a/openstackclient/api/object_store_v1.py b/openstackclient/api/object_store_v1.py index ae49922d..faa55118 100644 --- a/openstackclient/api/object_store_v1.py +++ b/openstackclient/api/object_store_v1.py @@ -17,11 +17,10 @@ import io import logging import os +from osc_lib import utils import six from six.moves import urllib -from osc_lib import utils - from openstackclient.api import api diff --git a/openstackclient/compute/v2/hypervisor_stats.py b/openstackclient/compute/v2/hypervisor_stats.py index a70f0ce1..c6fd2992 100644 --- a/openstackclient/compute/v2/hypervisor_stats.py +++ b/openstackclient/compute/v2/hypervisor_stats.py @@ -14,9 +14,8 @@ """Hypervisor Stats action implementations""" -import six - from osc_lib.command import command +import six class ShowHypervisorStats(command.ShowOne): diff --git a/openstackclient/identity/client.py b/openstackclient/identity/client.py index d932b970..0c609313 100644 --- a/openstackclient/identity/client.py +++ b/openstackclient/identity/client.py @@ -21,6 +21,7 @@ from osc_lib import utils from openstackclient.i18n import _ + LOG = logging.getLogger(__name__) DEFAULT_API_VERSION = '3' diff --git a/openstackclient/network/v2/subnet_pool.py b/openstackclient/network/v2/subnet_pool.py index ed2bb0ef..d3fab8ac 100644 --- a/openstackclient/network/v2/subnet_pool.py +++ b/openstackclient/network/v2/subnet_pool.py @@ -13,7 +13,6 @@ """Subnet pool action implementations""" import copy - import logging from osc_lib.cli import parseractions diff --git a/openstackclient/object/v1/container.py b/openstackclient/object/v1/container.py index 2b021ec2..f00cc150 100644 --- a/openstackclient/object/v1/container.py +++ b/openstackclient/object/v1/container.py @@ -15,7 +15,6 @@ """Container v1 action implementations""" - from osc_lib.cli import parseractions from osc_lib.command import command from osc_lib import utils diff --git a/openstackclient/tests/api/fakes.py b/openstackclient/tests/api/fakes.py index e285a61c..8d1d88ff 100644 --- a/openstackclient/tests/api/fakes.py +++ b/openstackclient/tests/api/fakes.py @@ -13,9 +13,9 @@ """API Test Fakes""" +from keystoneauth1 import session from requests_mock.contrib import fixture -from keystoneauth1 import session from openstackclient.tests import utils diff --git a/openstackclient/tests/api/test_image_v1.py b/openstackclient/tests/api/test_image_v1.py index f3479756..f8ad6692 100644 --- a/openstackclient/tests/api/test_image_v1.py +++ b/openstackclient/tests/api/test_image_v1.py @@ -13,9 +13,9 @@ """Image v1 API Library Tests""" +from keystoneauth1 import session from requests_mock.contrib import fixture -from keystoneauth1 import session from openstackclient.api import image_v1 from openstackclient.tests import utils diff --git a/openstackclient/tests/api/test_image_v2.py b/openstackclient/tests/api/test_image_v2.py index 77063997..28b0d580 100644 --- a/openstackclient/tests/api/test_image_v2.py +++ b/openstackclient/tests/api/test_image_v2.py @@ -13,9 +13,9 @@ """Image v2 API Library Tests""" +from keystoneauth1 import session from requests_mock.contrib import fixture -from keystoneauth1 import session from openstackclient.api import image_v2 from openstackclient.tests import utils diff --git a/openstackclient/tests/api/test_object_store_v1.py b/openstackclient/tests/api/test_object_store_v1.py index 8cc3a927..e6ac203d 100644 --- a/openstackclient/tests/api/test_object_store_v1.py +++ b/openstackclient/tests/api/test_object_store_v1.py @@ -15,9 +15,9 @@ import mock +from keystoneauth1 import session from requests_mock.contrib import fixture -from keystoneauth1 import session from openstackclient.api import object_store_v1 as object_store from openstackclient.tests import utils diff --git a/openstackclient/tests/common/test_availability_zone.py b/openstackclient/tests/common/test_availability_zone.py index feecaf55..014ab8bc 100644 --- a/openstackclient/tests/common/test_availability_zone.py +++ b/openstackclient/tests/common/test_availability_zone.py @@ -12,6 +12,7 @@ # import mock + import six from openstackclient.common import availability_zone diff --git a/openstackclient/tests/common/test_extension.py b/openstackclient/tests/common/test_extension.py index 17a3b492..10023aa6 100644 --- a/openstackclient/tests/common/test_extension.py +++ b/openstackclient/tests/common/test_extension.py @@ -14,12 +14,11 @@ import mock from openstackclient.common import extension -from openstackclient.tests import fakes -from openstackclient.tests import utils - from openstackclient.tests.compute.v2 import fakes as compute_fakes +from openstackclient.tests import fakes from openstackclient.tests.identity.v2_0 import fakes as identity_fakes from openstackclient.tests.network.v2 import fakes as network_fakes +from openstackclient.tests import utils from openstackclient.tests.volume.v2 import fakes as volume_fakes diff --git a/openstackclient/tests/common/test_parseractions.py b/openstackclient/tests/common/test_parseractions.py index 60d4a8cf..3038701f 100644 --- a/openstackclient/tests/common/test_parseractions.py +++ b/openstackclient/tests/common/test_parseractions.py @@ -49,7 +49,7 @@ class TestKeyValueAction(utils.TestCase): actual = getattr(results, 'property', {}) # All should pass through unmolested expect = {'red': '', 'green': '100%', 'blue': '50%', 'format': '#rgb'} - self.assertDictEqual(expect, actual) + self.assertEqual(expect, actual) def test_error_values(self): self.assertRaises( diff --git a/openstackclient/tests/common/test_quota.py b/openstackclient/tests/common/test_quota.py index c9ec5599..6f001c85 100644 --- a/openstackclient/tests/common/test_quota.py +++ b/openstackclient/tests/common/test_quota.py @@ -11,7 +11,6 @@ # under the License. import copy - import mock from openstackclient.common import quota diff --git a/openstackclient/tests/compute/v2/test_agent.py b/openstackclient/tests/compute/v2/test_agent.py index 7695ee41..07265bb0 100644 --- a/openstackclient/tests/compute/v2/test_agent.py +++ b/openstackclient/tests/compute/v2/test_agent.py @@ -14,8 +14,8 @@ # import mock - from mock import call + from osc_lib import exceptions from openstackclient.compute.v2 import agent diff --git a/openstackclient/tests/compute/v2/test_server.py b/openstackclient/tests/compute/v2/test_server.py index 9c89c6af..e487d57c 100644 --- a/openstackclient/tests/compute/v2/test_server.py +++ b/openstackclient/tests/compute/v2/test_server.py @@ -1793,4 +1793,4 @@ class TestServerGeneral(TestServer): server_detail.pop('networks') # Check the results. - self.assertDictEqual(info, server_detail) + self.assertEqual(info, server_detail) diff --git a/openstackclient/tests/fakes.py b/openstackclient/tests/fakes.py index d0cab019..786cd6d4 100644 --- a/openstackclient/tests/fakes.py +++ b/openstackclient/tests/fakes.py @@ -15,11 +15,11 @@ import json import mock -import six import sys from keystoneauth1 import fixture import requests +import six AUTH_TOKEN = "foobar" diff --git a/openstackclient/tests/identity/v3/test_identity_provider.py b/openstackclient/tests/identity/v3/test_identity_provider.py index 1ec61052..b5d784ef 100644 --- a/openstackclient/tests/identity/v3/test_identity_provider.py +++ b/openstackclient/tests/identity/v3/test_identity_provider.py @@ -13,7 +13,6 @@ # under the License. import copy - import mock from openstackclient.identity.v3 import identity_provider diff --git a/openstackclient/tests/identity/v3/test_mappings.py b/openstackclient/tests/identity/v3/test_mappings.py index 6aa1a6e5..09a383eb 100644 --- a/openstackclient/tests/identity/v3/test_mappings.py +++ b/openstackclient/tests/identity/v3/test_mappings.py @@ -13,7 +13,6 @@ # under the License. import copy - import mock from osc_lib import exceptions diff --git a/openstackclient/tests/identity/v3/test_user.py b/openstackclient/tests/identity/v3/test_user.py index c4fb1521..7b99a4cb 100644 --- a/openstackclient/tests/identity/v3/test_user.py +++ b/openstackclient/tests/identity/v3/test_user.py @@ -15,7 +15,6 @@ import contextlib import copy - import mock from openstackclient.identity.v3 import user diff --git a/openstackclient/tests/image/v2/test_image.py b/openstackclient/tests/image/v2/test_image.py index d9cca8af..2b116b4e 100644 --- a/openstackclient/tests/image/v2/test_image.py +++ b/openstackclient/tests/image/v2/test_image.py @@ -16,11 +16,10 @@ import copy import mock -import warlock - from glanceclient.v2 import schemas from osc_lib import exceptions from osc_lib import utils as common_utils +import warlock from openstackclient.image.v2 import image from openstackclient.tests.identity.v3 import fakes as identity_fakes diff --git a/openstackclient/tests/network/v2/test_address_scope.py b/openstackclient/tests/network/v2/test_address_scope.py index 502516f9..342cf49b 100644 --- a/openstackclient/tests/network/v2/test_address_scope.py +++ b/openstackclient/tests/network/v2/test_address_scope.py @@ -12,8 +12,8 @@ # import mock - from mock import call + from osc_lib import exceptions from openstackclient.network.v2 import address_scope diff --git a/openstackclient/tests/object/v1/fakes.py b/openstackclient/tests/object/v1/fakes.py index b9e86db7..6c367111 100644 --- a/openstackclient/tests/object/v1/fakes.py +++ b/openstackclient/tests/object/v1/fakes.py @@ -14,6 +14,7 @@ # from keystoneauth1 import session + from openstackclient.api import object_store_v1 as object_store from openstackclient.tests import utils diff --git a/openstackclient/tests/utils.py b/openstackclient/tests/utils.py index 8dead718..f3ab5ea6 100644 --- a/openstackclient/tests/utils.py +++ b/openstackclient/tests/utils.py @@ -14,9 +14,8 @@ # under the License. # -import os - import fixtures +import os import testtools from openstackclient.tests import fakes diff --git a/openstackclient/tests/volume/v2/test_snapshot.py b/openstackclient/tests/volume/v2/test_snapshot.py index 04e0285e..3eb740ba 100644 --- a/openstackclient/tests/volume/v2/test_snapshot.py +++ b/openstackclient/tests/volume/v2/test_snapshot.py @@ -12,6 +12,7 @@ # under the License. # +import argparse import mock from mock import call @@ -260,16 +261,33 @@ class TestSnapshotList(TestSnapshot): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) + + self.snapshots_mock.list.assert_called_once_with( + limit=None, marker=None, search_opts={'all_tenants': False}) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) def test_snapshot_list_with_options(self): - arglist = ["--long"] - verifylist = [("long", True), ('all_projects', False)] + arglist = [ + "--long", + "--limit", "2", + "--marker", self.snapshots[0].id, + ] + verifylist = [ + ("long", True), + ("limit", 2), + ("marker", self.snapshots[0].id), + ('all_projects', False), + ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) + self.snapshots_mock.list.assert_called_once_with( + limit=2, + marker=self.snapshots[0].id, + search_opts={'all_tenants': False} + ) self.assertEqual(self.columns_long, columns) self.assertEqual(self.data_long, list(data)) @@ -285,9 +303,21 @@ class TestSnapshotList(TestSnapshot): columns, data = self.cmd.take_action(parsed_args) + self.snapshots_mock.list.assert_called_once_with( + limit=None, marker=None, search_opts={'all_tenants': True}) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) + def test_snapshot_list_negative_limit(self): + arglist = [ + "--limit", "-2", + ] + verifylist = [ + ("limit", -2), + ] + self.assertRaises(argparse.ArgumentTypeError, self.check_parser, + self.cmd, arglist, verifylist) + class TestSnapshotSet(TestSnapshot): diff --git a/openstackclient/tests/volume/v2/test_type.py b/openstackclient/tests/volume/v2/test_type.py index 238b098f..b0316aef 100644 --- a/openstackclient/tests/volume/v2/test_type.py +++ b/openstackclient/tests/volume/v2/test_type.py @@ -197,23 +197,50 @@ class TestTypeList(TestType): def test_type_list_without_options(self): arglist = [] verifylist = [ - ("long", False) + ("long", False), + ("private", False), + ("public", False), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) + self.types_mock.list.assert_called_once_with(is_public=None) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) def test_type_list_with_options(self): - arglist = ["--long"] - verifylist = [("long", True)] + arglist = [ + "--long", + "--public", + ] + verifylist = [ + ("long", True), + ("private", False), + ("public", True), + ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) + self.types_mock.list.assert_called_once_with(is_public=True) self.assertEqual(self.columns_long, columns) self.assertEqual(self.data_long, list(data)) + def test_type_list_with_private_option(self): + arglist = [ + "--private", + ] + verifylist = [ + ("long", False), + ("private", True), + ("public", False), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + self.types_mock.list.assert_called_once_with(is_public=False) + self.assertEqual(self.columns, columns) + self.assertEqual(self.data, list(data)) + class TestTypeSet(TestType): diff --git a/openstackclient/volume/client.py b/openstackclient/volume/client.py index ea0c441c..11f20673 100644 --- a/openstackclient/volume/client.py +++ b/openstackclient/volume/client.py @@ -19,6 +19,7 @@ from osc_lib import utils from openstackclient.i18n import _ + LOG = logging.getLogger(__name__) DEFAULT_API_VERSION = '2' diff --git a/openstackclient/volume/v2/snapshot.py b/openstackclient/volume/v2/snapshot.py index ba692074..8304a5eb 100644 --- a/openstackclient/volume/v2/snapshot.py +++ b/openstackclient/volume/v2/snapshot.py @@ -134,6 +134,18 @@ class ListSnapshot(command.Lister): default=False, help=_('List additional fields in output'), ) + parser.add_argument( + '--marker', + metavar='<marker>', + help=_('The last snapshot ID of the previous page'), + ) + parser.add_argument( + '--limit', + type=int, + action=parseractions.NonNegativeAction, + metavar='<limit>', + help=_('Maximum number of snapshots to display'), + ) return parser def take_action(self, parsed_args): @@ -174,7 +186,10 @@ class ListSnapshot(command.Lister): } data = self.app.client_manager.volume.volume_snapshots.list( - search_opts=search_opts) + search_opts=search_opts, + marker=parsed_args.marker, + limit=parsed_args.limit, + ) return (column_headers, (utils.get_item_properties( s, columns, diff --git a/openstackclient/volume/v2/volume_type.py b/openstackclient/volume/v2/volume_type.py index 62d619d0..e42fffe0 100644 --- a/openstackclient/volume/v2/volume_type.py +++ b/openstackclient/volume/v2/volume_type.py @@ -160,6 +160,17 @@ class ListVolumeType(command.Lister): action='store_true', default=False, help=_('List additional fields in output')) + public_group = parser.add_mutually_exclusive_group() + public_group.add_argument( + "--public", + action="store_true", + help=_("List only public types") + ) + public_group.add_argument( + "--private", + action="store_true", + help=_("List only private types (admin only)") + ) return parser def take_action(self, parsed_args): @@ -169,7 +180,14 @@ class ListVolumeType(command.Lister): else: columns = ['ID', 'Name'] column_headers = columns - data = self.app.client_manager.volume.volume_types.list() + + is_public = None + if parsed_args.public: + is_public = True + if parsed_args.private: + is_public = False + data = self.app.client_manager.volume.volume_types.list( + is_public=is_public) return (column_headers, (utils.get_item_properties( s, columns, |
