Bug 585 Fix for scaling
[osm/LCM.git] / osm_lcm / data_utils / vnfr.py
index 042788e..9c0b148 100644 (file)
@@ -23,6 +23,7 @@
 ##
 
 from osm_lcm.data_utils import list_utils
+from osm_lcm.lcm_utils import get_iterable
 
 
 def find_VNFR_by_VDU_ID(vnfr, vdu_id):
@@ -57,3 +58,11 @@ def get_osm_params(db_vnfr, vdu_id=None, vdu_count_index=0):
             osm_params["vdu_id"] = vdu_id
             osm_params["count_index"] = vdu_count_index
     return osm_params
+
+
+def get_vdur_index(db_vnfr, vdu_delta):
+    vdur_list = get_iterable(db_vnfr, "vdur")
+    if vdur_list:
+        return len([x for x in vdur_list if x.get("vdu-id-ref") == vdu_delta["id"]])
+    else:
+        return 0