Files
Backup/_NDGOV_CS/ITD.Cohesity/template.py
T
Zack Meier 1d304511b8 update
2026-04-15 15:45:50 -05:00

55 lines
1.5 KiB
Python

#!/usr/bin/python
import sys,argparse,json,time
import time
sys.path.insert(0, './classes/')
import cohesityAPI as cohesity
import sharePointAPI as sharePoint
import serviceNowAPI as snow
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)
# ServiceNow object
ticketSystem = snow.SnowAPI("northdakotadev.service-now.com")
# Sharepoint Object
cmdb = sharePoint.API()
# Connect to the Cohesity cluster
cluster = cohesity.API(args.cluster)
authToken = cluster.GetAuthToken()
cluster.UpdateHeaders(authToken['accessToken'])
# Pull information from Cohestiy API
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'])