X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2ims%2Fviews%2Focloud_dto.py;h=26f9d100c654ef377160c0658575321aec407116;hb=refs%2Fchanges%2F15%2F10215%2F2;hp=c8e520237d97f4516e9a1f4dcb846c7dfc2280af;hpb=f7ef52a5b4ead0472b1b5828471b28c88d2a0aea;p=pti%2Fo2.git diff --git a/o2ims/views/ocloud_dto.py b/o2ims/views/ocloud_dto.py index c8e5202..26f9d10 100644 --- a/o2ims/views/ocloud_dto.py +++ b/o2ims/views/ocloud_dto.py @@ -14,7 +14,8 @@ from flask_restx import fields -from o2ims.views.api_ns import api_ims_inventory_v1 +from o2ims.views.api_ns import api_ims_inventory as api_ims_inventory_v1 +from o2common.views.flask_restx_fields import Json2Dict class OcloudDTO: @@ -22,16 +23,81 @@ class OcloudDTO: ocloud = api_ims_inventory_v1.model( "OcloudDto", { - 'oCloudId': fields.String(required=True), - 'globalCloudId': fields.String, - 'name': fields.String, - 'description': fields.String, - 'infrastructureManagementServiceEndpoint': fields.String, - } + 'oCloudId': fields.String( + required=True, + example='f078a1d3-56df-46c2-88a2-dd659aa3f6bd', + description='Identifier for the containing O-Cloud.'), + 'globalCloudId': fields.String( + example='10a07219-4201-4b3e-a52d-81ab6a755d8a', + description='Identifier of the O-Cloud instance. ' + + 'Globally unique across O-Cloud instances.'), + 'globalcloudId': fields.String( + attribute='globalCloudId', + example='10a07219-4201-4b3e-a52d-81ab6a755d8a', + description='Identifier of the O-Cloud instance. ' + + 'Globally unique across O-Cloud instances.(Specification)'), + 'name': fields.String( + example='95b818b8-b315-4d9f-af37-b82c492101f1', + description='Human readable name of the O-Cloud.'), + 'description': fields.String( + example='An ocloud', + description='Human readable description of the O-Cloud.'), + 'serviceUri': fields.String( + attribute='serviceUri', + example='https://128.224.115.51:30205', + description='The fully qualified URI root to all ' + + 'services provided by the O2ims interface'), + # 'infrastructureManagementServiceEndpoint': fields.String( + # attribute='serviceUri'), + # 'infrastructureMangementServiceEndPoint': fields.String( + # attribute='serviceUri'), + # 'resourceTypes': fields.String, + # 'resourcePools': fields.String, + # 'deploymentManagers': fields.String, + # 'smoRegistrationService': fields.String + 'extensions': fields.String( + example='', + description='These are unspecified (not standardized) ' +\ + 'properties (keys) which are tailored by the vendor ' +\ + 'to extend the information provided about the O-Cloud.'), + }, + mask='{oCloudId,globalCloudId,globalcloudId,name,description,' +\ + 'serviceUri}' ) class ResourceTypeDTO: + alarm_definition = api_ims_inventory_v1.model( + "AlarmDefinitionDto", + { + 'alarmDefinitionId': fields.String, + 'alarmName': fields.String, + 'alarmLastChange': fields.String, + 'alarmChangeType': fields.String, + 'alarmDescription': fields.String, + 'proposedRepairActions': fields.String, + 'clearingType': fields.String, + 'managementInterfaceId': fields.String, + 'pkNotificationField': fields.String, + 'alarmAdditionalFields': fields.String, + } + + ) + alarm_dictionary = api_ims_inventory_v1.model( + "AlarmDictionaryDto", + { + 'id': fields.String, + 'alarmDictionaryVersion': fields.String, + 'alarmDictionarySchemaVersion': fields.String, + 'entityType': fields.String, + 'vendor': fields.String, + 'managementInterfaceId': fields.String, + 'pkNotificationField': fields.String, + # 'alarmDefinition': fields.String, + 'alarmDefinition': fields.List(fields.Nested(alarm_definition), + attribute='alarmDefinition'), + } + ) resource_type_get = api_ims_inventory_v1.model( "ResourceTypeGetDto", @@ -39,10 +105,16 @@ class ResourceTypeDTO: 'resourceTypeId': fields.String(required=True, description='Resource type ID'), 'name': fields.String, + 'description': fields.String, 'vendor': fields.String, + 'model': fields.String, 'version': fields.String, - 'description': fields.String, - } + 'alarmDictionary': fields.Nested(alarm_dictionary, False, True), + # 'resourceKind': fields.String, + # 'resourceClass': fields.String, + 'extensions': fields.String + }, + mask='{resourceTypeId,name,description,model,vendor,version}' ) @@ -51,13 +123,37 @@ class ResourcePoolDTO: resource_pool_get = api_ims_inventory_v1.model( "ResourcePoolGetDto", { - 'resourcePoolId': fields.String(required=True, - description='Resource pool ID'), - 'name': fields.String, - 'globalLocationId': fields.String, - 'location': fields.String, - 'description': fields.String, - } + 'resourcePoolId': fields.String( + required=True, + example='f078a1d3-56df-46c2-88a2-dd659aa3f6bd', + description='Identifier for the Resource Pool in the ' + + 'O-Cloud instance.'), + 'globalLocationId': fields.String( + example='', + description='This identifier is copied from the O-Cloud ' + + 'Id assigned by the SMO during the O-Cloud deployment.'), + 'name': fields.String( + example='RegionOne', + description='Human readable name of the resource pool.'), + 'description': fields.String( + example='A Resource Pool', + description='Human readable description of the ' + + 'resource pool.'), + 'oCloudId': fields.String( + example='f078a1d3-56df-46c2-88a2-dd659aa3f6bd', + description='Identifier for the containing O-Cloud.'), + 'location': fields.String( + example='', + description='Information about the geographical ' + + 'location of the resource pool as detected by the O-Cloud.'), + # 'resources': fields.String, + 'extensions': fields.String( + example='', + description='List of metadata key-value pairs ' +\ + 'used to associate meaningful metadata to ' +\ + 'the related resource pool.') + }, + mask='{resourcePoolId,oCloudId,globalLocationId,name,description}' ) @@ -69,104 +165,41 @@ class ResourceDTO: description='Resource ID'), 'resourceTypeId': fields.String, 'resourcePoolId': fields.String, - 'name': fields.String, + 'globalAssetId': fields.String, + # 'name': fields.String, 'parentId': fields.String, 'description': fields.String, - } - ) - - list_result = api_ims_inventory_v1.model( - "ResourceListPagenationDto", - { - 'count': fields.Integer(), - 'page_num': fields.Integer(), - 'results': fields.List(fields.Nested(resource_list)) - } + # 'elements': fields.String, + # 'extensions': fields.String + 'extensions': Json2Dict(attribute='extensions') + # 'extensions': fields.Raw(attribute='extensions') + }, + mask='{resourceId,resourcePoolId,resourceTypeId,description,parentId}' ) - # 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, description='Resource ID'), 'resourceTypeId': fields.String, 'resourcePoolId': fields.String, - 'name': fields.String, + 'globalAssetId': fields.String, + # 'name': fields.String, 'parentId': fields.String, 'description': fields.String, - 'elements': fields.String, + # 'elements': fields.String, + # 'extensions': fields.String + 'extensions': Json2Dict(attribute='extensions') + # 'extensions': fields.Raw(attribute='extensions') } if iteration_number: - resource_json_mapping['children'] = fields.List( + resource_json_mapping['elements'] = fields.List( fields.Nested(ResourceDTO.recursive_resource_mapping( - iteration_number-1))) + iteration_number-1)), attribute='children') 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, - # '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())) - # } - # ) + 'ResourceGetDto' + str(iteration_number), resource_json_mapping, + mask='{resourceId,resourcePoolId,resourceTypeId,description,' + + 'parentId}') class DeploymentManagerDTO: @@ -179,30 +212,41 @@ class DeploymentManagerDTO: description='Deployment manager ID'), 'name': fields.String, 'description': fields.String, - 'deploymentManagementServiceEndpoint': fields.String, - 'supportedLocations': fields.String, - 'capabilities': fields.String, - 'capacity': fields.String, + 'oCloudId': fields.String, + 'serviceUri': fields.String(attribute='serviceUri'), + # 'deploymentManagementServiceEndpoint': fields.String( + # attribute='serviceUri'), + # 'supportedLocations': fields.String, + # 'capabilities': fields.String, + # 'capacity': fields.String, 'profileSupportList': fields.List( fields.String, description='Profile support list, use default for the return \ endpoint'), - } + 'extensions': fields.String + }, + mask='{deploymentManagerId,name,description,oCloudId,serviceUri,' + \ + 'profileSupportList}' ) 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') + attribute='cluster_api_endpoint'), + 'cluster_ca_cert': fields.String(attribute='cluster_ca_cert'), + 'admin_user': fields.String(attribute='admin_user'), + 'admin_client_cert': fields.String(attribute='admin_client_cert'), + 'admin_client_key': fields.String(attribute='admin_client_key'), + # 'kube_config_file': fields.String(attribute='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'), + attribute='helmcli_host_with_port'), + 'helmcli_username': fields.String(attribute='helmcli_username'), + 'helmcli_password': fields.String(attribute='helmcli_password'), + 'helmcli_kubeconfig': fields.String(attribute='helmcli_kubeconfig'), + }) + + extensions = api_ims_inventory_v1.model("DeploymentManagerExtensions", { + 'profileName': fields.String, + 'profileData': fields.Nested(profile, False, True), }) deployment_manager_get = api_ims_inventory_v1.model( @@ -213,13 +257,17 @@ class DeploymentManagerDTO: description='Deployment manager ID'), 'name': fields.String, 'description': fields.String, - 'deploymentManagementServiceEndpoint': fields.String, - 'supportedLocations': fields.String, - 'capabilities': fields.String, - 'capacity': fields.String, - 'profileName': fields.String, - 'profileData': fields.Nested(profile, False, True), - } + 'oCloudId': fields.String, + 'serviceUri': fields.String(attribute='serviceUri'), + # 'deploymentManagementServiceEndpoint': fields.String( + # attribute='serviceUri'), + # 'supportedLocations': fields.String, + # 'capabilities': fields.String, + # 'capacity': fields.String, + 'extensions': fields.Nested(extensions, True, True) + }, + mask='{deploymentManagerId,name,description,oCloudId,serviceUri,' +\ + 'extensions/profileName,extensions/profileData}' ) @@ -233,10 +281,11 @@ class SubscriptionDTO: 'callback': fields.String, 'consumerSubscriptionId': fields.String, 'filter': fields.String, - } + }, + mask='{subscriptionId,callback}' ) - subscription = api_ims_inventory_v1.model( + subscription_create = api_ims_inventory_v1.model( "SubscriptionCreateDto", { 'callback': fields.String( @@ -245,11 +294,3 @@ class SubscriptionDTO: 'filter': fields.String, } ) - - subscription_post_resp = api_ims_inventory_v1.model( - "SubscriptionCreatedRespDto", - { - 'subscriptionId': fields.String(required=True, - description='Subscription ID'), - } - )