ctx.obj.ns.update(ns_name, op_data, wait=wait)
+def process_common_heal_params(ctx, param, value):
+ logger.debug("")
+ if not value:
+ return
+ logger.debug(f"Param name: {param.name}")
+ if not ctx.params.get("heal_params", {}).get("healVnfData"):
+ raise ClientException(f"Expected option --vnf before {param.name}")
+ if param.name == "cause":
+ param_dict = ctx.params["heal_params"]["healVnfData"][-1]["cause"] = value
+ return
+ # If not "vnf" and not "cause", then the param lies on "additionalParams"
+ if not ctx.params["heal_params"]["healVnfData"][-1].get("additionalParams"):
+ ctx.params["heal_params"]["healVnfData"][-1]["additionalParams"] = {}
+ if param.name == "vdu":
+ # Check VDU id ?
+ if not ctx.params["heal_params"]["healVnfData"][-1]["additionalParams"].get(
+ "vdu"
+ ):
+ ctx.params["heal_params"]["healVnfData"][-1]["additionalParams"][
+ "vdu"
+ ] = []
+ vdu = {"vdu-id": value}
+ ctx.params["heal_params"]["healVnfData"][-1]["additionalParams"][
+ "vdu"
+ ].append(vdu)
+ ctx.params["heal_params"]["current_item"] = "vdu"
+ else:
+ current_item = ctx.params["heal_params"]["current_item"]
+ if current_item == "vnf":
+ param_dict = ctx.params["heal_params"]["healVnfData"][-1][
+ "additionalParams"
+ ]
+ else:
+ # if current_item == "vdu":
+ param_dict = ctx.params["heal_params"]["healVnfData"][-1][
+ "additionalParams"
+ ]["vdu"][-1]
+ if param.name == "count_index":
+ param_name = "count-index"
+ elif param.name == "run_day1":
+ param_name = "run-day1"
+ else:
+ param_name = param.name
+ param_dict[param_name] = value
+ return
+
+
+def process_ns_heal_params(ctx, param, value):
+ logger.debug("")
+ if not ctx.params.get("heal_params"):
+ ctx.params["heal_params"] = {}
+ ctx.params["heal_params"]["healVnfData"] = []
+ if param.name == "vnf" and value:
+ # Check VNF id ?
+ logger.debug(f"Param name: {param.name}")
+ vnf = {"vnfInstanceId": value}
+ ctx.params["heal_params"]["healVnfData"].append(vnf)
+ ctx.params["heal_params"]["current_item"] = "vnf"
+ else:
+ process_common_heal_params(ctx, param, value)
+
+
+def process_vnf_heal_params(ctx, param, value):
+ logger.debug("")
+ if not ctx.params.get("heal_params"):
+ ctx.params["heal_params"] = {}
+ ctx.params["heal_params"]["healVnfData"] = []
+ vnf = {"vnfInstanceId": "id_to_be_substituted"}
+ ctx.params["heal_params"]["healVnfData"].append(vnf)
+ ctx.params["heal_params"]["current_item"] = "vnf"
+ else:
+ process_common_heal_params(ctx, param, value)
+
+
+@click.command(
+ name="ns-heal", short_help="heals (recreates) VNFs or VDUs of a NS instance"
+)
+@click.argument("ns_name")
+@click.option(
+ "--vnf",
+ required=True,
+ default=None,
+ callback=process_ns_heal_params,
+ help="vnf-id if the target is a vnf instead of a ns)",
+)
+@click.option(
+ "--cause",
+ default=None,
+ callback=process_ns_heal_params,
+ help="human readable cause of the healing",
+)
+@click.option(
+ "--run-day1",
+ is_flag=True,
+ default=False,
+ callback=process_ns_heal_params,
+ help="indicates whether or not to run day1 primitives for the VNF/VDU",
+)
+@click.option(
+ "--vdu",
+ default=None,
+ callback=process_ns_heal_params,
+ help="vdu-id",
+)
+@click.option(
+ "--count-index",
+ type=int,
+ default=None,
+ callback=process_ns_heal_params,
+ help="count-index",
+)
+@click.option(
+ "--timeout",
+ type=int,
+ default=None,
+ help="timeout in seconds"
+)
+@click.option(
+ "--wait",
+ is_flag=True,
+ default=False,
+ help="do not return the control immediately, but keep it until the operation is completed, or timeout",
+)
+@click.pass_context
+def ns_heal(
+ ctx,
+ ns_name,
+ heal_params,
+ cause,
+ vnf,
+ run_day1,
+ vdu,
+ count_index,
+ wait,
+ timeout,
+):
+ """heals (recreates) VNFs or VDUs of a NS instance
+
+ NS_NAME: name or ID of the NS instance
+ """
+ logger.debug("")
+ heal_dict = ctx.params["heal_params"]
+ heal_dict.pop("current_item")
+ if cause:
+ heal_dict["cause"] = cause
+ logger.debug(f"Heal dict: {heal_dict}")
+ check_client_version(ctx.obj, ctx.command.name)
+ ctx.obj.ns.heal(ns_name, heal_dict, wait, timeout)
+
+
+@click.command(
+ name="vnf-heal",
+ short_help="heals (recreates) a VNF instance or the VDUs of a VNF instance",
+)
+@click.argument("vnf_name")
+@click.option(
+ "--cause",
+ default=None,
+ callback=process_vnf_heal_params,
+ help="human readable cause of the healing",
+)
+@click.option(
+ "--run-day1",
+ is_flag=True,
+ default=False,
+ callback=process_vnf_heal_params,
+ help="indicates whether or not to run day1 primitives for the VNF/VDU",
+)
+@click.option(
+ "--vdu",
+ default=None,
+ callback=process_vnf_heal_params,
+ help="vdu-id",
+)
+@click.option(
+ "--count-index",
+ type=int,
+ default=None,
+ callback=process_vnf_heal_params,
+ help="count-index",
+)
+@click.option(
+ "--timeout",
+ type=int,
+ default=None,
+ help="timeout in seconds"
+)
+@click.option(
+ "--wait",
+ default=False,
+ is_flag=True,
+ help="do not return the control immediately, but keep it until the operation is completed, or timeout",
+)
+@click.pass_context
+def vnf_heal(
+ ctx,
+ vnf_name,
+ heal_params,
+ cause,
+ run_day1,
+ vdu,
+ count_index,
+ wait,
+ timeout,
+):
+ """heals (recreates) a VNF instance or the VDUs of a VNF instance
+
+ VNF_NAME: name or ID of the VNF instance
+ """
+ logger.debug("")
+ heal_dict = ctx.params["heal_params"]
+ heal_dict.pop("current_item")
+ heal_dict["healVnfData"][-1]["vnfInstanceId"] = vnf_name
+ logger.debug(f"Heal dict: {heal_dict}")
+ check_client_version(ctx.obj, ctx.command.name)
+ ctx.obj.vnf.heal(vnf_name, heal_dict, wait, timeout)
+
+
@cli_osm.command(name="alarm-show", short_help="show alarm details")
@click.argument("uuid")
@click.pass_context