diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b62c5793..ec3495a7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -35,6 +35,9 @@ Changed * Our requirements are updated as like upper-constraints (the list of suggested tested versions to use) * Error messages become more user-friendly in ``rally env check``. +* Deprecate api_info argument of all clients which inherits from OSClient + and deprecate api_version argument of cleanup.manager.cleanup, because + api information has been moved into credentails object. Removed ~~~~~~~ diff --git a/rally_openstack/cleanup/manager.py b/rally_openstack/cleanup/manager.py index 767571d3..0b5c9d23 100644 --- a/rally_openstack/cleanup/manager.py +++ b/rally_openstack/cleanup/manager.py @@ -270,6 +270,11 @@ def cleanup(names=None, admin_required=None, admin=None, users=None, Scenario resources. :param task_id: The UUID of task """ + if api_versions: + LOG.warning("'api_version' argument of 'cleanup' method is deprecated" + " since rally-openstack 1.3.0 . API information should be" + " included into credentials object, you can directly" + " remove passed api_versions argument.") resource_classes = [cls for cls in discover.itersubclasses(superclass) if issubclass(cls, rutils.RandomNameGeneratorMixin)] if not resource_classes and issubclass(superclass, diff --git a/rally_openstack/contexts/cinder/volume_types.py b/rally_openstack/contexts/cinder/volume_types.py index 30de2a97..71d7c906 100644 --- a/rally_openstack/contexts/cinder/volume_types.py +++ b/rally_openstack/contexts/cinder/volume_types.py @@ -39,8 +39,7 @@ class VolumeTypeGenerator(context.Context): def setup(self): admin_clients = osclients.Clients( - self.context.get("admin", {}).get("credential"), - api_info=self.context["config"].get("api_versions")) + self.context.get("admin", {}).get("credential")) cinder_service = block.BlockStorage( admin_clients, name_generator=self.generate_random_name, @@ -57,6 +56,5 @@ class VolumeTypeGenerator(context.Context): resource_manager.cleanup( names=["cinder.volume_types"], admin=self.context["admin"], - api_versions=self.context["config"].get("api_versions"), superclass=mather, task_id=self.get_owner_id()) diff --git a/rally_openstack/contexts/cinder/volumes.py b/rally_openstack/contexts/cinder/volumes.py index c8f143ea..1daf451f 100644 --- a/rally_openstack/contexts/cinder/volumes.py +++ b/rally_openstack/contexts/cinder/volumes.py @@ -62,9 +62,7 @@ class VolumeGenerator(context.Context): for user, tenant_id in rutils.iterate_per_tenants( self.context["users"]): self.context["tenants"][tenant_id].setdefault("volumes", []) - clients = osclients.Clients( - user["credential"], - api_info=self.context["config"].get("api_versions")) + clients = osclients.Clients(user["credential"]) cinder_service = block.BlockStorage( clients, name_generator=self.generate_random_name, @@ -79,6 +77,5 @@ class VolumeGenerator(context.Context): resource_manager.cleanup( names=["cinder.volumes"], users=self.context.get("users", []), - api_versions=self.context["config"].get("api_versions"), superclass=self.__class__, task_id=self.get_owner_id()) diff --git a/rally_openstack/contexts/cleanup/admin.py b/rally_openstack/contexts/cleanup/admin.py index b89bbff2..8d3daea2 100644 --- a/rally_openstack/contexts/cleanup/admin.py +++ b/rally_openstack/contexts/cleanup/admin.py @@ -36,6 +36,5 @@ class AdminCleanup(base.CleanupMixin, context.Context): admin_required=True, admin=self.context["admin"], users=self.context.get("users", []), - api_versions=self.context["config"].get("api_versions"), superclass=scenario.OpenStackScenario, task_id=self.get_owner_id()) diff --git a/rally_openstack/contexts/cleanup/user.py b/rally_openstack/contexts/cleanup/user.py index f9ebd741..32f61a95 100644 --- a/rally_openstack/contexts/cleanup/user.py +++ b/rally_openstack/contexts/cleanup/user.py @@ -35,7 +35,6 @@ class UserCleanup(base.CleanupMixin, context.Context): names=self.config, admin_required=False, users=self.context.get("users", []), - api_versions=self.context["config"].get("api_versions"), superclass=scenario.OpenStackScenario, task_id=self.get_owner_id() ) diff --git a/rally_openstack/contexts/glance/images.py b/rally_openstack/contexts/glance/images.py index a9ddaaf1..59309bd4 100644 --- a/rally_openstack/contexts/glance/images.py +++ b/rally_openstack/contexts/glance/images.py @@ -162,9 +162,7 @@ class ImageGenerator(context.Context): for user, tenant_id in rutils.iterate_per_tenants( self.context["users"]): current_images = [] - clients = osclients.Clients( - user["credential"], - api_info=self.context["config"].get("api_versions")) + clients = osclients.Clients(user["credential"]) image_service = image.Image( clients, name_generator=self.generate_random_name) @@ -206,7 +204,5 @@ class ImageGenerator(context.Context): admin=admin, admin_required=admin_required, users=self.context.get("users", []), - api_versions=self.context["config"].get( - "api_versions"), superclass=matcher, task_id=self.get_owner_id()) diff --git a/rally_openstack/contexts/manila/manila_security_services.py b/rally_openstack/contexts/manila/manila_security_services.py index 6d33d1c7..967fe199 100644 --- a/rally_openstack/contexts/manila/manila_security_services.py +++ b/rally_openstack/contexts/manila/manila_security_services.py @@ -74,10 +74,7 @@ class SecurityServices(context.Context): manila_scenario = manila_utils.ManilaScenario({ "task": self.task, "owner_id": self.context["owner_id"], - "user": user, - "config": { - "api_versions": self.context["config"].get( - "api_versions", [])} + "user": user }) for ss in self.config["security_services"]: inst = manila_scenario._create_security_service( diff --git a/rally_openstack/contexts/manila/manila_share_networks.py b/rally_openstack/contexts/manila/manila_share_networks.py index 47a1517a..0122043b 100644 --- a/rally_openstack/contexts/manila/manila_share_networks.py +++ b/rally_openstack/contexts/manila/manila_share_networks.py @@ -118,10 +118,7 @@ class ShareNetworks(context.Context): "share_networks"] = [] manila_scenario = manila_utils.ManilaScenario({ - "user": existing_user, - "config": { - "api_versions": self.context["config"].get( - "api_versions", [])} + "user": existing_user }) existing_sns = manila_scenario._list_share_networks( detailed=False, search_opts={"project_id": tenant_id}) @@ -150,10 +147,7 @@ class ShareNetworks(context.Context): manila_scenario = manila_utils.ManilaScenario({ "task": self.task, "owner_id": self.get_owner_id(), - "user": user, - "config": { - "api_versions": self.context["config"].get( - "api_versions", [])} + "user": user }) manila_scenario.RESOURCE_NAME_FORMAT = self.RESOURCE_NAME_FORMAT self.context["tenants"][tenant_id][CONTEXT_NAME] = { @@ -201,7 +195,6 @@ class ShareNetworks(context.Context): names=["manila.share_networks"], users=self.context.get("users", []), superclass=self.__class__, - api_versions=self.context["config"].get("api_versions"), task_id=self.get_owner_id()) else: # NOTE(vponomaryov): assume that share networks were not created diff --git a/rally_openstack/contexts/manila/manila_shares.py b/rally_openstack/contexts/manila/manila_shares.py index de44e3b4..9bab99e0 100644 --- a/rally_openstack/contexts/manila/manila_shares.py +++ b/rally_openstack/contexts/manila/manila_shares.py @@ -83,10 +83,7 @@ class Shares(context.Context): manila_scenario = manila_utils.ManilaScenario({ "task": self.task, "owner_id": self.context["owner_id"], - "user": user, - "config": { - "api_versions": self.context["config"].get( - "api_versions", [])} + "user": user }) self._create_shares( manila_scenario, diff --git a/rally_openstack/contexts/nova/flavors.py b/rally_openstack/contexts/nova/flavors.py index 90aecbc5..63932d2a 100644 --- a/rally_openstack/contexts/nova/flavors.py +++ b/rally_openstack/contexts/nova/flavors.py @@ -106,7 +106,6 @@ class FlavorsGenerator(context.Context): resource_manager.cleanup( names=["nova.flavors"], admin=self.context["admin"], - api_versions=self.context["config"].get("api_versions"), superclass=mather, task_id=self.get_owner_id()) diff --git a/rally_openstack/contexts/quotas/quotas.py b/rally_openstack/contexts/quotas/quotas.py index 8ce7fb30..a4e6fa8d 100644 --- a/rally_openstack/contexts/quotas/quotas.py +++ b/rally_openstack/contexts/quotas/quotas.py @@ -50,8 +50,7 @@ class Quotas(context.Context): def __init__(self, ctx): super(Quotas, self).__init__(ctx) self.clients = osclients.Clients( - self.context["admin"]["credential"], - api_info=self.context["config"].get("api_versions")) + self.context["admin"]["credential"]) self.manager = { "nova": nova_quotas.NovaQuotas(self.clients), diff --git a/rally_openstack/contexts/sahara/sahara_image.py b/rally_openstack/contexts/sahara/sahara_image.py index 2fcdad50..b18aecc1 100644 --- a/rally_openstack/contexts/sahara/sahara_image.py +++ b/rally_openstack/contexts/sahara/sahara_image.py @@ -61,9 +61,7 @@ class SaharaImage(context.Context): def _create_image(self, hadoop_version, image_url, plugin_name, user, user_name): - clients = osclients.Clients( - user["credential"], - api_info=self.context["config"].get("api_versions")) + clients = osclients.Clients(user["credential"]) image_service = image_services.Image( clients, name_generator=self.generate_random_name) image = image_service.create_image(container_format="bare", diff --git a/rally_openstack/contexts/senlin/profiles.py b/rally_openstack/contexts/senlin/profiles.py index a1a73a9b..8eb7b91f 100644 --- a/rally_openstack/contexts/senlin/profiles.py +++ b/rally_openstack/contexts/senlin/profiles.py @@ -49,10 +49,7 @@ class ProfilesGenerator(context.Context): senlin_scenario = senlin_utils.SenlinScenario({ "user": user, - "task": self.context["task"], - "config": { - "api_versions": self.context["config"].get( - "api_versions", [])} + "task": self.context["task"] }) profile = senlin_scenario._create_profile(self.config) @@ -65,10 +62,7 @@ class ProfilesGenerator(context.Context): senlin_scenario = senlin_utils.SenlinScenario({ "user": user, - "task": self.context["task"], - "config": { - "api_versions": self.context["config"].get( - "api_versions", [])} + "task": self.context["task"] }) senlin_scenario._delete_profile( self.context["tenants"][tenant_id]["profile"]) diff --git a/rally_openstack/osclients.py b/rally_openstack/osclients.py index f360df8a..9f88bc07 100644 --- a/rally_openstack/osclients.py +++ b/rally_openstack/osclients.py @@ -107,13 +107,16 @@ def configure(name, default_version=None, default_service_type=None, class OSClient(plugin.Plugin): """Base class for OpenStack clients""" - def __init__(self, credential, api_info, cache_obj): + def __init__(self, credential, api_info=None, cache_obj=None): self.credential = credential if not isinstance(self.credential, oscred.OpenStackCredential): self.credential = oscred.OpenStackCredential(**self.credential) if api_info: + LOG.warning("api_info argument of %s is deprecated. api" + " information has been moved into credential" + " argument." % self.__class__.__name__) self.credential.api_info.update(api_info) - self.cache = cache_obj + self.cache = cache_obj if cache_obj is not None else {} def choose_version(self, version=None): """Return version string. diff --git a/tests/unit/contexts/cinder/test_volume_types.py b/tests/unit/contexts/cinder/test_volume_types.py index faec0f3a..c06f7fc3 100644 --- a/tests/unit/contexts/cinder/test_volume_types.py +++ b/tests/unit/contexts/cinder/test_volume_types.py @@ -46,10 +46,7 @@ class VolumeTypeGeneratorTestCase(test.ContextTestCase): @mock.patch("%s.resource_manager.cleanup" % CTX) def test_cleanup(self, mock_cleanup, mock_make_name_matcher): self.context.update({ - "config": {"volume_types": ["foo", "bar"], - "api_versions": { - "cinder": {"version": 2, - "service_type": "volumev2"}}}}) + "config": {"volume_types": ["foo", "bar"]}}) vtype_ctx = volume_types.VolumeTypeGenerator(self.context) @@ -58,7 +55,6 @@ class VolumeTypeGeneratorTestCase(test.ContextTestCase): mock_cleanup.assert_called_once_with( names=["cinder.volume_types"], admin=self.context["admin"], - api_versions=self.context["config"]["api_versions"], superclass=mock_make_name_matcher.return_value, task_id=vtype_ctx.get_owner_id()) diff --git a/tests/unit/contexts/cinder/test_volumes.py b/tests/unit/contexts/cinder/test_volumes.py index 2e835899..ec0c652c 100644 --- a/tests/unit/contexts/cinder/test_volumes.py +++ b/tests/unit/contexts/cinder/test_volumes.py @@ -142,59 +142,5 @@ class VolumeGeneratorTestCase(test.ScenarioTestCase): mock_cleanup.assert_called_once_with( names=["cinder.volumes"], users=self.context["users"], - api_versions=None, superclass=volumes_ctx.__class__, - task_id=self.context["owner_id"]) - - @mock.patch("%s.cinder.volumes.resource_manager.cleanup" % CTX) - def test_cleanup_api_versions(self, mock_cleanup): - - tenants_count = 2 - users_per_tenant = 5 - volumes_per_tenant = 5 - - tenants = self._gen_tenants(tenants_count) - users = [] - for id_ in tenants.keys(): - for i in range(users_per_tenant): - users.append({"id": i, "tenant_id": id_, - "credential": "credential"}) - tenants[id_].setdefault("volumes", []) - for j in range(volumes_per_tenant): - tenants[id_]["volumes"].append({"id": "uuid"}) - - api_version = { - "cinder": { - "version": 1, - "service_type": "volume" - } - } - self.context.update({ - "config": { - "users": { - "tenants": 2, - "users_per_tenant": 5, - "concurrent": 10, - }, - "volumes": { - "size": 1, - "type": "volume_type", - "volumes_per_tenant": 5, - }, - "api_versions": api_version - }, - "admin": { - "credential": mock.MagicMock() - }, - "users": users, - "tenants": tenants - }) - - volumes_ctx = volumes.VolumeGenerator(self.context) - volumes_ctx.cleanup() - - mock_cleanup.assert_called_once_with( - names=["cinder.volumes"], - users=self.context["users"], - api_versions=api_version, superclass=volumes_ctx.__class__, task_id=self.context["owner_id"]) diff --git a/tests/unit/contexts/cleanup/test_admin.py b/tests/unit/contexts/cleanup/test_admin.py index 926bcb07..7971815e 100644 --- a/tests/unit/contexts/cleanup/test_admin.py +++ b/tests/unit/contexts/cleanup/test_admin.py @@ -84,54 +84,3 @@ class AdminCleanupTestCase(test.TestCase): task_id="task_id"), mock.call().exterminate() ]) - - @mock.patch("rally.common.plugin.discover.itersubclasses") - @mock.patch("%s.manager.find_resource_managers" % ADMIN, - return_value=[mock.MagicMock(), mock.MagicMock()]) - @mock.patch("%s.manager.SeekAndDestroy" % ADMIN) - def test_cleanup_admin_with_api_versions(self, - mock_seek_and_destroy, - mock_find_resource_managers, - mock_itersubclasses): - class ResourceClass(utils.RandomNameGeneratorMixin): - pass - - mock_itersubclasses.return_value = [ResourceClass] - - ctx = { - "config": - {"admin_cleanup": ["a", "b"], - "api_versions": - {"cinder": - {"version": "1", - "service_type": "volume" - } - } - }, - "admin": mock.MagicMock(), - "users": mock.MagicMock(), - "task": mock.MagicMock() - } - - admin_cleanup = admin.AdminCleanup(ctx) - admin_cleanup.setup() - admin_cleanup.cleanup() - - mock_itersubclasses.assert_called_once_with(scenario.OpenStackScenario) - mock_find_resource_managers.assert_called_once_with(("a", "b"), True) - mock_seek_and_destroy.assert_has_calls([ - mock.call(mock_find_resource_managers.return_value[0], - ctx["admin"], - ctx["users"], - api_versions=ctx["config"]["api_versions"], - resource_classes=[ResourceClass], - task_id=ctx["task"]["uuid"]), - mock.call().exterminate(), - mock.call(mock_find_resource_managers.return_value[1], - ctx["admin"], - ctx["users"], - api_versions=ctx["config"]["api_versions"], - resource_classes=[ResourceClass], - task_id=ctx["task"]["uuid"]), - mock.call().exterminate() - ]) diff --git a/tests/unit/contexts/cleanup/test_user.py b/tests/unit/contexts/cleanup/test_user.py index 46b6783d..4c7106fa 100644 --- a/tests/unit/contexts/cleanup/test_user.py +++ b/tests/unit/contexts/cleanup/test_user.py @@ -78,56 +78,3 @@ class UserCleanupTestCase(test.TestCase): resource_classes=[ResourceClass], task_id="task_id"), mock.call().exterminate() ]) - - @mock.patch("rally.common.plugin.discover.itersubclasses") - @mock.patch("%s.manager.find_resource_managers" % ADMIN, - return_value=[mock.MagicMock(), mock.MagicMock()]) - @mock.patch("%s.manager.SeekAndDestroy" % ADMIN) - def test_cleanup_user_with_api_versions( - self, - mock_seek_and_destroy, - mock_find_resource_managers, - mock_itersubclasses): - - class ResourceClass(utils.RandomNameGeneratorMixin): - pass - - mock_itersubclasses.return_value = [ResourceClass] - - ctx = { - "config": - {"admin_cleanup": ["a", "b"], - "api_versions": - {"cinder": - {"version": "1", - "service_type": "volume" - } - } - }, - "admin": mock.MagicMock(), - "users": mock.MagicMock(), - "task": {"uuid": "task_id"} - } - - user_cleanup = user.UserCleanup(ctx) - user_cleanup.setup() - user_cleanup.cleanup() - - mock_itersubclasses.assert_called_once_with(scenario.OpenStackScenario) - mock_find_resource_managers.assert_called_once_with({}, False) - mock_seek_and_destroy.assert_has_calls([ - mock.call(mock_find_resource_managers.return_value[0], - None, - ctx["users"], - api_versions=ctx["config"]["api_versions"], - resource_classes=[ResourceClass], - task_id="task_id"), - mock.call().exterminate(), - mock.call(mock_find_resource_managers.return_value[1], - None, - ctx["users"], - api_versions=ctx["config"]["api_versions"], - resource_classes=[ResourceClass], - task_id="task_id"), - mock.call().exterminate() - ]) diff --git a/tests/unit/contexts/glance/test_images.py b/tests/unit/contexts/glance/test_images.py index 44d4ef88..ebf462c4 100644 --- a/tests/unit/contexts/glance/test_images.py +++ b/tests/unit/contexts/glance/test_images.py @@ -62,8 +62,7 @@ class ImageGeneratorTestCase(test.ScenarioTestCase): {}, {"min_disk": 1, "min_ram": 2}, {"image_name": "foo"}, - {"tenants": 3, "users_per_tenant": 2, "images_per_tenant": 5}, - {"api_versions": {"glance": {"version": 2, "service_type": "image"}}}) + {"tenants": 3, "users_per_tenant": 2, "images_per_tenant": 5}) @ddt.unpack @mock.patch("rally_openstack.osclients.Clients") def test_setup(self, mock_clients, @@ -71,7 +70,7 @@ class ImageGeneratorTestCase(test.ScenarioTestCase): image_url="http://example.com/fake/url", tenants=1, users_per_tenant=1, images_per_tenant=1, image_name=None, min_ram=None, min_disk=None, - api_versions=None, visibility="public"): + visibility="public"): image_service = self.mock_image.return_value tenant_data = self._gen_tenants(tenants) @@ -102,8 +101,6 @@ class ImageGeneratorTestCase(test.ScenarioTestCase): "users": users, "tenants": tenant_data }) - if api_versions: - self.context["config"]["api_versions"] = api_versions expected_image_args = {} if image_name is not None: @@ -134,8 +131,7 @@ class ImageGeneratorTestCase(test.ScenarioTestCase): name=mock.ANY, **expected_image_args)] * tenants * images_per_tenant) - mock_clients.assert_has_calls( - [mock.call(mock.ANY, api_info=api_versions)] * tenants) + mock_clients.assert_has_calls([mock.call(mock.ANY)] * tenants) @mock.patch("%s.image.Image" % CTX) @mock.patch("%s.LOG" % CTX) @@ -214,12 +210,10 @@ class ImageGeneratorTestCase(test.ScenarioTestCase): # specified, warning message should be printed. self.assertEqual(expected_warns, mock_log.warning.call_args_list) - @ddt.data( - {"admin": True}, - {"api_versions": {"glance": {"version": 2, "service_type": "image"}}}) + @ddt.data({"admin": True}) @ddt.unpack @mock.patch("%s.resource_manager.cleanup" % CTX) - def test_cleanup(self, mock_cleanup, admin=None, api_versions=None): + def test_cleanup(self, mock_cleanup, admin=None): images_per_tenant = 5 tenants = self._gen_tenants(self.tenants_num) @@ -242,8 +236,7 @@ class ImageGeneratorTestCase(test.ScenarioTestCase): "users_per_tenant": self.users_per_tenant, "concurrent": 10, }, - "images": {}, - "api_versions": api_versions + "images": {} }, "users": mock.Mock() }) @@ -261,7 +254,6 @@ class ImageGeneratorTestCase(test.ScenarioTestCase): admin=self.context.get("admin"), admin_required=None if admin else False, users=self.context["users"], - api_versions=api_versions, superclass=images_ctx.__class__, task_id=self.context["owner_id"]) @@ -283,6 +275,5 @@ class ImageGeneratorTestCase(test.ScenarioTestCase): admin=self.context.get("admin"), admin_required=None, users=self.context["users"], - api_versions=None, superclass=mock_make_name_matcher.return_value, task_id=self.context["owner_id"]) diff --git a/tests/unit/contexts/manila/test_manila_security_services.py b/tests/unit/contexts/manila/test_manila_security_services.py index c3c7c6c3..e118df17 100644 --- a/tests/unit/contexts/manila/test_manila_security_services.py +++ b/tests/unit/contexts/manila/test_manila_security_services.py @@ -111,7 +111,6 @@ class SecurityServicesTestCase(test.ScenarioTestCase): [mock.call({ "task": inst.task, "owner_id": "foo_uuid", - "config": {"api_versions": []}, "user": user}) for user in inst.context["users"] if user["id"] == 0] ) diff --git a/tests/unit/contexts/manila/test_manila_share_networks.py b/tests/unit/contexts/manila/test_manila_share_networks.py index d3aa3dc9..a95cf2ec 100644 --- a/tests/unit/contexts/manila/test_manila_share_networks.py +++ b/tests/unit/contexts/manila/test_manila_share_networks.py @@ -399,5 +399,4 @@ class ShareNetworksTestCase(test.TestCase): names=["manila.share_networks"], users=ctxt["users"], superclass=manila_share_networks.ShareNetworks, - api_versions=None, task_id=task_id) diff --git a/tests/unit/contexts/nova/test_flavors.py b/tests/unit/contexts/nova/test_flavors.py index 5898e320..b1e43ac4 100644 --- a/tests/unit/contexts/nova/test_flavors.py +++ b/tests/unit/contexts/nova/test_flavors.py @@ -117,7 +117,6 @@ class FlavorsGeneratorTestCase(test.TestCase): mock_cleanup.assert_called_once_with( names=["nova.flavors"], admin=real_context["admin"], - api_versions=None, superclass=mock_make_name_matcher.return_value, task_id=flavors_ctx.get_owner_id())