X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2ims%2Fviews%2Focloud_view.py;h=0436f3ae173494e853b785a4a1a9b58795bb3a84;hb=a6392b46c7b808b8adeede97c4dd69c5032e0d11;hp=f970517fb318aad1323c4c301093f8a4fd82d058;hpb=44f01a560347914798d8f913696d0e495ee076f8;p=pti%2Fo2.git diff --git a/o2ims/views/ocloud_view.py b/o2ims/views/ocloud_view.py index f970517..0436f3a 100644 --- a/o2ims/views/ocloud_view.py +++ b/o2ims/views/ocloud_view.py @@ -16,7 +16,10 @@ import uuid from o2common.service import unit_of_work from o2ims.views.ocloud_dto import SubscriptionDTO -from o2ims.domain.ocloud import Subscription +from o2ims.domain.subscription_obj import Subscription + +from o2common.helper import o2logging +logger = o2logging.get_logger(__name__) def oclouds(uow: unit_of_work.AbstractUnitOfWork): @@ -41,7 +44,6 @@ def resource_type_one(resourceTypeId: str, uow: unit_of_work.AbstractUnitOfWork): with uow: first = uow.resource_types.get(resourceTypeId) - print(first) return first.serialize() if first is not None else None @@ -58,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]