Add all_projects as a preferred alias for all_tenants
Now that we support both server-side and client-side names for parameters, we can add an all_projects alias. We already use project_id in resources instead of tenant_id. Put in logic to only pass all_projects along to the underlying list if it's True. That way we can easily use the interface with True/False and only send query parameters when we need to. Pehaps we could enhance QueryParameters to understand default values of parameters and that they don't need to be sent? Change-Id: I66117ab4c82d30ae3700e17f7598b3d3fbbac60d
This commit is contained in:
parent
d91723dbab
commit
3ba6e5fe5e
|
@ -45,7 +45,7 @@ class Proxy(proxy.Proxy):
|
|||
the snapshots being returned. Available parameters include:
|
||||
|
||||
* name: Name of the snapshot as a string.
|
||||
* all_tenants: Whether return the snapshots of all tenants.
|
||||
* all_projects: Whether return the snapshots in all projects.
|
||||
* volume_id: volume id of a snapshot.
|
||||
* status: Value of the status of the snapshot so that you can
|
||||
filter on "available" for example.
|
||||
|
@ -154,7 +154,7 @@ class Proxy(proxy.Proxy):
|
|||
the volumes being returned. Available parameters include:
|
||||
|
||||
* name: Name of the volume as a string.
|
||||
* all_tenants: Whether return the volumes of all tenants
|
||||
* all_projects: Whether return the volumes in all projects
|
||||
* status: Value of the status of the volume so that you can filter
|
||||
on "available" for example.
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class Snapshot(resource.Resource):
|
|||
base_path = "/snapshots"
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'all_tenants', 'name', 'status', 'volume_id')
|
||||
'name', 'status', 'volume_id', all_projects='all_tenants')
|
||||
|
||||
# capabilities
|
||||
allow_fetch = True
|
||||
|
|
|
@ -20,7 +20,7 @@ class Volume(resource.Resource):
|
|||
base_path = "/volumes"
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'all_tenants', 'name', 'status', 'project_id')
|
||||
'name', 'status', 'project_id', all_projects='all_tenants')
|
||||
|
||||
# capabilities
|
||||
allow_fetch = True
|
||||
|
|
|
@ -371,7 +371,7 @@ class Proxy(proxy.Proxy):
|
|||
"""
|
||||
return self._get(_server.Server, server)
|
||||
|
||||
def servers(self, details=True, **query):
|
||||
def servers(self, details=True, all_projects=False, **query):
|
||||
"""Retrieve a generator of servers
|
||||
|
||||
:param bool details: When set to ``False``
|
||||
|
@ -395,6 +395,8 @@ class Proxy(proxy.Proxy):
|
|||
* status: Value of the status of the server so that you can filter
|
||||
on "ACTIVE" for example.
|
||||
* host: Name of the host as a string.
|
||||
* all_projects: Flag to request servers be returned from all
|
||||
projects, not just the currently scoped one.
|
||||
* limit: Requests a specified page size of returned items from the
|
||||
query. Returns a number of items up to the specified
|
||||
limit value. Use the limit parameter to make an initial
|
||||
|
@ -408,6 +410,8 @@ class Proxy(proxy.Proxy):
|
|||
|
||||
:returns: A generator of server instances.
|
||||
"""
|
||||
if all_projects:
|
||||
query['all_projects'] = True
|
||||
srv = _server.ServerDetail if details else _server.Server
|
||||
return self._list(srv, paginated=True, **query)
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class Server(resource.Resource, metadata.MetadataMixin):
|
|||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
"image", "flavor", "name",
|
||||
"status", "host", "all_tenants",
|
||||
"status", "host",
|
||||
"sort_key", "sort_dir",
|
||||
"reservation_id", "tags",
|
||||
"project_id",
|
||||
|
@ -39,7 +39,8 @@ class Server(resource.Resource, metadata.MetadataMixin):
|
|||
is_deleted="deleted",
|
||||
ipv4_address="ip",
|
||||
ipv6_address="ip6",
|
||||
changes_since="changes-since")
|
||||
changes_since="changes-since",
|
||||
all_projects="all_tenants")
|
||||
|
||||
#: A list of dictionaries holding links relevant to this server.
|
||||
links = resource.Body('links')
|
||||
|
|
|
@ -53,7 +53,7 @@ class TestSnapshot(base.TestCase):
|
|||
|
||||
self.assertDictEqual({"name": "name",
|
||||
"status": "status",
|
||||
"all_tenants": "all_tenants",
|
||||
"all_projects": "all_tenants",
|
||||
"volume_id": "volume_id",
|
||||
"limit": "limit",
|
||||
"marker": "marker"},
|
||||
|
|
|
@ -76,7 +76,7 @@ class TestVolume(base.TestCase):
|
|||
|
||||
self.assertDictEqual({"name": "name",
|
||||
"status": "status",
|
||||
"all_tenants": "all_tenants",
|
||||
"all_projects": "all_tenants",
|
||||
"project_id": "project_id",
|
||||
"limit": "limit",
|
||||
"marker": "marker"},
|
||||
|
|
|
@ -84,7 +84,7 @@ class TestServer(base.TestCase):
|
|||
"name": "name",
|
||||
"status": "status",
|
||||
"host": "host",
|
||||
"all_tenants": "all_tenants",
|
||||
"all_projects": "all_tenants",
|
||||
"changes_since": "changes-since",
|
||||
"limit": "limit",
|
||||
"marker": "marker",
|
||||
|
|
Loading…
Reference in New Issue