Fixing bug 1437
[osm/RO.git] / RO-plugin / osm_ro_plugin / vim_dummy.py
index 3189239..22379b6 100644 (file)
@@ -25,6 +25,7 @@ from osm_ro_plugin import vimconn
 from uuid import uuid4
 from copy import deepcopy
 import logging
+from random import randrange
 
 __author__ = "Alfonso Tierno"
 __date__ = "2020-04-20"
@@ -40,7 +41,7 @@ class VimDummyConnector(vimconn.VimConnector):
                  config={}, persistent_info={}):
         super().__init__(uuid, name, tenant_id, tenant_name, url, url_admin, user, passwd, log_level,
                          config, persistent_info)
-        self.logger = logging.getLogger('openmano.vim.dummy')
+        self.logger = logging.getLogger('ro.vim.dummy')
         if log_level:
             self.logger.setLevel(getattr(logging, log_level))
         self.nets = {
@@ -248,6 +249,12 @@ class VimDummyConnector(vimconn.VimConnector):
                 "vim_interface_id": str(iface_index),
                 "vim_net_id": iface["net_id"],
             }
+            if iface.get("type") in ("SR-IOV", "PCI-PASSTHROUGH") and self.config.get("sdn-port-mapping"):
+                compute_index = randrange(len(self.config["sdn-port-mapping"]))
+                port_index = randrange(len(self.config["sdn-port-mapping"][compute_index]["ports"]))
+                interface["compute_node"] = self.config["sdn-port-mapping"][compute_index]["compute_node"]
+                interface["pci"] = self.config["sdn-port-mapping"][compute_index]["ports"][port_index]["pci"]
+
             interfaces.append(interface)
         vm = {
             "id": vm_id,