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 sqlalchemy import (
\r
28 from sqlalchemy.orm import mapper, relationship
\r
29 # from sqlalchemy.sql.sqltypes import Integer
\r
31 from o2ims.domain import ocloud as ocloudModel
\r
33 from o2common.helper import o2logging
\r
34 logger = o2logging.get_logger(__name__)
\r
36 metadata = MetaData()
\r
41 Column("updatetime", DateTime),
\r
42 Column("createtime", DateTime),
\r
43 Column("hash", String(255)),
\r
44 Column("version_number", Integer),
\r
46 Column("oCloudId", String(255), primary_key=True),
\r
47 Column("globalcloudId", String(255)),
\r
48 Column("name", String(255)),
\r
49 Column("description", String(255)),
\r
50 Column("infrastructureManagementServiceEndpoint", String(255))
\r
51 # Column("extensions", String(1024))
\r
54 resourcetype = Table(
\r
57 Column("updatetime", DateTime),
\r
58 Column("createtime", DateTime),
\r
59 Column("hash", String(255)),
\r
61 Column("resourceTypeId", String(255), primary_key=True),
\r
62 Column("oCloudId", ForeignKey("ocloud.oCloudId")),
\r
63 Column("name", String(255)),
\r
64 Column("vendor", String(255)),
\r
65 Column("model", String(255)),
\r
66 Column("version", String(255)),
\r
67 Column("description", String(255)),
\r
68 # Column("extensions", String(1024))
\r
71 resourcepool = Table(
\r
74 Column("updatetime", DateTime),
\r
75 Column("createtime", DateTime),
\r
76 Column("hash", String(255)),
\r
77 Column("version_number", Integer),
\r
79 Column("resourcePoolId", String(255), primary_key=True),
\r
80 Column("oCloudId", ForeignKey("ocloud.oCloudId")),
\r
81 Column("globalLocationId", String(255)),
\r
82 Column("name", String(255)),
\r
83 Column("location", String(255)),
\r
84 Column("description", String(255)),
\r
85 # Column("resources", String(1024))
\r
86 # Column("extensions", String(1024))
\r
92 Column("updatetime", DateTime),
\r
93 Column("createtime", DateTime),
\r
94 Column("hash", String(255)),
\r
95 Column("version_number", Integer),
\r
97 Column("resourceId", String(255), primary_key=True),
\r
98 Column("resourceTypeId", ForeignKey("resourcetype.resourceTypeId")),
\r
99 Column("resourcePoolId", ForeignKey("resourcepool.resourcePoolId")),
\r
100 # Column("globalAssetId", String(255)),
\r
101 # Column("oCloudId", ForeignKey("ocloud.oCloudId")),
\r
102 Column("parentId", String(255)),
\r
103 Column("description", String(255)),
\r
104 # Column("elements", String(255))
\r
105 # Column("extensions", String(1024))
\r
108 deploymentmanager = Table(
\r
109 "deploymentmanager",
\r
111 Column("updatetime", DateTime),
\r
112 Column("createtime", DateTime),
\r
113 Column("hash", String(255)),
\r
115 Column("deploymentManagerId", String(255), primary_key=True),
\r
116 Column("oCloudId", ForeignKey("ocloud.oCloudId")),
\r
117 Column("name", String(255)),
\r
118 Column("description", String(255)),
\r
119 Column("deploymentManagementServiceEndpoint", String(255)),
\r
120 Column("supportedLocations", String(255)),
\r
121 Column("capabilities", String(255)),
\r
122 Column("capacity", String(255)),
\r
123 # Column("extensions", String(1024))
\r
126 subscription = Table(
\r
129 Column("updatetime", DateTime),
\r
130 Column("createtime", DateTime),
\r
131 Column("hash", String(255)),
\r
132 Column("version_number", Integer),
\r
134 Column("subscriptionId", String(255), primary_key=True),
\r
135 Column("callback", String(255)),
\r
136 Column("consumerSubscriptionId", String(255)),
\r
137 Column("filter", String(255)),
\r
141 def start_o2ims_mappers(engine=None):
\r
142 logger.info("Starting O2 IMS mappers")
\r
144 dm_mapper = mapper(ocloudModel.DeploymentManager, deploymentmanager)
\r
145 resourcepool_mapper = mapper(ocloudModel.ResourcePool, resourcepool)
\r
146 resourcetype_mapper = mapper(ocloudModel.ResourceType, resourcetype)
\r
148 ocloudModel.Ocloud,
\r
151 "deploymentManagers": relationship(dm_mapper),
\r
152 "resourceTypes": relationship(resourcetype_mapper),
\r
153 "resourcePools": relationship(resourcepool_mapper)
\r
156 ocloudModel.Resource,
\r
159 "resourceTypes": relationship(resourcetype_mapper),
\r
160 "resourcePools": relationship(resourcepool_mapper)
\r
163 mapper(ocloudModel.Subscription, subscription)
\r
165 if engine is not None:
\r
166 metadata.create_all(engine)
\r