def _get_resources_by_filters(self, resource_type, unique_item=False, **filters): """Retrieves item(s) from filters. By default, a list is returned.
If unique_item set to True, only the first resource is returned.
"""
try: resources = getattr( self.network_proxy, f"{resource_type}s")(**filters) conversion_function = getattr( utils, 'convert_%s_to_model' % resource_type)
try:
# get first item to see if there is at least one resource res_list = [conversion_function(next(resources))]
except StopIteration:
# pylint: disable=raise-missing-from raise os_exceptions.NotFoundException( f'No resource of type {resource_type} found that matches ' f'given filter criteria: {filters}.')
if unique_item: return res_list[0]
return res_list + [conversion_function(r) for r in resources]
except os_exceptions.NotFoundException as e:
message = _('{resource_type} not found ' '({resource_type} Filters: {filters}.').format( resource_type=resource_type, filters=filters)
raise getattr(base, '%sNotFound' % ''.join( [w.capitalize() for w in resource_type.split('_')] ))(message) from e
except Exception as e:
message = _('Error retrieving {resource_type} ' '({resource_type} Filters: {filters}.').format( resource_type=resource_type, filters=filters) LOG.exception(message)
raise base.NetworkException(message) from e
Somewhere, it is not using context to create the correct filter.... I am dead in the water on octavia usage without this, its also impacting magnum as i using octavia for this ;0 Thoughts ?
https:/ /docs.openstack .org/octavia/ latest/ _modules/ octavia/ network/ drivers/ neutron/ base.html# BaseNeutronDriv er.get_ subnet
def _get_resources_ by_filters( self, resource_type, unique_item=False,
* *filters) :
"""Retrieves item(s) from filters. By default, a list is returned.
If unique_item set to True, only the first resource is returned.
resources = getattr(
self. network_ proxy, f"{resource_ type}s" )(**filters)
conversion _function = getattr(
utils,
'convert_ %s_to_model' % resource_type)
res_list = [conversion_ function( next(resources) )] raise-missing- from
raise os_exceptions. NotFoundExcepti on(
f' No resource of type {resource_type} found that matches '
f' given filter criteria: {filters}.')
"""
try:
try:
# get first item to see if there is at least one resource
except StopIteration:
# pylint: disable=
if unique_item:
return res_list[0] function( r) for r in resources]
return res_list + [conversion_
except os_exceptions. NotFoundExcepti on as e:
'({resource_ type} Filters: {filters} .').format(
resource_ type=resource_ type, filters=filters)
[w.capitalize () for w in resource_ type.split( '_')]
)) (message) from e
'({resource_ type} Filters: {filters} .').format(
resource_ type=resource_ type, filters=filters)
LOG. exception( message) eption( message) from e
message = _('{resource_type} not found '
raise getattr(base, '%sNotFound' % ''.join(
except Exception as e:
message = _('Error retrieving {resource_type} '
raise base.NetworkExc
[docs] resource( 'network' , network_id, context=context)
def get_network(self, network_id, context=None):
return self._get_
[docs] resource( 'subnet' , subnet_id, context=context)
def get_subnet(self, subnet_id, context=None):
return self._get_
Somewhere, it is not using context to create the correct filter.... I am dead in the water on octavia usage without this, its also impacting magnum as i using octavia for this ;0 Thoughts ?