X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=o2ims%2Fviews%2Focloud_view.py;h=441c938c5b31d2c65a1679b81f24bc779bda48c8;hb=d9000f0859a254f2c3c32f30ed71a143e731e2ff;hp=ed55ddac4bb03c1593ee1eca9e72cf38bd5aabf4;hpb=f7ef52a5b4ead0472b1b5828471b28c88d2a0aea;p=pti%2Fo2.git diff --git a/o2ims/views/ocloud_view.py b/o2ims/views/ocloud_view.py index ed55dda..441c938 100644 --- a/o2ims/views/ocloud_view.py +++ b/o2ims/views/ocloud_view.py @@ -22,6 +22,7 @@ import shutil from o2common.service import unit_of_work from o2common.config import config from o2common.views.pagination_view import Pagination +from o2common.views.view import gen_filter from o2ims.domain import ocloud from o2ims.views.ocloud_dto import SubscriptionDTO from o2ims.domain.subscription_obj import Subscription @@ -44,9 +45,11 @@ def ocloud_one(ocloudid: str, uow: unit_of_work.AbstractUnitOfWork): def resource_types(uow: unit_of_work.AbstractUnitOfWork, **kwargs): pagination = Pagination(**kwargs) - filter_kwargs = pagination.get_filter() + query_kwargs = pagination.get_pagination() + args = gen_filter(ocloud.ResourceType, + kwargs['filter']) if 'filter' in kwargs else [] with uow: - li = uow.resource_types.list_with_count(**filter_kwargs) + li = uow.resource_types.list_with_count(*args, **query_kwargs) return pagination.get_result(li) @@ -59,9 +62,11 @@ def resource_type_one(resourceTypeId: str, def resource_pools(uow: unit_of_work.AbstractUnitOfWork, **kwargs): pagination = Pagination(**kwargs) - filter_kwargs = pagination.get_filter() + query_kwargs = pagination.get_pagination() + args = gen_filter(ocloud.ResourcePool, + kwargs['filter']) if 'filter' in kwargs else [] with uow: - li = uow.resource_pools.list_with_count(**filter_kwargs) + li = uow.resource_pools.list_with_count(*args, **query_kwargs) return pagination.get_result(li) @@ -76,7 +81,7 @@ def resources(resourcePoolId: str, uow: unit_of_work.AbstractUnitOfWork, **kwargs): pagination = Pagination(**kwargs) # filter key should be the same with database name - filter_kwargs = pagination.get_filter() + query_kwargs = pagination.get_pagination() if 'resourceTypeName' in kwargs: resource_type_name = kwargs['resourceTypeName'] with uow: @@ -87,15 +92,20 @@ def resources(resourcePoolId: str, uow: unit_of_work.AbstractUnitOfWork, # 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 + query_kwargs['resourceTypeId'] = restype_id + args = gen_filter( + ocloud.Resource, kwargs['filter']) if 'filter' in kwargs else [] + args.append(ocloud.Resource.resourcePoolId == resourcePoolId) + # args.append(ocloud.Resource.parentId == None) if 'parentId' in kwargs: - filter_kwargs['parentId'] = kwargs['parentId'] + query_kwargs['parentId'] = kwargs['parentId'] if 'sort' in kwargs: - filter_kwargs['sort'] = kwargs['sort'] + query_kwargs['sort'] = kwargs['sort'] with uow: - ret = uow.resources.list_with_count(resourcePoolId, **filter_kwargs) + ret = uow.resources.list_with_count( + resourcePoolId, *args, **query_kwargs) return pagination.get_result(ret) @@ -108,15 +118,18 @@ def resource_one(resourceId: str, uow: unit_of_work.AbstractUnitOfWork): def deployment_managers(uow: unit_of_work.AbstractUnitOfWork, **kwargs): pagination = Pagination(**kwargs) - filter_kwargs = pagination.get_filter() + query_kwargs = pagination.get_pagination() + args = gen_filter(ocloud.DeploymentManager, + kwargs['filter']) if 'filter' in kwargs else [] with uow: - li = uow.deployment_managers.list_with_count(**filter_kwargs) + li = uow.deployment_managers.list_with_count(*args, **query_kwargs) return pagination.get_result(li) def deployment_manager_one(deploymentManagerId: str, uow: unit_of_work.AbstractUnitOfWork, - profile: str = 'default'): + profile: str = + ocloud.DeploymentManagerProfileDefault): profile = profile.lower() with uow: first = uow.deployment_managers.get(deploymentManagerId) @@ -128,15 +141,17 @@ def deployment_manager_one(deploymentManagerId: str, profile_data = result.pop("profile", None) result['profileName'] = profile + profiles = config.get_dms_support_profiles() + if profile not in profiles: + return "" - if ocloud.DeploymentManagerProfileDefault == profile: - pass - elif ocloud.DeploymentManagerProfileSOL018 == profile: - result['deploymentManagementServiceEndpoint'] = \ + if ocloud.DeploymentManagerProfileDefault == profile \ + or ocloud.DeploymentManagerProfileSOL018 == profile: + result['serviceUri'] = \ profile_data['cluster_api_endpoint'] result['profileData'] = profile_data elif ocloud.DeploymentManagerProfileSOL018HelmCLI == profile: - result['deploymentManagementServiceEndpoint'] = \ + result['serviceUri'] = \ profile_data['cluster_api_endpoint'] helmcli_profile = dict() @@ -147,7 +162,7 @@ def deployment_manager_one(deploymentManagerId: str, deploymentManagerId, profile_data) result['profileData'] = helmcli_profile else: - return None + return "" return result @@ -188,9 +203,11 @@ def _gen_kube_config(dmId: str, kubeconfig: dict) -> dict: def subscriptions(uow: unit_of_work.AbstractUnitOfWork, **kwargs): pagination = Pagination(**kwargs) - filter_kwargs = pagination.get_filter() + query_kwargs = pagination.get_pagination() + args = gen_filter(Subscription, + kwargs['filter']) if 'filter' in kwargs else [] with uow: - li = uow.subscriptions.list_with_count(**filter_kwargs) + li = uow.subscriptions.list_with_count(*args, **query_kwargs) return pagination.get_result(li)