-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb75ca2
commit a260c81
Showing
6 changed files
with
134 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import subprocess | ||
import argparse | ||
|
||
def check_if_recv_dataset_has_snapshots(recvName, recvHost, recvPort, recvHostUser): | ||
# Construct the SSH command | ||
if recvPort == '22': | ||
ssh_cmd = ['ssh', f'{recvHostUser}@{recvHost}', f'zfs list -H -o name -t snapshot {recvName}'] | ||
else: | ||
ssh_cmd = ['ssh', '-p', f'{recvPort}', f'{recvHostUser}@{recvHost}', f'zfs list -H -o name -t snapshot {recvName}'] | ||
|
||
# Run the SSH command | ||
process_check_snapshots = subprocess.Popen( | ||
ssh_cmd, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
universal_newlines=True, # Ensures text mode for stdout and stderr | ||
) | ||
|
||
# Wait for the command to complete and capture the output | ||
stdout, stderr = process_check_snapshots.communicate() | ||
|
||
# Check the return code | ||
if process_check_snapshots.returncode != 0: | ||
# raise Exception(f"Error:{stderr}") | ||
return False | ||
else: | ||
# Check if the output contains snapshots | ||
return bool(stdout.strip()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters