return db_ro_task
+ @staticmethod
+ def _process_image_params(
+ target_image: Dict[str, Any],
+ vim_info: Dict[str, Any],
+ target_record_id: str,
+ ) -> Dict[str, Any]:
+ """Function to process VDU image parameters.
+
+ Args:
+ target_image (Dict[str, Any]): [description]
+ vim_info (Dict[str, Any]): [description]
+ target_record_id (str): [description]
+
+ Returns:
+ Dict[str, Any]: [description]
+ """
+ find_params = {}
+
+ if target_image.get("image"):
+ find_params["filter_dict"] = {"name": target_image.get("image")}
+
+ if target_image.get("vim_image_id"):
+ find_params["filter_dict"] = {"id": target_image.get("vim_image_id")}
+
+ if target_image.get("image_checksum"):
+ find_params["filter_dict"] = {
+ "checksum": target_image.get("image_checksum")
+ }
+
+ return {"find_params": find_params}
+
+ @staticmethod
+ def _get_resource_allocation_params(
+ quota_descriptor: Dict[str, Any],
+ ) -> Dict[str, Any]:
+ """Read the quota_descriptor from vnfd and fetch the resource allocation properties from the
+ descriptor object.
+
+ Args:
+ quota_descriptor (Dict[str, Any]): cpu/mem/vif/disk-io quota descriptor
+
+ Returns:
+ Dict[str, Any]: quota params for limit, reserve, shares from the descriptor object
+ """
+ quota = {}
+
+ if quota_descriptor.get("limit"):
+ quota["limit"] = int(quota_descriptor["limit"])
+
+ if quota_descriptor.get("reserve"):
+ quota["reserve"] = int(quota_descriptor["reserve"])
+
+ if quota_descriptor.get("shares"):
+ quota["shares"] = int(quota_descriptor["shares"])
+
+ return quota
+
def deploy(self, session, indata, version, nsr_id, *args, **kwargs):
self.logger.debug("ns.deploy nsr_id={} indata={}".format(nsr_id, indata))
validate_input(indata, deploy_schema)
index += 1
- def _process_image_params(target_image, vim_info, target_record_id):
- find_params = {}
-
- if target_image.get("image"):
- find_params["filter_dict"] = {"name": target_image.get("image")}
-
- if target_image.get("vim_image_id"):
- find_params["filter_dict"] = {
- "id": target_image.get("vim_image_id")
- }
-
- if target_image.get("image_checksum"):
- find_params["filter_dict"] = {
- "checksum": target_image.get("image_checksum")
- }
-
- return {"find_params": find_params}
-
def _process_flavor_params(target_flavor, vim_info, target_record_id):
- def _get_resource_allocation_params(quota_descriptor):
- """
- read the quota_descriptor from vnfd and fetch the resource allocation properties from the
- descriptor object
- :param quota_descriptor: cpu/mem/vif/disk-io quota descriptor
- :return: quota params for limit, reserve, shares from the descriptor object
- """
- quota = {}
-
- if quota_descriptor.get("limit"):
- quota["limit"] = int(quota_descriptor["limit"])
-
- if quota_descriptor.get("reserve"):
- quota["reserve"] = int(quota_descriptor["reserve"])
-
- if quota_descriptor.get("shares"):
- quota["shares"] = int(quota_descriptor["shares"])
-
- return quota
+ nonlocal indata
flavor_data = {
"disk": int(target_flavor["storage-gb"]),
numa = {}
extended = {}
+ target_vdur = None
+ for vnf in indata.get("vnf", []):
+ for vdur in vnf.get("vdur", []):
+ if vdur.get("ns-flavor-id") == target_flavor["id"]:
+ target_vdur = vdur
+
+ for storage in target_vdur.get("virtual-storages", []):
+ if (
+ storage.get("type-of-storage")
+ == "etsi-nfv-descriptors:ephemeral-storage"
+ ):
+ flavor_data["ephemeral"] = int(
+ storage.get("size-of-storage", 0)
+ )
+ elif (
+ storage.get("type-of-storage")
+ == "etsi-nfv-descriptors:swap-storage"
+ ):
+ flavor_data["swap"] = int(storage.get("size-of-storage", 0))
+
if target_flavor.get("guest-epa"):
extended = {}
epa_vcpu_set = False
epa_vcpu_set = True
if target_flavor["guest-epa"].get("cpu-quota") and not epa_vcpu_set:
- cpuquota = _get_resource_allocation_params(
+ cpuquota = Ns._get_resource_allocation_params(
target_flavor["guest-epa"].get("cpu-quota")
)
extended["cpu-quota"] = cpuquota
if target_flavor["guest-epa"].get("mem-quota"):
- vduquota = _get_resource_allocation_params(
+ vduquota = Ns._get_resource_allocation_params(
target_flavor["guest-epa"].get("mem-quota")
)
extended["mem-quota"] = vduquota
if target_flavor["guest-epa"].get("disk-io-quota"):
- diskioquota = _get_resource_allocation_params(
+ diskioquota = Ns._get_resource_allocation_params(
target_flavor["guest-epa"].get("disk-io-quota")
)
extended["disk-io-quota"] = diskioquota
if target_flavor["guest-epa"].get("vif-quota"):
- vifquota = _get_resource_allocation_params(
+ vifquota = Ns._get_resource_allocation_params(
target_flavor["guest-epa"].get("vif-quota")
)
db_update=db_nsr_update,
db_path="image",
item="image",
- process_params=_process_image_params,
+ process_params=Ns._process_image_params,
)
step = "process NS flavors"