Add o2dms api endpoint
[pti/o2.git] / o2dms / adapter / orm.py
diff --git a/o2dms/adapter/orm.py b/o2dms/adapter/orm.py
new file mode 100644 (file)
index 0000000..7527515
--- /dev/null
@@ -0,0 +1,61 @@
+# Copyright (C) 2021 Wind River Systems, Inc.\r
+#\r
+#  Licensed under the Apache License, Version 2.0 (the "License");\r
+#  you may not use this file except in compliance with the License.\r
+#  You may obtain a copy of the License at\r
+#\r
+#      http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+#  Unless required by applicable law or agreed to in writing, software\r
+#  distributed under the License is distributed on an "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+#  See the License for the specific language governing permissions and\r
+#  limitations under the License.\r
+\r
+from sqlalchemy import (\r
+    Table,\r
+    MetaData,\r
+    Column,\r
+    Integer,\r
+    String,\r
+    # Date,\r
+    DateTime,\r
+    # ForeignKey,\r
+    # engine,\r
+    # event,\r
+)\r
+\r
+from sqlalchemy.orm import mapper\r
+from o2dms.domain import dms as dmsModel\r
+\r
+from o2common.helper import o2logging\r
+logger = o2logging.get_logger(__name__)\r
+\r
+metadata = MetaData()\r
+\r
+nfDeploymentDesc = Table(\r
+    "nfDeploymentDesc",\r
+    metadata,\r
+    Column("updatetime", DateTime),\r
+    Column("createtime", DateTime),\r
+    Column("hash", String(255)),\r
+    Column("version_number", Integer),\r
+\r
+    Column("id", String(255), primary_key=True),\r
+    Column("deploymentManagerId", String(255)),\r
+    Column("name", String(255)),\r
+    Column("description", String(255)),\r
+    Column("supportedLocations", String(255)),\r
+    Column("capabilities", String(255)),\r
+    Column("capacity", String(255)),\r
+    # Column("extensions", String(1024))\r
+)\r
+\r
+\r
+def start_o2dms_mappers(engine=None):\r
+    logger.info("Starting O2 DMS mappers")\r
+\r
+    mapper(dmsModel.NfDeploymentDesc, nfDeploymentDesc)\r
+\r
+    if engine is not None:\r
+        metadata.create_all(engine)\r