X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2ims%2Fviews%2Focloud_dto.py;h=c8e520237d97f4516e9a1f4dcb846c7dfc2280af;hb=bd72340e71574c7095e94aa2719df66c3f711545;hp=c6896e0bd8bb35041f32fb68737ed7180a4d981e;hpb=6c304dfab28ffd1bbe69b9ada3d11e8fbbde014b;p=pti%2Fo2.git diff --git a/o2ims/views/ocloud_dto.py b/o2ims/views/ocloud_dto.py index c6896e0..c8e5202 100644 --- a/o2ims/views/ocloud_dto.py +++ b/o2ims/views/ocloud_dto.py @@ -62,7 +62,6 @@ class ResourcePoolDTO: class ResourceDTO: - resource_list = api_ims_inventory_v1.model( "ResourceListDto", { @@ -76,6 +75,46 @@ class ResourceDTO: } ) + list_result = api_ims_inventory_v1.model( + "ResourceListPagenationDto", + { + 'count': fields.Integer(), + 'page_num': fields.Integer(), + 'results': fields.List(fields.Nested(resource_list)) + } + ) + + # def get_paginated_list(results, url, start, limit): + # start = int(start) + # limit = int(limit) + # count = len(results) + # if count < start or limit < 0: + # api_ims_inventory_v1.abort(404) + # # make response + # obj = {} + # obj['start'] = start + # obj['limit'] = limit + # obj['count'] = count + # # make URLs + # # make previous url + # if start == 1: + # obj['previous'] = '' + # else: + # start_copy = max(1, start - limit) + # limit_copy = start - 1 + # obj['previous'] = url + \ + # '?start=%d&limit=%d' % (start_copy, limit_copy) + # # make next url + # if start + limit > count: + # obj['next'] = '' + # else: + # start_copy = start + limit + # obj['next'] = url + '?start=%d&limit=%d' % (start_copy, limit) + # # finally extract result according to bounds + # # obj['results'] = results[(start - 1):(start - 1 + limit)] + # obj['result'] = fields.List(fields.Nested(ResourceDTO.resource_list)) + # return obj + def recursive_resource_mapping(iteration_number=2): resource_json_mapping = { 'resourceId': fields.String(required=True, @@ -94,43 +133,77 @@ class ResourceDTO: return api_ims_inventory_v1.model( 'ResourceGetDto' + str(iteration_number), resource_json_mapping) - def _recursive_resource_mapping(self, iteration_number=2): - resource_json_mapping = { - 'resourceId': fields.String(required=True, - description='Resource ID'), - 'resourceTypeId': fields.String, - 'resourcePoolId': fields.String, + # def _recursive_resource_mapping(self, iteration_number=2): + # resource_json_mapping = { + # 'resourceId': fields.String(required=True, + # description='Resource ID'), + # 'resourceTypeId': fields.String, + # 'resourcePoolId': fields.String, + # 'name': fields.String, + # 'parentId': fields.String, + # 'description': fields.String, + # } + # if iteration_number: + # resource_json_mapping['children'] = fields.List( + # fields.Nested(self._recursive_resource_mapping( + # iteration_number-1))) + # # print(type(resource_json_mapping['children'])) + # if resource_json_mapping['children'] is None: + # del resource_json_mapping['children'] + # return resource_json_mapping + + # def get_resource_get(self): + # return api_ims_inventory_v1.model( + # 'ResourceGetDto', + # { + # 'resourceId': fields.String(required=True, + # description='Resource ID'), + # 'resourceTypeId': fields.String, + # 'resourcePoolId': fields.String, + # 'name': fields.String, + # 'parentId': fields.String, + # 'description': fields.String, + # 'children': fields.List(fields.Nested( + # self._recursive_resource_mapping())) + # } + # ) + + +class DeploymentManagerDTO: + + deployment_manager_list = api_ims_inventory_v1.model( + "DeploymentManagerListDto", + { + 'deploymentManagerId': fields.String( + required=True, + description='Deployment manager ID'), 'name': fields.String, - 'parentId': fields.String, 'description': fields.String, + 'deploymentManagementServiceEndpoint': fields.String, + 'supportedLocations': fields.String, + 'capabilities': fields.String, + 'capacity': fields.String, + 'profileSupportList': fields.List( + fields.String, + description='Profile support list, use default for the return \ + endpoint'), } - if iteration_number: - resource_json_mapping['children'] = fields.List( - fields.Nested(self._recursive_resource_mapping( - iteration_number-1))) - # print(type(resource_json_mapping['children'])) - if resource_json_mapping['children'] is None: - del resource_json_mapping['children'] - return resource_json_mapping - - def get_resource_get(self): - return api_ims_inventory_v1.model( - 'ResourceGetDto', - { - 'resourceId': fields.String(required=True, - description='Resource ID'), - 'resourceTypeId': fields.String, - 'resourcePoolId': fields.String, - 'name': fields.String, - 'parentId': fields.String, - 'description': fields.String, - 'children': fields.List(fields.Nested( - self._recursive_resource_mapping())) - } - ) - + ) -class DeploymentManagerDTO: + profile = api_ims_inventory_v1.model("DeploymentManagerGetDtoProfile", { + 'cluster_api_endpoint': fields.String( + attributes='cluster_api_endpoint'), + 'cluster_ca_cert': fields.String(attributes='cluster_ca_cert'), + 'admin_user': fields.String(attributes='admin_user'), + 'admin_client_cert': fields.String(attributes='admin_client_cert'), + 'admin_client_key': fields.String(attributes='admin_client_key'), + # 'kube_config_file': fields.String(attributes='kube_config_file') + 'helmcli_host_with_port': fields.String( + attributes='helmcli_host_with_port'), + 'helmcli_username': fields.String(attributes='helmcli_username'), + 'helmcli_password': fields.String(attributes='helmcli_password'), + 'helmcli_kubeconfig': fields.String(attributes='helmcli_kubeconfig'), + }) deployment_manager_get = api_ims_inventory_v1.model( "DeploymentManagerGetDto", @@ -144,6 +217,8 @@ class DeploymentManagerDTO: 'supportedLocations': fields.String, 'capabilities': fields.String, 'capacity': fields.String, + 'profileName': fields.String, + 'profileData': fields.Nested(profile, False, True), } )