Feature 10509 manual scaling for native k8s charm

Also includes improvements for scale function

Change-Id: I23f51b8c1b219681841d0b1f7f4db3a0d9ed4c7b
Signed-off-by: aktas <emin.aktas@ulakhaberlesme.com.tr>
diff --git a/osm_lcm/data_utils/nsr.py b/osm_lcm/data_utils/nsr.py
index f62b0b4..006713c 100644
--- a/osm_lcm/data_utils/nsr.py
+++ b/osm_lcm/data_utils/nsr.py
@@ -22,6 +22,20 @@
 # contact: fbravo@whitestack.com
 ##
 
+from osm_lcm.lcm_utils import get_iterable
+
 
 def get_vlds(nsr):
     return nsr.get("vld", ())
+
+
+def get_deployed_kdu(nsr_deployed, kdu_name, member_vnf_index):
+    deployed_kdu = None
+    index = None
+    for index, deployed_kdu in enumerate(get_iterable(nsr_deployed, "K8s")):
+        if (
+            kdu_name == deployed_kdu["kdu-name"]
+            and deployed_kdu["member-vnf-index"] == member_vnf_index
+        ):
+            break
+    return deployed_kdu, index
diff --git a/osm_lcm/data_utils/vnfd.py b/osm_lcm/data_utils/vnfd.py
index 5351c41..17a98a9 100644
--- a/osm_lcm/data_utils/vnfd.py
+++ b/osm_lcm/data_utils/vnfd.py
@@ -101,6 +101,13 @@
     )
 
 
+def get_kdu_profile(vnfd, kdu_profile_id):
+    return list_utils.find_in_list(
+        vnfd.get("df", ())[0]["kdu-resource-profile"],
+        lambda kdu_profile: kdu_profile["id"] == kdu_profile_id,
+    )
+
+
 def get_configuration(vnfd, entity_id):
     lcm_ops_config = vnfd.get("df")[0].get("lcm-operations-configuration")
     if not lcm_ops_config:
diff --git a/osm_lcm/data_utils/vnfr.py b/osm_lcm/data_utils/vnfr.py
index 7e4d164..fe98102 100644
--- a/osm_lcm/data_utils/vnfr.py
+++ b/osm_lcm/data_utils/vnfr.py
@@ -69,3 +69,11 @@
         return len([x for x in vdur_list if x.get("vdu-id-ref") == vdu_delta["id"]])
     else:
         return 0
+
+
+def get_kdur(db_vnfr, kdu_name):
+    kdur_list = get_iterable(db_vnfr, "kdur")
+    if kdur_list:
+        return next(x for x in kdur_list if x.get("kdu-name") == kdu_name)
+    else:
+        return None