From eaef5943606b34b707942050f6cc7375b9478959 Mon Sep 17 00:00:00 2001 From: Michael Haigh Date: Mon, 29 Apr 2024 11:29:50 -0400 Subject: [PATCH] adding clusterFilter to list protections Signed-off-by: Michael Haigh --- astraSDK/protections.py | 5 ++++- tkSrc/list.py | 2 +- tkSrc/parser.py | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/astraSDK/protections.py b/astraSDK/protections.py index fcec280..a7e5453 100644 --- a/astraSDK/protections.py +++ b/astraSDK/protections.py @@ -38,7 +38,7 @@ def __init__(self, quiet=True, verbose=False, output="json"): super().__init__() self.apps = getApps(quiet=True, verbose=verbose).main() - def main(self, appFilter=None): + def main(self, appFilter=None, clusterFilter=None): if self.apps is False: print("Call to getApps() failed") return False @@ -50,6 +50,9 @@ def main(self, appFilter=None): if appFilter: if app["name"] != appFilter and app["id"] != appFilter: continue + if clusterFilter: + if app["clusterName"] != clusterFilter and app["clusterID"] != clusterFilter: + continue endpoint = f"k8s/v1/apps/{app['id']}/schedules" url = self.base + endpoint diff --git a/tkSrc/list.py b/tkSrc/list.py index a21438b..5285386 100644 --- a/tkSrc/list.py +++ b/tkSrc/list.py @@ -401,7 +401,7 @@ def main(args): else: rc = astraSDK.protections.getProtectionpolicies( quiet=args.quiet, verbose=args.verbose, output=args.output - ).main(appFilter=args.app) + ).main(appFilter=args.app, clusterFilter=args.cluster) if rc is False: raise SystemExit("astraSDK.protections.getProtectionpolicies() failed") elif args.objectType == "replications": diff --git a/tkSrc/parser.py b/tkSrc/parser.py index 79a1db2..7fdb314 100644 --- a/tkSrc/parser.py +++ b/tkSrc/parser.py @@ -1013,6 +1013,13 @@ def list_protections_args(self): self.subparserListProtections.add_argument( "-a", "--app", default=None, help="Only show protection policies from this app" ) + if not self.v3: + self.subparserListProtections.add_argument( + "-c", + "--cluster", + default=None, + help="Only show protection policies from this cluster", + ) def list_replications_args(self): """list replication policies args and flags"""