+ # get vnf.vdu.interface instantiation params to update vnfr.vdur.interfaces ip, mac
+ for vdu_inst_param in get_iterable(vnf_inst_params.get("vdu")):
+ for vdur_index, vdur in enumerate(vnfr["vdur"]):
+ if vdu_inst_param["id"] != vdur["vdu-id-ref"]:
+ continue
+ for iface_inst_param in get_iterable(vdu_inst_param.get("interface")):
+ iface_index, _ = next(i for i in enumerate(vdur["interfaces"])
+ if i[1]["name"] == iface_inst_param["name"])
+ vnfr_update_text = "vdur.{}.interfaces.{}".format(vdur_index, iface_index)
+ if iface_inst_param.get("ip-address"):
+ vnfr_update[vnfr_update_text + ".ip-address"] = increment_ip_mac(
+ iface_inst_param.get("ip-address"), vdur.get("count-index", 0))
+ vnfr_update[vnfr_update_text + ".fixed-ip"] = True
+ if iface_inst_param.get("mac-address"):
+ vnfr_update[vnfr_update_text + ".mac-address"] = increment_ip_mac(
+ iface_inst_param.get("mac-address"), vdur.get("count-index", 0))
+ vnfr_update[vnfr_update_text + ".fixed-mac"] = True
+ # get vnf.internal-vld.internal-conection-point instantiation params to update vnfr.vdur.interfaces
+ # TODO update vld with the ip-profile
+ for ivld_inst_param in get_iterable(vnf_inst_params.get("internal-vld")):
+ for icp_inst_param in get_iterable(ivld_inst_param.get("internal-connection-point")):
+ # look for iface
+ for vdur_index, vdur in enumerate(vnfr["vdur"]):
+ for iface_index, iface in enumerate(vdur["interfaces"]):
+ if iface.get("internal-connection-point-ref") == icp_inst_param["id-ref"]:
+ vnfr_update_text = "vdur.{}.interfaces.{}".format(vdur_index, iface_index)
+ if icp_inst_param.get("ip-address"):
+ vnfr_update[vnfr_update_text + ".ip-address"] = increment_ip_mac(
+ icp_inst_param.get("ip-address"), vdur.get("count-index", 0))
+ vnfr_update[vnfr_update_text + ".fixed-ip"] = True
+ if icp_inst_param.get("mac-address"):
+ vnfr_update[vnfr_update_text + ".mac-address"] = increment_ip_mac(
+ icp_inst_param.get("mac-address"), vdur.get("count-index", 0))
+ vnfr_update[vnfr_update_text + ".fixed-mac"] = True
+ break
+ # get ip address from instantiation parameters.vld.vnfd-connection-point-ref
+ for vld_inst_param in get_iterable(indata.get("vld")):
+ for vnfcp_inst_param in get_iterable(vld_inst_param.get("vnfd-connection-point-ref")):
+ if vnfcp_inst_param["member-vnf-index-ref"] != member_vnf_index:
+ continue
+ # look for iface
+ for vdur_index, vdur in enumerate(vnfr["vdur"]):
+ for iface_index, iface in enumerate(vdur["interfaces"]):
+ if iface.get("external-connection-point-ref") == \
+ vnfcp_inst_param["vnfd-connection-point-ref"]:
+ vnfr_update_text = "vdur.{}.interfaces.{}".format(vdur_index, iface_index)
+ if vnfcp_inst_param.get("ip-address"):
+ vnfr_update[vnfr_update_text + ".ip-address"] = increment_ip_mac(
+ vnfcp_inst_param.get("ip-address"), vdur.get("count-index", 0))
+ vnfr_update[vnfr_update_text + ".fixed-ip"] = True
+ if vnfcp_inst_param.get("mac-address"):
+ vnfr_update[vnfr_update_text + ".mac-address"] = increment_ip_mac(
+ vnfcp_inst_param.get("mac-address"), vdur.get("count-index", 0))
+ vnfr_update[vnfr_update_text + ".fixed-mac"] = True
+ break
+