Merge "[env][openstack] Change format of info method"
This commit is contained in:
commit
aa357407cd
@ -180,10 +180,17 @@ class OpenStack(platform.Platform):
|
||||
"""Return information about cloud as dict."""
|
||||
active_user = (self.platform_data["admin"] or
|
||||
self.platform_data["users"][0])
|
||||
services = osclients.Clients(active_user).services()
|
||||
services = []
|
||||
for stype, name in osclients.Clients(active_user).services().items():
|
||||
if name == "__unknown__":
|
||||
# `__unknown__` name misleads, let's just not include it...
|
||||
services.append({"type": stype})
|
||||
else:
|
||||
services.append({"type": stype, "name": name})
|
||||
|
||||
return {
|
||||
"info": {
|
||||
"services": services
|
||||
"services": sorted(services, key=lambda x: x["type"])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,9 @@ class ExistingPlatformTestCase(test_platform.PlatformBaseTestCase):
|
||||
|
||||
@mock.patch("rally.plugins.openstack.osclients.Clients")
|
||||
def test_info(self, mock_clients):
|
||||
mock_clients.return_value.services.return_value = ["a", "b"]
|
||||
mock_clients.return_value.services.return_value = {
|
||||
"foo": "bar",
|
||||
"volumev4": "__unknown__"}
|
||||
platform_data = {
|
||||
"admin": None,
|
||||
"users": [{"username": "u1", "password": "123"}]
|
||||
@ -206,5 +208,10 @@ class ExistingPlatformTestCase(test_platform.PlatformBaseTestCase):
|
||||
result = p.info()
|
||||
mock_clients.assert_called_once_with(platform_data["users"][0])
|
||||
mock_clients.return_value.services.assert_called_once_with()
|
||||
self.assertEqual({"info": {"services": ["a", "b"]}}, result)
|
||||
self.assertEqual(
|
||||
{
|
||||
"info": {
|
||||
"services": [{"type": "foo", "name": "bar"},
|
||||
{"type": "volumev4"}]}},
|
||||
result)
|
||||
self._check_info_schema(result)
|
||||
|
Loading…
Reference in New Issue
Block a user