Skip to content

Commit

Permalink
adding clusterFilter to list protections
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Haigh <mhaigh@netapp.com>
  • Loading branch information
MichaelHaigh committed Apr 29, 2024
1 parent b654a59 commit eaef594
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion astraSDK/protections.py
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tkSrc/list.py
Expand Up @@ -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":
Expand Down
7 changes: 7 additions & 0 deletions tkSrc/parser.py
Expand Up @@ -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"""
Expand Down

0 comments on commit eaef594

Please sign in to comment.