From f0db455fa51b95c93b8b7673d26a1d0814fa4708 Mon Sep 17 00:00:00 2001 From: Andre Kurait Date: Thu, 20 Jun 2024 10:19:46 -0500 Subject: [PATCH] Send snapshot output while command is running Signed-off-by: Andre Kurait --- .../src/main/java/com/rfs/CreateSnapshot.java | 14 +++++++++----- .../console_link/console_link/models/snapshot.py | 14 ++++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CreateSnapshot/src/main/java/com/rfs/CreateSnapshot.java b/CreateSnapshot/src/main/java/com/rfs/CreateSnapshot.java index 38865b0caa..51ebb508b9 100644 --- a/CreateSnapshot/src/main/java/com/rfs/CreateSnapshot.java +++ b/CreateSnapshot/src/main/java/com/rfs/CreateSnapshot.java @@ -40,6 +40,9 @@ public static class Args { @Parameter(names = {"--source-password"}, description = "Optional. The source password; if not provided, will assume no auth on source", required = false) public String sourcePass = null; + @Parameter(names = {"--source-insecure"}, description = "Allow untrusted SSL certificates for source", required = false) + public boolean sourceInsecure = false; + @Parameter(names = {"--target-host"}, description = "The target host and port (e.g. http://localhost:9200)", required = true) public String targetHost; @@ -49,8 +52,8 @@ public static class Args { @Parameter(names = {"--target-password"}, description = "Optional. The target password; if not provided, will assume no auth on target", required = false) public String targetPass = null; - @Parameter(names = {"--insecure"}, description = "Allow untrusted SSL certificates", required = false) - public boolean insecure = false; + @Parameter(names = {"--target-insecure"}, description = "Allow untrusted SSL certificates for target", required = false) + public boolean targetInsecure = false; } public static void main(String[] args) throws Exception { @@ -70,10 +73,11 @@ public static void main(String[] args) throws Exception { final String targetHost = arguments.targetHost; final String targetUser = arguments.targetUser; final String targetPass = arguments.targetPass; - final boolean insecure = arguments.insecure; + final boolean sourceInsecure = arguments.sourceInsecure; + final boolean targetInsecure = arguments.targetInsecure; - final ConnectionDetails sourceConnection = new ConnectionDetails(sourceHost, sourceUser, sourcePass, insecure); - final ConnectionDetails targetConnection = new ConnectionDetails(targetHost, targetUser, targetPass, insecure); + final ConnectionDetails sourceConnection = new ConnectionDetails(sourceHost, sourceUser, sourcePass, sourceInsecure); + final ConnectionDetails targetConnection = new ConnectionDetails(targetHost, targetUser, targetPass, targetInsecure); TryHandlePhaseFailure.executeWithTryCatch(() -> { log.info("Running RfsWorker"); diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/snapshot.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/snapshot.py index 72ca5de6ca..930ecbb868 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/snapshot.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/snapshot.py @@ -71,15 +71,21 @@ def create(self, *args, **kwargs) -> CommandResult: "--source-host", self.source_cluster.endpoint, "--target-host", self.target_cluster.endpoint, ] - if self.source_cluster.allow_insecure or self.target_cluster.allow_insecure: - command.append("--insecure") + + if self.source_cluster.allow_insecure: + command.append("--source-insecure") + if self.target_cluster.allow_insecure: + command.append("--target-insecure") + logger.info(f"Creating snapshot with command: {' '.join(command)}") try: - subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True) + # Pass None to stdout and stderr to not capture output and show in terminal + subprocess.run(command, stdout=None, stderr=None, text=True, check=True) logger.info(f"Snapshot {self.config['snapshot_name']} created successfully") return CommandResult(success=True, value=f"Snapshot {self.config['snapshot_name']} created successfully") except subprocess.CalledProcessError as e: logger.error(f"Failed to create snapshot: {str(e)}") - return CommandResult(success=False, value=f"Failed to create snapshot: {str(e)} {e.output} {e.stderr}") + return CommandResult(success=False, value=f"Failed to create snapshot: {str(e)}") + def status(self, *args, **kwargs) -> CommandResult: return CommandResult(success=False, value=f"Command not implemented")