Coverity CWE 330: Use of Insufficiently Random Values
[osm/RO.git] / RO-plugin / osm_ro_plugin / vim_dummy.py
index 6c59607..dc0e00e 100644 (file)
@@ -22,7 +22,7 @@ Implements a Dummy vim plugin.
 
 from copy import deepcopy
 import logging
-from random import randrange
+from random import SystemRandom
 from uuid import uuid4
 
 from osm_ro_plugin import vimconn
@@ -379,8 +379,10 @@ class VimDummyConnector(vimconn.VimConnector):
             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(
+                compute_index = SystemRandom().randrange(
+                    len(self.config["sdn-port-mapping"])
+                )
+                port_index = SystemRandom().randrange(
                     len(self.config["sdn-port-mapping"][compute_index]["ports"])
                 )
                 interface["compute_node"] = self.config["sdn-port-mapping"][
@@ -424,7 +426,7 @@ class VimDummyConnector(vimconn.VimConnector):
 
         return self.vms[vm_id]
 
-    def delete_vminstance(self, vm_id, created_items=None):
+    def delete_vminstance(self, vm_id, created_items=None, volumes_to_hold=None):
         if vm_id not in self.vms:
             raise vimconn.VimConnNotFoundException(
                 "vm with id {} not found".format(vm_id)