X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=RO-plugin%2Fosm_ro_plugin%2Fvim_dummy.py;h=dc0e00e9d747568587b582c7b9928a4c293d98e0;hb=51e72a0f7479b3064b4b11891eb524d42f4738b0;hp=c00071f896ef1fd79e9dee81ade5639758d705c3;hpb=80135b928ab442c38898750b4751480205b4affc;p=osm%2FRO.git diff --git a/RO-plugin/osm_ro_plugin/vim_dummy.py b/RO-plugin/osm_ro_plugin/vim_dummy.py index c00071f8..dc0e00e9 100644 --- a/RO-plugin/osm_ro_plugin/vim_dummy.py +++ b/RO-plugin/osm_ro_plugin/vim_dummy.py @@ -20,12 +20,14 @@ Implements a Dummy vim plugin. """ -import yaml -from osm_ro_plugin import vimconn -from uuid import uuid4 from copy import deepcopy import logging -from random import randrange +from random import SystemRandom +from uuid import uuid4 + +from osm_ro_plugin import vimconn +import yaml + __author__ = "Alfonso Tierno" __date__ = "2020-04-20" @@ -158,6 +160,11 @@ class VimDummyConnector(vimconn.VimConnector): nets.append(net) + # if no network is returned and search by name create a new one + if not nets and filter_dict and filter_dict.get("name"): + net_id, net = self.new_network(filter_dict.get("name"), "mgmt") + nets.append(net) + return nets def get_network(self, net_id): @@ -341,6 +348,7 @@ class VimDummyConnector(vimconn.VimConnector): start, image_id, flavor_id, + affinity_group_list, net_list, cloud_config=None, disk_list=None, @@ -371,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"][ @@ -416,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)