1 # Copyright (C) 2021 Wind River Systems, Inc.
\r
3 # Licensed under the Apache License, Version 2.0 (the "License");
\r
4 # you may not use this file except in compliance with the License.
\r
5 # You may obtain a copy of the License at
\r
7 # http://www.apache.org/licenses/LICENSE-2.0
\r
9 # Unless required by applicable law or agreed to in writing, software
\r
10 # distributed under the License is distributed on an "AS IS" BASIS,
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 # See the License for the specific language governing permissions and
\r
13 # limitations under the License.
\r
15 from __future__ import annotations
\r
17 from o2ims.domain.base import AgRoot
\r
18 # from dataclasses import dataclass
\r
19 # from datetime import date
\r
20 # from typing import Optional, List, Set
\r
21 from .resource_type import ResourceTypeEnum
\r
22 # from uuid import UUID
\r
25 class Subscription(AgRoot):
\r
26 def __init__(self, id: str, callback: str, consumersubid: str = '',
\r
27 filter: str = '') -> None:
\r
28 self.subscriptionId = id
\r
29 self.version_number = 0
\r
30 self.callback = callback
\r
31 self.consumerSubscriptionId = consumersubid
\r
32 self.filter = filter
\r
35 class DeploymentManager:
\r
36 def __init__(self, id: str, name: str, ocloudid: str,
\r
37 dmsendpoint: str, description: str = '',
\r
38 supportedLocations: str = '', capabilities: str = '',
\r
39 capacity: str = '') -> None:
\r
40 self.deploymentManagerId = id
\r
41 self.version_number = 0
\r
42 self.oCloudId = ocloudid
\r
44 self.description = description
\r
45 self.deploymentManagementServiceEndpoint = dmsendpoint
\r
46 self.supportedLocations = supportedLocations
\r
47 self.capabilities = capabilities
\r
48 self.capacity = capacity
\r
49 self.extensions = []
\r
52 class ResourcePool(AgRoot):
\r
53 def __init__(self, id: str, name: str, location: str,
\r
54 ocloudid: str, gLocationId: str = '',
\r
55 description: str = '') -> None:
\r
56 self.resourcePoolId = id
\r
57 self.version_number = 0
\r
58 self.oCloudId = ocloudid
\r
59 self.globalLocationId = gLocationId
\r
61 self.location = location
\r
62 self.description = description
\r
63 self.extensions = []
\r
66 class ResourceType(AgRoot):
\r
67 def __init__(self, typeid: str, name: str, typeEnum: ResourceTypeEnum,
\r
68 ocloudid: str, vender: str = '', model: str = '',
\r
70 description: str = '') -> None:
\r
71 self.resourceTypeId = typeid
\r
72 self.oCloudId = ocloudid
\r
73 self.resourceTypeEnum = typeEnum.value
\r
75 self.vender = vender
\r
77 self.version = version
\r
78 self.description = description
\r
79 self.extensions = []
\r
82 class Resource(AgRoot):
\r
83 def __init__(self, resourceId: str, resourceTypeId: str,
\r
84 resourcePoolId: str, oCloudId: str = '',
\r
85 parentId: str = '', elements: list = [],
\r
86 description: str = '') -> None:
\r
87 self.resourceId = resourceId
\r
88 self.version_number = 0
\r
89 self.oCloudId = oCloudId
\r
90 self.resourceTypeId = resourceTypeId
\r
91 self.resourcePoolId = resourcePoolId
\r
92 self.parentId = parentId
\r
93 self.elements = elements
\r
94 self.description = description
\r
95 self.extensions = []
\r
98 class Ocloud(AgRoot):
\r
99 def __init__(self, ocloudid: str, name: str, imsendpoint: str,
\r
100 globalcloudId: str = '',
\r
101 description: str = '', version_number: int = 0) -> None:
\r
103 self.oCloudId = ocloudid
\r
104 self.globalcloudId = globalcloudId
\r
105 self.version_number = version_number
\r
107 self.description = description
\r
108 self.infrastructureManagementServiceEndpoint = imsendpoint
\r
109 self.resourcePools = []
\r
110 self.deploymentManagers = []
\r
111 self.resourceTypes = []
\r
112 self.extensions = []
\r
115 def addDeploymentManager(self,
\r
116 deploymentManager: DeploymentManager):
\r
118 deploymentManager.oCloudId = self.oCloudId
\r
120 lambda x: x.deploymentManagerId ==
\r
121 deploymentManager.deploymentManagerId,
\r
122 self.deploymentManagers)
\r
123 for o in old or []:
\r
124 self.deploymentManagers.remove(o)
\r
125 self.deploymentManagers.append(deploymentManager)
\r