[api_versions]Deprecate and remove passed api_info argument
Api information has been moved into credential argument, api_info argument is not required, and will be removed after releasing several versions. Change-Id: I0f43ae931e481bf0efb8df5258ec986a732917a6
This commit is contained in:
parent
5bdb5b83fc
commit
e02c28600f
@ -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
|
||||
~~~~~~~
|
||||
|
@ -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,
|
||||
|
@ -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())
|
||||
|
@ -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())
|
||||
|
@ -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())
|
||||
|
@ -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()
|
||||
)
|
||||
|
@ -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())
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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())
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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",
|
||||
|
@ -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"])
|
||||
|
@ -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.
|
||||
|
@ -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())
|
||||
|
||||
|
@ -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"])
|
||||
|
@ -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()
|
||||
])
|
||||
|
@ -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()
|
||||
])
|
||||
|
@ -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"])
|
||||
|
@ -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]
|
||||
)
|
||||
|
@ -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)
|
||||
|
@ -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())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user