X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2Fdata_utils%2Fvim.py;h=15ca93fdfc530d73a460b75d21e62f96485216e9;hb=refs%2Fchanges%2F33%2F11733%2F3;hp=0e695728500d168377573d1a20fc90483d30da7a;hpb=064c6440a6cb76be6ca5a84d6fdd11e9f3f7db1a;p=osm%2FLCM.git diff --git a/osm_lcm/data_utils/vim.py b/osm_lcm/data_utils/vim.py index 0e69572..15ca93f 100644 --- a/osm_lcm/data_utils/vim.py +++ b/osm_lcm/data_utils/vim.py @@ -21,3 +21,29 @@ # For those usages not covered by the Apache License, Version 2.0 please # contact: fbravo@whitestack.com ## + +from osm_lcm.data_utils.database.vim_account import VimAccountDB + +__author__ = ( + "Lluis Gifre , Ricard Vilalta " +) + + +def get_vims_to_connect(db_nsr, db_vnfrs, target_vld): + vims_to_connect = set() + vld = next( + (vld for vld in db_nsr["vld"] if vld["id"] == target_vld["id"]), + None, + ) + if vld is None: + return vims_to_connect # VLD not in NS, means it is an internal VLD within a single VIM + # iterate over VNFs and retrieve name of VIMs they are planned to be deployed to + for vld_member_vnf_index_ref in vld["vnfd-connection-point-ref"]: + vld_member_vnf_index_ref = vld_member_vnf_index_ref["member-vnf-index-ref"] + db_vim = VimAccountDB.get_vim_account_with_id( + db_vnfrs[vld_member_vnf_index_ref]["vim-account-id"] + ) + if db_vim is None: + continue + vims_to_connect.add(db_vim["name"]) + return vims_to_connect