Pass through all_projects for get_server

This function currently does not allow getting of a server
from all projects, and it can be quite useful to do so (for
various admin/operator activities) so allow get_server to
pass through 'all_projects' to the internally called
'search_servers' (and default it to false to retain the old
behavior).

Change-Id: I7b7534a044cfa0ccbaa11a635edcca388db27f0f
This commit is contained in:
Joshua Harlow 2017-12-08 13:06:13 -08:00
parent cf47cf43dd
commit b3d47a032a

View File

@ -3110,7 +3110,8 @@ class OpenStackCloud(
return self._get_and_munchify('output', data) return self._get_and_munchify('output', data)
def get_server( def get_server(
self, name_or_id=None, filters=None, detailed=False, bare=False): self, name_or_id=None, filters=None, detailed=False, bare=False,
all_projects=False):
"""Get a server by name or ID. """Get a server by name or ID.
:param name_or_id: Name or ID of the server. :param name_or_id: Name or ID of the server.
@ -3134,13 +3135,16 @@ class OpenStackCloud(
server record. Defaults to False, meaning the addresses server record. Defaults to False, meaning the addresses
dict will be populated as needed from neutron. Setting dict will be populated as needed from neutron. Setting
to True implies detailed = False. to True implies detailed = False.
:param all_projects: Whether to get server from all projects or just
the current auth scoped project.
:returns: A server ``munch.Munch`` or None if no matching server is :returns: A server ``munch.Munch`` or None if no matching server is
found. found.
""" """
searchfunc = functools.partial(self.search_servers, searchfunc = functools.partial(self.search_servers,
detailed=detailed, bare=True) detailed=detailed, bare=True,
all_projects=all_projects)
server = _utils._get_entity(self, searchfunc, name_or_id, filters) server = _utils._get_entity(self, searchfunc, name_or_id, filters)
return self._expand_server(server, detailed, bare) return self._expand_server(server, detailed, bare)