X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2ims%2Fviews%2Focloud_view.py;h=0436f3ae173494e853b785a4a1a9b58795bb3a84;hb=91c02b447f2035ffbb11891ece162242c8f5a44f;hp=3735298da208f2d83d5d03b4271e942b42bfecc6;hpb=7ee63c4b8ad2bbc661ba9b4f39f66abe94b591ae;p=pti%2Fo2.git diff --git a/o2ims/views/ocloud_view.py b/o2ims/views/ocloud_view.py index 3735298..0436f3a 100644 --- a/o2ims/views/ocloud_view.py +++ b/o2ims/views/ocloud_view.py @@ -18,6 +18,9 @@ from o2common.service import unit_of_work from o2ims.views.ocloud_dto import SubscriptionDTO from o2ims.domain.subscription_obj import Subscription +from o2common.helper import o2logging +logger = o2logging.get_logger(__name__) + def oclouds(uow: unit_of_work.AbstractUnitOfWork): with uow: @@ -57,9 +60,29 @@ def resource_pool_one(resourcePoolId: str, return first.serialize() if first is not None else None -def resources(resourcePoolId: str, uow: unit_of_work.AbstractUnitOfWork): +def resources(resourcePoolId: str, uow: unit_of_work.AbstractUnitOfWork, + **kwargs): + + filter_kwargs = {} # filter key should be the same with database name + if 'resourceTypeName' in kwargs: + resource_type_name = kwargs['resourceTypeName'] + with uow: + # res_types = uow.resource_types.list() + # restype_ids = [ + # restype.resourceTypeId for restype in res_types + # if resourceTypeName == restype.name] + # restype_id = '' if len(restype_ids) == 0 else restype_ids[0] + res_type = uow.resource_types.get_by_name(resource_type_name) + restype_id = '' if res_type is None else res_type.resourceTypeId + filter_kwargs['resourceTypeId'] = restype_id + + # li = uow.resources.list(resourcePoolId) + # return [r.serialize() for r in li if r.resourceTypeId == restype_id] + if 'parentId' in kwargs: + filter_kwargs['parentId'] = kwargs['parentId'] + with uow: - li = uow.resources.list(resourcePoolId) + li = uow.resources.list(resourcePoolId, **filter_kwargs) return [r.serialize() for r in li]