From: Zhang Rong(Jon) Date: Mon, 31 Oct 2022 08:17:18 +0000 (+0800) Subject: Update model of resourcetype and set empty for the gLocationId of the resourcepool... X-Git-Tag: 2.0.0-rc1~14 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=c34ab47848138150a1456be2fa9f82d7260e37b8;p=pti%2Fo2.git Update model of resourcetype and set empty for the gLocationId of the resourcepool;bug fix Issue-ID: INF-306 Issue-ID: INF-310 Signed-off-by: Zhang Rong(Jon) Change-Id: Idd6440943db07edc3719ae89f4f54a243271e956 --- diff --git a/configs/o2app.conf b/configs/o2app.conf index 036ad09..8957236 100644 --- a/configs/o2app.conf +++ b/configs/o2app.conf @@ -1,12 +1,11 @@ [DEFAULT] ocloud_global_id = 4e24b97c-8c49-4c4f-b53e-3de5235a4e37 + smo_register_url = http://127.0.0.1:8090/register smo_token_data = smo_token_payload - [API] -test = "hello" [WATCHER] diff --git a/docs/installation-guide.rst b/docs/installation-guide.rst index 1e0a465..af661a9 100644 --- a/docs/installation-guide.rst +++ b/docs/installation-guide.rst @@ -186,11 +186,11 @@ The following instruction should be done outside of INF platform controller host [DEFAULT] ocloud_global_id = 4e24b97c-8c49-4c4f-b53e-3de5235a4e37 + smo_register_url = http://127.0.0.1:8090/register smo_token_data = ${SMO_TOKEN_DATA} [API] - test = "hello" [WATCHER] diff --git a/o2ims/domain/ocloud.py b/o2ims/domain/ocloud.py index a8e7c2f..a2047af 100644 --- a/o2ims/domain/ocloud.py +++ b/o2ims/domain/ocloud.py @@ -81,7 +81,7 @@ class ResourcePool(AgRoot, Serializer): class ResourceType(AgRoot, Serializer): def __init__(self, typeid: str, name: str, typeEnum: ResourceTypeEnum, - ocloudid: str, vender: str = '', model: str = '', + ocloudid: str, vendor: str = '', model: str = '', version: str = '', description: str = '') -> None: super().__init__() @@ -89,7 +89,7 @@ class ResourceType(AgRoot, Serializer): self.resourceTypeEnum = typeEnum self.name = name self.description = description - self.vender = vender + self.vendor = vendor self.model = model self.version = version self.alarmDictionary = {} diff --git a/o2ims/service/auditor/alarm_handler.py b/o2ims/service/auditor/alarm_handler.py index 8917264..2bd2681 100644 --- a/o2ims/service/auditor/alarm_handler.py +++ b/o2ims/service/auditor/alarm_handler.py @@ -37,8 +37,6 @@ def update_alarm( + " id: " + str(fmobj.id) + " hash: " + str(fmobj.hash)) with uow: - logger.debug('+++test alarm dict:' + - str(len(uow.alarm_dictionaries.list()))) alarm_event_record = uow.alarm_event_records.get(fmobj.id) if not alarm_event_record: logger.info("add alarm event record:" + fmobj.name diff --git a/o2ims/service/auditor/pserver_cpu_handler.py b/o2ims/service/auditor/pserver_cpu_handler.py index 6364226..3e965b7 100644 --- a/o2ims/service/auditor/pserver_cpu_handler.py +++ b/o2ims/service/auditor/pserver_cpu_handler.py @@ -51,11 +51,14 @@ def update_pserver_cpu( ) first = res.first() if first is None: - resourcetype_id = str(uuid.uuid4()) + res_type_name = 'pserver_cpu' + resourcetype_id = str(uuid.uuid3( + uuid.NAMESPACE_URL, res_type_name)) uow.resource_types.add(ResourceType( resourcetype_id, - 'pserver_cpu', stxobj.type, - resourcepool.oCloudId)) + res_type_name, stxobj.type, + resourcepool.oCloudId, + description='A CPU resource type of the Physical Server')) else: resourcetype_id = first['resourceTypeId'] @@ -96,7 +99,7 @@ def create_by(stxobj: StxGenericModel, parent: Resource, resourcetype_id: str)\ resourcepool_id = parent.resourcePoolId parent_id = parent.resourceId gAssetId = '' # TODO: global ID - description = "A CPU resource of the physical server" + description = "%s : A CPU resource of the physical server" % stxobj.name resource = Resource(stxobj.id, resourcetype_id, resourcepool_id, stxobj.name, parent_id, gAssetId, stxobj.content, description) diff --git a/o2ims/service/auditor/pserver_eth_handler.py b/o2ims/service/auditor/pserver_eth_handler.py index 5731618..65e48a4 100644 --- a/o2ims/service/auditor/pserver_eth_handler.py +++ b/o2ims/service/auditor/pserver_eth_handler.py @@ -51,11 +51,14 @@ def update_pserver_eth( ) first = res.first() if first is None: - resourcetype_id = str(uuid.uuid4()) + res_type_name = 'pserver_ethernet' + resourcetype_id = str(uuid.uuid3( + uuid.NAMESPACE_URL, res_type_name)) uow.resource_types.add(ResourceType( resourcetype_id, - 'pserver_ethernet', stxobj.type, - resourcepool.oCloudId)) + res_type_name, stxobj.type, + resourcepool.oCloudId, + description='An Ethernet resource type of Physical Server')) else: resourcetype_id = first['resourceTypeId'] @@ -96,7 +99,8 @@ def create_by(stxobj: StxGenericModel, parent: Resource, resourcetype_id: str)\ resourcepool_id = parent.resourcePoolId parent_id = parent.resourceId gAssetId = '' # TODO: global ID - description = "An ethernet resource of the physical server" + description = "%s : An ethernet resource of the physical server"\ + % stxobj.name resource = Resource(stxobj.id, resourcetype_id, resourcepool_id, stxobj.name, parent_id, gAssetId, stxobj.content, description) diff --git a/o2ims/service/auditor/pserver_handler.py b/o2ims/service/auditor/pserver_handler.py index 884f276..4d9da9c 100644 --- a/o2ims/service/auditor/pserver_handler.py +++ b/o2ims/service/auditor/pserver_handler.py @@ -54,11 +54,14 @@ def update_pserver( ) first = res.first() if first is None: - resourcetype_id = str(uuid.uuid4()) + res_type_name = 'pserver' + resourcetype_id = str(uuid.uuid3( + uuid.NAMESPACE_URL, res_type_name)) uow.resource_types.add(ResourceType( resourcetype_id, - 'pserver', stxobj.type, - resourcepool.oCloudId)) + res_type_name, stxobj.type, + resourcepool.oCloudId, + description='The Physical Server resource type')) else: resourcetype_id = first['resourceTypeId'] @@ -99,7 +102,7 @@ def create_by(stxobj: StxGenericModel, parentid: str, resourcetype_id: str) \ resourcepool_id = parentid parent_id = None # the root of the resource has no parent id gAssetId = '' # TODO: global ID - description = "A physical server resource" + description = "%s : A physical server resource" % stxobj.name resource = Resource(stxobj.id, resourcetype_id, resourcepool_id, stxobj.name, parent_id, gAssetId, stxobj.content, description) diff --git a/o2ims/service/auditor/pserver_if_handler.py b/o2ims/service/auditor/pserver_if_handler.py index 94602f7..481c055 100644 --- a/o2ims/service/auditor/pserver_if_handler.py +++ b/o2ims/service/auditor/pserver_if_handler.py @@ -51,11 +51,14 @@ def update_pserver_if( ) first = res.first() if first is None: - resourcetype_id = str(uuid.uuid4()) + res_type_name = 'pserver_if' + resourcetype_id = str(uuid.uuid3( + uuid.NAMESPACE_URL, res_type_name)) uow.resource_types.add(ResourceType( resourcetype_id, - 'pserver_if', stxobj.type, - resourcepool.oCloudId)) + res_type_name, stxobj.type, + resourcepool.oCloudId, + description='An Interface resource type of Physical Server')) else: resourcetype_id = first['resourceTypeId'] @@ -96,7 +99,8 @@ def create_by(stxobj: StxGenericModel, parent: Resource, resourcetype_id: str)\ resourcepool_id = parent.resourcePoolId parent_id = parent.resourceId gAssetId = '' # TODO: global ID - description = "An interface resource of the physical server" + description = "%s : An interface resource of the physical server"\ + % stxobj.name resource = Resource(stxobj.id, resourcetype_id, resourcepool_id, stxobj.name, parent_id, gAssetId, stxobj.content, description) diff --git a/o2ims/service/auditor/pserver_mem_handler.py b/o2ims/service/auditor/pserver_mem_handler.py index 388f041..2a0ba73 100644 --- a/o2ims/service/auditor/pserver_mem_handler.py +++ b/o2ims/service/auditor/pserver_mem_handler.py @@ -56,6 +56,14 @@ def update_pserver_mem( resourcetype_id, 'pserver_mem', stxobj.type, resourcepool.oCloudId)) + res_type_name = 'pserver_mem' + resourcetype_id = str(uuid.uuid3( + uuid.NAMESPACE_URL, res_type_name)) + uow.resource_types.add(ResourceType( + resourcetype_id, + res_type_name, stxobj.type, + resourcepool.oCloudId, + description='A Memory resource type of Physical Server')) else: resourcetype_id = first['resourceTypeId'] @@ -96,7 +104,8 @@ def create_by(stxobj: StxGenericModel, parent: Resource, resourcetype_id: str)\ resourcepool_id = parent.resourcePoolId parent_id = parent.resourceId gAssetId = '' # TODO: global ID - description = "A memory resource of the physical server" + description = "%s : A memory resource of the physical server"\ + % stxobj.name resource = Resource(stxobj.id, resourcetype_id, resourcepool_id, stxobj.name, parent_id, gAssetId, stxobj.content, description) diff --git a/o2ims/service/auditor/pserver_port_handler.py b/o2ims/service/auditor/pserver_port_handler.py index bfec06f..f911c2d 100644 --- a/o2ims/service/auditor/pserver_port_handler.py +++ b/o2ims/service/auditor/pserver_port_handler.py @@ -56,6 +56,14 @@ def update_pserver_port( resourcetype_id, 'pserver_if_port', stxobj.type, resourcepool.oCloudId)) + res_type_name = 'pserver_if_port' + resourcetype_id = str(uuid.uuid3( + uuid.NAMESPACE_URL, res_type_name)) + uow.resource_types.add(ResourceType( + resourcetype_id, + res_type_name, stxobj.type, + resourcepool.oCloudId, + description='A Port resource type of Physical Server')) else: resourcetype_id = first['resourceTypeId'] @@ -96,7 +104,8 @@ def create_by(stxobj: StxGenericModel, parent: Resource, resourcetype_id: str)\ resourcepool_id = parent.resourcePoolId parent_id = parent.resourceId gAssetId = '' # TODO: global ID - description = "A port resource of the interface" + description = "%s : A port resource of the interface"\ + % stxobj.name resource = Resource(stxobj.id, resourcetype_id, resourcepool_id, stxobj.name, parent_id, gAssetId, stxobj.content, description) diff --git a/o2ims/service/auditor/resourcepool_handler.py b/o2ims/service/auditor/resourcepool_handler.py index b5b0e0d..1fb2458 100644 --- a/o2ims/service/auditor/resourcepool_handler.py +++ b/o2ims/service/auditor/resourcepool_handler.py @@ -75,11 +75,12 @@ def is_outdated(resourcepool: ResourcePool, stxobj: StxGenericModel): def create_by(stxobj: StxGenericModel, parentid: str) -> ResourcePool: content = json.loads(stxobj.content) - globalcloudId = stxobj.id # to be updated + globalLocationId = '' # to be updated description = "A Resource Pool" + location = content['location'] if content['location'] is not None else '' resourcepool = ResourcePool(stxobj.id, stxobj.name, - content['location'], - parentid, globalcloudId, description) + location, + parentid, globalLocationId, description) resourcepool.createtime = stxobj.createtime resourcepool.updatetime = stxobj.updatetime resourcepool.hash = stxobj.hash @@ -93,7 +94,8 @@ def update_by(target: ResourcePool, stxobj: StxGenericModel, raise MismatchedModel("Mismatched Id") content = json.loads(stxobj.content) target.name = stxobj.name - target.location = content['location'] + target.location = content['location'] if content['location'] is not None \ + else '' target.createtime = stxobj.createtime target.updatetime = stxobj.updatetime target.hash = stxobj.hash diff --git a/o2ims/service/command/registration_handler.py b/o2ims/service/command/registration_handler.py index 8561c29..0c6bbef 100644 --- a/o2ims/service/command/registration_handler.py +++ b/o2ims/service/command/registration_handler.py @@ -42,7 +42,7 @@ def registry_to_smo( ocloud = uow.oclouds.get(data.id) if ocloud is None: return - logger.debug('O-Cloud Global UUID: {}'.format(ocloud.globalcloudId)) + logger.debug('O-Cloud Global UUID: {}'.format(ocloud.globalCloudId)) ocloud_dict = ocloud.serialize() if data.notificationEventType == NotificationEventEnum.CREATE: register_smo(uow, ocloud_dict) @@ -79,7 +79,7 @@ def call_smo(reg_data: dict): } callback_data = json.dumps({ - 'globalCloudId': reg_data['globalcloudId'], + 'globalCloudId': reg_data['globalCloudId'], 'oCloudId': reg_data['oCloudId'], 'IMS_EP': config.get_api_url(), 'smo_token_data': smo_token_info