Feature 5945 Adding WIM to LCM
[osm/LCM.git] / osm_lcm / lcm.py
index ef5fefa..5681683 100644 (file)
@@ -1,6 +1,22 @@
 #!/usr/bin/python3
 # -*- coding: utf-8 -*-
 
+##
+# Copyright 2018 Telefonica S.A.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+##
+
 import asyncio
 import yaml
 import logging
@@ -24,12 +40,12 @@ from n2vc import version as n2vc_version
 
 
 __author__ = "Alfonso Tierno"
-min_RO_version = [0, 5, 84]
+min_RO_version = [0, 6, 0]
 min_n2vc_version = "0.0.2"
 min_common_version = "0.1.11"
 # uncomment if LCM is installed as library and installed, and get them from __init__.py
-lcm_version = '0.1.26'
-lcm_version_date = '2018-11-27'
+lcm_version = '0.1.28'
+lcm_version_date = '2018-11-29'
 
 
 class Lcm:
@@ -146,6 +162,7 @@ class Lcm:
         self.netslice = netslice.NetsliceLcm(self.db, self.msg, self.fs, self.lcm_tasks, self.ro_config, 
                                              self.vca_config, self.loop)
         self.vim = vim_sdn.VimLcm(self.db, self.msg, self.fs, self.lcm_tasks, self.ro_config, self.loop)
+        self.wim = vim_sdn.WimLcm(self.db, self.msg, self.fs, self.lcm_tasks, self.ro_config, self.loop)
         self.sdn = vim_sdn.SdnLcm(self.db, self.msg, self.fs, self.lcm_tasks, self.ro_config, self.loop)
 
     async def check_RO_version(self):
@@ -204,7 +221,7 @@ class Lcm:
         first_start = True
         while consecutive_errors < 10:
             try:
-                topics = ("admin", "ns", "vim_account", "sdn", "nsi")
+                topics = ("admin", "ns", "vim_account", "wim_account", "sdn", "nsi")
                 topic, command, params = await self.msg.aioread(topics, self.loop)
                 if topic != "admin" and command != "ping":
                     self.logger.debug("Task kafka_read receives {} {}: {}".format(topic, command, params))
@@ -332,6 +349,25 @@ class Lcm:
                         task = asyncio.ensure_future(self.vim.edit(params, order_id))
                         self.lcm_tasks.register("vim_account", vim_id, order_id, "vim_edit", task)
                         continue
+                elif topic == "wim_account":
+                    wim_id = params["_id"]
+                    if command == "create":
+                        task = asyncio.ensure_future(self.wim.create(params, order_id))
+                        self.lcm_tasks.register("wim_account", wim_id, order_id, "wim_create", task)
+                        continue
+                    elif command == "delete":
+                        self.lcm_tasks.cancel(topic, wim_id)
+                        task = asyncio.ensure_future(self.wim.delete(wim_id, order_id))
+                        self.lcm_tasks.register("wim_account", wim_id, order_id, "wim_delete", task)
+                        continue
+                    elif command == "show":
+                        print("not implemented show with wim_account")
+                        sys.stdout.flush()
+                        continue
+                    elif command == "edit":
+                        task = asyncio.ensure_future(self.wim.edit(params, order_id))
+                        self.lcm_tasks.register("wim_account", wim_id, order_id, "wim_edit", task)
+                        continue
                 elif topic == "sdn":
                     _sdn_id = params["_id"]
                     if command == "create":