Files
Zack Meier 1d304511b8 update
2026-04-15 15:45:50 -05:00

56 lines
1.9 KiB
Python

#!/usr/bin/python
import sys,argparse,json,time
import time
sys.path.insert(0, './classes/')
import cohesityAPI as cohesity
import automationsAPI as dashboard
# Global variables that will be used across all functions
# Begin Functions
def GetArgs():
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--cluster', '-c', type=str, action='store')
parser.add_argument('--help', '-h', action='store_true')
return (parser.parse_args())
def PrintHelp():
print("\nBasic Usage:")
print("\npython3 sqlServerRegistration.py -c cluster.fqdn.tld")
print("\t -c FQDN of Cohesity cluster address")
print("\t -h Prints this help message")
args = GetArgs()
# Validate arguments & assign variables if necessary
if args.help:
PrintHelp()
exit(1)
if not args.cluster:
PrintHelp()
exit(1)
# Connect to the Cohesity cluster
cluster = cohesity.API(args.cluster)
authToken = cluster.GetAuthToken()
cluster.UpdateHeaders(authToken['accessToken'])
# Provide a listing of all backedup vmWare objects. VMs should not be listed twice, requires manual review
itdvmvc2 = cluster.GetFilteredRequest("/public/protectionSources/protectedObjects", "?environment=kVMware&id=1")
for record in itdvmvc2:
if "protectionSource" in record:
if "protectionJobs" in record:
for jobs in record['protectionJobs']:
print(record['protectionSource']['name'] + ", " + jobs['name'])
itdvmvc1 = cluster.GetFilteredRequest("/public/protectionSources/protectedObjects", "?environment=kVMware&id=3156")
for record in itdvmvc1:
if "protectionSource" in record:
if "protectionJobs" in record:
for jobs in record['protectionJobs']:
print(record['protectionSource']['name'] + ", " + jobs['name'])
dashboard.send_automation({'AutomationName': 'Infra-Cohesity', 'Action': 'Maintenance', 'Platform': 'Python-findDuplicates.py', 'Units': 60})