Feature 10996: Adds ns-op-cancel command
[osm/osmclient.git] / osmclient / cli_commands / nslcm_ops.py
index 46197d0..9528d08 100755 (executable)
@@ -149,3 +149,31 @@ def ns_op_show(ctx, id, filter, literal):
             table.add_row([k, utils.wrap_text(json.dumps(v, indent=2), 100)])
     table.align = "l"
     print(table)
+
+
+@click.command(name="ns-op-cancel", short_help="cancels an ongoing NS operation")
+@click.argument("id")
+@click.option(
+    "--cancel_mode",
+    required=False,
+    default="GRACEFUL",
+    show_default=True,
+    help="Mode of cancellation, can be FORCEFUL or GRACEFUL",
+)
+@click.option(
+    "--wait",
+    required=False,
+    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 ns_op_cancel(ctx, id, cancel_mode, wait):
+    """Cancels an ongoing NS operation
+
+    ID: operation identifier
+    """
+    logger.debug("")
+    utils.check_client_version(ctx.obj, ctx.command.name)
+    ctx.obj.ns.cancel_op(id, cancel_mode, wait)