Fix INF-378 inventory subscription filter not take effect as expected
[pti/o2.git] / o2ims / domain / ocloud.py
index a8e7c2f..eb4f34b 100644 (file)
 from __future__ import annotations
 import json
 
+from o2common.config import config
 from o2common.domain.base import AgRoot, Serializer
-from o2common.config import conf as CONF
 # from dataclasses import dataclass
 # from datetime import date
 # from typing import Optional, List, Set
 from .resource_type import ResourceKindEnum, ResourceTypeEnum
-# from uuid import UUID
+from .alarm_obj import AlarmDictionary
 
 
-DeploymentManagerProfileDefault = 'default'
+DeploymentManagerProfileDefault = 'native_k8sapi'
 DeploymentManagerProfileSOL018 = 'sol018'
 DeploymentManagerProfileSOL018HelmCLI = 'sol018_helmcli'
 
@@ -55,9 +55,13 @@ class DeploymentManager(AgRoot, Serializer):
             d['profile'] = json.loads(d['profile'])
         d['profileSupportList'] = [
             DeploymentManagerProfileDefault,
-            DeploymentManagerProfileSOL018,
-            DeploymentManagerProfileSOL018HelmCLI,
         ]
+        profiles = config.get_dms_support_profiles()
+        for profile in profiles:
+            if profile == DeploymentManagerProfileSOL018:
+                d['profileSupportList'].append(profile)
+            elif profile == DeploymentManagerProfileSOL018HelmCLI:
+                d['profileSupportList'].append(profile)
 
         return d
 
@@ -81,7 +85,7 @@ class ResourcePool(AgRoot, Serializer):
 
 class ResourceType(AgRoot, Serializer):
     def __init__(self, typeid: str, name: str, typeEnum: ResourceTypeEnum,
-                 ocloudid: str, vender: str = '', model: str = '',
+                 vendor: str = '', model: str = '',
                  version: str = '',
                  description: str = '') -> None:
         super().__init__()
@@ -89,10 +93,10 @@ 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 = {}
+        self.alarmDictionary = None
         self.resourceKind = ResourceKindEnum.UNDEFINED
         self.resourceClass = ResourceTypeEnum.UNDEFINED
         self.extensions = []
@@ -101,17 +105,17 @@ class ResourceType(AgRoot, Serializer):
 
     def serialize(self):
         d = Serializer.serialize(self)
-
-        d["alarmDictionary"] = CONF.alarm_dictionaries.get(
-            d['name']).serialize()
+        if 'alarmDictionary' in d and \
+                type(d['alarmDictionary']) is AlarmDictionary:
+            d['alarmDictionary'] = d['alarmDictionary'].serialize()
         return d
 
 
 class Resource(AgRoot, Serializer):
     def __init__(self, resourceId: str, resourceTypeId: str,
-                 resourcePoolId: str, name: str, parentId: str = '',
+                 resourcePoolId: str, parentId: str = '',
                  gAssetId: str = '', elements: str = '',
-                 description: str = '') -> None:
+                 description: str = '', extensions: str = '') -> None:
         super().__init__()
         self.resourceId = resourceId
         self.description = description
@@ -119,9 +123,8 @@ class Resource(AgRoot, Serializer):
         self.globalAssetId = gAssetId
         self.resourcePoolId = resourcePoolId
         self.elements = elements
-        self.extensions = []
+        self.extensions = extensions
 
-        self.name = name
         self.parentId = parentId
         self.children = []