Update model of resourcetype and set empty for the gLocationId of the resourcepool... 35/9435/1
authorZhang Rong(Jon) <rong.zhang@windriver.com>
Mon, 31 Oct 2022 08:17:18 +0000 (16:17 +0800)
committerZhang Rong(Jon) <rong.zhang@windriver.com>
Mon, 31 Oct 2022 08:17:18 +0000 (16:17 +0800)
Issue-ID: INF-306
Issue-ID: INF-310
Signed-off-by: Zhang Rong(Jon) <rong.zhang@windriver.com>
Change-Id: Idd6440943db07edc3719ae89f4f54a243271e956

12 files changed:
configs/o2app.conf
docs/installation-guide.rst
o2ims/domain/ocloud.py
o2ims/service/auditor/alarm_handler.py
o2ims/service/auditor/pserver_cpu_handler.py
o2ims/service/auditor/pserver_eth_handler.py
o2ims/service/auditor/pserver_handler.py
o2ims/service/auditor/pserver_if_handler.py
o2ims/service/auditor/pserver_mem_handler.py
o2ims/service/auditor/pserver_port_handler.py
o2ims/service/auditor/resourcepool_handler.py
o2ims/service/command/registration_handler.py

index 036ad09..8957236 100644 (file)
@@ -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]
 
index 1e0a465..af661a9 100644 (file)
@@ -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]
 
index a8e7c2f..a2047af 100644 (file)
@@ -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 = {}
index 8917264..2bd2681 100644 (file)
@@ -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
index 6364226..3e965b7 100644 (file)
@@ -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)
index 5731618..65e48a4 100644 (file)
@@ -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)
index 884f276..4d9da9c 100644 (file)
@@ -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)
index 94602f7..481c055 100644 (file)
@@ -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)
index 388f041..2a0ba73 100644 (file)
@@ -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)
index bfec06f..f911c2d 100644 (file)
@@ -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)
index b5b0e0d..1fb2458 100644 (file)
@@ -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
index 8561c29..0c6bbef 100644 (file)
@@ -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